Commit d05b3e4c authored by Romain Bioteau's avatar Romain Bioteau

Merge remote-tracking branch 'origin/release-7.8.0'

parents 1f41e5bc 786ebe1f
......@@ -22,17 +22,10 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
/**
* @author Mickael Istria
*
*/
public class OpenIntroCommandHandler extends AbstractHandler {
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
PlatformUtil.openIntro();
PlatformUtil.openIntro();
return null;
}
......
......@@ -32,6 +32,7 @@ import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditor;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
......@@ -43,6 +44,9 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
......@@ -228,6 +232,13 @@ public class SaveCommandHandler extends SaveHandler {
}
};
if (nameDialog.open() == Dialog.OK) {
final String author = System.getProperty("user.name", "unknown");
final TransactionalEditingDomain editingDomain = TransactionUtil
.getEditingDomain(proc.eResource());
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain,
((DiagramEditor) editorPart).getDiagramEditPart().resolveSemanticElement(),
ProcessPackage.Literals.ABSTRACT_PROCESS__AUTHOR, author));
editorPart.doSave(Repository.NULL_PROGRESS_MONITOR);
final RenameDiagramOperation renameDiagramOperation = new RenameDiagramOperation();
renameDiagramOperation.setDiagramToDuplicate(proc);
......
......@@ -28,7 +28,7 @@ public final class AutomaticSwitchPerspectivePartListener implements IPartListen
@Override
public void partActivated(final MPart part) {
switchPerspective(part);
}
@Override
......@@ -48,6 +48,10 @@ public final class AutomaticSwitchPerspectivePartListener implements IPartListen
@Override
public void partVisible(final MPart part) {
switchPerspective(part);
}
protected void switchPerspective(final MPart part) {
if (!isSwitching) {
isSwitching = true;
try {
......
package org.bonitasoft.studio.designer.core.operation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import java.util.List;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.designer.core.PageDesignerURLFactory;
import org.bonitasoft.studio.designer.core.operation.CreateUIDArtifactOperation.ArtifactyType;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
@SuppressWarnings("unchecked")
public class CreateUIDArtifactOperationTest {
private static final String TYPE = "type";
private static final String ROWS = "rows";
private RepositoryAccessor repositoryAccessor;
private PageDesignerURLFactory pageDesignerURLFactory;
private CreatePageOperation createPageOperation;
private CreateLayoutOperation createLayoutOperation;
private CreateFormOperation createFormOperation;
@Before
public void init() {
repositoryAccessor = mock(RepositoryAccessor.class);
pageDesignerURLFactory = mock(PageDesignerURLFactory.class);
createPageOperation = new CreatePageOperation(pageDesignerURLFactory, repositoryAccessor);
createLayoutOperation = new CreateLayoutOperation(pageDesignerURLFactory, repositoryAccessor);
createFormOperation = new CreateFormOperation(pageDesignerURLFactory, repositoryAccessor);
}
@Test
public void should_create_request_body_according_to_type() throws Exception {
validateJsonBodyForPages();
validateJsonBodyForForms();
validateJsonBodyForLayouts();
}
private void validateJsonBodyForPages() throws Exception {
JSONObject pageBody = createPageOperation.createBody();
assertThat(pageBody.get(TYPE)).isEqualTo(ArtifactyType.PAGE);
JSONArray rows = (JSONArray) pageBody.get(ROWS);
assertThat(rows.length()).isEqualTo(1);
assertThat((List) rows.get(0)).isEmpty();
}
private void validateJsonBodyForForms() throws Exception {
JSONObject pageBody = createFormOperation.createBody();
assertThat(pageBody.get(TYPE)).isEqualTo(ArtifactyType.FORM);
JSONArray rows = (JSONArray) pageBody.get(ROWS);
assertThat(rows.length()).isEqualTo(1);
assertThat((List) rows.get(0)).isEmpty();
}
private void validateJsonBodyForLayouts() throws Exception {
JSONObject pageBody = createLayoutOperation.createBody();
assertThat(pageBody.get(TYPE)).isEqualTo(ArtifactyType.LAYOUT);
JSONArray rows = (JSONArray) pageBody.get(ROWS);
assertThat(rows.length()).isEqualTo(1);
assertThat((List) rows.get(0)).isEmpty();
}
}
......@@ -85,9 +85,7 @@ public abstract class CreateUIDArtifactOperation implements IRunnableWithProgres
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", getArtifactType());
jsonObject.put("name", artifactName);
if (getArtifactType() == ArtifactyType.FORM
|| getArtifactType() == ArtifactyType.PAGE
|| getArtifactType() == ArtifactyType.FRAGMENT) {
if (getArtifactType() != ArtifactyType.WIDGET) {
jsonObject.put("rows", Arrays.asList(new ArrayList<>()));
}
return jsonObject;
......
......@@ -41,10 +41,7 @@ public class NewDiagramCommandHandler extends AbstractHandler {
@Override
public DiagramFileStore execute(final ExecutionEvent event) throws ExecutionException {
final DiagramFileStore diagramFileStore = newDiagram();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Display.getDefault().asyncExec(() -> {
final IEditorPart editor = (IEditorPart) diagramFileStore.open();
if (editor instanceof DiagramEditor) {
final String author = System.getProperty("user.name", "unknown");
......@@ -56,7 +53,6 @@ public class NewDiagramCommandHandler extends AbstractHandler {
ProcessPackage.Literals.ABSTRACT_PROCESS__AUTHOR, author));
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(editor);
}
}
});
return diagramFileStore;
}
......
......@@ -113,10 +113,7 @@ public class DiagramFileStore extends EMFFileStore implements IDeployable, IRena
return (MainProcess) super.getContent();
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.filestore.EMFFileStore#getDisplayName()
*/
@Override
public String getDisplayName() {
final String displayName = getResource().getLocation().removeFileExtension().lastSegment();
......@@ -133,10 +130,7 @@ public class DiagramFileStore extends EMFFileStore implements IDeployable, IRena
return URI.createPlatformResourceURI(fullPath.toOSString(), true);
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.filestore.EMFFileStore#getIcon()
*/
@Override
public Image getIcon() {
return Pics.getImage("ProcessDiagramFile.gif", Activator.getDefault());
......@@ -260,15 +254,13 @@ public class DiagramFileStore extends EMFFileStore implements IDeployable, IRena
@Override
protected IWorkbenchPart doOpen() {
final IWorkbenchPage activePage = closeOpenedEditorWithoutSaving();
IEditorPart part = null;
final Resource emfResource = getEMFResource();
final MainProcess content = getContent();
Assert.isLegal(content != null);
Assert.isLegal(emfResource != null && emfResource.isLoaded());
final Diagram diagram = ModelHelper.getDiagramFor(content, emfResource);
part = EditorService.getInstance().openEditor(new URIEditorInput(EcoreUtil.getURI(diagram)));
part = EditorService.getInstance().openEditor(new URIEditorInput(EcoreUtil.getURI(diagram).trimFragment()));
if (part instanceof DiagramEditor) {
final DiagramEditor editor = (DiagramEditor) part;
final MainProcess mainProcess = (MainProcess) editor.getDiagramEditPart().resolveSemanticElement();
......@@ -298,15 +290,6 @@ public class DiagramFileStore extends EMFFileStore implements IDeployable, IRena
}
}
protected IWorkbenchPage closeOpenedEditorWithoutSaving() {
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
final DiagramEditor openedEditor = getOpenedEditor();
if (openedEditor != null) {
activePage.closeEditor(openedEditor, false);
}
return activePage;
}
protected void setDefaultSelection(final DiagramEditor editor) {
Display.getDefault().syncExec(() -> {
//default selection
......
......@@ -14,7 +14,6 @@
*/
package org.bonitasoft.studio.groovy.ui.providers;
import java.io.File;
import java.util.List;
import java.util.Objects;
......@@ -49,7 +48,7 @@ public abstract class AbstractGroovyScriptConfigurationSynchronizer implements I
@Override
public void synchronize(Configuration configuration, AbstractProcess process, CompoundCommand cc,
EditingDomain editingDomain) {
GroovyRepositoryStore store = (GroovyRepositoryStore) RepositoryManager.getInstance()
GroovyRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(GroovyRepositoryStore.class);
addNewPackage(configuration, process, store, cc, editingDomain);
removeDeletedPackage(configuration, store, cc, editingDomain);
......@@ -83,8 +82,12 @@ public abstract class AbstractGroovyScriptConfigurationSynchronizer implements I
List<Expression> expressions = ModelHelper.getAllItemsOfType(process,
ExpressionPackage.Literals.EXPRESSION);
newFragment.setExported(false);
String qualifiedName = path.replaceAll(File.separator, ".").substring(0,
path.lastIndexOf(".groovy"));
String qualifiedName = path;
if (path.contains("/")) {
qualifiedName = qualifiedName.replaceAll("/", ".");
}
qualifiedName = qualifiedName.substring(0,
qualifiedName.lastIndexOf(".groovy"));
for (Expression exp : expressions) {
if (exp.getType() != null && exp.getType().equals(ExpressionConstants.SCRIPT_TYPE)) {
if (exp.getContent() != null && exp.getContent().contains(qualifiedName)) {
......
......@@ -679,6 +679,8 @@ public class GroovyScriptExpressionEditor extends SelectionAwareExpressionEditor
dataBindingContext.bindValue(SWTObservables.observeEnabled(testButton),
SWTObservables.observeText(groovyViewer.getSourceViewer().getTextWidget(), SWT.Modify), null,
evaluateStrategy);
sourceViewer.getUndoManager().reset();
}
@Override
......
......@@ -4,11 +4,6 @@ import java.util.Properties;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
......@@ -18,31 +13,19 @@ import org.eclipse.ui.intro.config.IIntroAction;
public class OpenProcess implements IIntroAction {
public void run(IIntroSite site, Properties param) {
try {
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
IHandlerService handlerService = (IHandlerService) part.getSite().getService(IHandlerService.class);
ICommandService cmdService = (ICommandService)part.getSite().getService( ICommandService.class);
// Do not replace by static link since this command does not resolve to the same between BOS and SP
Command open = cmdService.getCommand("org.bonitasoft.studio.diagram.command.openDiagram");//$NON-NLS-1$
ExecutionEvent executionEvent = handlerService.createExecutionEvent(open, null);
try {
open.executeWithChecks(executionEvent);
} catch (ExecutionException e) {
BonitaStudioLog.error(e);
} catch (NotDefinedException e) {
BonitaStudioLog.error(e);
} catch (NotEnabledException e) {
BonitaStudioLog.error(e);
} catch (NotHandledException e) {
BonitaStudioLog.error(e);
}
} catch (Exception e) {
BonitaStudioLog.error(e);
}
}
public void run(IIntroSite site, Properties param) {
try {
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
IHandlerService handlerService = (IHandlerService) part.getSite().getService(IHandlerService.class);
ICommandService cmdService = (ICommandService) part.getSite().getService(ICommandService.class);
// Do not replace by static link since this command does not resolve to the same between BOS and SP
Command open = cmdService.getCommand("org.bonitasoft.studio.diagram.command.openDiagram");//$NON-NLS-1$
if (open.isEnabled()) {
open.executeWithChecks(handlerService.createExecutionEvent(open, null));
}
} catch (Exception e) {
BonitaStudioLog.error(e);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment