| /* |
| * Copyright (c) 2007 Borland Software Corporation |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Dmitry Stadnik (Borland) - initial API and implementation |
| * Tatiana Fesenko (Borland) - bugzilla #230873 'Make diagram file extension shorter', |
| * #268252 'There should be a way to specify exact metaclass of the diagram canvas semantic element" |
| * |
| */ |
| |
| «IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'» |
| |
| «EXTENSION MetaModel» |
| «EXTENSION xpt::editor::Utils» |
| «EXTENSION aspects::xpt::FileExtensionUtils» |
| «EXTENSION u2t::wizard::Utils» |
| «EXTENSION xpt::editor::GenDiagram» |
| |
| «AROUND xpt::editor::CreationWizard::CreationWizard FOR gmfgen::GenDiagram-» |
| «EXPAND xpt::Common::copyright FOR editorGen-» |
| package «editorGen.editor.packageName»; |
| |
| «EXPAND xpt::Common::generatedClassComment» |
| public class «creationWizardClassName» |
| extends org.eclipse.jface.wizard.Wizard implements org.eclipse.ui.INewWizard { |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| private org.eclipse.ui.IWorkbench workbench; |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected org.eclipse.jface.viewers.IStructuredSelection selection; |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected «getCreationWizardPageQualifiedClassName()» diagramModelFilePage; |
| «IF standaloneDomainModel(self)-» |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected «getCreationWizardPageQualifiedClassName()» domainModelFilePage; |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| private org.eclipse.uml2.diagram.common.part.UMLModelWizardInitialObjectCreationPage initialObjectCreationPage; |
| «ENDIF-» |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected org.eclipse.emf.ecore.resource.Resource diagram; |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| private boolean openNewlyCreatedDiagramEditor = true; |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public org.eclipse.ui.IWorkbench getWorkbench() { |
| return workbench; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public org.eclipse.jface.viewers.IStructuredSelection getSelection() { |
| return selection; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public final org.eclipse.emf.ecore.resource.Resource getDiagram() { |
| return diagram; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public final boolean isOpenNewlyCreatedDiagramEditor() { |
| return openNewlyCreatedDiagramEditor; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) { |
| this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void init(org.eclipse.ui.IWorkbench workbench, org.eclipse.jface.viewers.IStructuredSelection selection) { |
| this.workbench = workbench; |
| this.selection = selection; |
| setWindowTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizard(self))) FOR editorGen»); |
| setDefaultPageImageDescriptor(«editorGen.plugin.getActivatorQualifiedClassName()».getBundledImageDescriptor( |
| "icons/wizban/New«IF domainDiagramElement <> null»«domainDiagramElement.genPackage.prefix»«ENDIF»Wizard.gif")); //$NON-NLS-1$ |
| setNeedsProgressMonitor(true); |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void addPages() { |
| «REM» #230873 'Make diagram file extension shorter' |
| The only change is here. We take the first extension from the comma-separated list«ENDREM-» |
| diagramModelFilePage = new «getCreationWizardPageQualifiedClassName()»( |
| "DiagramModelFile", getSelection(), "«getDefaultDiagramExtension(editorGen)»"); //$NON-NLS-1$ //$NON-NLS-2$ |
| «REM» END #230873 «ENDREM»«-» |
| diagramModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDiagramPage(self))) FOR editorGen»); |
| diagramModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDiagramPage(self))) FOR editorGen»); |
| addPage(diagramModelFilePage); |
| «IF standaloneDomainModel(self)-» |
| |
| domainModelFilePage = new «getCreationWizardPageQualifiedClassName()»( |
| "DomainModelFile", getSelection(), "«editorGen.domainFileExtension»"); //$NON-NLS-1$ //$NON-NLS-2$ |
| domainModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»); |
| domainModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»); |
| addPage(domainModelFilePage); |
| «IF needInitialObject(self)-» |
| «EXPAND u2t::wizard::InitialObject::addInitialObjectPage»«ENDIF-» |
| «ENDIF-» |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public boolean performFinish() { |
| org.eclipse.jface.operation.IRunnableWithProgress op = |
| «IF editorGen.application = null-» |
| new org.eclipse.ui.actions.WorkspaceModifyOperation(null) { |
| |
| protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor) |
| throws org.eclipse.core.runtime.CoreException, InterruptedException { |
| «ELSE-» |
| new org.eclipse.jface.operation.IRunnableWithProgress() { |
| |
| public void run(org.eclipse.core.runtime.IProgressMonitor monitor) |
| throws InvocationTargetException, InterruptedException { |
| «ENDIF-» |
| final String diagramName = diagramModelFilePage.getURI().lastSegment(); |
| final String diagramNameWithoutExtension = diagramModelFilePage.getURI().trimFileExtension().lastSegment(); |
| diagram = «getDiagramEditorUtilQualifiedClassName()».createDiagram(diagramModelFilePage.getEncodedURI(), |
| «IF standaloneDomainModel(self)-» |
| domainModelFilePage.getEncodedURI(), |
| «IF needInitialObject(self)-» |
| diagramName, diagramNameWithoutExtension, initialObjectCreationPage.getInitialObject(), initialObjectCreationPage.getEncoding(), |
| «ENDIF-» |
| «ENDIF-» |
| monitor); |
| if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { |
| try { |
| «getDiagramEditorUtilQualifiedClassName()».openDiagram(diagram); |
| } catch (org.eclipse.ui.PartInitException e) { |
| org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(), |
| «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardOpenEditorError(self)) FOR editorGen», null, e.getStatus()); |
| } |
| } |
| } |
| }; |
| try { |
| getContainer().run(false, true, op); |
| } catch (InterruptedException e) { |
| return false; |
| } catch (java.lang.reflect.InvocationTargetException e) { |
| if (e.getTargetException() instanceof org.eclipse.core.runtime.CoreException) { |
| org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(), |
| «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardCreationError(self)) FOR editorGen», null, |
| ((org.eclipse.core.runtime.CoreException) e.getTargetException()).getStatus()); |
| } else { |
| «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError( |
| "Error creating diagram", e.getTargetException()); //$NON-NLS-1$ |
| } |
| return false; |
| } |
| return diagram != null; |
| } |
| «EXPAND xpt::editor::CreationWizard::additions-» |
| } |
| «ENDAROUND» |
| |
| «AROUND i18nValues FOR gmfgen::GenDiagram-» |
| «targetDef.proceed()-» |
| «IF needInitialObject(self)-» |
| «EXPAND u2t::wizard::InitialObject::i18nValues» |
| «ENDIF-» |
| «ENDAROUND» |
| |
| «AROUND i18nAccessors FOR gmfgen::GenDiagram-» |
| «targetDef.proceed()-» |
| «IF needInitialObject(self)-» |
| «EXPAND u2t::wizard::InitialObject::i18nAccessors» |
| «ENDIF-» |
| «ENDAROUND» |
| |
| |