Commit be19cfd4 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

fix(firstSave) set author if not set (#1511)

parent f44b76eb
......@@ -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);
......
......@@ -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;
}
......
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