Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 13f60659a0702040832855737854db0f9605b1fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * Copyright (c) 2007, 2009 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
 */
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»

«EXTENSION xpt::editor::Utils»
«EXTENSION xpt::editor::GenDiagram»

«DEFINE 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;
	«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() {
		diagramModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
				"DiagramModelFile", getSelection(), "«editorGen.diagramFileExtension»"); //$NON-NLS-1$ //$NON-NLS-2$
		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$

			public void setVisible(boolean visible) {
				if (visible) {
					String fileName = diagramModelFilePage.getFileName();
					fileName = fileName.substring(0, fileName.length() - ".«editorGen.diagramFileExtension»".length()); //$NON-NLS-1$
					setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
							getContainerFullPath(), fileName, "«editorGen.domainFileExtension»")); //$NON-NLS-1$
				}
				super.setVisible(visible);
			}
		};
		domainModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»);
		domainModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»);
		addPage(domainModelFilePage);
	«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-»
				diagram = «getDiagramEditorUtilQualifiedClassName()».createDiagram(diagramModelFilePage.getURI(),
	«IF standaloneDomainModel(self)-»
						domainModelFilePage.getURI(),
	«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 additions-»
}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»

«DEFINE i18nValues FOR gmfgen::GenDiagram-»
«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizard(self)), 'New ' + editorGen.modelID + ' Diagram')-»
«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizardDiagramPage(self)), 'Create ' + editorGen.modelID + ' Diagram')-»
«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForCreationWizardDiagramPage(self)), (if standaloneDomainModel(self) then 'Select file that will contain diagram model.' else 'Select file that will contain diagram and domain models.' endif))-»
«IF standaloneDomainModel(self)-»
«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizardDomainPage(self)), 'Create ' + editorGen.modelID + ' Domain Model')-»
«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForCreationWizardDomainPage(self)), 'Select file that will contain domain model.')-»
«ENDIF-»
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardOpenEditorError(self), 'Error opening diagram editor')-»
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardCreationError(self), 'Creation Problems')-»
«ENDDEFINE»

«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizard(self)))-»
	«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizardDiagramPage(self)))-»
	«EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForCreationWizardDiagramPage(self)))-»
	«IF standaloneDomainModel(self)-»
	«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizardDomainPage(self)))-»
	«EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForCreationWizardDomainPage(self)))-»
	«ENDIF-»
	«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardOpenEditorError(self))-»
	«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardCreationError(self))-»
«ENDDEFINE»

Back to the top