diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLNewDiagramFileWizard.java')
-rw-r--r-- | plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLNewDiagramFileWizard.java | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLNewDiagramFileWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLNewDiagramFileWizard.java index 2bf85c98264..6fc2a88d64d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLNewDiagramFileWizard.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLNewDiagramFileWizard.java @@ -69,31 +69,25 @@ public class UMLNewDiagramFileWizard extends Wizard { assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$ assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$ assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$ - myFileCreationPage = new WizardNewFileCreationPage(Messages.UMLNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY); myFileCreationPage.setTitle(Messages.UMLNewDiagramFileWizard_CreationPageTitle); - myFileCreationPage.setDescription(NLS.bind( - Messages.UMLNewDiagramFileWizard_CreationPageDescription, - ActivityDiagramEditPart.MODEL_ID)); + myFileCreationPage.setDescription(NLS.bind(Messages.UMLNewDiagramFileWizard_CreationPageDescription, ActivityDiagramEditPart.MODEL_ID)); IPath filePath; String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment()); - if (domainModelURI.isPlatformResource()) { + if(domainModelURI.isPlatformResource()) { filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true)); - } else if (domainModelURI.isFile()) { + } else if(domainModelURI.isFile()) { filePath = new Path(domainModelURI.trimSegments(1).toFileString()); } else { // TODO : use some default path throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$ } myFileCreationPage.setContainerFullPath(filePath); - myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName( - filePath, fileName, "PapyrusUMLActivity_diagram")); //$NON-NLS-1$ - + myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(filePath, fileName, "PapyrusUMLActivity_diagram")); //$NON-NLS-1$ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.UMLNewDiagramFileWizard_RootSelectionPageName); diagramRootElementSelectionPage.setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle); diagramRootElementSelectionPage.setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription); diagramRootElementSelectionPage.setModelElement(diagramRoot); - myEditingDomain = editingDomain; } @@ -118,39 +112,29 @@ public class UMLNewDiagramFileWizard extends Wizard { URI diagramModelURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true); ResourceSet resourceSet = myEditingDomain.getResourceSet(); final Resource diagramResource = resourceSet.createResource(diagramModelURI); - AbstractTransactionalCommand command = new AbstractTransactionalCommand( - myEditingDomain, Messages.UMLNewDiagramFileWizard_InitDiagramCommand, affectedFiles) { + AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, Messages.UMLNewDiagramFileWizard_InitDiagramCommand, affectedFiles) { @Override - protected CommandResult doExecuteWithResult( - IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - int diagramVID = UMLVisualIDRegistry.getDiagramVisualID(diagramRootElementSelectionPage.getModelElement()); - if (diagramVID != ActivityDiagramEditPart.VISUAL_ID) { - return CommandResult.newErrorCommandResult( - Messages.UMLNewDiagramFileWizard_IncorrectRootError); + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + String diagramVID = UMLVisualIDRegistry.getDiagramVisualID(diagramRootElementSelectionPage.getModelElement()); + if(diagramVID.equals(ActivityDiagramEditPart.VISUAL_ID)) { + return CommandResult.newErrorCommandResult(Messages.UMLNewDiagramFileWizard_IncorrectRootError); } - Diagram diagram = ViewService.createDiagram( - diagramRootElementSelectionPage.getModelElement(), ActivityDiagramEditPart.MODEL_ID, - UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); + Diagram diagram = ViewService.createDiagram(diagramRootElementSelectionPage.getModelElement(), ActivityDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); diagramResource.getContents().add(diagram); return CommandResult.newOKCommandResult(); } }; try { - OperationHistoryFactory.getOperationHistory().execute( - command, new NullProgressMonitor(), null); + OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null); diagramResource.save(UMLDiagramEditorUtil.getSaveOptions()); UMLDiagramEditorUtil.openDiagram(diagramResource); } catch (ExecutionException e) { - UMLDiagramEditorPlugin.getInstance().logError( - "Unable to create model and diagram", e); //$NON-NLS-1$ + UMLDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$ } catch (IOException ex) { - UMLDiagramEditorPlugin.getInstance().logError( - "Save operation failed for: " + diagramModelURI, ex); //$NON-NLS-1$ + UMLDiagramEditorPlugin.getInstance().logError("Save operation failed for: " + diagramModelURI, ex); //$NON-NLS-1$ } catch (PartInitException ex) { - UMLDiagramEditorPlugin.getInstance().logError( - "Unable to open editor", ex); //$NON-NLS-1$ + UMLDiagramEditorPlugin.getInstance().logError("Unable to open editor", ex); //$NON-NLS-1$ } return true; } @@ -180,14 +164,11 @@ public class UMLNewDiagramFileWizard extends Wizard { */ @Override protected boolean validatePage() { - if (getModelElement() == null) { + if(getModelElement() == null) { setErrorMessage(Messages.UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage); return false; } - boolean result = ViewService.getInstance().provides( - new CreateDiagramViewOperation( - new EObjectAdapter(getModelElement()), - ActivityDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); + boolean result = ViewService.getInstance().provides(new CreateDiagramViewOperation(new EObjectAdapter(getModelElement()), ActivityDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); setErrorMessage(result ? null : Messages.UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage); return result; } |