Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2015-11-17 10:31:00 +0000
committerGerrit Code Review @ Eclipse.org2016-05-23 08:39:48 +0000
commitf04992d719875888482f347985bd417c6bd20ad5 (patch)
treebbb787473146455f58513d33c3b39dc3646199b8 /plugins/uml
parentaea7ae97401e60b919cc0a824b8bdf12a40fb25a (diff)
downloadorg.eclipse.papyrus-f04992d719875888482f347985bd417c6bd20ad5.tar.gz
org.eclipse.papyrus-f04992d719875888482f347985bd417c6bd20ad5.tar.xz
org.eclipse.papyrus-f04992d719875888482f347985bd417c6bd20ad5.zip
Bug 482344: [Wizard] There should not be duplicate version of the same profile on a model at creation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=482344 - modified the way the registered profiles are fetched Change-Id: Ifc3b6eee5a8d674d78a7e9c6ffd52c1ef874d81e Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java
index f7184edeb4d..64da2dc5b6a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java
@@ -37,8 +37,6 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
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.transaction.RecordingCommand;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -48,6 +46,7 @@ import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.papyrus.infra.core.editor.BackboneException;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry;
@@ -253,12 +252,12 @@ public class CreateModelWizard extends Wizard implements INewWizard {
if (diagramCategoryIds.length == 0) {
return false;
}
-
+
SelectDiagramCategoryPage selectDiagramCategoryPage = getSelectDiagramCategoryPage();
- if(selectDiagramCategoryPage != null){
+ if (selectDiagramCategoryPage != null) {
selectDiagramCategoryPage.performFinish();
}
-
+
String diagramCategoryId = diagramCategoryIds[0];
final URI newURI = createNewModelURI(diagramCategoryId);
@@ -328,13 +327,11 @@ public class CreateModelWizard extends Wizard implements INewWizard {
}
private void initProfile(ModelSet modelSet) {
- boolean isProfileApplied = selectDiagramKindPage.getProfileURI() != null;
- if (isProfileApplied) {
+ boolean isToApplyProfile = selectDiagramKindPage.getProfileURI() != null;
+ if (isToApplyProfile) {
applyProfile(modelSet);
saveDiagram(modelSet);
-
}
-
}
private void initTemplate(ModelSet modelSet) {
@@ -472,14 +469,14 @@ public class CreateModelWizard extends Wizard implements INewWizard {
protected void applyProfile(ModelSet modelSet) {
String profilePath = selectDiagramKindPage.getProfileURI();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(profilePath, true), true);
- Profile profile = (Profile) resource.getContents().get(0);
+ Resource resource = modelSet.getResource(URI.createURI(profilePath), true);
+ Profile profileToApply = (Profile) resource.getContents().get(0);
Resource myModelUMLResource = UmlUtils.getUmlResource(modelSet);
org.eclipse.uml2.uml.Package manipulatedModel = (org.eclipse.uml2.uml.Package) myModelUMLResource.getContents().get(0);
- getCommandStack(modelSet).execute(new ApplyProfileCommand(manipulatedModel, profile, modelSet.getTransactionalEditingDomain()));
+
+ RecordingCommand applyProfileCommand = new ApplyProfileCommand(manipulatedModel, profileToApply, modelSet.getTransactionalEditingDomain());
+ getCommandStack(modelSet).execute(applyProfileCommand);
}
protected void applyTemplateTransfo(ModelSet modelSet) {

Back to the top