Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-10-15 16:26:07 +0000
committercletavernie2012-10-15 16:26:07 +0000
commit0deece6c1f05e15594d8b111ad8d5ac12e1004ad (patch)
tree60a983e11a4284632422dede675b183846173e03 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards
parent3da13f092b20cf10f445dad148945c879057a7f5 (diff)
downloadorg.eclipse.papyrus-0deece6c1f05e15594d8b111ad8d5ac12e1004ad.tar.gz
org.eclipse.papyrus-0deece6c1f05e15594d8b111ad8d5ac12e1004ad.tar.xz
org.eclipse.papyrus-0deece6c1f05e15594d8b111ad8d5ac12e1004ad.zip
391945: [Refactoring] Part 2: Refactoring on Kepler (0.10)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391945
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/CreateModelWizard.java253
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/InitModelWizard.java123
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/category/PapyrusModelFromExistingDomainModelCommand.java12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindLabelProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/template/InitFromTemplateCommand.java98
8 files changed, 284 insertions, 221 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF
index 200ebc217d4..a0dd0877182 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF
@@ -10,7 +10,10 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="0.10.0",
org.eclipse.ui.ide;bundle-version="3.8.0",
org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="0.10.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0"
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.0"
Export-Package: org.eclipse.papyrus.uml.diagram.wizards,
org.eclipse.papyrus.uml.diagram.wizards.category,
org.eclipse.papyrus.uml.diagram.wizards.kind,
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/CreateModelWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/CreateModelWizard.java
index 5e2fdba45e4..2cc0c416758 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/CreateModelWizard.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/CreateModelWizard.java
@@ -32,9 +32,11 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.infra.core.editor.BackboneException;
-import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
import org.eclipse.papyrus.infra.core.extension.commands.IModelCreationCommand;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.uml.diagram.wizards.category.DiagramCategoryDescriptor;
@@ -53,13 +55,8 @@ import org.eclipse.ui.ide.IDE;
/**
* Create new model file and initialize a selected diagram. This wizard create
- * several files :
- * <li>*.di : the DI file to store Di diagrams and references all
- * external diagrams like GMF diagrams.</li>
- * <li>*.notation : the file to store pure GMF
- * diagrams</li>
- * <li>*.uml : the standard UML file to store UML semantics elements.
- * (Model, Package, Class,...)</li>
+ * several files : <li>*.di : the DI file to store Di diagrams and references all external diagrams like GMF diagrams.</li> <li>*.notation : the file
+ * to store pure GMF diagrams</li> <li>*.uml : the standard UML file to store UML semantics elements. (Model, Package, Class,...)</li>
*
* Those files can be used with the PapyrusEditor (see plugin.xml).
*/
@@ -94,7 +91,7 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Adds the pages.
- *
+ *
* {@inheritDoc}
*/
@Override
@@ -106,8 +103,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Adds the page if not null.
- *
- * @param page the page
+ *
+ * @param page
+ * the page
*/
protected final void addPageIfNotNull(IWizardPage page) {
if(page != null) {
@@ -117,10 +115,11 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Inits the.
- *
- * @param workbench the workbench
- * @param selection the selection
- * {@inheritDoc}
+ *
+ * @param workbench
+ * the workbench
+ * @param selection
+ * the selection {@inheritDoc}
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.workbench = workbench;
@@ -139,13 +138,12 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Perform finish.
- *
- * @return true, if successful
- * {@inheritDoc}
+ *
+ * @return true, if successful {@inheritDoc}
*/
@Override
public boolean performFinish() {
- DiResourceSet diResourceSet = new DiResourceSetExt();
+ ModelSet modelSet = new DiResourceSetExt();
String[] diagramCategoryIds = getDiagramCategoryIds();
if(diagramCategoryIds.length == 0) {
return false;
@@ -153,7 +151,7 @@ public class CreateModelWizard extends Wizard implements INewWizard {
String diagramCategoryId = diagramCategoryIds[0];
final IFile newFile = createNewModelFile(diagramCategoryId);
- createAndOpenPapyrusModel(diResourceSet, newFile, diagramCategoryId);
+ createAndOpenPapyrusModel(modelSet, newFile, diagramCategoryId);
saveDiagramCategorySettings();
saveDiagramKindSettings();
@@ -162,21 +160,24 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the and open papyrus model.
- *
- * @param diResourceSet the di resource set
- * @param newFile the new file
- * @param diagramCategoryId the diagram category id
+ *
+ * @param modelSet
+ * the di resource set
+ * @param newFile
+ * the new file
+ * @param diagramCategoryId
+ * the diagram category id
* @return true, if successful
*/
- protected boolean createAndOpenPapyrusModel(DiResourceSet diResourceSet, IFile newFile, String diagramCategoryId) {
+ protected boolean createAndOpenPapyrusModel(ModelSet modelSet, IFile newFile, String diagramCategoryId) {
if(newFile == null) {
return false;
}
- createPapyrusModels(diResourceSet, newFile);
+ createPapyrusModels(modelSet, newFile);
- initDomainModel(diResourceSet, newFile, diagramCategoryId);
+ initDomainModel(modelSet, newFile, diagramCategoryId);
- initDiagramModel(diResourceSet, diagramCategoryId);
+ initDiagramModel(modelSet, diagramCategoryId);
openDiagram(newFile);
@@ -185,7 +186,7 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Gets the diagram category ids.
- *
+ *
* @return the diagram category ids
*/
protected String[] getDiagramCategoryIds() {
@@ -197,8 +198,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Gets the diagram file extension.
- *
- * @param diagramCategoryId the diagram category id
+ *
+ * @param diagramCategoryId
+ * the diagram category id
* @return the diagram file extension
*/
protected String getDiagramFileExtension(String diagramCategoryId) {
@@ -207,9 +209,11 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Gets the diagram file extension.
- *
- * @param categoryId the category id
- * @param defaultExtension the default extension
+ *
+ * @param categoryId
+ * the category id
+ * @param defaultExtension
+ * the default extension
* @return the diagram file extension
*/
protected String getDiagramFileExtension(String categoryId, String defaultExtension) {
@@ -220,8 +224,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the new model file page.
- *
- * @param selection the selection
+ *
+ * @param selection
+ * the selection
* @return the new model file page
*/
protected NewModelFilePage createNewModelFilePage(IStructuredSelection selection) {
@@ -230,7 +235,7 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the select diagram category page.
- *
+ *
* @return the select diagram category page
*/
protected SelectDiagramCategoryPage createSelectDiagramCategoryPage() {
@@ -239,7 +244,7 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the select diagram kind page.
- *
+ *
* @return the select diagram kind page
*/
protected SelectDiagramKindPage createSelectDiagramKindPage() {
@@ -254,8 +259,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the new model file.
- *
- * @param categoryId the category id
+ *
+ * @param categoryId
+ * the category id
* @return the i file
*/
protected IFile createNewModelFile(String categoryId) {
@@ -264,40 +270,46 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Inits the domain model.
- *
- * @param diResourceSet the di resource set
- * @param newFile the new file
- * @param diagramCategoryId the diagram category id
- */
- protected void initDomainModel(DiResourceSet diResourceSet, final IFile newFile, String diagramCategoryId) {
+ *
+ * @param modelSet
+ * the di resource set
+ * @param newFile
+ * the new file
+ * @param diagramCategoryId
+ * the diagram category id
+ */
+ protected void initDomainModel(ModelSet modelSet, final IFile newFile, String diagramCategoryId) {
boolean isToInitFromTemplate = selectDiagramKindPage.getTemplatePath() != null;
if(isToInitFromTemplate) {
- initDomainModelFromTemplate(diResourceSet);
+ initDomainModelFromTemplate(modelSet);
} else {
- createEmptyDomainModel(diResourceSet, diagramCategoryId);
+ createEmptyDomainModel(modelSet, diagramCategoryId);
}
}
/**
* Inits the domain model from template.
- *
- * @param diResourceSet the di resource set
+ *
+ * @param modelSet
+ * the di resource set
*/
- protected void initDomainModelFromTemplate(DiResourceSet diResourceSet) {
- //getCommandStack(diResourceSet).execute(new InitFromTemplateCommand(diResourceSet.getTransactionalEditingDomain(), diResourceSet.getModelResource(), diResourceSet.getDiResource(), diResourceSet.getNotationResource(), selectDiagramKindPage.getTemplatePluginId(), selectDiagramKindPage.getTemplatePath(),selectDiagramKindPage.getNotationTemplatePath(),selectDiagramKindPage.getDiTemplatePath()));
- getCommandStack(diResourceSet).execute(new InitFromTemplateCommand(diResourceSet.getTransactionalEditingDomain(), diResourceSet, selectDiagramKindPage.getTemplatePluginId(), selectDiagramKindPage.getTemplatePath(),selectDiagramKindPage.getNotationTemplatePath(),selectDiagramKindPage.getDiTemplatePath()));
+ protected void initDomainModelFromTemplate(ModelSet modelSet) {
+ //getCommandStack(modelSet).execute(new InitFromTemplateCommand(modelSet.getTransactionalEditingDomain(), modelSet.getModelResource(), modelSet.getDiResource(), modelSet.getNotationResource(), selectDiagramKindPage.getTemplatePluginId(), selectDiagramKindPage.getTemplatePath(),selectDiagramKindPage.getNotationTemplatePath(),selectDiagramKindPage.getDiTemplatePath()));
+ getCommandStack(modelSet).execute(new InitFromTemplateCommand(modelSet.getTransactionalEditingDomain(), modelSet, selectDiagramKindPage.getTemplatePluginId(), selectDiagramKindPage.getTemplatePath(), selectDiagramKindPage.getNotationTemplatePath(), selectDiagramKindPage.getDiTemplatePath()));
}
/**
* Creates the empty domain model.
- *
- * @param diResourceSet the di resource set
- * @param diagramCategoryId the diagram category id
+ *
+ * @param modelSet
+ * the di resource set
+ * @param diagramCategoryId
+ * the diagram category id
*/
- protected void createEmptyDomainModel(DiResourceSet diResourceSet, String diagramCategoryId) {
+ protected void createEmptyDomainModel(ModelSet modelSet, String diagramCategoryId) {
try {
IModelCreationCommand creationCommand = getDiagramCategoryMap().get(diagramCategoryId).getCommand();
- creationCommand.createModel(diResourceSet);
+ creationCommand.createModel(modelSet);
} catch (BackboneException e) {
log.error(e);
}
@@ -305,13 +317,15 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the papyrus models.
- *
- * @param diResourceSet the di resource set
- * @param newFile the new file
+ *
+ * @param modelSet
+ * the di resource set
+ * @param newFile
+ * the new file
*/
- protected void createPapyrusModels(DiResourceSet diResourceSet, IFile newFile) {
- RecordingCommand command = new NewPapyrusModelCommand(diResourceSet, newFile);
- getCommandStack(diResourceSet).execute(command);
+ protected void createPapyrusModels(ModelSet modelSet, IFile newFile) {
+ RecordingCommand command = new NewPapyrusModelCommand(modelSet, newFile);
+ getCommandStack(modelSet).execute(command);
}
/**
@@ -334,7 +348,7 @@ public class CreateModelWizard extends Wizard implements INewWizard {
return;
}
SettingsHelper settingsHelper = new SettingsHelper(settings);
- for (String category: getDiagramCategoryIds()) {
+ for(String category : getDiagramCategoryIds()) {
if(selectDiagramKindPage.isRememberCurrentSelection()) {
saveDefaultDiagramKinds(settingsHelper, category);
saveDefaultTemplates(settingsHelper, category);
@@ -348,9 +362,11 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Save default diagram kinds.
- *
- * @param settingsHelper the settings helper
- * @param category the category
+ *
+ * @param settingsHelper
+ * the settings helper
+ * @param category
+ * the category
*/
private void saveDefaultDiagramKinds(SettingsHelper settingsHelper, String category) {
String[] selected = selectDiagramKindPage.getSelectedDiagramKinds(category);
@@ -359,9 +375,11 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Save default templates.
- *
- * @param settingsHelper the settings helper
- * @param category the category
+ *
+ * @param settingsHelper
+ * the settings helper
+ * @param category
+ * the category
*/
private void saveDefaultTemplates(SettingsHelper settingsHelper, String category) {
if(!selectDiagramKindPage.templatesEnabled()) {
@@ -373,8 +391,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Open diagram.
- *
- * @param newFile the new file
+ *
+ * @param newFile
+ * the new file
*/
protected void openDiagram(final IFile newFile) {
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
@@ -390,23 +409,26 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Inits the diagram model.
- *
- * @param diResourceSet the di resource set
- * @param categoryId the category id
+ *
+ * @param modelSet
+ * the di resource set
+ * @param categoryId
+ * the category id
*/
- protected void initDiagramModel(DiResourceSet diResourceSet, String categoryId) {
- initDiagrams(diResourceSet, categoryId);
- saveDiagram(diResourceSet);
+ protected void initDiagramModel(ModelSet modelSet, String categoryId) {
+ initDiagrams(modelSet, categoryId);
+ saveDiagram(modelSet);
}
/**
* Save diagram.
- *
- * @param diResourceSet the di resource set
+ *
+ * @param modelSet
+ * the di resource set
*/
- private void saveDiagram(DiResourceSet diResourceSet) {
+ private void saveDiagram(ModelSet modelSet) {
try {
- diResourceSet.save(new NullProgressMonitor());
+ modelSet.save(new NullProgressMonitor());
} catch (IOException e) {
log.error(e);
// return false;
@@ -415,22 +437,27 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Inits the diagrams.
- *
- * @param diResourceSet the di resource set
- * @param categoryId the category id
+ *
+ * @param modelSet
+ * the di resource set
+ * @param categoryId
+ * the category id
*/
- protected void initDiagrams(DiResourceSet diResourceSet, String categoryId) {
- initDiagrams(diResourceSet, null, categoryId);
+ protected void initDiagrams(ModelSet modelSet, String categoryId) {
+ initDiagrams(modelSet, null, categoryId);
}
/**
* Inits the diagrams.
- *
- * @param resourceSet the resource set
- * @param root the root
- * @param categoryId the category id
- */
- protected void initDiagrams(DiResourceSet resourceSet, EObject root, String categoryId) {
+ *
+ * @param resourceSet
+ * the resource set
+ * @param root
+ * the root
+ * @param categoryId
+ * the category id
+ */
+ protected void initDiagrams(ModelSet resourceSet, EObject root, String categoryId) {
List<ICreationCommand> creationCommands = getDiagramKindsFor(categoryId);
String diagramName = selectDiagramKindPage.getDiagramName();
if(creationCommands.isEmpty()) {
@@ -444,8 +471,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Gets the diagram kinds for.
- *
- * @param categoryId the category id
+ *
+ * @param categoryId
+ * the category id
* @return the diagram kinds for
*/
protected List<ICreationCommand> getDiagramKindsFor(String categoryId) {
@@ -455,29 +483,31 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Creates the empty diagram editor.
- *
- * @param diResourceSet the di resource set
+ *
+ * @param modelSet
+ * the model set
*/
- private void createEmptyDiagramEditor(DiResourceSet diResourceSet) {
+ private void createEmptyDiagramEditor(ModelSet modelSet) {
// Create an empty editor (no diagrams opened)
// Geting an IPageMngr is enough to initialize the
// SashSystem.
- EditorUtils.getTransactionalIPageMngr(diResourceSet.getDiResource(), diResourceSet.getTransactionalEditingDomain());
+ EditorUtils.getTransactionalIPageMngr(DiModelUtils.getDiResource(modelSet), modelSet.getTransactionalEditingDomain());
}
/**
* Gets the command stack.
- *
- * @param diResourceSet the di resource set
+ *
+ * @param modelSet
+ * the model set
* @return the command stack
*/
- protected final CommandStack getCommandStack(DiResourceSet diResourceSet) {
- return diResourceSet.getTransactionalEditingDomain().getCommandStack();
+ protected final CommandStack getCommandStack(ModelSet modelSet) {
+ return modelSet.getTransactionalEditingDomain().getCommandStack();
}
/**
* Gets the diagram category map.
- *
+ *
* @return the diagram category map
*/
protected Map<String, DiagramCategoryDescriptor> getDiagramCategoryMap() {
@@ -486,8 +516,9 @@ public class CreateModelWizard extends Wizard implements INewWizard {
/**
* Diagram category changed.
- *
- * @param newCategories the new categories
+ *
+ * @param newCategories
+ * the new categories
* @return the i status
*/
public IStatus diagramCategoryChanged(String... newCategories) {
@@ -500,15 +531,17 @@ public class CreateModelWizard extends Wizard implements INewWizard {
}
return Status.OK_STATUS;
}
-
+
// Bug 339504 - [Wizard] NPE when init diagram from an existing model
/**
* The Class DiResourceSetExt.
*/
public static class DiResourceSetExt extends DiResourceSet {
-
+
// open access to protected method to be set in PapyrusModelFromExistingDomainModelCommand
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.resource.ModelSet#setFilenameWithoutExtension(org.eclipse.core.runtime.IPath)
*/
@Override
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/InitModelWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/InitModelWizard.java
index 305b7c1c4aa..176f1e9d2d7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/InitModelWizard.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/InitModelWizard.java
@@ -17,20 +17,20 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
-import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.uml.diagram.wizards.category.PapyrusModelFromExistingDomainModelCommand;
import org.eclipse.papyrus.uml.diagram.wizards.pages.NewModelFilePage;
import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectDiagramKindPage;
import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectDiagramKindPage.CategoryProvider;
import org.eclipse.papyrus.uml.diagram.wizards.pages.SelectRootElementPage;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.ui.IWorkbench;
/**
*
- * The New Papyrus Model Wizard.
+ * The New Papyrus Model Wizard.
* If being invoke on the *.uml file - initializes a new Papyrus diagram for the selected domain model.
- * If is selected is empty or in not uml - creates a new Papyrus Model.
+ * If is selected is empty or in not uml - creates a new Papyrus Model.
*/
public class InitModelWizard extends CreateModelWizard {
@@ -42,10 +42,11 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Inits the.
- *
- * @param workbench the workbench
- * @param selection the selection
- * {@inheritDoc}
+ *
+ * @param workbench
+ * the workbench
+ * @param selection
+ * the selection {@inheritDoc}
*/
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
@@ -61,8 +62,9 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Creates the select root element page.
- *
- * @param file the file
+ *
+ * @param file
+ * the file
* @return the select root element page
*/
protected SelectRootElementPage createSelectRootElementPage(IFile file) {
@@ -75,9 +77,8 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Creates the select diagram kind page.
- *
- * @return the select diagram kind page
- * {@inheritDoc}
+ *
+ * @return the select diagram kind page {@inheritDoc}
*/
@Override
protected SelectDiagramKindPage createSelectDiagramKindPage() {
@@ -95,10 +96,10 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Creates the new model file page.
- *
- * @param selection the selection
- * @return the new model file page
- * {@inheritDoc}
+ *
+ * @param selection
+ * the selection
+ * @return the new model file page {@inheritDoc}
*/
@Override
protected NewModelFilePage createNewModelFilePage(IStructuredSelection selection) {
@@ -111,7 +112,7 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Adds the pages.
- *
+ *
* {@inheritDoc}
*/
@Override
@@ -128,8 +129,8 @@ public class InitModelWizard extends CreateModelWizard {
* @return true, if is supported domain model file
*/
public static boolean isSupportedDomainModelFile(IFile file) {
-// if(file != null && UmlModel.UML_FILE_EXTENSION.equals(file.getFileExtension())){System.err.println("is SupportedDomainModelFile");}
-// else {System.err.println("not SupportedDomainModelFile");}
+ // if(file != null && UmlModel.UML_FILE_EXTENSION.equals(file.getFileExtension())){System.err.println("is SupportedDomainModelFile");}
+ // else {System.err.println("not SupportedDomainModelFile");}
return file != null && UmlModel.UML_FILE_EXTENSION.equals(file.getFileExtension());
}
@@ -142,59 +143,63 @@ public class InitModelWizard extends CreateModelWizard {
*/
public static boolean isSupportedDomainModelFile(IStructuredSelection sselection) {
IFile file = getSelectedFile(sselection);
-// if(!isSupportedDomainModelFile(file)){System.err.println("not SupportedDomainModelFile");}
+ // if(!isSupportedDomainModelFile(file)){System.err.println("not SupportedDomainModelFile");}
return isSupportedDomainModelFile(file);
}
/**
* Creates the papyrus models.
- *
- * @param diResourceSet the di resource set
- * @param newFile the new file
- * {@inheritDoc}
+ *
+ * @param diResourceSet
+ * the di resource set
+ * @param newFile
+ * the new file {@inheritDoc}
*/
@Override
- protected void createPapyrusModels(DiResourceSet diResourceSet, IFile newFile) {
+ protected void createPapyrusModels(ModelSet modelSet, IFile newFile) {
if(isCreateFromExistingDomainModel()) {
- RecordingCommand command = new PapyrusModelFromExistingDomainModelCommand(diResourceSet, newFile, getRoot());
- getCommandStack(diResourceSet).execute(command);
+ RecordingCommand command = new PapyrusModelFromExistingDomainModelCommand(modelSet, newFile, getRoot());
+ getCommandStack(modelSet).execute(command);
} else {
- super.createPapyrusModels(diResourceSet, newFile);
+ super.createPapyrusModels(modelSet, newFile);
}
}
/**
* Inits the domain model.
- *
- * @param diResourceSet the di resource set
- * @param newFile the new file
- * @param diagramCategoryId the diagram category id
- * {@inheritDoc}
+ *
+ * @param diResourceSet
+ * the di resource set
+ * @param newFile
+ * the new file
+ * @param diagramCategoryId
+ * the diagram category id {@inheritDoc}
*/
@Override
- protected void initDomainModel(DiResourceSet diResourceSet, final IFile newFile, String diagramCategoryId) {
+ protected void initDomainModel(ModelSet modelSet, final IFile newFile, String diagramCategoryId) {
if(isCreateFromExistingDomainModel()) {
// do nothing
} else {
- super.initDomainModel(diResourceSet, newFile, diagramCategoryId);
+ super.initDomainModel(modelSet, newFile, diagramCategoryId);
}
}
/**
* Inits the diagrams.
- *
- * @param diResourceSet the di resource set
- * @param categoryId the category id
- * {@inheritDoc}
+ *
+ * @param diResourceSet
+ * the di resource set
+ * @param categoryId
+ * the category id {@inheritDoc}
*/
@Override
- protected void initDiagrams(DiResourceSet diResourceSet, String categoryId) {
- initDiagrams(diResourceSet, getRoot(), categoryId);
+ protected void initDiagrams(ModelSet modelSet, String categoryId) {
+ initDiagrams(modelSet, getRoot(), categoryId);
}
/**
* Checks if is creates the from existing domain model.
- *
+ *
* @return true, if is creates the from existing domain model
*/
protected boolean isCreateFromExistingDomainModel() {
@@ -203,15 +208,18 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Suggests a name of diagram file for the domain model file without extension.
- *
- * @param domainModel the domain model
+ *
+ * @param domainModel
+ * the domain model
* @return the diagram file name
*/
protected String getDiagramFileName(IFile domainModel) {
return domainModel.getLocation().removeFileExtension().lastSegment();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.papyrus.uml.diagram.wizards.CreateModelWizard#getDiagramFileExtension(java.lang.String)
*/
@Override
@@ -224,8 +232,9 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Returns the first file from the given selection.
- *
- * @param selection the selection
+ *
+ * @param selection
+ * the selection
* @return the selected file
*/
private static IFile getSelectedFile(IStructuredSelection selection) {
@@ -237,7 +246,7 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Gets the root.
- *
+ *
* @return the root
*/
private EObject getRoot() {
@@ -257,10 +266,13 @@ public class InitModelWizard extends CreateModelWizard {
/**
* Instantiates a new new diagram for existing model page.
- *
- * @param selection the selection
- * @param defaultFileName the default file name
- * @param diagramExtension the diagram extension
+ *
+ * @param selection
+ * the selection
+ * @param defaultFileName
+ * the default file name
+ * @param diagramExtension
+ * the diagram extension
*/
public NewDiagramForExistingModelPage(IStructuredSelection selection, String defaultFileName, String diagramExtension) {
super(selection);
@@ -271,9 +283,12 @@ public class InitModelWizard extends CreateModelWizard {
setDescription(Messages.InitModelWizard_init_papyrus_model_desc);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#validatePage()
*/
+ @Override
protected boolean validatePage() {
if(!super.validatePage()) {
return false;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/category/PapyrusModelFromExistingDomainModelCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/category/PapyrusModelFromExistingDomainModelCommand.java
index a881ee7b4a8..7e85ec1ad52 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/category/PapyrusModelFromExistingDomainModelCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/category/PapyrusModelFromExistingDomainModelCommand.java
@@ -21,10 +21,10 @@ import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.papyrus.infra.core.resource.IModel;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.ModelUtils;
-import org.eclipse.papyrus.infra.core.resource.notation.NotationModel;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
-import org.eclipse.papyrus.infra.core.resource.uml.UmlModel;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
import org.eclipse.papyrus.uml.diagram.wizards.CreateModelWizard.DiResourceSetExt;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
/**
* The command to initialize Papyrus diagram for a given domain model.
@@ -47,12 +47,12 @@ public class PapyrusModelFromExistingDomainModelCommand extends RecordingCommand
* @param newFile the new file
* @param root the root
*/
- public PapyrusModelFromExistingDomainModelCommand(ModelSet diResourceSet, IFile newFile, EObject root) {
- super(diResourceSet.getTransactionalEditingDomain());
- myDiResourceSet = diResourceSet;
+ public PapyrusModelFromExistingDomainModelCommand(ModelSet modelSet, IFile newFile, EObject root) {
+ super(modelSet.getTransactionalEditingDomain());
+ myDiResourceSet = modelSet;
myFileNameWithoutExtension = newFile.getFullPath().removeFileExtension();
// Bug 339504 - [Wizard] NPE when init diagram from an existing model
- ((DiResourceSetExt)diResourceSet).setFilenameWithoutExtension(myFileNameWithoutExtension);
+ ((DiResourceSetExt)modelSet).setFilenameWithoutExtension(myFileNameWithoutExtension);
myRoot = root;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java
index ecc896fab57..bb4e472ae95 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java
@@ -20,8 +20,8 @@ import java.util.List;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandDescriptor;
-import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommandRegistry;
+import org.eclipse.papyrus.commands.CreationCommandDescriptor;
+import org.eclipse.papyrus.commands.ICreationCommandRegistry;
/**
* The ContentProvider for DiagramCategory table.
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindLabelProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindLabelProvider.java
index 800a40738f1..c4e68a459b7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindLabelProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindLabelProvider.java
@@ -16,7 +16,7 @@ package org.eclipse.papyrus.uml.diagram.wizards.kind;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandDescriptor;
+import org.eclipse.papyrus.commands.CreationCommandDescriptor;
import org.eclipse.papyrus.uml.diagram.wizards.Messages;
import org.eclipse.swt.graphics.Image;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java
index bfee6dab5c6..4007b2aa697 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java
@@ -25,10 +25,10 @@ import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandDescriptor;
-import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandRegistry;
-import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
-import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommandRegistry;
+import org.eclipse.papyrus.commands.CreationCommandDescriptor;
+import org.eclipse.papyrus.commands.CreationCommandRegistry;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.commands.ICreationCommandRegistry;
import org.eclipse.papyrus.uml.diagram.wizards.Messages;
import org.eclipse.papyrus.uml.diagram.wizards.SettingsHelper;
import org.eclipse.papyrus.uml.diagram.wizards.kind.DiagramKindContentProvider;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/template/InitFromTemplateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/template/InitFromTemplateCommand.java
index 3d395b99575..46d534adb3a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/template/InitFromTemplateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/template/InitFromTemplateCommand.java
@@ -27,9 +27,12 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
-import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
import org.eclipse.papyrus.uml.diagram.wizards.utils.WizardsHelper;
+import org.eclipse.papyrus.uml.tools.model.UmlUtils;
/**
@@ -60,19 +63,25 @@ public class InitFromTemplateCommand extends RecordingCommand {
/**
* Instantiates a new inits the from template command.
- *
- * @param editingDomain the editing domain
- * @param diResouceSet the di resouce set
- * @param pluginId the plugin id
- * @param umlTemplatePath the uml template path
- * @param notationTemplatePath the notation template path
- * @param diTemplatePath the di template path
+ *
+ * @param editingDomain
+ * the editing domain
+ * @param diResouceSet
+ * the di resouce set
+ * @param pluginId
+ * the plugin id
+ * @param umlTemplatePath
+ * the uml template path
+ * @param notationTemplatePath
+ * the notation template path
+ * @param diTemplatePath
+ * the di template path
*/
- public InitFromTemplateCommand(TransactionalEditingDomain editingDomain, DiResourceSet diResouceSet, String pluginId, String umlTemplatePath, String notationTemplatePath, String diTemplatePath) {
+ public InitFromTemplateCommand(TransactionalEditingDomain editingDomain, ModelSet modelSet, String pluginId, String umlTemplatePath, String notationTemplatePath, String diTemplatePath) {
super(editingDomain);
- myModelUMLResource = diResouceSet.getModelResource();
- myModelDiResource = diResouceSet.getDiResource();
- myModelNotationResource = diResouceSet.getNotationResource();
+ myModelUMLResource = UmlUtils.getUmlResource(modelSet);
+ myModelDiResource = DiModelUtils.getDiResource(modelSet);
+ myModelNotationResource = NotationUtils.getNotationResource(modelSet);
myPluginId = pluginId;
myUmlTemplatePath = umlTemplatePath;
myDiTemplatePath = diTemplatePath;
@@ -81,7 +90,9 @@ public class InitFromTemplateCommand extends RecordingCommand {
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
*/
@Override
@@ -101,19 +112,20 @@ public class InitFromTemplateCommand extends RecordingCommand {
/**
* Initialize from template.
- *
-
- * @throws IOException Signals that an I/O exception has occurred.
+ *
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
*/
private void initializeFromTemplate() throws IOException {
- Resource templateDiResource=null;
- Resource templateNotationResource=null;
- Resource templateUmlResource=null;
+ Resource templateDiResource = null;
+ Resource templateNotationResource = null;
+ Resource templateUmlResource = null;
//0. initalization of the UML object
ResourceSet resourceSet = new ResourceSetImpl();
- templateUmlResource = loadTemplateResource(myUmlTemplatePath,resourceSet);
+ templateUmlResource = loadTemplateResource(myUmlTemplatePath, resourceSet);
//1. prepare the copy of UML element
@@ -123,52 +135,51 @@ public class InitFromTemplateCommand extends RecordingCommand {
//2. test if di and notation exist
//verify if .di file and .notation file were filled in the org.eclipse.papyrus.uml.diagram.wizards.templates extension
- if ((myDiTemplatePath!=null) && (myNotationTemplatePath!=null)){
+ if((myDiTemplatePath != null) && (myNotationTemplatePath != null)) {
//2.1 verify if the .di , .notation and .uml files have the same name
- String diFileName= WizardsHelper.getFileNameWithoutExtension(myDiTemplatePath);
- String umlFileName= WizardsHelper.getFileNameWithoutExtension(myUmlTemplatePath);
- String notationFileName= WizardsHelper.getFileNameWithoutExtension(myNotationTemplatePath);
+ String diFileName = WizardsHelper.getFileNameWithoutExtension(myDiTemplatePath);
+ String umlFileName = WizardsHelper.getFileNameWithoutExtension(myUmlTemplatePath);
+ String notationFileName = WizardsHelper.getFileNameWithoutExtension(myNotationTemplatePath);
- if (diFileName.contentEquals(umlFileName) && diFileName.contentEquals(notationFileName)){
+ if(diFileName.contentEquals(umlFileName) && diFileName.contentEquals(notationFileName)) {
//2.2 load di resource
- if( myDiTemplatePath!=null){
- templateDiResource = loadTemplateResource(myDiTemplatePath,resourceSet);
+ if(myDiTemplatePath != null) {
+ templateDiResource = loadTemplateResource(myDiTemplatePath, resourceSet);
}
//2.3 load notation resource
- if( myNotationTemplatePath!=null){
- templateNotationResource = loadTemplateResource(myNotationTemplatePath,resourceSet);
+ if(myNotationTemplatePath != null) {
+ templateNotationResource = loadTemplateResource(myNotationTemplatePath, resourceSet);
}
//Visits all proxies in the resource set and tries to resolve them.
EcoreUtil.resolveAll(resourceSet);
//2.4 prepare the copy of di and notation elements
- if(templateNotationResource!=null){
- eObjectsToAdd.addAll(templateNotationResource.getContents());}
- if(templateDiResource!=null){
+ if(templateNotationResource != null) {
+ eObjectsToAdd.addAll(templateNotationResource.getContents());
+ }
+ if(templateDiResource != null) {
eObjectsToAdd.addAll(templateDiResource.getContents());
}
}
}
//3. copy all element into eObjectResult
List<EObject> eObjectsResult = new ArrayList<EObject>();
- eObjectsResult.addAll((List<EObject>)EcoreUtil.copyAll(eObjectsToAdd));
+ eObjectsResult.addAll(EcoreUtil.copyAll(eObjectsToAdd));
//4. set copied elements in goods resources
for(EObject eObject : eObjectsResult) {
- if( eObject.eContainer()==null){
- if (eObject instanceof Diagram)
- {
+ if(eObject.eContainer() == null) {
+ if(eObject instanceof Diagram) {
myModelNotationResource.getContents().add(eObject);
+ } else if(eObject instanceof SashWindowsMngr) {
+ myModelDiResource.getContents().add(eObject);
+ } else {
+ myModelUMLResource.getContents().add(eObject);
}
- else
- if (eObject instanceof SashWindowsMngr)
- {myModelDiResource.getContents().add(eObject);}
- else
- {myModelUMLResource.getContents().add(eObject);}
}
}
}
@@ -177,8 +188,9 @@ public class InitFromTemplateCommand extends RecordingCommand {
/**
* Load template resource.
- *
- * @param path the path
+ *
+ * @param path
+ * the path
* @return the resource
*/
private Resource loadTemplateResource(String path, ResourceSet resourceSet) {

Back to the top