...
 
Commits (7)
......@@ -14689,6 +14689,9 @@
<releases xmi:id="_z5RnUKwvEeiFZ5S8g2gj5Q" date="2018-08-30T11:43:27.494+0200" label="7.8.0-002">
<changes xsi:type="history:MigrationChange" xmi:id="_z5RnUawvEeiFZ5S8g2gj5Q" migration="org.bonitasoft.studio.migration.custom.migration.connector.UpdateRestConnectorVersionTo106"/>
</releases>
<releases xmi:id="_7NF0QDj6Eem-ZO25_WoPnQ" date="2019-02-25T10:43:27.494+0100" label="7.8.3-001">
<changes xsi:type="history:MigrationChange" xmi:id="_7NF0QTj6Eem-ZO25_WoPnQ" migration="org.bonitasoft.studio.migration.custom.migration.UpdateConfigurationId"/>
</releases>
<releases xmi:id="_lGPssDBZEemIIINmMdyzoA" date="2019-02-14T10:43:27.494+0100" label="7.9.0-001">
<changes xsi:type="history:OperationChange" xmi:id="_p10aMDBZEemIIINmMdyzoA">
<changes xsi:type="history:Create" xmi:id="_p10aMTBZEemIIINmMdyzoA" referenceName="eStructuralFeatures">
......
......@@ -55,10 +55,6 @@ public class OpenHandler extends AbstractHandler {
return null;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
*/
@Override
public boolean isEnabled() {
ISelection selection = fileStoreFinder.getSelectionInExplorer();
......@@ -72,9 +68,8 @@ public class OpenHandler extends AbstractHandler {
.getFileStore(adapter);
if (fileStore != null) {
return !fileStore.getName().endsWith(".jar");
} else {
return true;
}
return true;
}
}
}
......
......@@ -24,6 +24,8 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.IStructuredSelection;
public class RenameHandler extends AbstractHandler {
......@@ -43,11 +45,12 @@ public class RenameHandler extends AbstractHandler {
Repository currentRepository = RepositoryManager.getInstance().getCurrentRepository();
Optional<IStructuredSelection> selection = selectionFinder.getCurrentStructuredSelection();
if (selection.isPresent() && selection.get().toList().size() == 1) {
if (selection.get().getFirstElement() instanceof IProject) {
IProject project = (IProject) selection.get().getFirstElement();
return Objects.equals(project, currentRepository.getProject());
IResource resource = ((IAdaptable) selection.get().getFirstElement()).getAdapter(IResource.class);
if (resource.getAdapter(IProject.class) != null) {
return Objects.equals(resource.getAdapter(IProject.class), currentRepository.getProject());
}
return selectionFinder.findElementToRename(RepositoryManager.getInstance().getCurrentRepository()).isPresent();
return selectionFinder.findElementToRename(resource, RepositoryManager.getInstance().getCurrentRepository())
.isPresent();
}
return false;
}
......
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.application.property.tester;
import java.util.Objects;
......@@ -10,7 +24,6 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
public class BonitaProjectPropertyTester extends PropertyTester {
@Override
......
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.application.property.tester;
import java.util.Objects;
......@@ -10,7 +24,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.IPackageFragment;
public class GroovySrcPropertyTester extends PropertyTester {
@Override
......@@ -19,11 +32,8 @@ public class GroovySrcPropertyTester extends PropertyTester {
IPackageFragment packageFragment = ((IAdaptable) receiver).getAdapter(IPackageFragment.class);
IFolder groovySrcFolder = RepositoryManager.getInstance().getRepositoryStore(GroovyRepositoryStore.class)
.getResource();
return Objects.equals(
groovySrcFolder,
adapter)
|| (packageFragment != null
&& groovySrcFolder.getLocation().isPrefixOf(packageFragment.getResource().getLocation()));
return Objects.equals(groovySrcFolder, adapter) || (packageFragment != null
&& groovySrcFolder.getLocation().isPrefixOf(packageFragment.getResource().getLocation()));
}
}
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.application.views.provider;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bonitasoft.studio.application.views.BonitaProjectExplorer;
import org.bonitasoft.studio.application.views.CustomPopupMenuExtender;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.e4.core.commands.ExpressionContext;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuSeparator;
import org.eclipse.e4.ui.workbench.renderers.swt.ContributionRecord;
import org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.navigator.NavigatorActionService;
public class CreateContributionItem extends ContributionItem {
private NavigatorActionService navigatorActionService;
private IWorkbenchPart part;
public CreateContributionItem(IWorkbenchPart part, NavigatorActionService navigatorActionService) {
this.part = part;
this.navigatorActionService = navigatorActionService;
}
@Override
public void fill(ToolBar parent, int index) {
IEclipseContext e4Context = ((PartSite) part.getSite()).getContext();
ToolItem createItem = new ToolItem(parent, SWT.PUSH);
createItem.setImage(Pics.getImage(PicsConstants.addFile));
createItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
MenuManager menuManager = new MenuManager(getId());
menuManager.setRemoveAllWhenShown(true);
menuManager.createContextMenu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
CustomPopupMenuExtender customPopupMenuExtender = new CustomPopupMenuExtender(BonitaProjectExplorer.ID,
menuManager, projectSelectionProvider(), part, e4Context, true);
Listener[] listeners = menuManager.getMenu().getListeners(SWT.Show);
menuManager.getMenu().removeListener(SWT.Show, listeners[0]);
menuManager.getMenu().removeListener(SWT.Hide, listeners[0]);
MenuManagerRenderer renderer = customPopupMenuExtender.getMenuManagerRenderer();
navigatorActionService.setContext(new ActionContext(projectSelectionProvider().getSelection()));
navigatorActionService.fillContextMenu(menuManager);
customPopupMenuExtender.menuAboutToShow(menuManager);
MenuManager contributionItem = (MenuManager) menuManager
.find("org.bonitasoft.studio.application.project.explorer.new");
MMenu mMenu = renderer.getMenuModel(contributionItem);
Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
ExpressionContext expressionContext = getExpressionContext(e4Context);
for (MMenuElement menuElement : mMenu.getChildren()) {
IContributionItem contribution = renderer.getContribution(menuElement);
if (isVisible(renderer, mMenu, menuElement, expressionContext)) {
contribution.fill(menu, -1);
}
}
final ToolItem item = (ToolItem) event.widget;
final Rectangle rect = item.getBounds();
final Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
private boolean isVisible(MenuManagerRenderer renderer, MMenu mMenu, MMenuElement menuElement,
ExpressionContext expressionContext) {
if (menuElement instanceof MMenuSeparator) {
int indexOf = mMenu.getChildren().indexOf(menuElement);
if (indexOf > 0) {
MMenuElement mMenuElement = mMenu.getChildren().get(indexOf - 1);
if (mMenuElement instanceof MMenuSeparator) {
return false;
}
}
}
ContributionRecord contributionRecord = renderer.getContributionRecord(menuElement);
contributionRecord.updateIsVisible(expressionContext);
return contributionRecord.computeVisibility(new HashSet<>(), menuElement,
expressionContext);
}
});
}
private ExpressionContext getExpressionContext(IEclipseContext e4Context) {
return new ExpressionContext(e4Context) {
@Override
public Object getDefaultVariable() {
List<Object> vars = new ArrayList<>();
vars.add(RepositoryManager.getInstance().getCurrentRepository().getProject());
return vars;
}
};
}
private ISelectionProvider projectSelectionProvider() {
return new ISelectionProvider() {
@Override
public void setSelection(ISelection selection) {
}
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
}
@Override
public ISelection getSelection() {
return getProjectSelection();
}
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
}
};
}
private ISelection getProjectSelection() {
return new StructuredSelection(RepositoryManager.getInstance().getCurrentRepository().getProject());
}
}
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.application.views.provider;
import java.util.stream.Stream;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.internal.navigator.CommonViewerSiteIViewSiteDelegate;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
public class CreationActionProvider extends CommonActionProvider {
private CreateContributionItem createContributionItem;
/*
* (non-Javadoc)
* @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
*/
@Override
public void init(ICommonActionExtensionSite aSite) {
super.init(aSite);
IWorkbenchPart part = ((CommonViewerSiteIViewSiteDelegate) aSite.getViewSite()).getPart();
createContributionItem = new CreateContributionItem(part,
((CommonViewer) aSite.getStructuredViewer()).getCommonNavigator().getNavigatorActionService());
createContributionItem.setId(aSite.getContentService()
.getViewerDescriptor().getPopupMenuId());
}
@Override
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
if (Stream.of(actionBars.getToolBarManager().getItems()).noneMatch(createContributionItem::equals)) {
actionBars.getToolBarManager().add(createContributionItem);
}
}
}
......@@ -38,6 +38,7 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.edapt.migration.MigrationException;
......@@ -65,6 +66,8 @@ public class RepositoryTest {
private ProjectClasspathFactory bonitaBPMProjectClasspath;
@Mock
private DatabaseHandler bonitaHomeHandler;
@Mock
private IWorkspaceRoot root;
@Test
public void should_open_trigger_project_manifest_factory() throws Exception {
......@@ -110,6 +113,8 @@ public class RepositoryTest {
IResource resource2 = mock(IResource.class);
when(resource1.getName()).thenReturn("name.xml");
when(resource2.getName()).thenReturn("name.xml");
when(workspace.getRoot()).thenReturn(root);
when(resource2.getWorkspace()).thenReturn(workspace);
IRepositoryStore<IRepositoryFileStore> repositoryStore1 = mock(IRepositoryStore.class);
IRepositoryStore<IRepositoryFileStore> repositoryStore2 = mock(IRepositoryStore.class);
......
......@@ -58,15 +58,16 @@ public class FileStoreFinderTest {
IStructuredSelection selection = new StructuredSelection(file);
doReturn(Optional.of(selection)).when(finder).getCurrentStructuredSelection();
Repository repository = initRepository();
Repository repository = mock(Repository.class);
when(repository.getFileStore(file)).thenReturn(new FileStoreWithInterface(FILE_NAME, mock(IRepositoryStore.class)));
Optional<IRenamable> elementToRename = finder.findElementToRename(repository);
assertThat(elementToRename).isPresent();
FileStoreWithInterface fileStore = (FileStoreWithInterface) elementToRename.get();
assertThat(fileStore.getName()).isEqualTo(FILE_NAME);
when(file.getName()).thenReturn(DOCUMENT_NAME);
when(repository.getFileStore(file))
.thenReturn(new FileStoreWithoutInterface(DOCUMENT_NAME, mock(IRepositoryStore.class)));
elementToRename = finder.findElementToRename(repository);
assertThat(elementToRename).isEmpty();
}
......@@ -85,55 +86,21 @@ public class FileStoreFinderTest {
when(adaptable.getAdapter(IResource.class)).thenReturn(file);
IStructuredSelection selection = new StructuredSelection(adaptable);
doReturn(Optional.of(selection)).when(finder).getCurrentStructuredSelection();
Repository repository = initRepository();
Repository repository = mock(Repository.class);
when(repository.getFileStore(file)).thenReturn(new FileStoreWithInterface(FILE_NAME, mock(IRepositoryStore.class)));
Optional<IDeployable> elementToDeploy = finder.findElementToDeploy(repository);
assertThat(elementToDeploy).isPresent();
FileStoreWithInterface fileStore = (FileStoreWithInterface) elementToDeploy.get();
assertThat(fileStore.getName()).isEqualTo(FILE_NAME);
when(file.getName()).thenReturn(DOCUMENT_NAME);
when(repository.getFileStore(file))
.thenReturn(new FileStoreWithoutInterface(DOCUMENT_NAME, mock(IRepositoryStore.class)));
elementToDeploy = finder.findElementToDeploy(repository);
assertThat(elementToDeploy).isEmpty();
}
@Test
public void should_find_correct_file_store_if_two_files_have_the_same_name() {
FileStoreFinder finder = spy(FileStoreFinder.class);
IFile file = mock(IFile.class);
IFolder parent = mock(IFolder.class);
when(parent.getName()).thenReturn(ORGANIZATION_FOLDER_NAME);
when(file.getName()).thenReturn(FILE_NAME);
when(file.getParent()).thenReturn(parent);
IStructuredSelection selection = new StructuredSelection(file);
doReturn(Optional.of(selection)).when(finder).getCurrentStructuredSelection();
Repository repository = initRepository();
Optional<? extends IRepositoryFileStore> selectedFileStore = finder.findSelectedFileStore(repository);
assertThat(selectedFileStore).isPresent();
assertThat(selectedFileStore.get().getName()).isEqualTo(FILE_NAME);
assertThat(selectedFileStore.get().getParentStore().getName()).isEqualTo(ORGANIZATION_FOLDER_NAME);
when(parent.getName()).thenReturn(DIAGRAMS_FOLDER_NAME);
selectedFileStore = finder.findSelectedFileStore(repository);
assertThat(selectedFileStore).isPresent();
assertThat(selectedFileStore.get().getName()).isEqualTo(FILE_NAME);
assertThat(selectedFileStore.get().getParentStore().getName()).isEqualTo(DIAGRAMS_FOLDER_NAME);
}
private Repository initRepository() {
Repository repository = mock(Repository.class);
IRepositoryStore<? extends IRepositoryFileStore> storeWithInterfaces = initStoreWithInterfaces();
IRepositoryStore<? extends IRepositoryFileStore> storeWithInterfaces2 = initStoreWithInterfaces2();
IRepositoryStore<? extends IRepositoryFileStore> storeWithoutInterface = initStoreWithoutInterface();
when(repository.getAllStores())
.thenReturn(Arrays.asList(storeWithInterfaces, storeWithInterfaces2, storeWithoutInterface));
return repository;
}
private IRepositoryStore<? extends IRepositoryFileStore> initStoreWithInterfaces() {
IRepositoryStore<FileStoreWithInterface> repositoryStore = mock(IRepositoryStore.class);
......
......@@ -592,7 +592,8 @@ public class Repository implements IRepository, IJavaContainer, IRenamable {
}
for (final IRepositoryStore<? extends IRepositoryFileStore> store : getAllStores()) {
IFolder container = store.getResource();
if (Objects.equals(resource.getParent(), container) || Objects.equals(store.getName(), "restAPIExtensions")) {
if (Objects.equals(resource.getParent(), container)
|| Objects.equals(resource.getParent(), resource.getWorkspace().getRoot())) {
IRepositoryFileStore fStore = store.getChild(resource.getName());
if (fStore != null) {
return fStore;
......
......@@ -14,8 +14,6 @@
*/
package org.bonitasoft.studio.common.repository.filestore;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import org.bonitasoft.studio.common.repository.Repository;
......@@ -23,7 +21,6 @@ import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.model.IDeployable;
import org.bonitasoft.studio.common.repository.model.IRenamable;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
......@@ -109,16 +106,7 @@ public class FileStoreFinder {
}
public Optional<? extends IRepositoryFileStore> findFileStore(IResource resource, Repository currentRepository) {
return currentRepository.getAllStores().stream()
.map(IRepositoryStore::getChildren)
.flatMap(Collection::stream)
.filter(fileStore -> Objects.equals(fileStore.getName(), resource.getName()))
.filter(fileStore -> {
return resource instanceof IProject
? true
: Objects.equals(fileStore.getParentStore().getName(), resource.getParent().getName());
})
.findFirst();
return Optional.ofNullable(currentRepository.getFileStore(resource));
}
public ISelection getSelectionInExplorer() {
......
......@@ -23,7 +23,7 @@ public class ConfigurationIdProvider implements IConfigurationIdProvider {
@Override
public Object getConfigurationId(MainProcess diagram) {
return get(diagram.getName(), diagram.getBonitaModelVersion(), diagram.getBonitaVersion());
return get(diagram.getBonitaModelVersion(), diagram.getBonitaVersion());
}
@Override
......@@ -33,18 +33,18 @@ public class ConfigurationIdProvider implements IConfigurationIdProvider {
diagram.getBonitaVersion());
}
protected String get(String diagramName, String modelVersion, String bonitaVersion) {
return diagramName + modelVersion + bonitaVersion;
protected String get(String modelVersion, String bonitaVersion) {
return modelVersion + bonitaVersion;
}
@Override
public boolean isConfigurationIdValid(Object configId, String diagramName, String modelVersion, String bonitaVersion) {
return configId != null && configId.toString().equals(get(diagramName, modelVersion, bonitaVersion));
return configId != null && configId.toString().endsWith(get(modelVersion, bonitaVersion));
}
@Override
public Object getConfigurationId(String diagramName, String bonitaModelVersion, String bonitaVersion) {
return get(diagramName, bonitaModelVersion, bonitaVersion);
return get(bonitaModelVersion, bonitaVersion);
}
}
......@@ -15,11 +15,9 @@
package org.bonitasoft.studio.diagram.custom.handlers;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.filestore.FileStoreFinder;
import org.bonitasoft.studio.diagram.custom.actions.DuplicateDiagramAction;
import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
public class DuplicateDiagramHandler {
......@@ -40,12 +38,4 @@ public class DuplicateDiagramHandler {
new DuplicateDiagramAction(repositoryAccessor).duplicate(fileStore.getContent());
}
@CanExecute
public boolean canExecute(RepositoryAccessor repositoryAccessor) {
return RepositoryManager.getInstance().hasActiveRepository() && fileStoreFinder
.findSelectedFileStore(repositoryAccessor.getCurrentRepository())
.filter(DiagramFileStore.class::isInstance)
.isPresent();
}
}
......@@ -33,11 +33,13 @@ import org.bonitasoft.studio.connector.model.definition.ConnectorDefinition;
import org.bonitasoft.studio.connector.model.definition.ConnectorDefinitionFactory;
import org.bonitasoft.studio.connector.model.i18n.Messages;
import org.bonitasoft.studio.connector.model.implementation.ConnectorImplementation;
import org.bonitasoft.studio.swtbot.framework.conditions.AssertionCondition;
import org.bonitasoft.studio.swtbot.framework.rule.SWTGefBotRule;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
......@@ -134,13 +136,19 @@ public class ActorFilterImplementationTest implements SWTBotConstants {
return "Editor for implementation has not been opened.";
}
}, 30000);
Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, Repository.NULL_PROGRESS_MONITOR);
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, Repository.NULL_PROGRESS_MONITOR);
bot.sleep(1000);
int length = bot.activeEditor().toTextEditor().getText().length();
assertTrue("Invalid file length", length > 0);
StyleRange[] styles = bot.activeEditor().toTextEditor().getStyles(0, 0, length);
containsError(styles);
bot.waitUntil(new AssertionCondition() {
@Override
protected void makeAssert() throws Exception {
SWTBotEclipseEditor editor = ActorFilterImplementationTest.this.bot.activeEditor().toTextEditor();
int length = editor.getText().length();
assertTrue("Invalid file length", editor.getText().length() > 0);
containsError(editor.getStyles(0, 0, length));
}
},10000);
removeImplementation(id);
}
......
......@@ -23,6 +23,7 @@ import org.bonitasoft.studio.decision.i18n.Messages;
import org.bonitasoft.studio.expression.editor.viewer.ExpressionViewer;
import org.bonitasoft.studio.swtbot.framework.SWTBotTestUtil;
import org.bonitasoft.studio.swtbot.framework.application.BotApplicationWorkbenchWindow;
import org.bonitasoft.studio.swtbot.framework.conditions.AssertionCondition;
import org.bonitasoft.studio.swtbot.framework.rule.SWTGefBotRule;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
......@@ -74,7 +75,6 @@ public class TestDecisionTable {
changeCondition(2, "myBoolean");
testUpdateLineButtonEnabled();
bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_ERASEBUTTON, 0).click();
bot.sleep(1000);
testUpdateLineButtonNotEnabled();
changeCondition(0, "myText==\"\"");
......@@ -101,17 +101,27 @@ public class TestDecisionTable {
private void changeCondition(final int idx, final String condition) {
bot.text(idx).setText(condition);
bot.sleep(1000);
}
private void testUpdateLineButtonEnabled() {
Assert.assertTrue("Update Line Button should be enabled", bot.button(Messages.updateLine).isEnabled());
bot.waitUntil(new AssertionCondition() {
@Override
protected void makeAssert() throws Exception {
Assert.assertTrue("Update Line Button should be enabled", bot.button(Messages.updateLine).isEnabled());
}
});
}
private void testUpdateLineButtonNotEnabled() {
Assert.assertTrue("Update Line Button should not be enabled", !bot.button(Messages.updateLine).isEnabled());
bot.waitUntil(new AssertionCondition() {
@Override
protected void makeAssert() throws Exception {
Assert.assertTrue("Update Line Button should not be enabled",
!bot.button(Messages.updateLine).isEnabled());
}
});
}
}