Commit 93a2f40b authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Fix testFirstSave test

parent 57c1e55d
......@@ -82,7 +82,6 @@ public class DuplicateDiagramOperation implements IRunnableWithProgress {
private String diagramVersion;
private String diagramName;
private List<ProcessesNameVersion> pools = new ArrayList<ProcessesNameVersion>();
private final DiagramRepositoryStore store = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);
/*
* (non-Javadoc)
......@@ -104,6 +103,11 @@ public class DuplicateDiagramOperation implements IRunnableWithProgress {
}
final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(newDiagram);
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, newDiagram, ProcessPackage.Literals.ABSTRACT_PROCESS__AUTHOR,
System.getProperty("user.name", "Unknown")));
boolean poolRenamed = false;
for (final ProcessesNameVersion pnv : pools) {
final AbstractProcess fromPool = pnv.getAbstractProcess();
final String fromPoolName = fromPool.getName();
......@@ -113,14 +117,17 @@ public class DuplicateDiagramOperation implements IRunnableWithProgress {
if (element instanceof AbstractProcess) {
if (element.getName().equals(fromPoolName)
&& ((AbstractProcess) element).getVersion().equals(fromPoolVersion)) {
changeProcessNameAndVersion((AbstractProcess) element, editingDomain, pnv.getNewName(), pnv.getNewVersion());
break;
if (!pnv.getNewName().equals(fromPoolName) || !pnv.getNewVersion().equals(fromPoolVersion)) {
changeProcessNameAndVersion((AbstractProcess) element, editingDomain, pnv.getNewName(), pnv.getNewVersion());
poolRenamed = true;
break;
}
}
}
}
}
if (!pools.isEmpty()) {
if (poolRenamed) {
try {
if (newDiagram.eResource() != null) {
newDiagram.eResource().save(ProcessDiagramEditorUtil.getSaveOptions());
......
......@@ -18,6 +18,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.NamingUtils;
import org.bonitasoft.studio.common.OpenNameAndVersionForDiagramDialog.ProcessesNameVersion;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.repository.Repository;
......@@ -116,24 +117,22 @@ public class RenameDiagramOperation implements IRunnableWithProgress {
}
}
diagramFileStore.delete();
}
final DiagramFileStore fStore = diagramStore.getDiagram(diagramName, diagramVersion);
IWorkbenchPart partToActivate = fStore.open();
final MainProcess mainProcess = fStore.getContent();
for (final Form form : forms) {
final List<Form> allItemsOfTypeForms = ModelHelper.getAllItemsOfType(mainProcess, FormPackage.Literals.FORM);
for (final Form f : allItemsOfTypeForms) {
if (EcoreUtil.equals(form, f)) {
final DiagramEditor ed = FormsUtils.openDiagram(f, AdapterFactoryEditingDomain.getEditingDomainFor(f));
if (partName.equals(ed.getTitle())) {
partToActivate = ed;
final DiagramFileStore fStore = diagramStore.getChild(NamingUtils.toDiagramFilename(diagramName, diagramVersion));
IWorkbenchPart partToActivate = fStore.open();
final MainProcess mainProcess = fStore.getContent();
for (final Form form : forms) {
final List<Form> allItemsOfTypeForms = ModelHelper.getAllItemsOfType(mainProcess, FormPackage.Literals.FORM);
for (final Form f : allItemsOfTypeForms) {
if (EcoreUtil.equals(form, f)) {
final DiagramEditor ed = FormsUtils.openDiagram(f, AdapterFactoryEditingDomain.getEditingDomainFor(f));
if (partName.equals(ed.getTitle())) {
partToActivate = ed;
}
}
}
}
partToActivate.getSite().getPage().activate(partToActivate);
}
partToActivate.getSite().getPage().activate(partToActivate);
}
......
Supports Markdown
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