Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 114200
Collapse All | Expand All

(-)templates/editor/Editor.javajet (-25 / +137 lines)
Lines 4-9 Link Here
4
final GenEditorView genEditor = (GenEditorView) ((Object[]) argument)[0];
4
final GenEditorView genEditor = (GenEditorView) ((Object[]) argument)[0];
5
final GenDiagram genDiagram = genEditor.getEditorGen().getDiagram();
5
final GenDiagram genDiagram = genEditor.getEditorGen().getDiagram();
6
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
6
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
7
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
7
8
8
importManager.emitPackageStatement(stringBuffer);
9
importManager.emitPackageStatement(stringBuffer);
9
importManager.markImportLocation(stringBuffer);%>
10
importManager.markImportLocation(stringBuffer);%>
Lines 24-30 Link Here
24
importManager.addImport("org.eclipse.core.runtime.Status");
25
importManager.addImport("org.eclipse.core.runtime.Status");
25
importManager.addImport("org.eclipse.draw2d.PositionConstants");
26
importManager.addImport("org.eclipse.draw2d.PositionConstants");
26
importManager.addImport("org.eclipse.emf.common.command.BasicCommandStack");
27
importManager.addImport("org.eclipse.emf.common.command.BasicCommandStack");
27
importManager.addImport("org.eclipse.emf.common.ui.URIEditorInput");
28
importManager.addImport("org.eclipse.emf.common.util.URI");
28
importManager.addImport("org.eclipse.emf.common.util.URI");
29
importManager.addImport("org.eclipse.emf.ecore.resource.Resource");
29
importManager.addImport("org.eclipse.emf.ecore.resource.Resource");
30
importManager.addImport("org.eclipse.emf.ecore.resource.ResourceSet");
30
importManager.addImport("org.eclipse.emf.ecore.resource.ResourceSet");
Lines 76-82 Link Here
76
importManager.addImport("org.eclipse.ui.IEditorPart");
76
importManager.addImport("org.eclipse.ui.IEditorPart");
77
importManager.addImport("org.eclipse.ui.IEditorInput");
77
importManager.addImport("org.eclipse.ui.IEditorInput");
78
importManager.addImport("org.eclipse.ui.IEditorSite");
78
importManager.addImport("org.eclipse.ui.IEditorSite");
79
importManager.addImport("org.eclipse.ui.IPathEditorInput");
80
importManager.addImport("org.eclipse.ui.ISelectionListener");
79
importManager.addImport("org.eclipse.ui.ISelectionListener");
81
importManager.addImport("org.eclipse.ui.IWorkbenchPart");
80
importManager.addImport("org.eclipse.ui.IWorkbenchPart");
82
importManager.addImport("org.eclipse.ui.PartInitException");
81
importManager.addImport("org.eclipse.ui.PartInitException");
Lines 93-98 Link Here
93
 * @generated
92
 * @generated
94
 */
93
 */
95
public class <%=genEditor.getClassName()%> extends GraphicalEditorWithFlyoutPalette {
94
public class <%=genEditor.getClassName()%> extends GraphicalEditorWithFlyoutPalette {
95
<%
96
if (!isRichClientPlatform) {
97
%>
98
	/**
99
	 * This class listens to changes to the file system in the workspace, and
100
	 * makes the following changes: 
101
	 * <ul><li>If an open, saved file gets deleted, the editor is closed.</li>
102
	 * <li>If an open file gets renamed or moved, the editor's
103
	 * input is changed accordingly.</li></ul>
104
	 *
105
	 * @generated
106
	 */
107
	private class ResourceTracker implements <%=importManager.getImportedName("org.eclipse.core.resources.IResourceChangeListener")%> {
108
		/**
109
		 * @generated
110
		 */
111
		public void resourceChanged(<%=importManager.getImportedName("org.eclipse.core.resources.IResourceChangeEvent")%> event) {
112
			<%=importManager.getImportedName("org.eclipse.core.resources.IResourceDelta")%> delta = event.getDelta();
113
			if (delta != null) {
114
				<%=importManager.getImportedName("org.eclipse.core.resources.IResourceDelta")%> fileDelta = delta.findMember(((<%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) getEditorInput()).getFile().getFullPath());
115
				if (fileDelta != null) {
116
					processFileDelta(fileDelta);
117
				}
118
			}
119
		}
120
121
		/**
122
		 * @generated
123
		 */
124
		private void processFileDelta(<%=importManager.getImportedName("org.eclipse.core.resources.IResourceDelta")%> delta) {
125
			assert (delta != null && delta.getResource().equals(((<%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) getEditorInput()).getFile()));
126
			if (delta.getKind() == <%=importManager.getImportedName("org.eclipse.core.resources.IResourceDelta")%>.REMOVED) {
127
				if ((<%=importManager.getImportedName("org.eclipse.core.resources.IResourceDelta")%>.MOVED_TO & delta.getFlags()) == 0) {
128
					<%/*XXX: make sure unsaved deleted file is handled correctly*/%>
129
					if (!isDirty()) {
130
						closeEditor();
131
					}
132
				} else {
133
					// else if it was moved or renamed
134
					final <%=importManager.getImportedName("org.eclipse.core.resources.IFile")%> newFile = <%=importManager.getImportedName("org.eclipse.core.resources.ResourcesPlugin")%>.getWorkspace().getRoot().getFile(delta.getMovedToPath());
135
					<%=importManager.getImportedName("org.eclipse.swt.widgets.Display")%> display = getSite().getShell().getDisplay();
136
					display.asyncExec(new Runnable() {
137
						public void run() {
138
							setInput(new <%=importManager.getImportedName("org.eclipse.ui.part.FileEditorInput")%>(newFile));
139
						}
140
					});
141
				}
142
			}
143
		}
144
	}
145
146
	/**
147
	 * @generated
148
	 */
149
	private ResourceTracker resourceTracker;
150
151
	/**
152
	 * @generated
153
	 */
154
	private ResourceTracker getResourceTracker() {
155
		if (resourceTracker == null) {
156
			resourceTracker = new ResourceTracker();
157
		}
158
		return resourceTracker;
159
	}
160
161
<%
162
}
163
%>
96
	/**
164
	/**
97
	 * @generated
165
	 * @generated
98
	 */
166
	 */
Lines 294-299 Link Here
294
		getSite().getKeyBindingService().registerAction(zoomOut);
362
		getSite().getKeyBindingService().registerAction(zoomOut);
295
	}
363
	}
296
364
365
<%
366
if (!isRichClientPlatform) {
367
%>
368
	/**
369
	 * @generated
370
	 */
371
	void closeEditor() {
372
		getSite().getShell().getDisplay().syncExec(new Runnable() {
373
			public void run() {
374
				getSite().getPage().closeEditor(<%=genEditor.getClassName()%>.this, false);
375
			}
376
		});
377
	}
378
<%
379
}
380
%>
297
	/**
381
	/**
298
	 * @generated
382
	 * @generated
299
	 */
383
	 */
Lines 494-516 Link Here
494
	 * @generated
578
	 * @generated
495
	 */
579
	 */
496
	protected void setInput(IEditorInput input)  {
580
	protected void setInput(IEditorInput input)  {
581
<%
582
if (!isRichClientPlatform) {
583
%>
584
		if (getEditorInput() instanceof <%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) {
585
			<%=importManager.getImportedName("org.eclipse.core.resources.IFile")%> resource = ((<%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) getEditorInput()).getFile();
586
			resource.getWorkspace().removeResourceChangeListener(getResourceTracker());
587
		}
588
<%
589
}
590
%>
497
		URI file = getURIFromInput(input);
591
		URI file = getURIFromInput(input);
498
		load(file);
592
		load(file);
499
		setPartName(file.lastSegment());
593
		setPartName(file.lastSegment());
500
		setContentDescription(file.toFileString());
501
		super.setInput(input);
594
		super.setInput(input);
595
<%
596
if (!isRichClientPlatform) {
597
%>
598
		if (getEditorInput() instanceof <%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) {
599
			<%=importManager.getImportedName("org.eclipse.core.resources.IFile")%> resource = ((<%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) getEditorInput()).getFile();
600
			resource.getWorkspace().addResourceChangeListener(getResourceTracker());
601
		}
602
<%
603
}
604
%>
502
	}
605
	}
503
606
504
	/**
607
	/**
505
	 * @generated
608
	 * @generated
506
	 */
609
	 */
507
	private URI getURIFromInput(IEditorInput input) {
610
	private URI getURIFromInput(IEditorInput input) {
508
		if (input instanceof URIEditorInput) {
611
<%if (isRichClientPlatform) {%>
509
			return ((URIEditorInput) input).getURI();
612
		if (input instanceof <%=importManager.getImportedName("org.eclipse.emf.common.ui.URIEditorInput")%>) {
613
			return ((<%=importManager.getImportedName("org.eclipse.emf.common.ui.URIEditorInput")%>) input).getURI();
510
		}
614
		}
511
		if (input instanceof IPathEditorInput) {
615
		if (input instanceof <%=importManager.getImportedName("org.eclipse.ui.IPathEditorInput")%>) {
512
			return URI.createFileURI(((IPathEditorInput)input).getPath().toOSString());
616
			return URI.createFileURI(((IPathEditorInput)input).getPath().toOSString());
513
		}
617
		}
618
<%} else {%>
619
		if (input instanceof <%=importManager.getImportedName("org.eclipse.ui.IFileEditorInput")%>) {
620
			return URI.createPlatformResourceURI(((IFileEditorInput)input).getFile().getFullPath().toString());
621
		}
622
<%}%>
514
		return null;
623
		return null;
515
	}
624
	}
516
625
Lines 592-597 Link Here
592
				return;
701
				return;
593
			}
702
			}
594
		}
703
		}
704
		<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = (<%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%>) diagram.getElement();
705
		if (<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> == null) {
595
<%
706
<%
596
{
707
{
597
%>
708
%>
Lines 600-631 Link Here
600
	String resourceToUse;
711
	String resourceToUse;
601
	if (!sameFile) {
712
	if (!sameFile) {
602
%>
713
%>
603
		URI modelFile = <%=genDiagram.getDiagramEditorUtilClassName()%>.getModelFileURI(diagramFile);
714
			URI modelFile = <%=genDiagram.getDiagramEditorUtilClassName()%>.getModelFileURI(diagramFile);
604
		Resource modelResource = resourceSet.getResource(modelFile, true);
715
			Resource modelResource = resourceSet.getResource(modelFile, true);
605
		if (modelResource == null) {
716
			if (modelResource == null) {
606
			modelResource = resourceSet.createResource(modelFile);
717
				modelResource = resourceSet.createResource(modelFile);
607
		}
718
			}
608
<%
719
<%
609
		resourceToUse = "modelResource";
720
		resourceToUse = "modelResource";
610
	} else {
721
	} else {
611
		resourceToUse = "diagramResource";
722
		resourceToUse = "diagramResource";
612
	}
723
	}
613
%>
724
%>
614
		<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = (<%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%>) findInResource(<%=resourceToUse%>, <%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%>.class);
725
			<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = (<%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%>) findInResource(<%=resourceToUse%>, <%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName())%>.class);
615
		if (<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> == null) {
726
			if (<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> == null) {
616
			<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = <%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getGenPackage().getQualifiedFactoryClassName())%>.eINSTANCE.create<%=genDiagram.getDomainDiagramElement().getClassifierAccessorName()%>();
727
				<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = <%=importManager.getImportedName(genDiagram.getDomainDiagramElement().getGenPackage().getQualifiedFactoryClassName())%>.eINSTANCE.create<%=genDiagram.getDomainDiagramElement().getClassifierAccessorName()%>();
617
			<%=resourceToUse%>.getContents().add(0, <%=genDiagram.getDomainDiagramElement().getSafeUncapName()%>);
728
				<%=resourceToUse%>.getContents().add(0, <%=genDiagram.getDomainDiagramElement().getSafeUncapName()%>);
618
			//We don't want this auxiliary creation to be undoable.
729
				//We don't want this auxiliary creation to be undoable.
619
			try {
730
				try {
620
				<%=resourceToUse%>.save(Collections.EMPTY_MAP);
731
					<%=resourceToUse%>.save(Collections.EMPTY_MAP);
621
			} catch (IOException e) {
732
				} catch (IOException e) {
622
				diagram = null;
733
					diagram = null;
623
				<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = null;
734
					<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%> = null;
624
				return;
735
					return;
736
				}
737
			}
738
			if (!diagram.isSetElement()) {
739
				diagram.setElement(<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%>);
625
			}
740
			}
626
		}
627
		if (!diagram.isSetElement()) {
628
			diagram.setElement(<%=genDiagram.getDomainDiagramElement().getSafeUncapName()%>);
629
		}
741
		}
630
	}
742
	}
631
<%
743
<%
(-)templates/editor/manifest.mfjet (+2 lines)
Lines 29-34 Link Here
29
Bundle-Localization: plugin
29
Bundle-Localization: plugin
30
Export-Package: <%=genPlugin.getEditorGen().getEditor().getPackageName()%>
30
Export-Package: <%=genPlugin.getEditorGen().getEditor().getPackageName()%>
31
Require-Bundle: org.eclipse.core.runtime,
31
Require-Bundle: org.eclipse.core.runtime,
32
 <%if (!genModel.isRichClientPlatform()) {%>org.eclipse.core.resources,
33
 org.eclipse.ui.ide,<%}%>
32
 org.eclipse.jface,
34
 org.eclipse.jface,
33
 org.eclipse.ui.views,
35
 org.eclipse.ui.views,
34
 org.eclipse.ui.workbench,
36
 org.eclipse.ui.workbench,
(-)templates/editor/DiagramEditorUtil.javajet (-3 / +341 lines)
Lines 1-9 Link Here
1
<%@ jet package="org.eclipse.gmf.codegen.templates.lite.editor" class="DiagramEditorUtilGenerator"
1
<%@ jet package="org.eclipse.gmf.codegen.templates.lite.editor" class="DiagramEditorUtilGenerator"
2
    imports="org.eclipse.gmf.codegen.gmfgen.* org.eclipse.gmf.common.codegen.*"%>
2
    imports="org.eclipse.gmf.codegen.gmfgen.* org.eclipse.gmf.common.codegen.* org.eclipse.emf.codegen.ecore.genmodel.*"%>
3
<%
3
<%
4
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
4
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
5
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
5
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
6
final GenPlugin genPlugin = editorGen.getPlugin();
6
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
7
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
8
final GenModel genModel = genDiagram.getEditorGen().getDomainGenModel();
9
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
7
10
8
importManager.emitPackageStatement(stringBuffer);%>
11
importManager.emitPackageStatement(stringBuffer);%>
9
12
Lines 51-57 Link Here
51
		IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
54
		IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
52
		IWorkbenchPage page = workbenchWindow.getActivePage();
55
		IWorkbenchPage page = workbenchWindow.getActivePage();
53
56
54
		IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
57
		IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().getDefaultEditor(fileURI.lastSegment());
55
		if (editorDescriptor == null) {
58
		if (editorDescriptor == null) {
56
			MessageDialog.openError(
59
			MessageDialog.openError(
57
			workbenchWindow.getShell(),
60
			workbenchWindow.getShell(),
Lines 73-78 Link Here
73
		return true;
76
		return true;
74
	}
77
	}
75
78
79
<%
80
if (!genDiagram.getEditorGen().isSameFileForDiagramAndModel()) {
81
%>
76
	/**
82
	/**
77
	 * @generated
83
	 * @generated
78
	 */
84
	 */
Lines 92-96 Link Here
92
		}
98
		}
93
		return diagramFileURI.trimFileExtension().appendFileExtension("<%=editorGen.getDomainFileExtension()%>");
99
		return diagramFileURI.trimFileExtension().appendFileExtension("<%=editorGen.getDomainFileExtension()%>");
94
	}
100
	}
95
 }
101
<%
102
}
103
%>
104
<%
105
if (isRichClientPlatform) {
106
	boolean shouldGenerateApplication = true;	/*XXX: option in gmfgen*/
107
	if (shouldGenerateApplication) {
108
%>
109
	/**
110
	 * Looks up a string in the plugin's plugin.properties file.
111
	 * @generated
112
	 */
113
	private static String getString(String key) {
114
		return <%=importManager.getImportedName(genPlugin.getActivatorQualifiedClassName())%>.getInstance().getBundleString(key);
115
	}
116
117
	/**
118
	 * RCP's application
119
	 * @generated
120
	 */
121
	public static class Application implements <%=importManager.getImportedName("org.eclipse.core.runtime.IPlatformRunnable")%> {
122
		/**
123
		 * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
124
		 * @generated
125
		 */
126
		public Object run(Object args) {
127
			<%=importManager.getImportedName("org.eclipse.ui.application.WorkbenchAdvisor")%> workbenchAdvisor = new Advisor();
128
			<%=importManager.getImportedName("org.eclipse.swt.widgets.Display")%> display = <%=importManager.getImportedName("org.eclipse.ui.PlatformUI")%>.createDisplay();
129
			try {
130
				int returnCode = <%=importManager.getImportedName("org.eclipse.ui.PlatformUI")%>.createAndRunWorkbench(display, workbenchAdvisor);
131
				if (returnCode == <%=importManager.getImportedName("org.eclipse.ui.PlatformUI")%>.RETURN_RESTART) {
132
					return <%=importManager.getImportedName("org.eclipse.core.runtime.IPlatformRunnable")%>.EXIT_RESTART;
133
				} else {
134
					return <%=importManager.getImportedName("org.eclipse.core.runtime.IPlatformRunnable")%>.EXIT_OK;
135
				}
136
			} finally {
137
				display.dispose();
138
			}
139
		}
140
	}
141
 
142
  	/**
143
	 * RCP's perspective
144
	 * @generated
145
	 */
146
	public static class Advisor extends <%=importManager.getImportedName("org.eclipse.ui.application.WorkbenchAdvisor")%> {
147
		/**
148
		 * @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
149
		 * @generated
150
		 */
151
		public String getInitialWindowPerspectiveId() {
152
			return Perspective.ID_PERSPECTIVE;
153
		}
154
155
		/**
156
		 * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
157
		 * @generated
158
		 */
159
		public void initialize(<%=importManager.getImportedName("org.eclipse.ui.application.IWorkbenchConfigurer")%> configurer) {
160
			super.initialize(configurer);
161
			configurer.setSaveAndRestore(true);
162
		}
163
164
		/**
165
		 * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
166
		 * @generated
167
		 */
168
		public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(<%=importManager.getImportedName("org.eclipse.ui.application.IWorkbenchWindowConfigurer")%> configurer) {
169
			return new WindowAdvisor(configurer);
170
		}
171
	}
172
173
  	/**
174
	 * RCP's perspective
175
	 * @generated
176
	 */
177
	public static class Perspective implements <%=importManager.getImportedName("org.eclipse.ui.IPerspectiveFactory")%> {
178
		/**
179
		 * Perspective ID
180
		 * @generated
181
		 */
182
		public static final String ID_PERSPECTIVE = "<%=genPlugin.getID()%>.Perspective";	//$NON-NLS-1$
183
184
		/**
185
		 * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
186
		 * @generated
187
		 */
188
		public void createInitialLayout(<%=importManager.getImportedName("org.eclipse.ui.IPageLayout")%> layout) {
189
			layout.setEditorAreaVisible(true);
190
			layout.addPerspectiveShortcut(ID_PERSPECTIVE);
191
192
			<%=importManager.getImportedName("org.eclipse.ui.IFolderLayout")%> right = layout.createFolder("right", <%=importManager.getImportedName("org.eclipse.ui.IPageLayout")%>.RIGHT, (float)0.66, layout.getEditorArea());	//$NON-NLS-1$
193
			right.addView(IPageLayout.ID_OUTLINE);
194
195
			<%=importManager.getImportedName("org.eclipse.ui.IFolderLayout")%> bottomRight = layout.createFolder("bottonRight", <%=importManager.getImportedName("org.eclipse.ui.IPageLayout")%>.BOTTOM, (float)0.60, "right");	//$NON-NLS-1$	//$NON-NLS-2$
196
			bottomRight.addView(<%=importManager.getImportedName("org.eclipse.ui.IPageLayout")%>.ID_PROP_SHEET);
197
		}
198
	}
199
200
	/**
201
	 * RCP's window advisor
202
	 * @generated
203
	 */
204
	public static class WindowAdvisor extends <%=importManager.getImportedName("org.eclipse.ui.application.WorkbenchWindowAdvisor")%> {
205
		/**
206
		 * @see WorkbenchWindowAdvisor#WorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
207
		 * @generated
208
		 */
209
		public WindowAdvisor(<%=importManager.getImportedName("org.eclipse.ui.application.IWorkbenchWindowConfigurer")%> configurer) {
210
			super(configurer);
211
		}
212
		
213
		/**
214
		 * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#preWindowOpen()
215
		 * @generated
216
		 */
217
		public void preWindowOpen() {
218
			<%=importManager.getImportedName("org.eclipse.ui.application.IWorkbenchWindowConfigurer")%> configurer = getWindowConfigurer();
219
			configurer.setInitialSize(new <%=importManager.getImportedName("org.eclipse.swt.graphics.Point")%>(600, 450));
220
			configurer.setShowCoolBar(false);
221
			configurer.setShowStatusLine(true);
222
			configurer.setTitle(getString("_UI_Application_title"));	//$NON-NLS-1$
223
		}
224
		
225
		/**
226
		 * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
227
		 * @generated
228
		 */
229
		public <%=importManager.getImportedName("org.eclipse.ui.application.ActionBarAdvisor")%> createActionBarAdvisor(<%=importManager.getImportedName("org.eclipse.ui.application.IActionBarConfigurer")%> configurer) {
230
			return new WindowActionBarAdvisor(configurer);
231
		}
232
	}
233
234
	/**
235
	 * RCP's action bar advisor
236
	 * @generated
237
	 */
238
	public static class WindowActionBarAdvisor extends <%=importManager.getImportedName("org.eclipse.ui.application.ActionBarAdvisor")%> {
239
		/**
240
		 * @see ActionBarAdvisor#ActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
241
		 * @generated
242
		 */
243
		public WindowActionBarAdvisor(<%=importManager.getImportedName("org.eclipse.ui.application.IActionBarConfigurer")%> configurer) {
244
			super(configurer);
245
		}
246
		
247
		/**
248
		 * @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager)
249
		 * @generated
250
		 */
251
		protected void fillMenuBar(<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> menuBar) {
252
			<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow")%> window = getActionBarConfigurer().getWindowConfigurer().getWindow();
253
			menuBar.add(createFileMenu(window));
254
			menuBar.add(createEditMenu(window));
255
			menuBar.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.MB_ADDITIONS));
256
			menuBar.add(createWindowMenu(window));
257
			menuBar.add(createHelpMenu(window));					
258
		}
259
260
		/**
261
		 * Creates the 'File' menu.
262
		 * @generated
263
		 */
264
		protected <%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> createFileMenu(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow")%> window) {
265
			<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> menu = new <%=importManager.getImportedName("org.eclipse.jface.action.MenuManager")%>(getString("_UI_Menu_File_label"),	//$NON-NLS-1$
266
				<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.M_FILE);
267
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.FILE_START));
268
	
269
			<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> newMenu = new <%=importManager.getImportedName("org.eclipse.jface.action.MenuManager")%>(getString("_UI_Menu_New_label"), "new");	//$NON-NLS-1$	//$NON-NLS-2$
270
			newMenu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.MB_ADDITIONS));
271
	
272
			menu.add(newMenu);
273
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
274
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.MB_ADDITIONS));
275
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
276
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.CLOSE.create(window));
277
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.CLOSE_ALL.create(window));
278
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
279
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.SAVE.create(window));
280
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.SAVE_AS.create(window));
281
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.SAVE_ALL.create(window));
282
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
283
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.QUIT.create(window));
284
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.FILE_END));
285
			return menu;
286
		}
287
288
		/**
289
		 * Creates the 'Edit' menu.
290
		 * @generated
291
		 */
292
		protected <%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> createEditMenu(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow")%> window) {
293
			<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> menu = new <%=importManager.getImportedName("org.eclipse.jface.action.MenuManager")%>(getString("_UI_Menu_Edit_label"),	//$NON-NLS-1$
294
				<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.M_EDIT);
295
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.EDIT_START));
296
	
297
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.UNDO.create(window));
298
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.REDO.create(window));
299
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.UNDO_EXT));
300
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
301
	
302
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.CUT.create(window));
303
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.COPY.create(window));
304
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.PASTE.create(window));
305
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.CUT_EXT));
306
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
307
	
308
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.DELETE.create(window));
309
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.SELECT_ALL.create(window));
310
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>());
311
	
312
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.ADD_EXT));
313
	
314
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.EDIT_END));
315
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.Separator")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.MB_ADDITIONS));
316
			return menu;
317
		}
318
	
319
		/**
320
		 * Creates the 'Window' menu.
321
		 * @generated
322
		 */
323
		protected <%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> createWindowMenu(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow")%> window) {
324
			<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> menu = new <%=importManager.getImportedName("org.eclipse.jface.action.MenuManager")%>(getString("_UI_Menu_Window_label"),	//$NON-NLS-1$
325
				<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.M_WINDOW);
326
	
327
			addToMenuAndRegister(menu, <%=importManager.getImportedName("org.eclipse.ui.actions.ActionFactory")%>.OPEN_NEW_WINDOW.create(window));
328
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.MB_ADDITIONS));
329
			menu.add(<%=importManager.getImportedName("org.eclipse.ui.actions.ContributionItemFactory")%>.OPEN_WINDOWS.create(window));
330
	
331
			return menu;
332
		}
333
	
334
		/**
335
		 * Creates the 'Help' menu.
336
		 * @generated
337
		 */
338
		protected <%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> createHelpMenu(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow")%> window) {
339
			<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> menu = new <%=importManager.getImportedName("org.eclipse.jface.action.MenuManager")%>(getString("_UI_Menu_Help_label"), <%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.M_HELP);	//$NON-NLS-1$
340
			// Welcome or intro page would go here
341
			// Help contents would go here
342
			// Tips and tricks page would go here
343
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.HELP_START));
344
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.HELP_END));
345
			menu.add(new <%=importManager.getImportedName("org.eclipse.jface.action.GroupMarker")%>(<%=importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants")%>.MB_ADDITIONS));
346
			return menu;
347
		}
348
		
349
		/**
350
		 * Adds the specified action to the given menu and also registers the action with the
351
		 * action bar configurer, in order to activate its key binding.
352
		 * @generated
353
		 */
354
		protected void addToMenuAndRegister(<%=importManager.getImportedName("org.eclipse.jface.action.IMenuManager")%> menuManager, <%=importManager.getImportedName("org.eclipse.jface.action.IAction")%> action) {
355
			menuManager.add(action);
356
			getActionBarConfigurer().registerGlobalAction(action);			
357
		}		
358
	}
359
360
	/**
361
	 * About action for the RCP application.
362
	 * @generated
363
	 */
364
	public static class AboutAction extends <%=importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate")%> {
365
		/**
366
		 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
367
		 * @generated
368
		 */
369
		public void run(<%=importManager.getImportedName("org.eclipse.jface.action.IAction")%> action) {
370
			<%=importManager.getImportedName("org.eclipse.jface.dialogs.MessageDialog")%>.openInformation(getWindow().getShell(), getString("_UI_About_title"),	//$NON-NLS-1$
371
			getString("_UI_About_text"));	//$NON-NLS-1$
372
		}
373
	}
374
 <%
375
 	}
376
 %>
377
378
 	/**
379
	 * Open action for the <%=genModel.getModelName()%> diagram.
380
	 * @generated
381
	 */
382
	public static class OpenDiagramAction extends <%=importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate")%> {
383
		/**
384
		 * Opens the editors for the files selected using the file dialog.
385
		 * @generated
386
		 */
387
		public void run(<%=importManager.getImportedName("org.eclipse.jface.action.IAction")%> action) {
388
			String filePath = openFilePathDialog(getWindow().getShell(), "*.<%=editorGen.getDiagramFileExtension()%>", <%=importManager.getImportedName("org.eclipse.swt.SWT")%>.OPEN);	//$NON-NLS-1$
389
			if (filePath != null) {
390
				openEditor(URI.createFileURI(filePath));
391
			}
392
		}
393
 	}
394
395
	/**
396
	 * Open URI action for the <%=genModel.getModelName()%> diagram.
397
	 * @generated
398
	 */
399
	public static class OpenURIAction extends <%=importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate")%> {
400
		/**
401
		 * Opens the editors for the files selected using the LoadResourceDialog.
402
		 * @generated
403
		 */
404
		public void run(<%=importManager.getImportedName("org.eclipse.jface.action.IAction")%> action) {
405
			<%=importManager.getImportedName("org.eclipse.emf.edit.ui.action.LoadResourceAction")%>.LoadResourceDialog loadResourceDialog = new <%=importManager.getImportedName("org.eclipse.emf.edit.ui.action.LoadResourceAction")%>.LoadResourceDialog(getWindow().getShell());
406
			if (<%=importManager.getImportedName("org.eclipse.jface.dialogs.Dialog")%>.OK == loadResourceDialog.open()) {
407
				for (<%=importManager.getImportedName("java.util.Iterator")%> it = loadResourceDialog.getURIs().iterator(); it.hasNext(); ) {
408
					openEditor((URI) it.next());
409
				}
410
			}
411
		}
412
	}
413
414
	/**
415
	 * New diagram action for the <%=genModel.getModelName()%> diagram.
416
	 * @generated
417
	 */
418
	public static class NewDiagramAction extends <%=importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate")%> {
419
		/**
420
		 * Opens the wizard to create the diagram.
421
		 * @generated
422
		 */
423
		public void run(<%=importManager.getImportedName("org.eclipse.jface.action.IAction")%> action) {
424
			<%=importManager.getImportedName(genDiagram.getCreationWizardQualifiedClassName())%> wizard = new <%=importManager.getImportedName(genDiagram.getCreationWizardQualifiedClassName())%>();
425
			wizard.init(getWindow().getWorkbench(), <%=importManager.getImportedName("org.eclipse.jface.viewers.StructuredSelection")%>.EMPTY);
426
			<%=importManager.getImportedName("org.eclipse.jface.wizard.WizardDialog")%> wizardDialog = new <%=importManager.getImportedName("org.eclipse.jface.wizard.WizardDialog")%>(getWindow().getShell(), wizard);
427
			wizardDialog.open();
428
		}
429
	}
430
<%
431
}
432
%>
433
}
96
<%importManager.emitSortedImports();%>
434
<%importManager.emitSortedImports();%>
(-)templates/editor/Plugin.javajet (+11 lines)
Lines 154-159 Link Here
154
	/**
154
	/**
155
	 * @generated
155
	 * @generated
156
	 */
156
	 */
157
	public String getBundleString(String key) {
158
		try {
159
			return <%=importManager.getImportedName("org.eclipse.core.runtime.Platform")%>.getResourceBundle(getBundle()).getString(key);
160
		} catch (<%=importManager.getImportedName("java.util.MissingResourceException")%> e) {
161
			return "!" + key + "!";	//$NON-NLS-1$	//$NON-NLS-2$
162
		}
163
	}
164
165
	/**
166
	 * @generated
167
	 */
157
	public void logError(String error) {
168
	public void logError(String error) {
158
		logError(error, null);
169
		logError(error, null);
159
	}
170
	}
(-)templates/editor/CreationWizardPage.javajet (-19 / +185 lines)
Lines 5-32 Link Here
5
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
5
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
6
final GenPlugin genPlugin = editorGen.getPlugin();
6
final GenPlugin genPlugin = editorGen.getPlugin();
7
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
7
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
8
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
8
9
9
importManager.emitPackageStatement(stringBuffer);
10
importManager.emitPackageStatement(stringBuffer);
10
importManager.markImportLocation(stringBuffer);
11
importManager.markImportLocation(stringBuffer);
11
12
12
importManager.addImport("java.io.File");
13
importManager.addImport("org.eclipse.core.runtime.IProgressMonitor");
13
importManager.addImport("org.eclipse.core.runtime.IProgressMonitor");
14
importManager.addImport("org.eclipse.core.runtime.CoreException");
14
importManager.addImport("org.eclipse.core.runtime.CoreException");
15
importManager.addImport("java.io.IOException");
15
importManager.addImport("java.io.IOException");
16
importManager.addImport("org.eclipse.swt.widgets.Text");
17
importManager.addImport("org.eclipse.emf.common.util.URI");
16
importManager.addImport("org.eclipse.emf.common.util.URI");
17
if (isRichClientPlatform) {
18
importManager.addImport("java.io.File");
18
importManager.addImport("org.eclipse.swt.widgets.Composite");
19
importManager.addImport("org.eclipse.swt.widgets.Composite");
19
importManager.addImport("org.eclipse.swt.widgets.Label");
20
importManager.addImport("org.eclipse.swt.widgets.Label");
21
importManager.addImport("org.eclipse.swt.widgets.Text");
20
importManager.addImport("org.eclipse.swt.events.ModifyListener");
22
importManager.addImport("org.eclipse.swt.events.ModifyListener");
21
importManager.addImport("org.eclipse.swt.events.ModifyEvent");
23
importManager.addImport("org.eclipse.swt.events.ModifyEvent");
22
importManager.addImport("org.eclipse.swt.layout.GridLayout");
24
importManager.addImport("org.eclipse.swt.layout.GridLayout");
23
importManager.addImport("org.eclipse.swt.layout.GridData");
25
importManager.addImport("org.eclipse.swt.layout.GridData");
26
}
24
%>
27
%>
25
28
26
/**
29
/**
27
 * @generated
30
 * @generated
28
 */
31
 */
29
public class <%=genDiagram.getCreationWizardPageClassName()%> extends <%=importManager.getImportedName("org.eclipse.jface.wizard.WizardPage")%> {
32
public class <%=genDiagram.getCreationWizardPageClassName()%> extends <%=importManager.getImportedName(isRichClientPlatform ? "org.eclipse.jface.wizard.WizardPage" : "org.eclipse.ui.dialogs.WizardNewFileCreationPage")%> {
33
<%
34
if (isRichClientPlatform) {
35
%>
30
	/**
36
	/**
31
	 * @generated
37
	 * @generated
32
	 */
38
	 */
Lines 36-51 Link Here
36
	 * @generated
42
	 * @generated
37
	 */
43
	 */
38
	private URI createdDiagramFileURI;
44
	private URI createdDiagramFileURI;
45
<%
46
} else {
47
%>
48
	/**
49
	 * @generated
50
	 */
51
	private <%=importManager.getImportedName("org.eclipse.core.resources.IFile")%> createdDiagramFile;
52
<%
53
}
54
%>
39
55
40
	/**
56
	/**
41
	 * @generated
57
	 * @generated
42
	 */
58
	 */
59
<%
60
if (isRichClientPlatform) {
61
%>
43
	public <%=genDiagram.getCreationWizardPageClassName()%>() {
62
	public <%=genDiagram.getCreationWizardPageClassName()%>() {
44
		super("CreationWizardPage"); //$NON-NLS-1$
63
		super("CreationWizardPage"); //$NON-NLS-1$
64
<%
65
} else {
66
%>
67
	public <%=genDiagram.getCreationWizardPageClassName()%>(<%=importManager.getImportedName("org.eclipse.jface.viewers.IStructuredSelection")%> selection) {
68
		super("CreationWizardPage", selection);	//$NON-NLS-1$
69
<%
70
}
71
%>
45
		setTitle("Create <%=editorGen.getDomainGenModel().getModelName()%> Diagram"); //$NON-NLS-1$
72
		setTitle("Create <%=editorGen.getDomainGenModel().getModelName()%> Diagram"); //$NON-NLS-1$
46
		setDescription("Create a new <%=editorGen.getDomainGenModel().getModelName()%> diagram."); //$NON-NLS-1$
73
		setDescription("Create a new <%=editorGen.getDomainGenModel().getModelName()%> diagram."); //$NON-NLS-1$
47
	}
74
	}
48
75
76
<%
77
if (isRichClientPlatform) {
78
%>
49
	/**
79
	/**
50
	 * @generated
80
	 * @generated
51
	 */
81
	 */
Lines 126-147 Link Here
126
				setPageComplete(validatePage());
156
				setPageComplete(validatePage());
127
			}
157
			}
128
		};
158
		};
129
 
159
160
<%
161
}
162
%>
130
	/**
163
	/**
131
	 * @generated
164
	 * @generated
132
	 */
165
	 */
133
	 protected boolean validatePage() {
166
	 protected boolean validatePage() {
167
<%
168
if (isRichClientPlatform) {
169
%>
134
		URI diagramFileURI = getDiagramFileURI();
170
		URI diagramFileURI = getDiagramFileURI();
135
		if (diagramFileURI == null || diagramFileURI.isEmpty()) {
171
		if (diagramFileURI == null || diagramFileURI.isEmpty()) {
136
			setErrorMessage(null);
172
			setErrorMessage(null);
137
			return false;
173
			return false;
138
		}
174
		}
139
		String requiredExt = "<%=editorGen.getDiagramFileExtension()%>";
140
		String enteredExt = diagramFileURI.fileExtension();
141
		if (enteredExt == null || !enteredExt.equals(requiredExt)) {
142
			setErrorMessage("The file name must end in " + requiredExt); 
143
			return false;
144
		}
145
175
146
		if (diagramFileURI.isFile()) {
176
		if (diagramFileURI.isFile()) {
147
			File diagramFile = new File(diagramFileURI.toFileString());
177
			File diagramFile = new File(diagramFileURI.toFileString());
Lines 149-174 Link Here
149
				setErrorMessage("Diagram File already exists: " + diagramFile);
179
				setErrorMessage("Diagram File already exists: " + diagramFile);
150
				return false;
180
				return false;
151
			}
181
			}
152
<%if (!editorGen.isSameFileForDiagramAndModel()) {%>
182
		}
183
<%
184
} else {
185
%>
186
		if (!super.validatePage()) {
187
			return false;
188
		}
189
		String fileName = getFileName();
190
191
		if (fileName == null) {
192
			setErrorMessage(null);
193
			return false;
194
		}
195
196
		<%=importManager.getImportedName("org.eclipse.core.runtime.IPath")%> path = getContainerFullPath().append(fileName);
197
		if (path.getFileExtension() == null) {
198
			path = path.addFileExtension("<%=editorGen.getDiagramFileExtension()%>");	//$NON-NLS-1$
199
		}
200
201
		if (<%=importManager.getImportedName("org.eclipse.core.resources.ResourcesPlugin")%>.getWorkspace().getRoot().exists(path)) {
202
			setErrorMessage("Diagram File already exists: " + path.toOSString());
203
			return false;
204
		}
205
<%
206
}
207
%>
208
		String requiredExt = "<%=editorGen.getDiagramFileExtension()%>";
209
<%
210
if (isRichClientPlatform) {
211
%>
212
		String enteredExt = diagramFileURI.fileExtension();
213
<%
214
} else {
215
%>
216
		String enteredExt = path.getFileExtension();
217
<%
218
}
219
%>
220
		if (enteredExt == null || !enteredExt.equals(requiredExt)) {
221
			setErrorMessage("The file name must end in " + requiredExt); 
222
			return false;
223
		}
224
<%
225
if (!editorGen.isSameFileForDiagramAndModel()) {
226
	if (isRichClientPlatform) {
227
%>
153
			URI modelFileURI = getModelFileURI();
228
			URI modelFileURI = getModelFileURI();
154
			File modelFile = new File(modelFileURI.toFileString());
229
			File modelFile = new File(modelFileURI.toFileString());
155
			if (modelFile.exists()) {
230
			if (modelFile.exists()) {
156
				setErrorMessage("Model File already exists: " + modelFile);
231
				setErrorMessage("Model File already exists: " + modelFile);
157
				return false;
232
				return false;
158
			}
233
			}
159
<%}%>
234
<%
160
		}
235
	} else {
161
		setErrorMessage(null); 
236
%>
237
			path = path.removeFileExtension().addFileExtension("<%=editorGen.getDomainFileExtension()%>"); //$NON-NLS-1$
238
			if (<%=importManager.getImportedName("org.eclipse.core.resources.ResourcesPlugin")%>.getWorkspace().getRoot().exists(path)) {
239
				setErrorMessage("Model File already exists: " + path.lastSegment());
240
				return false;
241
			}
242
<%
243
	}
244
}
245
%>
246
		setErrorMessage(null);
162
		return true;
247
		return true;
163
	}
248
	}
164
249
250
<%
251
if (isRichClientPlatform) {
252
%>
165
	/**
253
	/**
166
	 * @generated
254
	 * @generated
167
	 */
255
	 */
168
	public URI getCreatedDiagramFileURI() {
256
	public URI getCreatedDiagramFileURI() {
169
		return createdDiagramFileURI;
257
		return createdDiagramFileURI;
170
	}
258
	}
259
<%
260
} else {
261
%>
262
	/**
263
	 * @generated
264
	 */
265
	public IFile getCreatedDiagramFile() {
266
		return createdDiagramFile;
267
	}
268
<%
269
}
270
%>
171
271
272
<%
273
if (isRichClientPlatform) {
274
%>
172
	/**
275
	/**
173
	 * @generated
276
	 * @generated
174
	 */
277
	 */
Lines 180-186 Link Here
180
		return null;
283
		return null;
181
	}
284
	}
182
285
183
<%if (!editorGen.isSameFileForDiagramAndModel()) {%>
286
<%
287
	if (!editorGen.isSameFileForDiagramAndModel()) {
288
%>
184
	/**
289
	/**
185
	 * @generated
290
	 * @generated
186
	 */
291
	 */
Lines 191-197 Link Here
191
		}
296
		}
192
		return diagramFileURI.trimFileExtension().appendFileExtension("<%=editorGen.getDomainFileExtension()%>");
297
		return diagramFileURI.trimFileExtension().appendFileExtension("<%=editorGen.getDomainFileExtension()%>");
193
	}
298
	}
194
<%}%>
299
<%
300
	}
301
}
302
%>
195
303
196
	/**
304
	/**
197
	 * Performs the operations necessary to create and open the diagram
305
	 * Performs the operations necessary to create and open the diagram
Lines 200-207 Link Here
200
	 */
308
	 */
201
	public boolean finish() {
309
	public boolean finish() {
202
		final boolean[] result = new boolean[1];
310
		final boolean[] result = new boolean[1];
311
<%
312
if (isRichClientPlatform) {
313
%>
203
		<%=importManager.getImportedName("org.eclipse.jface.operation.IRunnableWithProgress")%> op = new IRunnableWithProgress() {
314
		<%=importManager.getImportedName("org.eclipse.jface.operation.IRunnableWithProgress")%> op = new IRunnableWithProgress() {
204
			public void run(IProgressMonitor monitor) {
315
			public void run(IProgressMonitor monitor) {
316
<%
317
} else {
318
%>
319
		<%=importManager.getImportedName("org.eclipse.ui.actions.WorkspaceModifyOperation")%> op = new WorkspaceModifyOperation(null) {
320
			protected void execute(IProgressMonitor monitor) {
321
<%
322
}
323
%>
205
				result[0] = doFinish(monitor);
324
				result[0] = doFinish(monitor);
206
			}
325
			}
207
		};
326
		};
Lines 233-255 Link Here
233
	 * @generated
352
	 * @generated
234
	 */
353
	 */
235
	public boolean doFinish(IProgressMonitor monitor) {
354
	public boolean doFinish(IProgressMonitor monitor) {
236
		createdDiagramFileURI = createDiagramFile(monitor);
355
<%
237
		return createdDiagramFileURI != null;
356
String createdVar = isRichClientPlatform ? "createdDiagramFileURI" : "createdDiagramFile";
357
%>
358
		<%=createdVar%> = createDiagramFile(monitor);
359
		return <%=createdVar%> != null;
238
	}
360
	}
239
361
240
	/**
362
	/**
241
	 * @generated
363
	 * @generated
242
	 */
364
	 */
365
<%if (isRichClientPlatform) {%>
243
	private URI createDiagramFile(IProgressMonitor monitor) {
366
	private URI createDiagramFile(IProgressMonitor monitor) {
367
<%} else {%>
368
	private IFile createDiagramFile(IProgressMonitor monitor) {
369
<%}%>
244
		//TODO: Editing domain!
370
		//TODO: Editing domain!
245
		<%=importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet")%> resourceSet = new <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl")%>();
371
		<%=importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet")%> resourceSet = new <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl")%>();
372
<%
373
if (isRichClientPlatform) {
374
%>
246
		final <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.Resource")%> diagramResource = resourceSet.createResource(getDiagramFileURI());
375
		final <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.Resource")%> diagramResource = resourceSet.createResource(getDiagramFileURI());
247
<%
376
<%
377
} else {
378
%>
379
		IPath diagramFilePath = getContainerFullPath().append(getFileName());
380
		if (diagramFilePath.getFileExtension() == null) {
381
			diagramFilePath = diagramFilePath.addFileExtension("<%=editorGen.getDiagramFileExtension()%>");		//$NON-NLS-1$
382
		}
383
		final IFile diagramFile = ResourcesPlugin.getWorkspace().getRoot().getFile(diagramFilePath);
384
		final <%=importManager.getImportedName("org.eclipse.emf.ecore.resource.Resource")%> diagramResource = resourceSet.createResource(URI.createPlatformResourceURI(diagramFilePath.toString()));
385
<%
386
}
387
%>
388
<%
248
final boolean standaloneDomainModel = !editorGen.isSameFileForDiagramAndModel() && genDiagram.getDomainDiagramElement() != null;
389
final boolean standaloneDomainModel = !editorGen.isSameFileForDiagramAndModel() && genDiagram.getDomainDiagramElement() != null;
249
if (standaloneDomainModel) {
390
if (standaloneDomainModel) {
391
	if (isRichClientPlatform) {
250
%>
392
%>
251
		final Resource modelResource = resourceSet.createResource(getModelFileURI());
393
		final Resource modelResource = resourceSet.createResource(getModelFileURI());
252
<%}%>
394
<%
395
	} else {
396
%>
397
		IPath modelFilePath = diagramFilePath.removeFileExtension().addFileExtension("<%=editorGen.getDomainFileExtension()%>"); //$NON-NLS-1$
398
		final Resource modelResource = resourceSet.createResource(URI.createPlatformResourceURI(modelFilePath.toString()));
399
<%
400
	}
401
}
402
%>
253
403
254
		if (diagramResource != null<%if (standaloneDomainModel) {%> && modelResource != null<%}%>) {
404
		if (diagramResource != null<%if (standaloneDomainModel) {%> && modelResource != null<%}%>) {
255
			//TODO: Editing domain!
405
			//TODO: Editing domain!
Lines 280-290 Link Here
280
				handleSaveException(e);
430
				handleSaveException(e);
281
			}
431
			}
282
		}
432
		}
433
<%
434
if (isRichClientPlatform) {
435
%>
283
		boolean result = <%=genDiagram.getDiagramEditorUtilClassName()%>.openEditor(getDiagramFileURI());
436
		boolean result = <%=genDiagram.getDiagramEditorUtilClassName()%>.openEditor(getDiagramFileURI());
284
		if (!result) {
437
		if (!result) {
285
			return null;
438
			return null;
286
		}
439
		}
287
		return getDiagramFileURI();
440
		return getDiagramFileURI();
441
<%
442
} else {
443
%>
444
		try {
445
			<%=importManager.getImportedName("org.eclipse.ui.ide.IDE")%>.openEditor(<%=importManager.getImportedName("org.eclipse.ui.PlatformUI")%>.getWorkbench().getActiveWorkbenchWindow().getActivePage(), diagramFile);
446
		} catch (<%=importManager.getImportedName("org.eclipse.ui.PartInitException")%> e) {
447
			<%=genPlugin.getActivatorClassName()%>.getInstance().getLog().log(e.getStatus());
448
			return null;
449
		}
450
		return diagramFile;
451
<%
452
}
453
%>
288
	}
454
	}
289
455
290
	/**
456
	/**
(-)templates/editor/plugin.propertiesjet (-2 / +35 lines)
Lines 1-5 Link Here
1
<%@ jet package="org.eclipse.gmf.codegen.templates.lite.editor" class="PluginPropertiesGenerator"
1
<%@ jet package="org.eclipse.gmf.codegen.templates.lite.editor" class="PluginPropertiesGenerator"
2
    imports="org.eclipse.gmf.codegen.gmfgen.*"%>
2
    imports="org.eclipse.gmf.codegen.gmfgen.* org.eclipse.emf.codegen.ecore.genmodel.*"%>
3
<%GenPlugin genPlugin = (GenPlugin) argument;%>
3
<%
4
GenPlugin genPlugin = (GenPlugin) argument;
5
final GenDiagram genDiagram = genPlugin.getEditorGen().getDiagram();
6
final GenModel genModel = genPlugin.getEditorGen().getDomainGenModel();
7
final boolean isRichClientPlatform = genModel.isRichClientPlatform();
8
%>
4
pluginName=<%=genPlugin.getName()%>
9
pluginName=<%=genPlugin.getName()%>
5
providerName=<%=genPlugin.getProvider()%>
10
providerName=<%=genPlugin.getProvider()%>
11
12
<%if (isRichClientPlatform) {%>
13
_UI_Menu_OpenURI_label=Open Diagram &URI...
14
_UI_Menu_OpenURI_description=Opens a <%=genModel.getModelName()%> diagram loading it from a URI
15
_UI_Menu_Open_label=&Open Diagram...
16
_UI_Menu_Open_description=Opens a <%=genModel.getModelName()%> diagram
17
18
_UI_<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>_ActionSet_label=<%=genModel.getModelName()%> Diagram Action Set 
19
_UI_<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>NewDiagramCommand=<%=genModel.getModelName()%> diagram
20
21
<%
22
	boolean shouldGenerateApplication = true;	/*XXX: option in gmfgen*/
23
	if (shouldGenerateApplication) {
24
%>
25
_UI_Perspective_label = <%=genModel.getModelName()%> Diagram
26
_UI_Application_title=<%=genModel.getModelName()%> Diagram Application 
27
_UI_Menu_File_label=&File
28
_UI_Menu_New_label=&New
29
_UI_Menu_Edit_label=&Edit
30
_UI_Menu_Window_label=&Window
31
_UI_Menu_Help_label=&Help
32
_UI_Menu_About_label=<%=genModel.getModelName()%> Diagram &About...
33
_UI_About_title = <%=genModel.getModelName()%> Diagram Application
34
_UI_About_text = <%=genModel.getModelName()%> Diagram Application about box goes here.
35
<%
36
	}
37
}
38
%>
(-)templates/editor/plugin.xmljet (+98 lines)
Lines 5-10 Link Here
5
final GenEditorGenerator editorGen = genPlugin.getEditorGen();
5
final GenEditorGenerator editorGen = genPlugin.getEditorGen();
6
final GenDiagram genDiagram = editorGen.getDiagram();
6
final GenDiagram genDiagram = editorGen.getDiagram();
7
final GenModel genModel = editorGen.getDomainGenModel();
7
final GenModel genModel = editorGen.getDomainGenModel();
8
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
8
%>
9
%>
9
<?xml version="1.0" encoding="UTF-8"?>
10
<?xml version="1.0" encoding="UTF-8"?>
10
<?eclipse version="3.0"?>
11
<?eclipse version="3.0"?>
Lines 28-33 Link Here
28
     </editor>
29
     </editor>
29
   </extension>
30
   </extension>
30
31
32
<%
33
if (isRichClientPlatform) {
34
	final boolean shouldGenerateApplication = true;	/*XXX: option in gmfgen*/
35
	if (shouldGenerateApplication) {
36
%>
37
  <extension
38
    point="org.eclipse.core.runtime.applications"
39
    id="<%=genModel.getModelName()%>DiagramApplication">
40
    <application>
41
      <run
42
        class="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>$Application">
43
      </run>
44
    </application>
45
  </extension>
46
47
   <extension
48
    point="org.eclipse.ui.perspectives">
49
    <perspective
50
      name="%_UI_Perspective_label"
51
      class="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>$Perspective"
52
      id="<%=genPlugin.getID()%>.Perspective">
53
    </perspective>
54
  </extension>
55
<%
56
	}
57
%>
58
  <extension
59
    point="org.eclipse.ui.commands">
60
    <command
61
      name="%_UI_Menu_OpenURI_label"
62
      description="%_UI_Menu_OpenURI_description"
63
      categoryId="org.eclipse.ui.category.file"
64
      id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenURICommand" />  
65
    <command
66
      name="%_UI_Menu_Open_label"
67
      description="%_UI_Menu_Open_description"
68
      categoryId="org.eclipse.ui.category.file"
69
      id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenCommand" />  
70
  </extension> 
71
72
  <extension
73
    point="org.eclipse.ui.bindings">
74
    <key
75
      commandId="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenURICommand"
76
      sequence="M1+U"
77
      schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
78
    <key
79
      commandId="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenCommand"
80
      sequence="M1+O"
81
      schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
82
  </extension>
83
  <extension
84
    point="org.eclipse.ui.actionSets">
85
    <actionSet
86
      label="%_UI_<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>_ActionSet_label"
87
      visible="true"
88
      id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>ActionSet">
89
<%
90
	if (shouldGenerateApplication) {
91
%>
92
      <action
93
        label="%_UI_Menu_About_label"
94
        class="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>$AboutAction"
95
        menubarPath="help/additions"
96
        id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>AboutAction">
97
      </action>
98
<%
99
	}
100
%>
101
      <action
102
        label="%_UI_Menu_OpenURI_label"
103
        definitionId="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenURICommand"
104
        class="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>$OpenURIAction"
105
        menubarPath="file/additions"
106
        id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenURIAction">
107
      </action>
108
      <action
109
        label="%_UI_Menu_Open_label"
110
        definitionId="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenCommand"
111
        class="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>$OpenDiagramAction"
112
        menubarPath="file/additions"
113
        id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>OpenDiagramAction">
114
      </action>
115
      <action
116
        label="%_UI_<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>NewDiagramCommand"
117
        class="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>$NewDiagramAction"
118
        menubarPath="file/new/additions"
119
        id="<%=genDiagram.getDiagramEditorUtilQualifiedClassName()%>NewAction">
120
      </action>
121
    </actionSet> 
122
  </extension>
123
<%
124
} else {
125
%>
31
   <extension point="org.eclipse.ui.newWizards">
126
   <extension point="org.eclipse.ui.newWizards">
32
  	  <wizard
127
  	  <wizard
33
  	     name="<%=genModel.getModelName()%> Diagram"
128
  	     name="<%=genModel.getModelName()%> Diagram"
Lines 41-44 Link Here
41
      </wizard>
136
      </wizard>
42
   </extension>
137
   </extension>
43
138
139
<%
140
}
141
%>
44
</plugin>
142
</plugin>
(-)templates/editor/CreationWizard.javajet (-2 / +50 lines)
Lines 4-9 Link Here
4
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
4
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
5
final GenModel genModel = genDiagram.getEditorGen().getDomainGenModel();
5
final GenModel genModel = genDiagram.getEditorGen().getDomainGenModel();
6
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
6
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
7
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
7
8
8
importManager.emitPackageStatement(stringBuffer);
9
importManager.emitPackageStatement(stringBuffer);
9
importManager.markImportLocation(stringBuffer);
10
importManager.markImportLocation(stringBuffer);
Lines 15-25 Link Here
15
/**
16
/**
16
 * @generated
17
 * @generated
17
 */
18
 */
18
public class <%=genDiagram.getCreationWizardClassName()%> extends <%=importManager.getImportedName("org.eclipse.jface.wizard.Wizard")%> implements <%=importManager.getImportedName("org.eclipse.ui.INewWizard")%> {
19
public class <%=genDiagram.getCreationWizardClassName()%> extends <%=importManager.getImportedName(isRichClientPlatform ? "org.eclipse.jface.wizard.Wizard" : "org.eclipse.ui.wizards.newresource.BasicNewResourceWizard")%> implements <%=importManager.getImportedName("org.eclipse.ui.INewWizard")%> {
20
<%
21
if (isRichClientPlatform) {
22
%>
19
	/**
23
	/**
20
	 * @generated
24
	 * @generated
21
	 */
25
	 */
22
	 private <%=importManager.getImportedName("org.eclipse.emf.common.util.URI")%> diagramFileURI;
26
	 private <%=importManager.getImportedName("org.eclipse.emf.common.util.URI")%> diagramFileURI;
27
<%
28
} else {
29
%>
30
	/**
31
	 * @generated
32
	 */
33
	 private <%=importManager.getImportedName("org.eclipse.core.resources.IFile")%> diagramFile;
34
<%
35
}
36
%>
23
37
24
	/**
38
	/**
25
	 * @generated
39
	 * @generated
Lines 32-38 Link Here
32
	public void addPages() {
46
	public void addPages() {
33
		super.addPages();
47
		super.addPages();
34
		if (page == null) {
48
		if (page == null) {
35
			page = new <%=importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName())%>();
49
			page = new <%=importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName())%>(<%if(!isRichClientPlatform) {%>getSelection()<%}%>);
36
		}
50
		}
37
		addPage(page);
51
		addPage(page);
38
	}
52
	}
Lines 41-46 Link Here
41
	 * @generated
55
	 * @generated
42
	 */
56
	 */
43
	public void init(IWorkbench workbench, IStructuredSelection selection) {
57
	public void init(IWorkbench workbench, IStructuredSelection selection) {
58
<%
59
if (!isRichClientPlatform) {
60
%>
61
		super.init(workbench, selection);
62
<%
63
}
64
%>
44
		setWindowTitle("New <%=genModel.getModelName()%> Diagram"); //$NON-NLS-1$
65
		setWindowTitle("New <%=genModel.getModelName()%> Diagram"); //$NON-NLS-1$
45
		setDefaultPageImageDescriptor(<%=genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName()%>.getBundledImageDescriptor(
66
		setDefaultPageImageDescriptor(<%=genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName()%>.getBundledImageDescriptor(
46
			"icons/full/wizban/New<%=genModel.getModelName()%>.gif")); //$NON-NLS-1$
67
			"icons/full/wizban/New<%=genModel.getModelName()%>.gif")); //$NON-NLS-1$
Lines 52-61 Link Here
52
	 */
73
	 */
53
	public boolean performFinish() {
74
	public boolean performFinish() {
54
		boolean retVal = page.finish();
75
		boolean retVal = page.finish();
76
<%
77
if (isRichClientPlatform) {
78
%>
55
		diagramFileURI = page.getCreatedDiagramFileURI();
79
		diagramFileURI = page.getCreatedDiagramFileURI();
80
<%
81
} else {
82
%>
83
		diagramFile = page.getCreatedDiagramFile();
84
<%
85
}
86
%>
56
		return retVal;
87
		return retVal;
57
	}
88
	}
58
89
90
<%
91
if (isRichClientPlatform) {
92
%>
59
	/**
93
	/**
60
	 * returns the diagram file 
94
	 * returns the diagram file 
61
	 * @return URI the diagram file
95
	 * @return URI the diagram file
Lines 64-68 Link Here
64
	public final URI getDiagramFileURI() {
98
	public final URI getDiagramFileURI() {
65
		return diagramFileURI;
99
		return diagramFileURI;
66
	}
100
	}
101
<%
102
} else {
103
%>
104
	/**
105
	 * returns the diagram file 
106
	 * @return IFile the diagram file
107
	 * @generated
108
	 */
109
	public final IFile getDiagramFile() {
110
		return diagramFile;
111
	}
112
<%
113
}
114
%>
67
}
115
}
68
<%importManager.emitSortedImports();%>
116
<%importManager.emitSortedImports();%>
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/PluginGenerator.java (-7 / +13 lines)
Lines 27-36 Link Here
27
  protected final String TEXT_8 = NL + "\t\tfactories.add(new ";
27
  protected final String TEXT_8 = NL + "\t\tfactories.add(new ";
28
  protected final String TEXT_9 = "());";
28
  protected final String TEXT_9 = "());";
29
  protected final String TEXT_10 = NL + "\t\tfactories.add(new ResourceItemProviderAdapterFactory());" + NL + "\t\tfactories.add(new ReflectiveItemProviderAdapterFactory());" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic AdapterFactory getItemProvidersAdapterFactory() {" + NL + "\t\treturn adapterFactory;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ImageDescriptor getItemImageDescriptor(Object item) {" + NL + "\t\tIItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);" + NL + "\t\tif (labelProvider != null) {";
29
  protected final String TEXT_10 = NL + "\t\tfactories.add(new ResourceItemProviderAdapterFactory());" + NL + "\t\tfactories.add(new ReflectiveItemProviderAdapterFactory());" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic AdapterFactory getItemProvidersAdapterFactory() {" + NL + "\t\treturn adapterFactory;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ImageDescriptor getItemImageDescriptor(Object item) {" + NL + "\t\tIItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);" + NL + "\t\tif (labelProvider != null) {";
30
  protected final String TEXT_11 = NL + "\t\t\treturn ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item));" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Returns an image descriptor for the image file at the given" + NL + "\t * plug-in relative path." + NL + "\t *" + NL + "\t * @generated" + NL + "\t * @param path the path" + NL + "\t * @return the image descriptor" + NL + "\t */" + NL + "\tpublic static ImageDescriptor getBundledImageDescriptor(String path) {" + NL + "\t\treturn AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * Returns an image for the image file at the given plug-in relative path." + NL + "\t * Client do not need to dispose this image. Images will be disposed automatically." + NL + "\t *" + NL + "\t * @generated" + NL + "\t * @param path the path" + NL + "\t * @return image instance" + NL + "\t */" + NL + "\tpublic Image getBundledImage(String path) {" + NL + "\t\tImage image = getImageRegistry().get(path);" + NL + "\t\tif (image == null) {" + NL + "\t\t\tgetImageRegistry().put(path, getBundledImageDescriptor(path));" + NL + "\t\t\timage = getImageRegistry().get(path);" + NL + "\t\t}" + NL + "\t\treturn image;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logError(String error) {" + NL + "\t\tlogError(error, null);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @param throwable actual error or null could be passed" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logError(String error, Throwable throwable) {" + NL + "\t\tif (error == null && throwable != null) {" + NL + "\t\t\terror = throwable.getMessage();" + NL + "\t\t}" + NL + "\t\tgetLog().log(new Status(IStatus.ERROR, ";
30
  protected final String TEXT_11 = NL + "\t\t\treturn ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item));" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Returns an image descriptor for the image file at the given" + NL + "\t * plug-in relative path." + NL + "\t *" + NL + "\t * @generated" + NL + "\t * @param path the path" + NL + "\t * @return the image descriptor" + NL + "\t */" + NL + "\tpublic static ImageDescriptor getBundledImageDescriptor(String path) {" + NL + "\t\treturn AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * Returns an image for the image file at the given plug-in relative path." + NL + "\t * Client do not need to dispose this image. Images will be disposed automatically." + NL + "\t *" + NL + "\t * @generated" + NL + "\t * @param path the path" + NL + "\t * @return image instance" + NL + "\t */" + NL + "\tpublic Image getBundledImage(String path) {" + NL + "\t\tImage image = getImageRegistry().get(path);" + NL + "\t\tif (image == null) {" + NL + "\t\t\tgetImageRegistry().put(path, getBundledImageDescriptor(path));" + NL + "\t\t\timage = getImageRegistry().get(path);" + NL + "\t\t}" + NL + "\t\treturn image;" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic String getBundleString(String key) {" + NL + "\t\ttry {" + NL + "\t\t\treturn ";
31
  protected final String TEXT_12 = ".ID, IStatus.OK, error, throwable));" + NL + "\t\tdebug(error, throwable);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logInfo(String message) {" + NL + "\t\tlogInfo(message, null);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @param throwable actual error or null could be passed" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logInfo(String message, Throwable throwable) {" + NL + "\t\tif (message == null && message != null) {" + NL + "\t\t\tmessage = throwable.getMessage();" + NL + "\t\t}" + NL + "\t\tgetLog().log(new Status(IStatus.INFO, ";
31
  protected final String TEXT_12 = ".getResourceBundle(getBundle()).getString(key);" + NL + "\t\t} catch (";
32
  protected final String TEXT_13 = ".ID, IStatus.OK, message, throwable));" + NL + "\t\tdebug(message, throwable);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void debug(String message, Throwable throwable) {" + NL + "\t\tif (!isDebugging()) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tif (message != null) {" + NL + "\t\t\tSystem.err.println(message);" + NL + "\t\t}" + NL + "\t\tif (throwable != null) {" + NL + "\t\t\tthrowable.printStackTrace();" + NL + "\t\t}" + NL + "\t}" + NL + "\t" + NL + "}";
32
  protected final String TEXT_13 = " e) {" + NL + "\t\t\treturn \"!\" + key + \"!\";\t//$NON-NLS-1$\t//$NON-NLS-2$" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logError(String error) {" + NL + "\t\tlogError(error, null);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @param throwable actual error or null could be passed" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logError(String error, Throwable throwable) {" + NL + "\t\tif (error == null && throwable != null) {" + NL + "\t\t\terror = throwable.getMessage();" + NL + "\t\t}" + NL + "\t\tgetLog().log(new Status(IStatus.ERROR, ";
33
  protected final String TEXT_14 = NL;
33
  protected final String TEXT_14 = ".ID, IStatus.OK, error, throwable));" + NL + "\t\tdebug(error, throwable);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logInfo(String message) {" + NL + "\t\tlogInfo(message, null);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @param throwable actual error or null could be passed" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void logInfo(String message, Throwable throwable) {" + NL + "\t\tif (message == null && message != null) {" + NL + "\t\t\tmessage = throwable.getMessage();" + NL + "\t\t}" + NL + "\t\tgetLog().log(new Status(IStatus.INFO, ";
34
  protected final String TEXT_15 = ".ID, IStatus.OK, message, throwable));" + NL + "\t\tdebug(message, throwable);" + NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void debug(String message, Throwable throwable) {" + NL + "\t\tif (!isDebugging()) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tif (message != null) {" + NL + "\t\t\tSystem.err.println(message);" + NL + "\t\t}" + NL + "\t\tif (throwable != null) {" + NL + "\t\t\tthrowable.printStackTrace();" + NL + "\t\t}" + NL + "\t}" + NL + "\t" + NL + "}";
35
  protected final String TEXT_16 = NL;
34
36
35
  public String generate(Object argument)
37
  public String generate(Object argument)
36
  {
38
  {
Lines 68-79 Link Here
68
			// FIXME move image registry to plugin class code
70
			// FIXME move image registry to plugin class code
69
71
70
    stringBuffer.append(TEXT_11);
72
    stringBuffer.append(TEXT_11);
71
    stringBuffer.append(genPlugin.getActivatorClassName());
73
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.Platform"));
72
    stringBuffer.append(TEXT_12);
74
    stringBuffer.append(TEXT_12);
73
    stringBuffer.append(genPlugin.getActivatorClassName());
75
    stringBuffer.append(importManager.getImportedName("java.util.MissingResourceException"));
74
    stringBuffer.append(TEXT_13);
76
    stringBuffer.append(TEXT_13);
75
    importManager.emitSortedImports();
77
    stringBuffer.append(genPlugin.getActivatorClassName());
76
    stringBuffer.append(TEXT_14);
78
    stringBuffer.append(TEXT_14);
79
    stringBuffer.append(genPlugin.getActivatorClassName());
80
    stringBuffer.append(TEXT_15);
81
    importManager.emitSortedImports();
82
    stringBuffer.append(TEXT_16);
77
    return stringBuffer.toString();
83
    return stringBuffer.toString();
78
  }
84
  }
79
}
85
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/ManifestGenerator.java (-9 / +15 lines)
Lines 20-31 Link Here
20
  protected final String TEXT_2 = "; singleton:=true" + NL + "Bundle-Version: ";
20
  protected final String TEXT_2 = "; singleton:=true" + NL + "Bundle-Version: ";
21
  protected final String TEXT_3 = NL + "Bundle-ClassPath: ." + NL + "Bundle-Activator: ";
21
  protected final String TEXT_3 = NL + "Bundle-ClassPath: ." + NL + "Bundle-Activator: ";
22
  protected final String TEXT_4 = NL + "Bundle-Vendor: %providerName" + NL + "Bundle-Localization: plugin" + NL + "Export-Package: ";
22
  protected final String TEXT_4 = NL + "Bundle-Vendor: %providerName" + NL + "Bundle-Localization: plugin" + NL + "Export-Package: ";
23
  protected final String TEXT_5 = NL + "Require-Bundle: org.eclipse.core.runtime," + NL + " org.eclipse.jface," + NL + " org.eclipse.ui.views," + NL + " org.eclipse.ui.workbench," + NL + " org.eclipse.emf.ecore," + NL + " org.eclipse.emf.edit.ui," + NL + " org.eclipse.gef;visibility:=reexport," + NL + " org.eclipse.gmf.runtime.notation," + NL + " org.eclipse.gmf.runtime.notation.edit";
23
  protected final String TEXT_5 = NL + "Require-Bundle: org.eclipse.core.runtime,";
24
  protected final String TEXT_6 = ",";
24
  protected final String TEXT_6 = "org.eclipse.core.resources," + NL + " org.eclipse.ui.ide,";
25
  protected final String TEXT_7 = NL + " ";
25
  protected final String TEXT_7 = NL + " org.eclipse.jface," + NL + " org.eclipse.ui.views," + NL + " org.eclipse.ui.workbench," + NL + " org.eclipse.emf.ecore," + NL + " org.eclipse.emf.edit.ui," + NL + " org.eclipse.gef;visibility:=reexport," + NL + " org.eclipse.gmf.runtime.notation," + NL + " org.eclipse.gmf.runtime.notation.edit";
26
  protected final String TEXT_8 = ";visibility:=reexport";
26
  protected final String TEXT_8 = ",";
27
  protected final String TEXT_9 = NL + "Eclipse-LazyStart: true";
27
  protected final String TEXT_9 = NL + " ";
28
  protected final String TEXT_10 = NL;
28
  protected final String TEXT_10 = ";visibility:=reexport";
29
  protected final String TEXT_11 = NL + "Eclipse-LazyStart: true";
30
  protected final String TEXT_12 = NL;
29
31
30
  public String generate(Object argument)
32
  public String generate(Object argument)
31
  {
33
  {
Lines 57-70 Link Here
57
    stringBuffer.append(TEXT_4);
59
    stringBuffer.append(TEXT_4);
58
    stringBuffer.append(genPlugin.getEditorGen().getEditor().getPackageName());
60
    stringBuffer.append(genPlugin.getEditorGen().getEditor().getPackageName());
59
    stringBuffer.append(TEXT_5);
61
    stringBuffer.append(TEXT_5);
60
    while(requiredBundleIterator.hasNext()) {
62
    if (!genModel.isRichClientPlatform()) {
61
    stringBuffer.append(TEXT_6);
63
    stringBuffer.append(TEXT_6);
64
    }
62
    stringBuffer.append(TEXT_7);
65
    stringBuffer.append(TEXT_7);
63
    stringBuffer.append(requiredBundleIterator.next());
66
    while(requiredBundleIterator.hasNext()) {
64
    stringBuffer.append(TEXT_8);
67
    stringBuffer.append(TEXT_8);
65
    }
66
    stringBuffer.append(TEXT_9);
68
    stringBuffer.append(TEXT_9);
69
    stringBuffer.append(requiredBundleIterator.next());
67
    stringBuffer.append(TEXT_10);
70
    stringBuffer.append(TEXT_10);
71
    }
72
    stringBuffer.append(TEXT_11);
73
    stringBuffer.append(TEXT_12);
68
    return stringBuffer.toString();
74
    return stringBuffer.toString();
69
  }
75
  }
70
}
76
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/DiagramEditorUtilGenerator.java (-7 / +423 lines)
Lines 2-7 Link Here
2
2
3
import org.eclipse.gmf.codegen.gmfgen.*;
3
import org.eclipse.gmf.codegen.gmfgen.*;
4
import org.eclipse.gmf.common.codegen.*;
4
import org.eclipse.gmf.common.codegen.*;
5
import org.eclipse.emf.codegen.ecore.genmodel.*;
5
6
6
public class DiagramEditorUtilGenerator
7
public class DiagramEditorUtilGenerator
7
{
8
{
Lines 17-26 Link Here
17
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18
  protected final String TEXT_1 = "";
19
  protected final String TEXT_1 = "";
19
  protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
20
  protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
20
  protected final String TEXT_3 = " {" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static String openFilePathDialog(Shell shell, String fileExtensionFilter, int style) {" + NL + "\t\tFileDialog fileDialog = new FileDialog(shell, style);" + NL + "\t\tfileDialog.setFilterExtensions(new String[]{fileExtensionFilter});" + NL + "" + NL + "\t\tfileDialog.open();" + NL + "\t\tif (fileDialog.getFileName() != null && fileDialog.getFileName().length() > 0) {" + NL + "\t\t\treturn fileDialog.getFilterPath() + File.separator + fileDialog.getFileName();" + NL + "\t\t}" + NL + "\t\telse" + NL + "\t\t{" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static boolean openEditor(URI fileURI) {" + NL + "\t\tIWorkbench workbench = PlatformUI.getWorkbench();" + NL + "\t\tIWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();" + NL + "\t\tIWorkbenchPage page = workbenchWindow.getActivePage();" + NL + "" + NL + "\t\tIEditorDescriptor editorDescriptor = workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());" + NL + "\t\tif (editorDescriptor == null) {" + NL + "\t\t\tMessageDialog.openError(" + NL + "\t\t\tworkbenchWindow.getShell()," + NL + "\t\t\t\"Error\"," + NL + "\t\t\t\"There is no editor registered for the file \" + fileURI.toFileString());" + NL + "\t\t\treturn false;" + NL + "\t\t} else {" + NL + "\t\t\ttry {" + NL + "\t\t\t\tpage.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());" + NL + "\t\t\t} catch (PartInitException exception) {" + NL + "\t\t\t\tMessageDialog.openError(" + NL + "\t\t\t\tworkbenchWindow.getShell()," + NL + "\t\t\t\t\"Error Opening Editor\"," + NL + "\t\t\t\texception.getMessage());" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\treturn true;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static URI getDiagramFileURI(URI modelFileURI) {" + NL + "\t\tif (modelFileURI == null || !modelFileURI.isFile()) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn modelFileURI.trimFileExtension().appendFileExtension(\"";
21
  protected final String TEXT_3 = " {" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static String openFilePathDialog(Shell shell, String fileExtensionFilter, int style) {" + NL + "\t\tFileDialog fileDialog = new FileDialog(shell, style);" + NL + "\t\tfileDialog.setFilterExtensions(new String[]{fileExtensionFilter});" + NL + "" + NL + "\t\tfileDialog.open();" + NL + "\t\tif (fileDialog.getFileName() != null && fileDialog.getFileName().length() > 0) {" + NL + "\t\t\treturn fileDialog.getFilterPath() + File.separator + fileDialog.getFileName();" + NL + "\t\t}" + NL + "\t\telse" + NL + "\t\t{" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static boolean openEditor(URI fileURI) {" + NL + "\t\tIWorkbench workbench = PlatformUI.getWorkbench();" + NL + "\t\tIWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();" + NL + "\t\tIWorkbenchPage page = workbenchWindow.getActivePage();" + NL + "" + NL + "\t\tIEditorDescriptor editorDescriptor = workbench.getEditorRegistry().getDefaultEditor(fileURI.lastSegment());" + NL + "\t\tif (editorDescriptor == null) {" + NL + "\t\t\tMessageDialog.openError(" + NL + "\t\t\tworkbenchWindow.getShell()," + NL + "\t\t\t\"Error\"," + NL + "\t\t\t\"There is no editor registered for the file \" + fileURI.toFileString());" + NL + "\t\t\treturn false;" + NL + "\t\t} else {" + NL + "\t\t\ttry {" + NL + "\t\t\t\tpage.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());" + NL + "\t\t\t} catch (PartInitException exception) {" + NL + "\t\t\t\tMessageDialog.openError(" + NL + "\t\t\t\tworkbenchWindow.getShell()," + NL + "\t\t\t\t\"Error Opening Editor\"," + NL + "\t\t\t\texception.getMessage());" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\treturn true;" + NL + "\t}" + NL;
21
  protected final String TEXT_4 = "\");" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static URI getModelFileURI(URI diagramFileURI) {" + NL + "\t\tif (diagramFileURI == null || !diagramFileURI.isFile()) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn diagramFileURI.trimFileExtension().appendFileExtension(\"";
22
  protected final String TEXT_4 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static URI getDiagramFileURI(URI modelFileURI) {" + NL + "\t\tif (modelFileURI == null || !modelFileURI.isFile()) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn modelFileURI.trimFileExtension().appendFileExtension(\"";
22
  protected final String TEXT_5 = "\");" + NL + "\t}" + NL + " }";
23
  protected final String TEXT_5 = "\");" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static URI getModelFileURI(URI diagramFileURI) {" + NL + "\t\tif (diagramFileURI == null || !diagramFileURI.isFile()) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn diagramFileURI.trimFileExtension().appendFileExtension(\"";
23
  protected final String TEXT_6 = NL;
24
  protected final String TEXT_6 = "\");" + NL + "\t}";
25
  protected final String TEXT_7 = NL + "\t/**" + NL + "\t * Looks up a string in the plugin's plugin.properties file." + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static String getString(String key) {" + NL + "\t\treturn ";
26
  protected final String TEXT_8 = ".getInstance().getBundleString(key);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * RCP's application" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class Application implements ";
27
  protected final String TEXT_9 = " {" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic Object run(Object args) {" + NL + "\t\t\t";
28
  protected final String TEXT_10 = " workbenchAdvisor = new Advisor();" + NL + "\t\t\t";
29
  protected final String TEXT_11 = " display = ";
30
  protected final String TEXT_12 = ".createDisplay();" + NL + "\t\t\ttry {" + NL + "\t\t\t\tint returnCode = ";
31
  protected final String TEXT_13 = ".createAndRunWorkbench(display, workbenchAdvisor);" + NL + "\t\t\t\tif (returnCode == ";
32
  protected final String TEXT_14 = ".RETURN_RESTART) {" + NL + "\t\t\t\t\treturn ";
33
  protected final String TEXT_15 = ".EXIT_RESTART;" + NL + "\t\t\t\t} else {" + NL + "\t\t\t\t\treturn ";
34
  protected final String TEXT_16 = ".EXIT_OK;" + NL + "\t\t\t\t}" + NL + "\t\t\t} finally {" + NL + "\t\t\t\tdisplay.dispose();" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + " " + NL + "  \t/**" + NL + "\t * RCP's perspective" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class Advisor extends ";
35
  protected final String TEXT_17 = " {" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic String getInitialWindowPerspectiveId() {" + NL + "\t\t\treturn Perspective.ID_PERSPECTIVE;" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void initialize(";
36
  protected final String TEXT_18 = " configurer) {" + NL + "\t\t\tsuper.initialize(configurer);" + NL + "\t\t\tconfigurer.setSaveAndRestore(true);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(";
37
  protected final String TEXT_19 = " configurer) {" + NL + "\t\t\treturn new WindowAdvisor(configurer);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "  \t/**" + NL + "\t * RCP's perspective" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class Perspective implements ";
38
  protected final String TEXT_20 = " {" + NL + "\t\t/**" + NL + "\t\t * Perspective ID" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic static final String ID_PERSPECTIVE = \"";
39
  protected final String TEXT_21 = ".Perspective\";\t//$NON-NLS-1$" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void createInitialLayout(";
40
  protected final String TEXT_22 = " layout) {" + NL + "\t\t\tlayout.setEditorAreaVisible(true);" + NL + "\t\t\tlayout.addPerspectiveShortcut(ID_PERSPECTIVE);" + NL + "" + NL + "\t\t\t";
41
  protected final String TEXT_23 = " right = layout.createFolder(\"right\", ";
42
  protected final String TEXT_24 = ".RIGHT, (float)0.66, layout.getEditorArea());\t//$NON-NLS-1$" + NL + "\t\t\tright.addView(IPageLayout.ID_OUTLINE);" + NL + "" + NL + "\t\t\t";
43
  protected final String TEXT_25 = " bottomRight = layout.createFolder(\"bottonRight\", ";
44
  protected final String TEXT_26 = ".BOTTOM, (float)0.60, \"right\");\t//$NON-NLS-1$\t//$NON-NLS-2$" + NL + "\t\t\tbottomRight.addView(";
45
  protected final String TEXT_27 = ".ID_PROP_SHEET);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * RCP's window advisor" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class WindowAdvisor extends ";
46
  protected final String TEXT_28 = " {" + NL + "\t\t/**" + NL + "\t\t * @see WorkbenchWindowAdvisor#WorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic WindowAdvisor(";
47
  protected final String TEXT_29 = " configurer) {" + NL + "\t\t\tsuper(configurer);" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#preWindowOpen()" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void preWindowOpen() {" + NL + "\t\t\t";
48
  protected final String TEXT_30 = " configurer = getWindowConfigurer();" + NL + "\t\t\tconfigurer.setInitialSize(new ";
49
  protected final String TEXT_31 = "(600, 450));" + NL + "\t\t\tconfigurer.setShowCoolBar(false);" + NL + "\t\t\tconfigurer.setShowStatusLine(true);" + NL + "\t\t\tconfigurer.setTitle(getString(\"_UI_Application_title\"));\t//$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic ";
50
  protected final String TEXT_32 = " createActionBarAdvisor(";
51
  protected final String TEXT_33 = " configurer) {" + NL + "\t\t\treturn new WindowActionBarAdvisor(configurer);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * RCP's action bar advisor" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class WindowActionBarAdvisor extends ";
52
  protected final String TEXT_34 = " {" + NL + "\t\t/**" + NL + "\t\t * @see ActionBarAdvisor#ActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic WindowActionBarAdvisor(";
53
  protected final String TEXT_35 = " configurer) {" + NL + "\t\t\tsuper(configurer);" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprotected void fillMenuBar(";
54
  protected final String TEXT_36 = " menuBar) {" + NL + "\t\t\t";
55
  protected final String TEXT_37 = " window = getActionBarConfigurer().getWindowConfigurer().getWindow();" + NL + "\t\t\tmenuBar.add(createFileMenu(window));" + NL + "\t\t\tmenuBar.add(createEditMenu(window));" + NL + "\t\t\tmenuBar.add(new ";
56
  protected final String TEXT_38 = "(";
57
  protected final String TEXT_39 = ".MB_ADDITIONS));" + NL + "\t\t\tmenuBar.add(createWindowMenu(window));" + NL + "\t\t\tmenuBar.add(createHelpMenu(window));\t\t\t\t\t" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * Creates the 'File' menu." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprotected ";
58
  protected final String TEXT_40 = " createFileMenu(";
59
  protected final String TEXT_41 = " window) {" + NL + "\t\t\t";
60
  protected final String TEXT_42 = " menu = new ";
61
  protected final String TEXT_43 = "(getString(\"_UI_Menu_File_label\"),\t//$NON-NLS-1$" + NL + "\t\t\t\t";
62
  protected final String TEXT_44 = ".M_FILE);" + NL + "\t\t\tmenu.add(new ";
63
  protected final String TEXT_45 = "(";
64
  protected final String TEXT_46 = ".FILE_START));" + NL + "\t" + NL + "\t\t\t";
65
  protected final String TEXT_47 = " newMenu = new ";
66
  protected final String TEXT_48 = "(getString(\"_UI_Menu_New_label\"), \"new\");\t//$NON-NLS-1$\t//$NON-NLS-2$" + NL + "\t\t\tnewMenu.add(new ";
67
  protected final String TEXT_49 = "(";
68
  protected final String TEXT_50 = ".MB_ADDITIONS));" + NL + "\t" + NL + "\t\t\tmenu.add(newMenu);" + NL + "\t\t\tmenu.add(new ";
69
  protected final String TEXT_51 = "());" + NL + "\t\t\tmenu.add(new ";
70
  protected final String TEXT_52 = "(";
71
  protected final String TEXT_53 = ".MB_ADDITIONS));" + NL + "\t\t\tmenu.add(new ";
72
  protected final String TEXT_54 = "());" + NL + "\t\t\taddToMenuAndRegister(menu, ";
73
  protected final String TEXT_55 = ".CLOSE.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
74
  protected final String TEXT_56 = ".CLOSE_ALL.create(window));" + NL + "\t\t\tmenu.add(new ";
75
  protected final String TEXT_57 = "());" + NL + "\t\t\taddToMenuAndRegister(menu, ";
76
  protected final String TEXT_58 = ".SAVE.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
77
  protected final String TEXT_59 = ".SAVE_AS.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
78
  protected final String TEXT_60 = ".SAVE_ALL.create(window));" + NL + "\t\t\tmenu.add(new ";
79
  protected final String TEXT_61 = "());" + NL + "\t\t\taddToMenuAndRegister(menu, ";
80
  protected final String TEXT_62 = ".QUIT.create(window));" + NL + "\t\t\tmenu.add(new ";
81
  protected final String TEXT_63 = "(";
82
  protected final String TEXT_64 = ".FILE_END));" + NL + "\t\t\treturn menu;" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * Creates the 'Edit' menu." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprotected ";
83
  protected final String TEXT_65 = " createEditMenu(";
84
  protected final String TEXT_66 = " window) {" + NL + "\t\t\t";
85
  protected final String TEXT_67 = " menu = new ";
86
  protected final String TEXT_68 = "(getString(\"_UI_Menu_Edit_label\"),\t//$NON-NLS-1$" + NL + "\t\t\t\t";
87
  protected final String TEXT_69 = ".M_EDIT);" + NL + "\t\t\tmenu.add(new ";
88
  protected final String TEXT_70 = "(";
89
  protected final String TEXT_71 = ".EDIT_START));" + NL + "\t" + NL + "\t\t\taddToMenuAndRegister(menu, ";
90
  protected final String TEXT_72 = ".UNDO.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
91
  protected final String TEXT_73 = ".REDO.create(window));" + NL + "\t\t\tmenu.add(new ";
92
  protected final String TEXT_74 = "(";
93
  protected final String TEXT_75 = ".UNDO_EXT));" + NL + "\t\t\tmenu.add(new ";
94
  protected final String TEXT_76 = "());" + NL + "\t" + NL + "\t\t\taddToMenuAndRegister(menu, ";
95
  protected final String TEXT_77 = ".CUT.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
96
  protected final String TEXT_78 = ".COPY.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
97
  protected final String TEXT_79 = ".PASTE.create(window));" + NL + "\t\t\tmenu.add(new ";
98
  protected final String TEXT_80 = "(";
99
  protected final String TEXT_81 = ".CUT_EXT));" + NL + "\t\t\tmenu.add(new ";
100
  protected final String TEXT_82 = "());" + NL + "\t" + NL + "\t\t\taddToMenuAndRegister(menu, ";
101
  protected final String TEXT_83 = ".DELETE.create(window));" + NL + "\t\t\taddToMenuAndRegister(menu, ";
102
  protected final String TEXT_84 = ".SELECT_ALL.create(window));" + NL + "\t\t\tmenu.add(new ";
103
  protected final String TEXT_85 = "());" + NL + "\t" + NL + "\t\t\tmenu.add(new ";
104
  protected final String TEXT_86 = "(";
105
  protected final String TEXT_87 = ".ADD_EXT));" + NL + "\t" + NL + "\t\t\tmenu.add(new ";
106
  protected final String TEXT_88 = "(";
107
  protected final String TEXT_89 = ".EDIT_END));" + NL + "\t\t\tmenu.add(new ";
108
  protected final String TEXT_90 = "(";
109
  protected final String TEXT_91 = ".MB_ADDITIONS));" + NL + "\t\t\treturn menu;" + NL + "\t\t}" + NL + "\t" + NL + "\t\t/**" + NL + "\t\t * Creates the 'Window' menu." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprotected ";
110
  protected final String TEXT_92 = " createWindowMenu(";
111
  protected final String TEXT_93 = " window) {" + NL + "\t\t\t";
112
  protected final String TEXT_94 = " menu = new ";
113
  protected final String TEXT_95 = "(getString(\"_UI_Menu_Window_label\"),\t//$NON-NLS-1$" + NL + "\t\t\t\t";
114
  protected final String TEXT_96 = ".M_WINDOW);" + NL + "\t" + NL + "\t\t\taddToMenuAndRegister(menu, ";
115
  protected final String TEXT_97 = ".OPEN_NEW_WINDOW.create(window));" + NL + "\t\t\tmenu.add(new ";
116
  protected final String TEXT_98 = "(";
117
  protected final String TEXT_99 = ".MB_ADDITIONS));" + NL + "\t\t\tmenu.add(";
118
  protected final String TEXT_100 = ".OPEN_WINDOWS.create(window));" + NL + "\t" + NL + "\t\t\treturn menu;" + NL + "\t\t}" + NL + "\t" + NL + "\t\t/**" + NL + "\t\t * Creates the 'Help' menu." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprotected ";
119
  protected final String TEXT_101 = " createHelpMenu(";
120
  protected final String TEXT_102 = " window) {" + NL + "\t\t\t";
121
  protected final String TEXT_103 = " menu = new ";
122
  protected final String TEXT_104 = "(getString(\"_UI_Menu_Help_label\"), ";
123
  protected final String TEXT_105 = ".M_HELP);\t//$NON-NLS-1$" + NL + "\t\t\t// Welcome or intro page would go here" + NL + "\t\t\t// Help contents would go here" + NL + "\t\t\t// Tips and tricks page would go here" + NL + "\t\t\tmenu.add(new ";
124
  protected final String TEXT_106 = "(";
125
  protected final String TEXT_107 = ".HELP_START));" + NL + "\t\t\tmenu.add(new ";
126
  protected final String TEXT_108 = "(";
127
  protected final String TEXT_109 = ".HELP_END));" + NL + "\t\t\tmenu.add(new ";
128
  protected final String TEXT_110 = "(";
129
  protected final String TEXT_111 = ".MB_ADDITIONS));" + NL + "\t\t\treturn menu;" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * Adds the specified action to the given menu and also registers the action with the" + NL + "\t\t * action bar configurer, in order to activate its key binding." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprotected void addToMenuAndRegister(";
130
  protected final String TEXT_112 = " menuManager, ";
131
  protected final String TEXT_113 = " action) {" + NL + "\t\t\tmenuManager.add(action);" + NL + "\t\t\tgetActionBarConfigurer().registerGlobalAction(action);\t\t\t" + NL + "\t\t}\t\t" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * About action for the RCP application." + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class AboutAction extends ";
132
  protected final String TEXT_114 = " {" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void run(";
133
  protected final String TEXT_115 = " action) {" + NL + "\t\t\t";
134
  protected final String TEXT_116 = ".openInformation(getWindow().getShell(), getString(\"_UI_About_title\"),\t//$NON-NLS-1$" + NL + "\t\t\tgetString(\"_UI_About_text\"));\t//$NON-NLS-1$" + NL + "\t\t}" + NL + "\t}";
135
  protected final String TEXT_117 = NL + NL + " \t/**" + NL + "\t * Open action for the ";
136
  protected final String TEXT_118 = " diagram." + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class OpenDiagramAction extends ";
137
  protected final String TEXT_119 = " {" + NL + "\t\t/**" + NL + "\t\t * Opens the editors for the files selected using the file dialog." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void run(";
138
  protected final String TEXT_120 = " action) {" + NL + "\t\t\tString filePath = openFilePathDialog(getWindow().getShell(), \"*.";
139
  protected final String TEXT_121 = "\", ";
140
  protected final String TEXT_122 = ".OPEN);\t//$NON-NLS-1$" + NL + "\t\t\tif (filePath != null) {" + NL + "\t\t\t\topenEditor(URI.createFileURI(filePath));" + NL + "\t\t\t}" + NL + "\t\t}" + NL + " \t}" + NL + "" + NL + "\t/**" + NL + "\t * Open URI action for the ";
141
  protected final String TEXT_123 = " diagram." + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class OpenURIAction extends ";
142
  protected final String TEXT_124 = " {" + NL + "\t\t/**" + NL + "\t\t * Opens the editors for the files selected using the LoadResourceDialog." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void run(";
143
  protected final String TEXT_125 = " action) {" + NL + "\t\t\t";
144
  protected final String TEXT_126 = ".LoadResourceDialog loadResourceDialog = new ";
145
  protected final String TEXT_127 = ".LoadResourceDialog(getWindow().getShell());" + NL + "\t\t\tif (";
146
  protected final String TEXT_128 = ".OK == loadResourceDialog.open()) {" + NL + "\t\t\t\tfor (";
147
  protected final String TEXT_129 = " it = loadResourceDialog.getURIs().iterator(); it.hasNext(); ) {" + NL + "\t\t\t\t\topenEditor((URI) it.next());" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * New diagram action for the ";
148
  protected final String TEXT_130 = " diagram." + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class NewDiagramAction extends ";
149
  protected final String TEXT_131 = " {" + NL + "\t\t/**" + NL + "\t\t * Opens the wizard to create the diagram." + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void run(";
150
  protected final String TEXT_132 = " action) {" + NL + "\t\t\t";
151
  protected final String TEXT_133 = " wizard = new ";
152
  protected final String TEXT_134 = "();" + NL + "\t\t\twizard.init(getWindow().getWorkbench(), ";
153
  protected final String TEXT_135 = ".EMPTY);" + NL + "\t\t\t";
154
  protected final String TEXT_136 = " wizardDialog = new ";
155
  protected final String TEXT_137 = "(getWindow().getShell(), wizard);" + NL + "\t\t\twizardDialog.open();" + NL + "\t\t}" + NL + "\t}";
156
  protected final String TEXT_138 = NL + "}";
157
  protected final String TEXT_139 = NL;
24
158
25
  public String generate(Object argument)
159
  public String generate(Object argument)
26
  {
160
  {
Lines 28-34 Link Here
28
    
162
    
29
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
163
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
30
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
164
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
165
final GenPlugin genPlugin = editorGen.getPlugin();
31
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
166
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
167
final GenModel genModel = genDiagram.getEditorGen().getDomainGenModel();
168
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
32
169
33
importManager.emitPackageStatement(stringBuffer);
170
importManager.emitPackageStatement(stringBuffer);
34
    stringBuffer.append(TEXT_1);
171
    stringBuffer.append(TEXT_1);
Lines 49-60 Link Here
49
    stringBuffer.append(TEXT_2);
186
    stringBuffer.append(TEXT_2);
50
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
187
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
51
    stringBuffer.append(TEXT_3);
188
    stringBuffer.append(TEXT_3);
52
    stringBuffer.append(editorGen.getDiagramFileExtension());
189
    
190
if (!genDiagram.getEditorGen().isSameFileForDiagramAndModel()) {
191
53
    stringBuffer.append(TEXT_4);
192
    stringBuffer.append(TEXT_4);
54
    stringBuffer.append(editorGen.getDomainFileExtension());
193
    stringBuffer.append(editorGen.getDiagramFileExtension());
55
    stringBuffer.append(TEXT_5);
194
    stringBuffer.append(TEXT_5);
56
    importManager.emitSortedImports();
195
    stringBuffer.append(editorGen.getDomainFileExtension());
57
    stringBuffer.append(TEXT_6);
196
    stringBuffer.append(TEXT_6);
197
    
198
}
199
200
    
201
if (isRichClientPlatform) {
202
	boolean shouldGenerateApplication = true;	/*XXX: option in gmfgen*/
203
	if (shouldGenerateApplication) {
204
205
    stringBuffer.append(TEXT_7);
206
    stringBuffer.append(importManager.getImportedName(genPlugin.getActivatorQualifiedClassName()));
207
    stringBuffer.append(TEXT_8);
208
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IPlatformRunnable"));
209
    stringBuffer.append(TEXT_9);
210
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.WorkbenchAdvisor"));
211
    stringBuffer.append(TEXT_10);
212
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Display"));
213
    stringBuffer.append(TEXT_11);
214
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.PlatformUI"));
215
    stringBuffer.append(TEXT_12);
216
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.PlatformUI"));
217
    stringBuffer.append(TEXT_13);
218
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.PlatformUI"));
219
    stringBuffer.append(TEXT_14);
220
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IPlatformRunnable"));
221
    stringBuffer.append(TEXT_15);
222
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IPlatformRunnable"));
223
    stringBuffer.append(TEXT_16);
224
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.WorkbenchAdvisor"));
225
    stringBuffer.append(TEXT_17);
226
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.IWorkbenchConfigurer"));
227
    stringBuffer.append(TEXT_18);
228
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.IWorkbenchWindowConfigurer"));
229
    stringBuffer.append(TEXT_19);
230
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IPerspectiveFactory"));
231
    stringBuffer.append(TEXT_20);
232
    stringBuffer.append(genPlugin.getID());
233
    stringBuffer.append(TEXT_21);
234
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IPageLayout"));
235
    stringBuffer.append(TEXT_22);
236
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFolderLayout"));
237
    stringBuffer.append(TEXT_23);
238
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IPageLayout"));
239
    stringBuffer.append(TEXT_24);
240
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFolderLayout"));
241
    stringBuffer.append(TEXT_25);
242
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IPageLayout"));
243
    stringBuffer.append(TEXT_26);
244
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IPageLayout"));
245
    stringBuffer.append(TEXT_27);
246
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.WorkbenchWindowAdvisor"));
247
    stringBuffer.append(TEXT_28);
248
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.IWorkbenchWindowConfigurer"));
249
    stringBuffer.append(TEXT_29);
250
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.IWorkbenchWindowConfigurer"));
251
    stringBuffer.append(TEXT_30);
252
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.Point"));
253
    stringBuffer.append(TEXT_31);
254
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.ActionBarAdvisor"));
255
    stringBuffer.append(TEXT_32);
256
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.IActionBarConfigurer"));
257
    stringBuffer.append(TEXT_33);
258
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.ActionBarAdvisor"));
259
    stringBuffer.append(TEXT_34);
260
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.application.IActionBarConfigurer"));
261
    stringBuffer.append(TEXT_35);
262
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
263
    stringBuffer.append(TEXT_36);
264
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow"));
265
    stringBuffer.append(TEXT_37);
266
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
267
    stringBuffer.append(TEXT_38);
268
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
269
    stringBuffer.append(TEXT_39);
270
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
271
    stringBuffer.append(TEXT_40);
272
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow"));
273
    stringBuffer.append(TEXT_41);
274
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
275
    stringBuffer.append(TEXT_42);
276
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.MenuManager"));
277
    stringBuffer.append(TEXT_43);
278
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
279
    stringBuffer.append(TEXT_44);
280
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
281
    stringBuffer.append(TEXT_45);
282
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
283
    stringBuffer.append(TEXT_46);
284
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
285
    stringBuffer.append(TEXT_47);
286
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.MenuManager"));
287
    stringBuffer.append(TEXT_48);
288
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
289
    stringBuffer.append(TEXT_49);
290
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
291
    stringBuffer.append(TEXT_50);
292
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
293
    stringBuffer.append(TEXT_51);
294
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
295
    stringBuffer.append(TEXT_52);
296
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
297
    stringBuffer.append(TEXT_53);
298
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
299
    stringBuffer.append(TEXT_54);
300
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
301
    stringBuffer.append(TEXT_55);
302
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
303
    stringBuffer.append(TEXT_56);
304
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
305
    stringBuffer.append(TEXT_57);
306
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
307
    stringBuffer.append(TEXT_58);
308
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
309
    stringBuffer.append(TEXT_59);
310
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
311
    stringBuffer.append(TEXT_60);
312
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
313
    stringBuffer.append(TEXT_61);
314
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
315
    stringBuffer.append(TEXT_62);
316
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
317
    stringBuffer.append(TEXT_63);
318
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
319
    stringBuffer.append(TEXT_64);
320
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
321
    stringBuffer.append(TEXT_65);
322
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow"));
323
    stringBuffer.append(TEXT_66);
324
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
325
    stringBuffer.append(TEXT_67);
326
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.MenuManager"));
327
    stringBuffer.append(TEXT_68);
328
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
329
    stringBuffer.append(TEXT_69);
330
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
331
    stringBuffer.append(TEXT_70);
332
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
333
    stringBuffer.append(TEXT_71);
334
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
335
    stringBuffer.append(TEXT_72);
336
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
337
    stringBuffer.append(TEXT_73);
338
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
339
    stringBuffer.append(TEXT_74);
340
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
341
    stringBuffer.append(TEXT_75);
342
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
343
    stringBuffer.append(TEXT_76);
344
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
345
    stringBuffer.append(TEXT_77);
346
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
347
    stringBuffer.append(TEXT_78);
348
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
349
    stringBuffer.append(TEXT_79);
350
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
351
    stringBuffer.append(TEXT_80);
352
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
353
    stringBuffer.append(TEXT_81);
354
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
355
    stringBuffer.append(TEXT_82);
356
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
357
    stringBuffer.append(TEXT_83);
358
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
359
    stringBuffer.append(TEXT_84);
360
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
361
    stringBuffer.append(TEXT_85);
362
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
363
    stringBuffer.append(TEXT_86);
364
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
365
    stringBuffer.append(TEXT_87);
366
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
367
    stringBuffer.append(TEXT_88);
368
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
369
    stringBuffer.append(TEXT_89);
370
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.Separator"));
371
    stringBuffer.append(TEXT_90);
372
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
373
    stringBuffer.append(TEXT_91);
374
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
375
    stringBuffer.append(TEXT_92);
376
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow"));
377
    stringBuffer.append(TEXT_93);
378
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
379
    stringBuffer.append(TEXT_94);
380
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.MenuManager"));
381
    stringBuffer.append(TEXT_95);
382
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
383
    stringBuffer.append(TEXT_96);
384
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ActionFactory"));
385
    stringBuffer.append(TEXT_97);
386
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
387
    stringBuffer.append(TEXT_98);
388
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
389
    stringBuffer.append(TEXT_99);
390
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.ContributionItemFactory"));
391
    stringBuffer.append(TEXT_100);
392
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
393
    stringBuffer.append(TEXT_101);
394
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchWindow"));
395
    stringBuffer.append(TEXT_102);
396
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
397
    stringBuffer.append(TEXT_103);
398
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.MenuManager"));
399
    stringBuffer.append(TEXT_104);
400
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
401
    stringBuffer.append(TEXT_105);
402
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
403
    stringBuffer.append(TEXT_106);
404
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
405
    stringBuffer.append(TEXT_107);
406
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
407
    stringBuffer.append(TEXT_108);
408
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
409
    stringBuffer.append(TEXT_109);
410
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.GroupMarker"));
411
    stringBuffer.append(TEXT_110);
412
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IWorkbenchActionConstants"));
413
    stringBuffer.append(TEXT_111);
414
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IMenuManager"));
415
    stringBuffer.append(TEXT_112);
416
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IAction"));
417
    stringBuffer.append(TEXT_113);
418
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate"));
419
    stringBuffer.append(TEXT_114);
420
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IAction"));
421
    stringBuffer.append(TEXT_115);
422
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.dialogs.MessageDialog"));
423
    stringBuffer.append(TEXT_116);
424
    
425
 	}
426
 
427
    stringBuffer.append(TEXT_117);
428
    stringBuffer.append(genModel.getModelName());
429
    stringBuffer.append(TEXT_118);
430
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate"));
431
    stringBuffer.append(TEXT_119);
432
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IAction"));
433
    stringBuffer.append(TEXT_120);
434
    stringBuffer.append(editorGen.getDiagramFileExtension());
435
    stringBuffer.append(TEXT_121);
436
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.SWT"));
437
    stringBuffer.append(TEXT_122);
438
    stringBuffer.append(genModel.getModelName());
439
    stringBuffer.append(TEXT_123);
440
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate"));
441
    stringBuffer.append(TEXT_124);
442
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IAction"));
443
    stringBuffer.append(TEXT_125);
444
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.edit.ui.action.LoadResourceAction"));
445
    stringBuffer.append(TEXT_126);
446
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.edit.ui.action.LoadResourceAction"));
447
    stringBuffer.append(TEXT_127);
448
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.dialogs.Dialog"));
449
    stringBuffer.append(TEXT_128);
450
    stringBuffer.append(importManager.getImportedName("java.util.Iterator"));
451
    stringBuffer.append(TEXT_129);
452
    stringBuffer.append(genModel.getModelName());
453
    stringBuffer.append(TEXT_130);
454
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate"));
455
    stringBuffer.append(TEXT_131);
456
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.action.IAction"));
457
    stringBuffer.append(TEXT_132);
458
    stringBuffer.append(importManager.getImportedName(genDiagram.getCreationWizardQualifiedClassName()));
459
    stringBuffer.append(TEXT_133);
460
    stringBuffer.append(importManager.getImportedName(genDiagram.getCreationWizardQualifiedClassName()));
461
    stringBuffer.append(TEXT_134);
462
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.viewers.StructuredSelection"));
463
    stringBuffer.append(TEXT_135);
464
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.wizard.WizardDialog"));
465
    stringBuffer.append(TEXT_136);
466
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.wizard.WizardDialog"));
467
    stringBuffer.append(TEXT_137);
468
    
469
}
470
471
    stringBuffer.append(TEXT_138);
472
    importManager.emitSortedImports();
473
    stringBuffer.append(TEXT_139);
58
    return stringBuffer.toString();
474
    return stringBuffer.toString();
59
  }
475
  }
60
}
476
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/EditorGenerator.java (-105 / +237 lines)
Lines 19-76 Link Here
19
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
19
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
20
  protected final String TEXT_1 = "";
20
  protected final String TEXT_1 = "";
21
  protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
21
  protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
22
  protected final String TEXT_3 = " extends GraphicalEditorWithFlyoutPalette {" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static class UpdatableActionGroup {" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void addAction(UpdateAction action) {" + NL + "\t\t\tassert action != null;" + NL + "\t\t\tmyActions.add(action);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void removeAction(UpdateAction action) {" + NL + "\t\t\tmyActions.remove(action);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void update() {" + NL + "\t\t\tfor (Iterator it = myActions.iterator(); it.hasNext();) {" + NL + "\t\t\t\tUpdateAction next = (UpdateAction) it.next();" + NL + "\t\t\t\tnext.update();" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate ArrayList myActions = new ArrayList();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate EditingDomain editingDomain;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
22
  protected final String TEXT_3 = " extends GraphicalEditorWithFlyoutPalette {";
23
  protected final String TEXT_4 = " ";
23
  protected final String TEXT_4 = NL + "\t/**" + NL + "\t * This class listens to changes to the file system in the workspace, and" + NL + "\t * makes the following changes: " + NL + "\t * <ul><li>If an open, saved file gets deleted, the editor is closed.</li>" + NL + "\t * <li>If an open file gets renamed or moved, the editor's" + NL + "\t * input is changed accordingly.</li></ul>" + NL + "\t *" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate class ResourceTracker implements ";
24
  protected final String TEXT_5 = ";" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
24
  protected final String TEXT_5 = " {" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void resourceChanged(";
25
  protected final String TEXT_6 = " diagram;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isDirty = false;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate PaletteRoot paletteRoot;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate PropertySheetPage undoablePropertySheetPage;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate UpdatableActionGroup stackActions = new UpdatableActionGroup();" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate CommandStackListener commandStackListener = new CommandStackListener() {" + NL + "" + NL + "\t\tpublic void commandStackChanged(EventObject event) {" + NL + "\t\t\tstackActions.update();" + NL + "\t\t\tsetDirty(((CommandStack) event.getSource()).isDirty());" + NL + "\t\t}" + NL + "\t};" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate UpdatableActionGroup editPartActions = new UpdatableActionGroup();" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ISelectionListener selectionListener = new ISelectionListener() {" + NL + "" + NL + "\t\tpublic void selectionChanged(IWorkbenchPart part, ISelection selection) {" + NL + "\t\t\teditPartActions.update();" + NL + "\t\t}" + NL + "\t};" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate UpdatableActionGroup editorActions = new UpdatableActionGroup();" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ComposedAdapterFactory domainAdapterFactory;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void firePropertyChange(int propertyId) {" + NL + "\t\tsuper.firePropertyChange(propertyId);" + NL + "\t\teditorActions.update();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an action to this editor's <code>ActionRegistry</code>. (This is" + NL + "\t * a helper method.)" + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the action to add." + NL + "\t */" + NL + "\tprotected void addAction(IAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an editor action to this editor." + NL + "\t * " + NL + "\t * <p>" + NL + "\t * Editor actions are actions that depend and work on the editor." + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the editor action" + NL + "\t */" + NL + "\tprotected void addEditorAction(WorkbenchPartAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t\teditorActions.addAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an <code>EditPart</code> action to this editor." + NL + "\t * " + NL + "\t * <p>" + NL + "\t * <code>EditPart</code> actions are actions that depend and work on the" + NL + "\t * selected <code>EditPart</code>s." + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the <code>EditPart</code> action" + NL + "\t */" + NL + "\tprotected void addEditPartAction(SelectionAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t\teditPartActions.addAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an <code>CommandStack</code> action to this editor." + NL + "\t * " + NL + "\t * <p>" + NL + "\t * <code>CommandStack</code> actions are actions that depend and work on" + NL + "\t * the <code>CommandStack</code>." + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the <code>CommandStack</code> action" + NL + "\t */" + NL + "\tprotected void addStackAction(StackAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t\tstackActions.addAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void createActions() {" + NL + "\t\taddStackAction(new UndoAction(this));" + NL + "\t\taddStackAction(new RedoAction(this));" + NL + "" + NL + "\t\taddEditPartAction(new DeleteAction((IWorkbenchPart) this));" + NL + "\t\taddEditPartAction(new DirectEditAction((IWorkbenchPart) this));" + NL + "" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE));" + NL + "" + NL + "\t\taddEditorAction(new SaveAction(this));" + NL + "\t\taddEditorAction(new PrintAction(this));" + NL + "" + NL + "\t\tIAction zoomIn = new ZoomInAction(getZoomManager());" + NL + "\t\tIAction zoomOut = new ZoomOutAction(getZoomManager());" + NL + "\t\taddAction(zoomIn);" + NL + "\t\taddAction(zoomOut);" + NL + "\t\tgetSite().getKeyBindingService().registerAction(zoomIn);" + NL + "\t\tgetSite().getKeyBindingService().registerAction(zoomOut);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void dispose() {" + NL + "\t\t// remove CommandStackListener" + NL + "\t\tgetCommandStack().removeCommandStackListener(getStackActionsListener());" + NL + "" + NL + "\t\t// remove selection listener" + NL + "\t\tgetSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(getSelectionListener());" + NL + "" + NL + "\t\t// dispose the ActionRegistry (will dispose all actions)" + NL + "\t\tgetActionRegistry().dispose();" + NL + "" + NL + "\t\t// important: always call super implementation of dispose" + NL + "\t\tsuper.dispose();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void doSave(IProgressMonitor monitor) {" + NL + "\t\ttry {" + NL + "\t\t\tsave(monitor);" + NL + "\t\t\tgetCommandStack().markSaveLocation();" + NL + "\t\t} catch (CoreException e) {" + NL + "\t\t\tErrorDialog.openError(getSite().getShell(), \"Error During Save\", \"The current ";
25
  protected final String TEXT_6 = " event) {" + NL + "\t\t\t";
26
  protected final String TEXT_7 = " model could not be saved.\", e.getStatus());" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void save(IProgressMonitor progressMonitor) throws CoreException {" + NL + "\t\tif (progressMonitor == null) {" + NL + "\t\t\tprogressMonitor = new NullProgressMonitor();" + NL + "\t\t}" + NL + "\t\tprogressMonitor.beginTask(\"Saving\", getEditingDomain().getResourceSet().getResources().size());" + NL + "\t\ttry {" + NL + "\t\t\tfor(Iterator it = getEditingDomain().getResourceSet().getResources().iterator(); it.hasNext(); ) {" + NL + "\t\t\t\tResource next = (Resource)it.next();" + NL + "\t\t\t\tnext.save(Collections.EMPTY_MAP);" + NL + "\t\t\t\tprogressMonitor.worked(1);" + NL + "\t\t\t}" + NL + "\t\t} catch (IOException e) {" + NL + "\t\t\tIStatus status = new Status(IStatus.ERROR, ";
26
  protected final String TEXT_7 = " delta = event.getDelta();" + NL + "\t\t\tif (delta != null) {" + NL + "\t\t\t\t";
27
  protected final String TEXT_8 = ".ID, 0, \"Error writing file.\", e);" + NL + "\t\t\tthrow new CoreException(status);" + NL + "\t\t} finally {" + NL + "\t\t\tprogressMonitor.done();" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean isSaveAsAllowed() {" + NL + "\t\t// TODO: should be allowed." + NL + "\t\treturn false;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void doSaveAs() {" + NL + "\t\t// TODO: Implement." + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Object getAdapter(Class type) {" + NL + "\t\tif (type == IPropertySheetPage.class) {" + NL + "\t\t\treturn getPropertySheetPage();" + NL + "\t\t} else if (type == IContentOutlinePage.class) {" + NL + "\t\t\treturn getOutlinePage();" + NL + "\t\t} else if (type == ZoomManager.class) {" + NL + "\t\t\treturn getZoomManager();" + NL + "\t\t}" + NL + "\t\treturn super.getAdapter(type);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ZoomManager getZoomManager() {" + NL + "\t\treturn getZoomManager(getGraphicalViewer());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ZoomManager getZoomManager(GraphicalViewer viewer) {" + NL + "\t\t// get zoom manager from root edit part" + NL + "\t\tRootEditPart rootEditPart = viewer.getRootEditPart();" + NL + "\t\tZoomManager zoomManager = null;" + NL + "\t\tif (rootEditPart instanceof ScalableFreeformRootEditPart) {" + NL + "\t\t\tzoomManager = ((ScalableFreeformRootEditPart) rootEditPart).getZoomManager();" + NL + "\t\t} else if (rootEditPart instanceof ScalableRootEditPart) {" + NL + "\t\t\tzoomManager = ((ScalableRootEditPart) rootEditPart).getZoomManager();" + NL + "\t\t}" + NL + "\t\treturn zoomManager;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate CommandStackListener getStackActionsListener() {" + NL + "\t\treturn commandStackListener;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected IContentOutlinePage getOutlinePage() {" + NL + "\t\t//TODO: outline page missing" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected PaletteRoot getPaletteRoot() {" + NL + "\t\tif (paletteRoot == null) {" + NL + "\t\t\tpaletteRoot = new PaletteRoot();";
27
  protected final String TEXT_8 = " fileDelta = delta.findMember(((";
28
  protected final String TEXT_9 = NL + "\t\t\tnew ";
28
  protected final String TEXT_9 = ") getEditorInput()).getFile().getFullPath());" + NL + "\t\t\t\tif (fileDelta != null) {" + NL + "\t\t\t\t\tprocessFileDelta(fileDelta);" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate void processFileDelta(";
29
  protected final String TEXT_10 = "(getDomainAdapterFactory()).contributeToPalette(paletteRoot);";
29
  protected final String TEXT_10 = " delta) {" + NL + "\t\t\tassert (delta != null && delta.getResource().equals(((";
30
  protected final String TEXT_11 = NL + "\t\t}" + NL + "\t\treturn paletteRoot;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected PropertySheetPage getPropertySheetPage() {" + NL + "\t\tif (undoablePropertySheetPage == null) {" + NL + "\t\t\tundoablePropertySheetPage = new PropertySheetPage();" + NL + "\t\t\t";
30
  protected final String TEXT_11 = ") getEditorInput()).getFile()));" + NL + "\t\t\tif (delta.getKind() == ";
31
  protected final String TEXT_12 = " rootEntry = new ";
31
  protected final String TEXT_12 = ".REMOVED) {" + NL + "\t\t\t\tif ((";
32
  protected final String TEXT_13 = "(getCommandStack());" + NL + "\t\t\trootEntry.setPropertySourceProvider(new ";
32
  protected final String TEXT_13 = ".MOVED_TO & delta.getFlags()) == 0) {" + NL + "\t\t\t\t\t";
33
  protected final String TEXT_14 = "(getDomainAdapterFactory()));" + NL + "\t\t\tundoablePropertySheetPage.setRootEntry(rootEntry);" + NL + "\t\t}" + NL + "" + NL + "\t\treturn undoablePropertySheetPage;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ISelectionListener getSelectionListener() {" + NL + "\t\treturn selectionListener;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
33
  protected final String TEXT_14 = NL + "\t\t\t\t\tif (!isDirty()) {" + NL + "\t\t\t\t\t\tcloseEditor();" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t} else {" + NL + "\t\t\t\t\t// else if it was moved or renamed" + NL + "\t\t\t\t\tfinal ";
34
  protected final String TEXT_15 = " get";
34
  protected final String TEXT_15 = " newFile = ";
35
  protected final String TEXT_16 = "() {" + NL + "\t\treturn ";
35
  protected final String TEXT_16 = ".getWorkspace().getRoot().getFile(delta.getMovedToPath());" + NL + "\t\t\t\t\t";
36
  protected final String TEXT_17 = ";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Diagram getDiagram() {" + NL + "\t\treturn diagram;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void init(IEditorSite site, IEditorInput input) throws PartInitException {" + NL + "\t\tURI file = getURIFromInput(input);" + NL + "\t\tif (file == null) {" + NL + "\t\t\tthrow new PartInitException(\"The specified input is not valid.\");" + NL + "\t\t}" + NL + "\t\tsetSite(site);" + NL + "\t\tsetInput(input);" + NL + "\t\tsetEditDomain(new DefaultEditDomain(this));" + NL + "" + NL + "\t\t// validate" + NL + "\t\tif (get";
36
  protected final String TEXT_17 = " display = getSite().getShell().getDisplay();" + NL + "\t\t\t\t\tdisplay.asyncExec(new Runnable() {" + NL + "\t\t\t\t\t\tpublic void run() {" + NL + "\t\t\t\t\t\t\tsetInput(new ";
37
  protected final String TEXT_18 = "() == null) {" + NL + "\t\t\tthrow new PartInitException(\"The specified input is not valid.\");" + NL + "\t\t}" + NL + "" + NL + "\t\t// add CommandStackListener" + NL + "\t\tgetCommandStack().addCommandStackListener(getStackActionsListener());" + NL + "" + NL + "\t\t// add selection change listener" + NL + "\t\tgetSite().getWorkbenchWindow().getSelectionService().addSelectionListener(getSelectionListener());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setInput(IEditorInput input)  {" + NL + "\t\tURI file = getURIFromInput(input);" + NL + "\t\tload(file);" + NL + "\t\tsetPartName(file.lastSegment());" + NL + "\t\tsetContentDescription(file.toFileString());" + NL + "\t\tsuper.setInput(input);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI getURIFromInput(IEditorInput input) {" + NL + "\t\tif (input instanceof URIEditorInput) {" + NL + "\t\t\treturn ((URIEditorInput) input).getURI();" + NL + "\t\t}" + NL + "\t\tif (input instanceof IPathEditorInput) {" + NL + "\t\t\treturn URI.createFileURI(((IPathEditorInput)input).getPath().toOSString());" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean isDirty() {" + NL + "\t\treturn isDirty;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void setDirty(boolean dirty) {" + NL + "\t\tif (isDirty != dirty) {" + NL + "\t\t\tisDirty = dirty;" + NL + "\t\t\tfirePropertyChange(IEditorPart.PROP_DIRTY);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected EditingDomain getEditingDomain() {" + NL + "\t\tif (editingDomain == null) {" + NL + "\t\t\tBasicCommandStack commandStack = new BasicCommandStack();" + NL + "\t\t\teditingDomain = new AdapterFactoryEditingDomain(getDomainAdapterFactory(), commandStack, new HashMap());" + NL + "\t\t\teditingDomain.getResourceSet().eAdapters().add(new AdapterFactoryEditingDomain.EditingDomainProvider(editingDomain));" + NL + "\t\t}" + NL + "\t\treturn editingDomain;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate AdapterFactory getDomainAdapterFactory() {" + NL + "\t\tif (domainAdapterFactory == null) {" + NL + "\t\t\tList factories = new ArrayList();" + NL + "\t\t\tfactories.add(new ResourceItemProviderAdapterFactory());";
37
  protected final String TEXT_18 = "(newFile));" + NL + "\t\t\t\t\t\t}" + NL + "\t\t\t\t\t});" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ResourceTracker resourceTracker;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ResourceTracker getResourceTracker() {" + NL + "\t\tif (resourceTracker == null) {" + NL + "\t\t\tresourceTracker = new ResourceTracker();" + NL + "\t\t}" + NL + "\t\treturn resourceTracker;" + NL + "\t}" + NL;
38
  protected final String TEXT_19 = NL + "\t\t\tfactories.add(new ";
38
  protected final String TEXT_19 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static class UpdatableActionGroup {" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void addAction(UpdateAction action) {" + NL + "\t\t\tassert action != null;" + NL + "\t\t\tmyActions.add(action);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void removeAction(UpdateAction action) {" + NL + "\t\t\tmyActions.remove(action);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void update() {" + NL + "\t\t\tfor (Iterator it = myActions.iterator(); it.hasNext();) {" + NL + "\t\t\t\tUpdateAction next = (UpdateAction) it.next();" + NL + "\t\t\t\tnext.update();" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate ArrayList myActions = new ArrayList();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate EditingDomain editingDomain;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
39
  protected final String TEXT_20 = "());";
39
  protected final String TEXT_20 = " ";
40
  protected final String TEXT_21 = NL + "\t\t\tfactories.add(new ReflectiveItemProviderAdapterFactory());" + NL + "\t\t\tfactories.add(new NotationItemProviderAdapterFactory());" + NL + "\t\t\tdomainAdapterFactory = new ComposedAdapterFactory(factories);" + NL + "\t\t}" + NL + "\t\treturn domainAdapterFactory;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void load(URI diagramFile) {" + NL + "\t\t";
40
  protected final String TEXT_21 = ";" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
41
  protected final String TEXT_22 = " = null;" + NL + "\t\tdiagram = null;" + NL + "\t\tif (diagramFile == null) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tEditingDomain editingDomain = getEditingDomain();" + NL + "\t\tResourceSet resourceSet = editingDomain.getResourceSet();" + NL + "\t\tResource diagramResource = resourceSet.getResource(diagramFile, true);" + NL + "\t\tif (diagramResource == null) {" + NL + "\t\t\tdiagramResource = resourceSet.createResource(diagramFile);" + NL + "\t\t}" + NL + "\t\tdiagram = (Diagram) findInResource(diagramResource, Diagram.class);" + NL + "\t\tif (diagram == null) {" + NL + "\t\t\tdiagram = NotationFactory.eINSTANCE.createDiagram();" + NL + "\t\t\tdiagramResource.getContents().add(0, diagram);" + NL + "\t\t\t//Auxiliary creation should not be undoable." + NL + "\t\t\ttry {" + NL + "\t\t\t\tdiagramResource.save(Collections.EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\tdiagram = null;" + NL + "\t\t\t\t";
41
  protected final String TEXT_22 = " diagram;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean isDirty = false;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate PaletteRoot paletteRoot;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate PropertySheetPage undoablePropertySheetPage;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate UpdatableActionGroup stackActions = new UpdatableActionGroup();" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate CommandStackListener commandStackListener = new CommandStackListener() {" + NL + "" + NL + "\t\tpublic void commandStackChanged(EventObject event) {" + NL + "\t\t\tstackActions.update();" + NL + "\t\t\tsetDirty(((CommandStack) event.getSource()).isDirty());" + NL + "\t\t}" + NL + "\t};" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate UpdatableActionGroup editPartActions = new UpdatableActionGroup();" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ISelectionListener selectionListener = new ISelectionListener() {" + NL + "" + NL + "\t\tpublic void selectionChanged(IWorkbenchPart part, ISelection selection) {" + NL + "\t\t\teditPartActions.update();" + NL + "\t\t}" + NL + "\t};" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate UpdatableActionGroup editorActions = new UpdatableActionGroup();" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ComposedAdapterFactory domainAdapterFactory;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void firePropertyChange(int propertyId) {" + NL + "\t\tsuper.firePropertyChange(propertyId);" + NL + "\t\teditorActions.update();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an action to this editor's <code>ActionRegistry</code>. (This is" + NL + "\t * a helper method.)" + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the action to add." + NL + "\t */" + NL + "\tprotected void addAction(IAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an editor action to this editor." + NL + "\t * " + NL + "\t * <p>" + NL + "\t * Editor actions are actions that depend and work on the editor." + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the editor action" + NL + "\t */" + NL + "\tprotected void addEditorAction(WorkbenchPartAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t\teditorActions.addAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an <code>EditPart</code> action to this editor." + NL + "\t * " + NL + "\t * <p>" + NL + "\t * <code>EditPart</code> actions are actions that depend and work on the" + NL + "\t * selected <code>EditPart</code>s." + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the <code>EditPart</code> action" + NL + "\t */" + NL + "\tprotected void addEditPartAction(SelectionAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t\teditPartActions.addAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Adds an <code>CommandStack</code> action to this editor." + NL + "\t * " + NL + "\t * <p>" + NL + "\t * <code>CommandStack</code> actions are actions that depend and work on" + NL + "\t * the <code>CommandStack</code>." + NL + "\t * " + NL + "\t * @generated" + NL + "\t * @param action" + NL + "\t *            the <code>CommandStack</code> action" + NL + "\t */" + NL + "\tprotected void addStackAction(StackAction action) {" + NL + "\t\tgetActionRegistry().registerAction(action);" + NL + "\t\tstackActions.addAction(action);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void createActions() {" + NL + "\t\taddStackAction(new UndoAction(this));" + NL + "\t\taddStackAction(new RedoAction(this));" + NL + "" + NL + "\t\taddEditPartAction(new DeleteAction((IWorkbenchPart) this));" + NL + "\t\taddEditPartAction(new DirectEditAction((IWorkbenchPart) this));" + NL + "" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER));" + NL + "\t\taddEditPartAction(new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE));" + NL + "" + NL + "\t\taddEditorAction(new SaveAction(this));" + NL + "\t\taddEditorAction(new PrintAction(this));" + NL + "" + NL + "\t\tIAction zoomIn = new ZoomInAction(getZoomManager());" + NL + "\t\tIAction zoomOut = new ZoomOutAction(getZoomManager());" + NL + "\t\taddAction(zoomIn);" + NL + "\t\taddAction(zoomOut);" + NL + "\t\tgetSite().getKeyBindingService().registerAction(zoomIn);" + NL + "\t\tgetSite().getKeyBindingService().registerAction(zoomOut);" + NL + "\t}" + NL;
42
  protected final String TEXT_23 = " = null;" + NL + "\t\t\t\treturn;" + NL + "\t\t\t}" + NL + "\t\t}";
42
  protected final String TEXT_23 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tvoid closeEditor() {" + NL + "\t\tgetSite().getShell().getDisplay().syncExec(new Runnable() {" + NL + "\t\t\tpublic void run() {" + NL + "\t\t\t\tgetSite().getPage().closeEditor(";
43
  protected final String TEXT_24 = NL + "\t\tURI modelFile = ";
43
  protected final String TEXT_24 = ".this, false);" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}";
44
  protected final String TEXT_25 = ".getModelFileURI(diagramFile);" + NL + "\t\tResource modelResource = resourceSet.getResource(modelFile, true);" + NL + "\t\tif (modelResource == null) {" + NL + "\t\t\tmodelResource = resourceSet.createResource(modelFile);" + NL + "\t\t}";
44
  protected final String TEXT_25 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void dispose() {" + NL + "\t\t// remove CommandStackListener" + NL + "\t\tgetCommandStack().removeCommandStackListener(getStackActionsListener());" + NL + "" + NL + "\t\t// remove selection listener" + NL + "\t\tgetSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(getSelectionListener());" + NL + "" + NL + "\t\t// dispose the ActionRegistry (will dispose all actions)" + NL + "\t\tgetActionRegistry().dispose();" + NL + "" + NL + "\t\t// important: always call super implementation of dispose" + NL + "\t\tsuper.dispose();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void doSave(IProgressMonitor monitor) {" + NL + "\t\ttry {" + NL + "\t\t\tsave(monitor);" + NL + "\t\t\tgetCommandStack().markSaveLocation();" + NL + "\t\t} catch (CoreException e) {" + NL + "\t\t\tErrorDialog.openError(getSite().getShell(), \"Error During Save\", \"The current ";
45
  protected final String TEXT_26 = NL + "\t\t";
45
  protected final String TEXT_26 = " model could not be saved.\", e.getStatus());" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void save(IProgressMonitor progressMonitor) throws CoreException {" + NL + "\t\tif (progressMonitor == null) {" + NL + "\t\t\tprogressMonitor = new NullProgressMonitor();" + NL + "\t\t}" + NL + "\t\tprogressMonitor.beginTask(\"Saving\", getEditingDomain().getResourceSet().getResources().size());" + NL + "\t\ttry {" + NL + "\t\t\tfor(Iterator it = getEditingDomain().getResourceSet().getResources().iterator(); it.hasNext(); ) {" + NL + "\t\t\t\tResource next = (Resource)it.next();" + NL + "\t\t\t\tnext.save(Collections.EMPTY_MAP);" + NL + "\t\t\t\tprogressMonitor.worked(1);" + NL + "\t\t\t}" + NL + "\t\t} catch (IOException e) {" + NL + "\t\t\tIStatus status = new Status(IStatus.ERROR, ";
46
  protected final String TEXT_27 = " = (";
46
  protected final String TEXT_27 = ".ID, 0, \"Error writing file.\", e);" + NL + "\t\t\tthrow new CoreException(status);" + NL + "\t\t} finally {" + NL + "\t\t\tprogressMonitor.done();" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean isSaveAsAllowed() {" + NL + "\t\t// TODO: should be allowed." + NL + "\t\treturn false;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void doSaveAs() {" + NL + "\t\t// TODO: Implement." + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Object getAdapter(Class type) {" + NL + "\t\tif (type == IPropertySheetPage.class) {" + NL + "\t\t\treturn getPropertySheetPage();" + NL + "\t\t} else if (type == IContentOutlinePage.class) {" + NL + "\t\t\treturn getOutlinePage();" + NL + "\t\t} else if (type == ZoomManager.class) {" + NL + "\t\t\treturn getZoomManager();" + NL + "\t\t}" + NL + "\t\treturn super.getAdapter(type);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ZoomManager getZoomManager() {" + NL + "\t\treturn getZoomManager(getGraphicalViewer());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ZoomManager getZoomManager(GraphicalViewer viewer) {" + NL + "\t\t// get zoom manager from root edit part" + NL + "\t\tRootEditPart rootEditPart = viewer.getRootEditPart();" + NL + "\t\tZoomManager zoomManager = null;" + NL + "\t\tif (rootEditPart instanceof ScalableFreeformRootEditPart) {" + NL + "\t\t\tzoomManager = ((ScalableFreeformRootEditPart) rootEditPart).getZoomManager();" + NL + "\t\t} else if (rootEditPart instanceof ScalableRootEditPart) {" + NL + "\t\t\tzoomManager = ((ScalableRootEditPart) rootEditPart).getZoomManager();" + NL + "\t\t}" + NL + "\t\treturn zoomManager;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate CommandStackListener getStackActionsListener() {" + NL + "\t\treturn commandStackListener;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected IContentOutlinePage getOutlinePage() {" + NL + "\t\t//TODO: outline page missing" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected PaletteRoot getPaletteRoot() {" + NL + "\t\tif (paletteRoot == null) {" + NL + "\t\t\tpaletteRoot = new PaletteRoot();";
47
  protected final String TEXT_28 = ") findInResource(";
47
  protected final String TEXT_28 = NL + "\t\t\tnew ";
48
  protected final String TEXT_29 = ", ";
48
  protected final String TEXT_29 = "(getDomainAdapterFactory()).contributeToPalette(paletteRoot);";
49
  protected final String TEXT_30 = ".class);" + NL + "\t\tif (";
49
  protected final String TEXT_30 = NL + "\t\t}" + NL + "\t\treturn paletteRoot;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected PropertySheetPage getPropertySheetPage() {" + NL + "\t\tif (undoablePropertySheetPage == null) {" + NL + "\t\t\tundoablePropertySheetPage = new PropertySheetPage();" + NL + "\t\t\t";
50
  protected final String TEXT_31 = " == null) {" + NL + "\t\t\t";
50
  protected final String TEXT_31 = " rootEntry = new ";
51
  protected final String TEXT_32 = " = ";
51
  protected final String TEXT_32 = "(getCommandStack());" + NL + "\t\t\trootEntry.setPropertySourceProvider(new ";
52
  protected final String TEXT_33 = ".eINSTANCE.create";
52
  protected final String TEXT_33 = "(getDomainAdapterFactory()));" + NL + "\t\t\tundoablePropertySheetPage.setRootEntry(rootEntry);" + NL + "\t\t}" + NL + "" + NL + "\t\treturn undoablePropertySheetPage;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ISelectionListener getSelectionListener() {" + NL + "\t\treturn selectionListener;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
53
  protected final String TEXT_34 = "();" + NL + "\t\t\t";
53
  protected final String TEXT_34 = " get";
54
  protected final String TEXT_35 = ".getContents().add(0, ";
54
  protected final String TEXT_35 = "() {" + NL + "\t\treturn ";
55
  protected final String TEXT_36 = ");" + NL + "\t\t\t//We don't want this auxiliary creation to be undoable." + NL + "\t\t\ttry {" + NL + "\t\t\t\t";
55
  protected final String TEXT_36 = ";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Diagram getDiagram() {" + NL + "\t\treturn diagram;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void init(IEditorSite site, IEditorInput input) throws PartInitException {" + NL + "\t\tURI file = getURIFromInput(input);" + NL + "\t\tif (file == null) {" + NL + "\t\t\tthrow new PartInitException(\"The specified input is not valid.\");" + NL + "\t\t}" + NL + "\t\tsetSite(site);" + NL + "\t\tsetInput(input);" + NL + "\t\tsetEditDomain(new DefaultEditDomain(this));" + NL + "" + NL + "\t\t// validate" + NL + "\t\tif (get";
56
  protected final String TEXT_37 = ".save(Collections.EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\tdiagram = null;" + NL + "\t\t\t\t";
56
  protected final String TEXT_37 = "() == null) {" + NL + "\t\t\tthrow new PartInitException(\"The specified input is not valid.\");" + NL + "\t\t}" + NL + "" + NL + "\t\t// add CommandStackListener" + NL + "\t\tgetCommandStack().addCommandStackListener(getStackActionsListener());" + NL + "" + NL + "\t\t// add selection change listener" + NL + "\t\tgetSite().getWorkbenchWindow().getSelectionService().addSelectionListener(getSelectionListener());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setInput(IEditorInput input)  {";
57
  protected final String TEXT_38 = " = null;" + NL + "\t\t\t\treturn;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\tif (!diagram.isSetElement()) {" + NL + "\t\t\tdiagram.setElement(";
57
  protected final String TEXT_38 = NL + "\t\tif (getEditorInput() instanceof ";
58
  protected final String TEXT_39 = ");" + NL + "\t\t}" + NL + "\t}";
58
  protected final String TEXT_39 = ") {" + NL + "\t\t\t";
59
  protected final String TEXT_40 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Object findInResource(Resource resource, Class expectedClass) {" + NL + "\t\tfor(Iterator it = resource.getContents().iterator(); it.hasNext(); ) {" + NL + "\t\t\tObject next = it.next();" + NL + "\t\t\tif (expectedClass.isInstance(next)) {" + NL + "\t\t\t\treturn next;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void setFocus() {" + NL + "\t\tgetGraphicalViewer().getControl().setFocus();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic final void createPartControl(Composite parent) {" + NL + "\t\tsuper.createPartControl(parent);" + NL + "\t\t// initialize actions" + NL + "\t\tcreateActions();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void createGraphicalViewer(Composite parent) {" + NL + "\t\tsuper.createGraphicalViewer(parent);" + NL + "\t\t// initialize the viewer with input" + NL + "\t\tScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart();" + NL + "\t\tgetGraphicalViewer().setRootEditPart(root);" + NL + "\t\tgetGraphicalViewer().setEditPartFactory(new ";
59
  protected final String TEXT_40 = " resource = ((";
60
  protected final String TEXT_41 = "());" + NL + "\t\tgetGraphicalViewer().setContents(getDiagram());" + NL + "" + NL + "\t\t";
60
  protected final String TEXT_41 = ") getEditorInput()).getFile();" + NL + "\t\t\tresource.getWorkspace().removeResourceChangeListener(getResourceTracker());" + NL + "\t\t}";
61
  protected final String TEXT_42 = " printableLayers = (";
61
  protected final String TEXT_42 = NL + "\t\tURI file = getURIFromInput(input);" + NL + "\t\tload(file);" + NL + "\t\tsetPartName(file.lastSegment());" + NL + "\t\tsuper.setInput(input);";
62
  protected final String TEXT_43 = ") root.getLayer(";
62
  protected final String TEXT_43 = NL + "\t\tif (getEditorInput() instanceof ";
63
  protected final String TEXT_44 = ".PRINTABLE_LAYERS);" + NL + "\t\t";
63
  protected final String TEXT_44 = ") {" + NL + "\t\t\t";
64
  protected final String TEXT_45 = " extLabelsLayer = new ";
64
  protected final String TEXT_45 = " resource = ((";
65
  protected final String TEXT_46 = "();" + NL + "\t\textLabelsLayer.setLayoutManager(new ";
65
  protected final String TEXT_46 = ") getEditorInput()).getFile();" + NL + "\t\t\tresource.getWorkspace().addResourceChangeListener(getResourceTracker());" + NL + "\t\t}";
66
  protected final String TEXT_47 = "());" + NL + "\t\tprintableLayers.addLayerAfter(extLabelsLayer, ";
66
  protected final String TEXT_47 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI getURIFromInput(IEditorInput input) {";
67
  protected final String TEXT_48 = ".EXTERNAL_NODE_LABELS_LAYER, ";
67
  protected final String TEXT_48 = NL + "\t\tif (input instanceof ";
68
  protected final String TEXT_49 = ".PRIMARY_LAYER);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void configureGraphicalViewer() {" + NL + "\t\tsuper.configureGraphicalViewer();" + NL + "\t\tGraphicalViewer viewer = getGraphicalViewer();" + NL + "\t\t// configure the context menu" + NL + "\t\tContextMenuProvider provider = new ";
68
  protected final String TEXT_49 = ") {" + NL + "\t\t\treturn ((";
69
  protected final String TEXT_50 = "ContextMenuProvider(viewer);" + NL + "\t\tviewer.setContextMenu(provider);" + NL + "\t\tgetSite().registerContextMenu(";
69
  protected final String TEXT_50 = ") input).getURI();" + NL + "\t\t}" + NL + "\t\tif (input instanceof ";
70
  protected final String TEXT_51 = ".ID + \".editor.contextmenu\", provider, getSite().getSelectionProvider()); //$NON-NLS-1$" + NL + "" + NL + "\t\tKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);" + NL + "\t\tkeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));" + NL + "\t\tkeyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));" + NL + "\t\tviewer.setKeyHandler(keyHandler);" + NL + "" + NL + "\t\tviewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate class ";
70
  protected final String TEXT_51 = ") {" + NL + "\t\t\treturn URI.createFileURI(((IPathEditorInput)input).getPath().toOSString());" + NL + "\t\t}";
71
  protected final String TEXT_52 = "ContextMenuProvider extends ContextMenuProvider {" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic ";
71
  protected final String TEXT_52 = NL + "\t\tif (input instanceof ";
72
  protected final String TEXT_53 = "ContextMenuProvider(EditPartViewer viewer) {" + NL + "\t\t\tsuper(viewer);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t    public void buildContextMenu(IMenuManager menuManager) {" + NL + "\t        GEFActionConstants.addStandardActionGroups(menuManager);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.UNDO.getId(), GEFActionConstants.GROUP_UNDO);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.REDO.getId(), GEFActionConstants.GROUP_UNDO);" + NL + "\t" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.COPY.getId(), GEFActionConstants.GROUP_EDIT);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.PASTE.getId(), GEFActionConstants.GROUP_EDIT);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.DELETE.getId(), GEFActionConstants.GROUP_EDIT);" + NL + "\t\t\tappendActionToMenu(menuManager, GEFActionConstants.DIRECT_EDIT, GEFActionConstants.GROUP_EDIT);" + NL + "" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.SAVE.getId(), GEFActionConstants.GROUP_SAVE);" + NL + "" + NL + "\t\t\tappendAlignmentSubmenu(menuManager);" + NL + "\t    }" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate void appendAlignmentSubmenu(IMenuManager menuManager) {" + NL + "\t\t\t// Alignment Actions" + NL + "\t\t\tMenuManager submenu = new MenuManager(\"Align\");" + NL + "\t\t\tsubmenu.add(new Separator(GEFActionConstants.MB_ADDITIONS));" + NL + "\t" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_LEFT, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_CENTER, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_RIGHT, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_TOP, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_MIDDLE, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_BOTTOM, GEFActionConstants.MB_ADDITIONS);" + NL + "\t" + NL + "\t\t\tif (!submenu.isEmpty()) {" + NL + "\t\t\t\tmenuManager.appendToGroup(GEFActionConstants.GROUP_REST, submenu);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate void appendActionToMenu(IMenuManager menu, String actionId, String menuGroup) {" + NL + "\t\t\tIAction action = getActionRegistry().getAction(actionId);" + NL + "\t\t\tif (action != null && action.isEnabled()) {" + NL + "\t\t\t\tmenu.appendToGroup(menuGroup, action);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "}";
72
  protected final String TEXT_53 = ") {" + NL + "\t\t\treturn URI.createPlatformResourceURI(((IFileEditorInput)input).getFile().getFullPath().toString());" + NL + "\t\t}";
73
  protected final String TEXT_54 = NL;
73
  protected final String TEXT_54 = NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean isDirty() {" + NL + "\t\treturn isDirty;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void setDirty(boolean dirty) {" + NL + "\t\tif (isDirty != dirty) {" + NL + "\t\t\tisDirty = dirty;" + NL + "\t\t\tfirePropertyChange(IEditorPart.PROP_DIRTY);" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected EditingDomain getEditingDomain() {" + NL + "\t\tif (editingDomain == null) {" + NL + "\t\t\tBasicCommandStack commandStack = new BasicCommandStack();" + NL + "\t\t\teditingDomain = new AdapterFactoryEditingDomain(getDomainAdapterFactory(), commandStack, new HashMap());" + NL + "\t\t\teditingDomain.getResourceSet().eAdapters().add(new AdapterFactoryEditingDomain.EditingDomainProvider(editingDomain));" + NL + "\t\t}" + NL + "\t\treturn editingDomain;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate AdapterFactory getDomainAdapterFactory() {" + NL + "\t\tif (domainAdapterFactory == null) {" + NL + "\t\t\tList factories = new ArrayList();" + NL + "\t\t\tfactories.add(new ResourceItemProviderAdapterFactory());";
74
  protected final String TEXT_55 = NL + "\t\t\tfactories.add(new ";
75
  protected final String TEXT_56 = "());";
76
  protected final String TEXT_57 = NL + "\t\t\tfactories.add(new ReflectiveItemProviderAdapterFactory());" + NL + "\t\t\tfactories.add(new NotationItemProviderAdapterFactory());" + NL + "\t\t\tdomainAdapterFactory = new ComposedAdapterFactory(factories);" + NL + "\t\t}" + NL + "\t\treturn domainAdapterFactory;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void load(URI diagramFile) {" + NL + "\t\t";
77
  protected final String TEXT_58 = " = null;" + NL + "\t\tdiagram = null;" + NL + "\t\tif (diagramFile == null) {" + NL + "\t\t\treturn;" + NL + "\t\t}" + NL + "\t\tEditingDomain editingDomain = getEditingDomain();" + NL + "\t\tResourceSet resourceSet = editingDomain.getResourceSet();" + NL + "\t\tResource diagramResource = resourceSet.getResource(diagramFile, true);" + NL + "\t\tif (diagramResource == null) {" + NL + "\t\t\tdiagramResource = resourceSet.createResource(diagramFile);" + NL + "\t\t}" + NL + "\t\tdiagram = (Diagram) findInResource(diagramResource, Diagram.class);" + NL + "\t\tif (diagram == null) {" + NL + "\t\t\tdiagram = NotationFactory.eINSTANCE.createDiagram();" + NL + "\t\t\tdiagramResource.getContents().add(0, diagram);" + NL + "\t\t\t//Auxiliary creation should not be undoable." + NL + "\t\t\ttry {" + NL + "\t\t\t\tdiagramResource.save(Collections.EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\tdiagram = null;" + NL + "\t\t\t\t";
78
  protected final String TEXT_59 = " = null;" + NL + "\t\t\t\treturn;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\t";
79
  protected final String TEXT_60 = " = (";
80
  protected final String TEXT_61 = ") diagram.getElement();" + NL + "\t\tif (";
81
  protected final String TEXT_62 = " == null) {";
82
  protected final String TEXT_63 = NL + "\t\t\tURI modelFile = ";
83
  protected final String TEXT_64 = ".getModelFileURI(diagramFile);" + NL + "\t\t\tResource modelResource = resourceSet.getResource(modelFile, true);" + NL + "\t\t\tif (modelResource == null) {" + NL + "\t\t\t\tmodelResource = resourceSet.createResource(modelFile);" + NL + "\t\t\t}";
84
  protected final String TEXT_65 = NL + "\t\t\t";
85
  protected final String TEXT_66 = " = (";
86
  protected final String TEXT_67 = ") findInResource(";
87
  protected final String TEXT_68 = ", ";
88
  protected final String TEXT_69 = ".class);" + NL + "\t\t\tif (";
89
  protected final String TEXT_70 = " == null) {" + NL + "\t\t\t\t";
90
  protected final String TEXT_71 = " = ";
91
  protected final String TEXT_72 = ".eINSTANCE.create";
92
  protected final String TEXT_73 = "();" + NL + "\t\t\t\t";
93
  protected final String TEXT_74 = ".getContents().add(0, ";
94
  protected final String TEXT_75 = ");" + NL + "\t\t\t\t//We don't want this auxiliary creation to be undoable." + NL + "\t\t\t\ttry {" + NL + "\t\t\t\t\t";
95
  protected final String TEXT_76 = ".save(Collections.EMPTY_MAP);" + NL + "\t\t\t\t} catch (IOException e) {" + NL + "\t\t\t\t\tdiagram = null;" + NL + "\t\t\t\t\t";
96
  protected final String TEXT_77 = " = null;" + NL + "\t\t\t\t\treturn;" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t\tif (!diagram.isSetElement()) {" + NL + "\t\t\t\tdiagram.setElement(";
97
  protected final String TEXT_78 = ");" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}";
98
  protected final String TEXT_79 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Object findInResource(Resource resource, Class expectedClass) {" + NL + "\t\tfor(Iterator it = resource.getContents().iterator(); it.hasNext(); ) {" + NL + "\t\t\tObject next = it.next();" + NL + "\t\t\tif (expectedClass.isInstance(next)) {" + NL + "\t\t\t\treturn next;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void setFocus() {" + NL + "\t\tgetGraphicalViewer().getControl().setFocus();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic final void createPartControl(Composite parent) {" + NL + "\t\tsuper.createPartControl(parent);" + NL + "\t\t// initialize actions" + NL + "\t\tcreateActions();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void createGraphicalViewer(Composite parent) {" + NL + "\t\tsuper.createGraphicalViewer(parent);" + NL + "\t\t// initialize the viewer with input" + NL + "\t\tScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart();" + NL + "\t\tgetGraphicalViewer().setRootEditPart(root);" + NL + "\t\tgetGraphicalViewer().setEditPartFactory(new ";
99
  protected final String TEXT_80 = "());" + NL + "\t\tgetGraphicalViewer().setContents(getDiagram());" + NL + "" + NL + "\t\t";
100
  protected final String TEXT_81 = " printableLayers = (";
101
  protected final String TEXT_82 = ") root.getLayer(";
102
  protected final String TEXT_83 = ".PRINTABLE_LAYERS);" + NL + "\t\t";
103
  protected final String TEXT_84 = " extLabelsLayer = new ";
104
  protected final String TEXT_85 = "();" + NL + "\t\textLabelsLayer.setLayoutManager(new ";
105
  protected final String TEXT_86 = "());" + NL + "\t\tprintableLayers.addLayerAfter(extLabelsLayer, ";
106
  protected final String TEXT_87 = ".EXTERNAL_NODE_LABELS_LAYER, ";
107
  protected final String TEXT_88 = ".PRIMARY_LAYER);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void configureGraphicalViewer() {" + NL + "\t\tsuper.configureGraphicalViewer();" + NL + "\t\tGraphicalViewer viewer = getGraphicalViewer();" + NL + "\t\t// configure the context menu" + NL + "\t\tContextMenuProvider provider = new ";
108
  protected final String TEXT_89 = "ContextMenuProvider(viewer);" + NL + "\t\tviewer.setContextMenu(provider);" + NL + "\t\tgetSite().registerContextMenu(";
109
  protected final String TEXT_90 = ".ID + \".editor.contextmenu\", provider, getSite().getSelectionProvider()); //$NON-NLS-1$" + NL + "" + NL + "\t\tKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);" + NL + "\t\tkeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));" + NL + "\t\tkeyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));" + NL + "\t\tviewer.setKeyHandler(keyHandler);" + NL + "" + NL + "\t\tviewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate class ";
110
  protected final String TEXT_91 = "ContextMenuProvider extends ContextMenuProvider {" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic ";
111
  protected final String TEXT_92 = "ContextMenuProvider(EditPartViewer viewer) {" + NL + "\t\t\tsuper(viewer);" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t    public void buildContextMenu(IMenuManager menuManager) {" + NL + "\t        GEFActionConstants.addStandardActionGroups(menuManager);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.UNDO.getId(), GEFActionConstants.GROUP_UNDO);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.REDO.getId(), GEFActionConstants.GROUP_UNDO);" + NL + "\t" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.COPY.getId(), GEFActionConstants.GROUP_EDIT);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.PASTE.getId(), GEFActionConstants.GROUP_EDIT);" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.DELETE.getId(), GEFActionConstants.GROUP_EDIT);" + NL + "\t\t\tappendActionToMenu(menuManager, GEFActionConstants.DIRECT_EDIT, GEFActionConstants.GROUP_EDIT);" + NL + "" + NL + "\t\t\tappendActionToMenu(menuManager, ActionFactory.SAVE.getId(), GEFActionConstants.GROUP_SAVE);" + NL + "" + NL + "\t\t\tappendAlignmentSubmenu(menuManager);" + NL + "\t    }" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate void appendAlignmentSubmenu(IMenuManager menuManager) {" + NL + "\t\t\t// Alignment Actions" + NL + "\t\t\tMenuManager submenu = new MenuManager(\"Align\");" + NL + "\t\t\tsubmenu.add(new Separator(GEFActionConstants.MB_ADDITIONS));" + NL + "\t" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_LEFT, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_CENTER, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_RIGHT, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_TOP, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_MIDDLE, GEFActionConstants.MB_ADDITIONS);" + NL + "\t\t\tappendActionToMenu(submenu, GEFActionConstants.ALIGN_BOTTOM, GEFActionConstants.MB_ADDITIONS);" + NL + "\t" + NL + "\t\t\tif (!submenu.isEmpty()) {" + NL + "\t\t\t\tmenuManager.appendToGroup(GEFActionConstants.GROUP_REST, submenu);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "" + NL + "\t\t/**" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tprivate void appendActionToMenu(IMenuManager menu, String actionId, String menuGroup) {" + NL + "\t\t\tIAction action = getActionRegistry().getAction(actionId);" + NL + "\t\t\tif (action != null && action.isEnabled()) {" + NL + "\t\t\t\tmenu.appendToGroup(menuGroup, action);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "}";
112
  protected final String TEXT_93 = NL;
74
113
75
  public String generate(Object argument)
114
  public String generate(Object argument)
76
  {
115
  {
Lines 79-84 Link Here
79
final GenEditorView genEditor = (GenEditorView) ((Object[]) argument)[0];
118
final GenEditorView genEditor = (GenEditorView) ((Object[]) argument)[0];
80
final GenDiagram genDiagram = genEditor.getEditorGen().getDiagram();
119
final GenDiagram genDiagram = genEditor.getEditorGen().getDiagram();
81
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
120
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
121
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
82
122
83
importManager.emitPackageStatement(stringBuffer);
123
importManager.emitPackageStatement(stringBuffer);
84
importManager.markImportLocation(stringBuffer);
124
importManager.markImportLocation(stringBuffer);
Lines 99-105 Link Here
99
importManager.addImport("org.eclipse.core.runtime.Status");
139
importManager.addImport("org.eclipse.core.runtime.Status");
100
importManager.addImport("org.eclipse.draw2d.PositionConstants");
140
importManager.addImport("org.eclipse.draw2d.PositionConstants");
101
importManager.addImport("org.eclipse.emf.common.command.BasicCommandStack");
141
importManager.addImport("org.eclipse.emf.common.command.BasicCommandStack");
102
importManager.addImport("org.eclipse.emf.common.ui.URIEditorInput");
103
importManager.addImport("org.eclipse.emf.common.util.URI");
142
importManager.addImport("org.eclipse.emf.common.util.URI");
104
importManager.addImport("org.eclipse.emf.ecore.resource.Resource");
143
importManager.addImport("org.eclipse.emf.ecore.resource.Resource");
105
importManager.addImport("org.eclipse.emf.ecore.resource.ResourceSet");
144
importManager.addImport("org.eclipse.emf.ecore.resource.ResourceSet");
Lines 151-157 Link Here
151
importManager.addImport("org.eclipse.ui.IEditorPart");
190
importManager.addImport("org.eclipse.ui.IEditorPart");
152
importManager.addImport("org.eclipse.ui.IEditorInput");
191
importManager.addImport("org.eclipse.ui.IEditorInput");
153
importManager.addImport("org.eclipse.ui.IEditorSite");
192
importManager.addImport("org.eclipse.ui.IEditorSite");
154
importManager.addImport("org.eclipse.ui.IPathEditorInput");
155
importManager.addImport("org.eclipse.ui.ISelectionListener");
193
importManager.addImport("org.eclipse.ui.ISelectionListener");
156
importManager.addImport("org.eclipse.ui.IWorkbenchPart");
194
importManager.addImport("org.eclipse.ui.IWorkbenchPart");
157
importManager.addImport("org.eclipse.ui.PartInitException");
195
importManager.addImport("org.eclipse.ui.PartInitException");
Lines 166-222 Link Here
166
    stringBuffer.append(TEXT_2);
204
    stringBuffer.append(TEXT_2);
167
    stringBuffer.append(genEditor.getClassName());
205
    stringBuffer.append(genEditor.getClassName());
168
    stringBuffer.append(TEXT_3);
206
    stringBuffer.append(TEXT_3);
169
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
207
    
208
if (!isRichClientPlatform) {
209
170
    stringBuffer.append(TEXT_4);
210
    stringBuffer.append(TEXT_4);
171
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
211
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceChangeListener"));
172
    stringBuffer.append(TEXT_5);
212
    stringBuffer.append(TEXT_5);
173
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Diagram"));
213
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceChangeEvent"));
174
    stringBuffer.append(TEXT_6);
214
    stringBuffer.append(TEXT_6);
175
    stringBuffer.append(genDiagram.getEditorGen().getDomainGenModel().getModelName());
215
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceDelta"));
176
    stringBuffer.append(TEXT_7);
216
    stringBuffer.append(TEXT_7);
177
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName()));
217
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceDelta"));
178
    stringBuffer.append(TEXT_8);
218
    stringBuffer.append(TEXT_8);
219
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
220
    stringBuffer.append(TEXT_9);
221
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceDelta"));
222
    stringBuffer.append(TEXT_10);
223
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
224
    stringBuffer.append(TEXT_11);
225
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceDelta"));
226
    stringBuffer.append(TEXT_12);
227
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IResourceDelta"));
228
    stringBuffer.append(TEXT_13);
229
    /*XXX: make sure unsaved deleted file is handled correctly*/
230
    stringBuffer.append(TEXT_14);
231
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IFile"));
232
    stringBuffer.append(TEXT_15);
233
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.ResourcesPlugin"));
234
    stringBuffer.append(TEXT_16);
235
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Display"));
236
    stringBuffer.append(TEXT_17);
237
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.part.FileEditorInput"));
238
    stringBuffer.append(TEXT_18);
239
    
240
}
241
242
    stringBuffer.append(TEXT_19);
243
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
244
    stringBuffer.append(TEXT_20);
245
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
246
    stringBuffer.append(TEXT_21);
247
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Diagram"));
248
    stringBuffer.append(TEXT_22);
249
    
250
if (!isRichClientPlatform) {
251
252
    stringBuffer.append(TEXT_23);
253
    stringBuffer.append(genEditor.getClassName());
254
    stringBuffer.append(TEXT_24);
255
    
256
}
257
258
    stringBuffer.append(TEXT_25);
259
    stringBuffer.append(genDiagram.getEditorGen().getDomainGenModel().getModelName());
260
    stringBuffer.append(TEXT_26);
261
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName()));
262
    stringBuffer.append(TEXT_27);
179
    
263
    
180
{
264
{
181
	final Palette palette = genDiagram.getPalette();
265
	final Palette palette = genDiagram.getPalette();
182
	if (palette != null) {
266
	if (palette != null) {
183
267
184
    stringBuffer.append(TEXT_9);
268
    stringBuffer.append(TEXT_28);
185
    stringBuffer.append(importManager.getImportedName(palette.getFactoryQualifiedClassName()));
269
    stringBuffer.append(importManager.getImportedName(palette.getFactoryQualifiedClassName()));
186
    stringBuffer.append(TEXT_10);
270
    stringBuffer.append(TEXT_29);
187
    
271
    
188
	}
272
	}
189
}
273
}
190
274
191
    stringBuffer.append(TEXT_11);
275
    stringBuffer.append(TEXT_30);
192
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.ui.properties.UndoablePropertySheetEntry"));
276
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.ui.properties.UndoablePropertySheetEntry"));
193
    stringBuffer.append(TEXT_12);
277
    stringBuffer.append(TEXT_31);
194
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.ui.properties.UndoablePropertySheetEntry"));
278
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.ui.properties.UndoablePropertySheetEntry"));
195
    stringBuffer.append(TEXT_13);
279
    stringBuffer.append(TEXT_32);
196
    stringBuffer.append(importManager.getImportedName(genDiagram.getPropertyProviderQualifiedClassName()));
280
    stringBuffer.append(importManager.getImportedName(genDiagram.getPropertyProviderQualifiedClassName()));
197
    stringBuffer.append(TEXT_14);
281
    stringBuffer.append(TEXT_33);
198
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
282
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
199
    stringBuffer.append(TEXT_15);
283
    stringBuffer.append(TEXT_34);
200
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
284
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
201
    stringBuffer.append(TEXT_16);
285
    stringBuffer.append(TEXT_35);
202
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
286
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
203
    stringBuffer.append(TEXT_17);
287
    stringBuffer.append(TEXT_36);
204
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
288
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
205
    stringBuffer.append(TEXT_18);
289
    stringBuffer.append(TEXT_37);
290
    
291
if (!isRichClientPlatform) {
292
293
    stringBuffer.append(TEXT_38);
294
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
295
    stringBuffer.append(TEXT_39);
296
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IFile"));
297
    stringBuffer.append(TEXT_40);
298
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
299
    stringBuffer.append(TEXT_41);
300
    
301
}
302
303
    stringBuffer.append(TEXT_42);
304
    
305
if (!isRichClientPlatform) {
306
307
    stringBuffer.append(TEXT_43);
308
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
309
    stringBuffer.append(TEXT_44);
310
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IFile"));
311
    stringBuffer.append(TEXT_45);
312
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
313
    stringBuffer.append(TEXT_46);
314
    
315
}
316
317
    stringBuffer.append(TEXT_47);
318
    if (isRichClientPlatform) {
319
    stringBuffer.append(TEXT_48);
320
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.ui.URIEditorInput"));
321
    stringBuffer.append(TEXT_49);
322
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.ui.URIEditorInput"));
323
    stringBuffer.append(TEXT_50);
324
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IPathEditorInput"));
325
    stringBuffer.append(TEXT_51);
326
    } else {
327
    stringBuffer.append(TEXT_52);
328
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.IFileEditorInput"));
329
    stringBuffer.append(TEXT_53);
330
    }
331
    stringBuffer.append(TEXT_54);
206
    
332
    
207
final EList genPackages = genDiagram.getEditorGen().getAllDomainGenPackages(true);
333
final EList genPackages = genDiagram.getEditorGen().getAllDomainGenPackages(true);
208
for (int i = 0; i < genPackages.size(); i++) {
334
for (int i = 0; i < genPackages.size(); i++) {
209
	GenPackage genPackage = (GenPackage) genPackages.get(i);
335
	GenPackage genPackage = (GenPackage) genPackages.get(i);
210
336
211
    stringBuffer.append(TEXT_19);
337
    stringBuffer.append(TEXT_55);
212
    stringBuffer.append(importManager.getImportedName(genPackage.getQualifiedItemProviderAdapterFactoryClassName()));
338
    stringBuffer.append(importManager.getImportedName(genPackage.getQualifiedItemProviderAdapterFactoryClassName()));
213
    stringBuffer.append(TEXT_20);
339
    stringBuffer.append(TEXT_56);
214
    }
340
    }
215
    stringBuffer.append(TEXT_21);
341
    stringBuffer.append(TEXT_57);
216
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
342
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
217
    stringBuffer.append(TEXT_22);
343
    stringBuffer.append(TEXT_58);
218
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
344
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
219
    stringBuffer.append(TEXT_23);
345
    stringBuffer.append(TEXT_59);
346
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
347
    stringBuffer.append(TEXT_60);
348
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
349
    stringBuffer.append(TEXT_61);
350
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
351
    stringBuffer.append(TEXT_62);
220
    
352
    
221
{
353
{
222
354
Lines 225-298 Link Here
225
	String resourceToUse;
357
	String resourceToUse;
226
	if (!sameFile) {
358
	if (!sameFile) {
227
359
228
    stringBuffer.append(TEXT_24);
360
    stringBuffer.append(TEXT_63);
229
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
361
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
230
    stringBuffer.append(TEXT_25);
362
    stringBuffer.append(TEXT_64);
231
    
363
    
232
		resourceToUse = "modelResource";
364
		resourceToUse = "modelResource";
233
	} else {
365
	} else {
234
		resourceToUse = "diagramResource";
366
		resourceToUse = "diagramResource";
235
	}
367
	}
236
368
237
    stringBuffer.append(TEXT_26);
369
    stringBuffer.append(TEXT_65);
238
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
370
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
239
    stringBuffer.append(TEXT_27);
371
    stringBuffer.append(TEXT_66);
240
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
372
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
241
    stringBuffer.append(TEXT_28);
373
    stringBuffer.append(TEXT_67);
242
    stringBuffer.append(resourceToUse);
374
    stringBuffer.append(resourceToUse);
243
    stringBuffer.append(TEXT_29);
375
    stringBuffer.append(TEXT_68);
244
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
376
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
245
    stringBuffer.append(TEXT_30);
377
    stringBuffer.append(TEXT_69);
246
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
378
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
247
    stringBuffer.append(TEXT_31);
379
    stringBuffer.append(TEXT_70);
248
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
380
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
249
    stringBuffer.append(TEXT_32);
381
    stringBuffer.append(TEXT_71);
250
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getGenPackage().getQualifiedFactoryClassName()));
382
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getGenPackage().getQualifiedFactoryClassName()));
251
    stringBuffer.append(TEXT_33);
383
    stringBuffer.append(TEXT_72);
252
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
384
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
253
    stringBuffer.append(TEXT_34);
385
    stringBuffer.append(TEXT_73);
254
    stringBuffer.append(resourceToUse);
386
    stringBuffer.append(resourceToUse);
255
    stringBuffer.append(TEXT_35);
387
    stringBuffer.append(TEXT_74);
256
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
388
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
257
    stringBuffer.append(TEXT_36);
389
    stringBuffer.append(TEXT_75);
258
    stringBuffer.append(resourceToUse);
390
    stringBuffer.append(resourceToUse);
259
    stringBuffer.append(TEXT_37);
391
    stringBuffer.append(TEXT_76);
260
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
392
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
261
    stringBuffer.append(TEXT_38);
393
    stringBuffer.append(TEXT_77);
262
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
394
    stringBuffer.append(genDiagram.getDomainDiagramElement().getSafeUncapName());
263
    stringBuffer.append(TEXT_39);
395
    stringBuffer.append(TEXT_78);
264
    
396
    
265
}
397
}
266
398
267
    stringBuffer.append(TEXT_40);
399
    stringBuffer.append(TEXT_79);
268
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartFactoryQualifiedClassName()));
400
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartFactoryQualifiedClassName()));
269
    stringBuffer.append(TEXT_41);
401
    stringBuffer.append(TEXT_80);
270
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.LayeredPane"));
402
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.LayeredPane"));
271
    stringBuffer.append(TEXT_42);
403
    stringBuffer.append(TEXT_81);
272
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.LayeredPane"));
404
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.LayeredPane"));
273
    stringBuffer.append(TEXT_43);
405
    stringBuffer.append(TEXT_82);
274
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.LayerConstants"));
406
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.LayerConstants"));
275
    stringBuffer.append(TEXT_44);
407
    stringBuffer.append(TEXT_83);
276
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.FreeformLayer"));
408
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.FreeformLayer"));
277
    stringBuffer.append(TEXT_45);
409
    stringBuffer.append(TEXT_84);
278
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.FreeformLayer"));
410
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.FreeformLayer"));
279
    stringBuffer.append(TEXT_46);
411
    stringBuffer.append(TEXT_85);
280
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.DelegatingLayout"));
412
    stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.DelegatingLayout"));
281
    stringBuffer.append(TEXT_47);
413
    stringBuffer.append(TEXT_86);
282
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartFactoryQualifiedClassName()));
414
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditPartFactoryQualifiedClassName()));
283
    stringBuffer.append(TEXT_48);
415
    stringBuffer.append(TEXT_87);
284
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.LayerConstants"));
416
    stringBuffer.append(importManager.getImportedName("org.eclipse.gef.LayerConstants"));
285
    stringBuffer.append(TEXT_49);
417
    stringBuffer.append(TEXT_88);
286
    stringBuffer.append(genEditor.getClassName());
418
    stringBuffer.append(genEditor.getClassName());
287
    stringBuffer.append(TEXT_50);
419
    stringBuffer.append(TEXT_89);
288
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName()));
420
    stringBuffer.append(importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName()));
289
    stringBuffer.append(TEXT_51);
421
    stringBuffer.append(TEXT_90);
290
    stringBuffer.append(genEditor.getClassName());
422
    stringBuffer.append(genEditor.getClassName());
291
    stringBuffer.append(TEXT_52);
423
    stringBuffer.append(TEXT_91);
292
    stringBuffer.append(genEditor.getClassName());
424
    stringBuffer.append(genEditor.getClassName());
293
    stringBuffer.append(TEXT_53);
425
    stringBuffer.append(TEXT_92);
294
    importManager.emitSortedImports();
426
    importManager.emitSortedImports();
295
    stringBuffer.append(TEXT_54);
427
    stringBuffer.append(TEXT_93);
296
    return stringBuffer.toString();
428
    return stringBuffer.toString();
297
  }
429
  }
298
}
430
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/PluginXML.java (-12 / +108 lines)
Lines 22-34 Link Here
22
  protected final String TEXT_5 = "\"" + NL + "        extensions=\"";
22
  protected final String TEXT_5 = "\"" + NL + "        extensions=\"";
23
  protected final String TEXT_6 = "\"" + NL + "        default=\"true\"" + NL + "        class=\"";
23
  protected final String TEXT_6 = "\"" + NL + "        default=\"true\"" + NL + "        class=\"";
24
  protected final String TEXT_7 = "\"" + NL + "        contributorClass=\"";
24
  protected final String TEXT_7 = "\"" + NL + "        contributorClass=\"";
25
  protected final String TEXT_8 = "\">" + NL + "     </editor>" + NL + "   </extension>" + NL + "" + NL + "   <extension point=\"org.eclipse.ui.newWizards\">" + NL + "  \t  <wizard" + NL + "  \t     name=\"";
25
  protected final String TEXT_8 = "\">" + NL + "     </editor>" + NL + "   </extension>" + NL;
26
  protected final String TEXT_9 = " Diagram\"" + NL + "  \t     icon=\"";
26
  protected final String TEXT_9 = NL + "  <extension" + NL + "    point=\"org.eclipse.core.runtime.applications\"" + NL + "    id=\"";
27
  protected final String TEXT_10 = "\"" + NL + "  \t     category=\"org.eclipse.ui.Examples\"" + NL + "  \t     class=\"";
27
  protected final String TEXT_10 = "DiagramApplication\">" + NL + "    <application>" + NL + "      <run" + NL + "        class=\"";
28
  protected final String TEXT_11 = "\"" + NL + "  \t     id=\"";
28
  protected final String TEXT_11 = "$Application\">" + NL + "      </run>" + NL + "    </application>" + NL + "  </extension>" + NL + "" + NL + "   <extension" + NL + "    point=\"org.eclipse.ui.perspectives\">" + NL + "    <perspective" + NL + "      name=\"%_UI_Perspective_label\"" + NL + "      class=\"";
29
  protected final String TEXT_12 = "ID\">" + NL + "  \t  \t <description>" + NL + "  \t  \t\tCreates ";
29
  protected final String TEXT_12 = "$Perspective\"" + NL + "      id=\"";
30
  protected final String TEXT_13 = " diagram." + NL + "  \t  \t </description>  " + NL + "      </wizard>" + NL + "   </extension>" + NL + "" + NL + "</plugin>";
30
  protected final String TEXT_13 = ".Perspective\">" + NL + "    </perspective>" + NL + "  </extension>";
31
  protected final String TEXT_14 = NL;
31
  protected final String TEXT_14 = NL + "  <extension" + NL + "    point=\"org.eclipse.ui.commands\">" + NL + "    <command" + NL + "      name=\"%_UI_Menu_OpenURI_label\"" + NL + "      description=\"%_UI_Menu_OpenURI_description\"" + NL + "      categoryId=\"org.eclipse.ui.category.file\"" + NL + "      id=\"";
32
  protected final String TEXT_15 = "OpenURICommand\" />  " + NL + "    <command" + NL + "      name=\"%_UI_Menu_Open_label\"" + NL + "      description=\"%_UI_Menu_Open_description\"" + NL + "      categoryId=\"org.eclipse.ui.category.file\"" + NL + "      id=\"";
33
  protected final String TEXT_16 = "OpenCommand\" />  " + NL + "  </extension> " + NL + "" + NL + "  <extension" + NL + "    point=\"org.eclipse.ui.bindings\">" + NL + "    <key" + NL + "      commandId=\"";
34
  protected final String TEXT_17 = "OpenURICommand\"" + NL + "      sequence=\"M1+U\"" + NL + "      schemeId=\"org.eclipse.ui.defaultAcceleratorConfiguration\" />" + NL + "    <key" + NL + "      commandId=\"";
35
  protected final String TEXT_18 = "OpenCommand\"" + NL + "      sequence=\"M1+O\"" + NL + "      schemeId=\"org.eclipse.ui.defaultAcceleratorConfiguration\" />" + NL + "  </extension>" + NL + "  <extension" + NL + "    point=\"org.eclipse.ui.actionSets\">" + NL + "    <actionSet" + NL + "      label=\"%_UI_";
36
  protected final String TEXT_19 = "_ActionSet_label\"" + NL + "      visible=\"true\"" + NL + "      id=\"";
37
  protected final String TEXT_20 = "ActionSet\">";
38
  protected final String TEXT_21 = NL + "      <action" + NL + "        label=\"%_UI_Menu_About_label\"" + NL + "        class=\"";
39
  protected final String TEXT_22 = "$AboutAction\"" + NL + "        menubarPath=\"help/additions\"" + NL + "        id=\"";
40
  protected final String TEXT_23 = "AboutAction\">" + NL + "      </action>";
41
  protected final String TEXT_24 = NL + "      <action" + NL + "        label=\"%_UI_Menu_OpenURI_label\"" + NL + "        definitionId=\"";
42
  protected final String TEXT_25 = "OpenURICommand\"" + NL + "        class=\"";
43
  protected final String TEXT_26 = "$OpenURIAction\"" + NL + "        menubarPath=\"file/additions\"" + NL + "        id=\"";
44
  protected final String TEXT_27 = "OpenURIAction\">" + NL + "      </action>" + NL + "      <action" + NL + "        label=\"%_UI_Menu_Open_label\"" + NL + "        definitionId=\"";
45
  protected final String TEXT_28 = "OpenCommand\"" + NL + "        class=\"";
46
  protected final String TEXT_29 = "$OpenDiagramAction\"" + NL + "        menubarPath=\"file/additions\"" + NL + "        id=\"";
47
  protected final String TEXT_30 = "OpenDiagramAction\">" + NL + "      </action>" + NL + "      <action" + NL + "        label=\"%_UI_";
48
  protected final String TEXT_31 = "NewDiagramCommand\"" + NL + "        class=\"";
49
  protected final String TEXT_32 = "$NewDiagramAction\"" + NL + "        menubarPath=\"file/new/additions\"" + NL + "        id=\"";
50
  protected final String TEXT_33 = "NewAction\">" + NL + "      </action>" + NL + "    </actionSet> " + NL + "  </extension>";
51
  protected final String TEXT_34 = NL + "   <extension point=\"org.eclipse.ui.newWizards\">" + NL + "  \t  <wizard" + NL + "  \t     name=\"";
52
  protected final String TEXT_35 = " Diagram\"" + NL + "  \t     icon=\"";
53
  protected final String TEXT_36 = "\"" + NL + "  \t     category=\"org.eclipse.ui.Examples\"" + NL + "  \t     class=\"";
54
  protected final String TEXT_37 = "\"" + NL + "  \t     id=\"";
55
  protected final String TEXT_38 = "ID\">" + NL + "  \t  \t <description>" + NL + "  \t  \t\tCreates ";
56
  protected final String TEXT_39 = " diagram." + NL + "  \t  \t </description>  " + NL + "      </wizard>" + NL + "   </extension>" + NL;
57
  protected final String TEXT_40 = NL + "</plugin>";
58
  protected final String TEXT_41 = NL;
32
59
33
  public String generate(Object argument)
60
  public String generate(Object argument)
34
  {
61
  {
Lines 38-43 Link Here
38
final GenEditorGenerator editorGen = genPlugin.getEditorGen();
65
final GenEditorGenerator editorGen = genPlugin.getEditorGen();
39
final GenDiagram genDiagram = editorGen.getDiagram();
66
final GenDiagram genDiagram = editorGen.getDiagram();
40
final GenModel genModel = editorGen.getDomainGenModel();
67
final GenModel genModel = editorGen.getDomainGenModel();
68
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
41
69
42
    stringBuffer.append(TEXT_1);
70
    stringBuffer.append(TEXT_1);
43
    stringBuffer.append(editorGen.getDiagramFileExtension());
71
    stringBuffer.append(editorGen.getDiagramFileExtension());
Lines 54-70 Link Here
54
    stringBuffer.append(TEXT_7);
82
    stringBuffer.append(TEXT_7);
55
    stringBuffer.append(editorGen.getEditor().getActionBarContributorQualifiedClassName());
83
    stringBuffer.append(editorGen.getEditor().getActionBarContributorQualifiedClassName());
56
    stringBuffer.append(TEXT_8);
84
    stringBuffer.append(TEXT_8);
57
    stringBuffer.append(genModel.getModelName());
85
    
86
if (isRichClientPlatform) {
87
	final boolean shouldGenerateApplication = true;	/*XXX: option in gmfgen*/
88
	if (shouldGenerateApplication) {
89
58
    stringBuffer.append(TEXT_9);
90
    stringBuffer.append(TEXT_9);
59
    stringBuffer.append(genDiagram.getCreationWizardIconPath());
91
    stringBuffer.append(genModel.getModelName());
60
    stringBuffer.append(TEXT_10);
92
    stringBuffer.append(TEXT_10);
61
    stringBuffer.append(genDiagram.getCreationWizardQualifiedClassName());
93
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
62
    stringBuffer.append(TEXT_11);
94
    stringBuffer.append(TEXT_11);
63
    stringBuffer.append(genDiagram.getCreationWizardQualifiedClassName());
95
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
64
    stringBuffer.append(TEXT_12);
96
    stringBuffer.append(TEXT_12);
65
    stringBuffer.append(genModel.getModelName());
97
    stringBuffer.append(genPlugin.getID());
66
    stringBuffer.append(TEXT_13);
98
    stringBuffer.append(TEXT_13);
99
    
100
	}
101
67
    stringBuffer.append(TEXT_14);
102
    stringBuffer.append(TEXT_14);
103
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
104
    stringBuffer.append(TEXT_15);
105
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
106
    stringBuffer.append(TEXT_16);
107
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
108
    stringBuffer.append(TEXT_17);
109
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
110
    stringBuffer.append(TEXT_18);
111
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
112
    stringBuffer.append(TEXT_19);
113
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
114
    stringBuffer.append(TEXT_20);
115
    
116
	if (shouldGenerateApplication) {
117
118
    stringBuffer.append(TEXT_21);
119
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
120
    stringBuffer.append(TEXT_22);
121
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
122
    stringBuffer.append(TEXT_23);
123
    
124
	}
125
126
    stringBuffer.append(TEXT_24);
127
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
128
    stringBuffer.append(TEXT_25);
129
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
130
    stringBuffer.append(TEXT_26);
131
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
132
    stringBuffer.append(TEXT_27);
133
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
134
    stringBuffer.append(TEXT_28);
135
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
136
    stringBuffer.append(TEXT_29);
137
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
138
    stringBuffer.append(TEXT_30);
139
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
140
    stringBuffer.append(TEXT_31);
141
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
142
    stringBuffer.append(TEXT_32);
143
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
144
    stringBuffer.append(TEXT_33);
145
    
146
} else {
147
148
    stringBuffer.append(TEXT_34);
149
    stringBuffer.append(genModel.getModelName());
150
    stringBuffer.append(TEXT_35);
151
    stringBuffer.append(genDiagram.getCreationWizardIconPath());
152
    stringBuffer.append(TEXT_36);
153
    stringBuffer.append(genDiagram.getCreationWizardQualifiedClassName());
154
    stringBuffer.append(TEXT_37);
155
    stringBuffer.append(genDiagram.getCreationWizardQualifiedClassName());
156
    stringBuffer.append(TEXT_38);
157
    stringBuffer.append(genModel.getModelName());
158
    stringBuffer.append(TEXT_39);
159
    
160
}
161
162
    stringBuffer.append(TEXT_40);
163
    stringBuffer.append(TEXT_41);
68
    return stringBuffer.toString();
164
    return stringBuffer.toString();
69
  }
165
  }
70
}
166
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/CreationWizardGenerator.java (-16 / +81 lines)
Lines 19-32 Link Here
19
  protected final String TEXT_1 = NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
19
  protected final String TEXT_1 = NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
20
  protected final String TEXT_2 = " extends ";
20
  protected final String TEXT_2 = " extends ";
21
  protected final String TEXT_3 = " implements ";
21
  protected final String TEXT_3 = " implements ";
22
  protected final String TEXT_4 = " {" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t private ";
22
  protected final String TEXT_4 = " {";
23
  protected final String TEXT_5 = " diagramFileURI;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t private ";
23
  protected final String TEXT_5 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t private ";
24
  protected final String TEXT_6 = " page;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void addPages() {" + NL + "\t\tsuper.addPages();" + NL + "\t\tif (page == null) {" + NL + "\t\t\tpage = new ";
24
  protected final String TEXT_6 = " diagramFileURI;";
25
  protected final String TEXT_7 = "();" + NL + "\t\t}" + NL + "\t\taddPage(page);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void init(IWorkbench workbench, IStructuredSelection selection) {" + NL + "\t\tsetWindowTitle(\"New ";
25
  protected final String TEXT_7 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t private ";
26
  protected final String TEXT_8 = " Diagram\"); //$NON-NLS-1$" + NL + "\t\tsetDefaultPageImageDescriptor(";
26
  protected final String TEXT_8 = " diagramFile;";
27
  protected final String TEXT_9 = ".getBundledImageDescriptor(" + NL + "\t\t\t\"icons/full/wizban/New";
27
  protected final String TEXT_9 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t private ";
28
  protected final String TEXT_10 = ".gif\")); //$NON-NLS-1$" + NL + "\t\tsetNeedsProgressMonitor(true);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean performFinish() {" + NL + "\t\tboolean retVal = page.finish();" + NL + "\t\tdiagramFileURI = page.getCreatedDiagramFileURI();" + NL + "\t\treturn retVal;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * returns the diagram file " + NL + "\t * @return URI the diagram file" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic final URI getDiagramFileURI() {" + NL + "\t\treturn diagramFileURI;" + NL + "\t}" + NL + "}";
28
  protected final String TEXT_10 = " page;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void addPages() {" + NL + "\t\tsuper.addPages();" + NL + "\t\tif (page == null) {" + NL + "\t\t\tpage = new ";
29
  protected final String TEXT_11 = NL;
29
  protected final String TEXT_11 = "(";
30
  protected final String TEXT_12 = "getSelection()";
31
  protected final String TEXT_13 = ");" + NL + "\t\t}" + NL + "\t\taddPage(page);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void init(IWorkbench workbench, IStructuredSelection selection) {";
32
  protected final String TEXT_14 = NL + "\t\tsuper.init(workbench, selection);";
33
  protected final String TEXT_15 = NL + "\t\tsetWindowTitle(\"New ";
34
  protected final String TEXT_16 = " Diagram\"); //$NON-NLS-1$" + NL + "\t\tsetDefaultPageImageDescriptor(";
35
  protected final String TEXT_17 = ".getBundledImageDescriptor(" + NL + "\t\t\t\"icons/full/wizban/New";
36
  protected final String TEXT_18 = ".gif\")); //$NON-NLS-1$" + NL + "\t\tsetNeedsProgressMonitor(true);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean performFinish() {" + NL + "\t\tboolean retVal = page.finish();";
37
  protected final String TEXT_19 = NL + "\t\tdiagramFileURI = page.getCreatedDiagramFileURI();";
38
  protected final String TEXT_20 = NL + "\t\tdiagramFile = page.getCreatedDiagramFile();";
39
  protected final String TEXT_21 = NL + "\t\treturn retVal;" + NL + "\t}" + NL;
40
  protected final String TEXT_22 = NL + "\t/**" + NL + "\t * returns the diagram file " + NL + "\t * @return URI the diagram file" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic final URI getDiagramFileURI() {" + NL + "\t\treturn diagramFileURI;" + NL + "\t}";
41
  protected final String TEXT_23 = NL + "\t/**" + NL + "\t * returns the diagram file " + NL + "\t * @return IFile the diagram file" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic final IFile getDiagramFile() {" + NL + "\t\treturn diagramFile;" + NL + "\t}";
42
  protected final String TEXT_24 = NL + "}";
43
  protected final String TEXT_25 = NL;
30
44
31
  public String generate(Object argument)
45
  public String generate(Object argument)
32
  {
46
  {
Lines 35-40 Link Here
35
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
49
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
36
final GenModel genModel = genDiagram.getEditorGen().getDomainGenModel();
50
final GenModel genModel = genDiagram.getEditorGen().getDomainGenModel();
37
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
51
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
52
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
38
53
39
importManager.emitPackageStatement(stringBuffer);
54
importManager.emitPackageStatement(stringBuffer);
40
importManager.markImportLocation(stringBuffer);
55
importManager.markImportLocation(stringBuffer);
Lines 45-68 Link Here
45
    stringBuffer.append(TEXT_1);
60
    stringBuffer.append(TEXT_1);
46
    stringBuffer.append(genDiagram.getCreationWizardClassName());
61
    stringBuffer.append(genDiagram.getCreationWizardClassName());
47
    stringBuffer.append(TEXT_2);
62
    stringBuffer.append(TEXT_2);
48
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.wizard.Wizard"));
63
    stringBuffer.append(importManager.getImportedName(isRichClientPlatform ? "org.eclipse.jface.wizard.Wizard" : "org.eclipse.ui.wizards.newresource.BasicNewResourceWizard"));
49
    stringBuffer.append(TEXT_3);
64
    stringBuffer.append(TEXT_3);
50
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.INewWizard"));
65
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.INewWizard"));
51
    stringBuffer.append(TEXT_4);
66
    stringBuffer.append(TEXT_4);
52
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.util.URI"));
67
    
68
if (isRichClientPlatform) {
69
53
    stringBuffer.append(TEXT_5);
70
    stringBuffer.append(TEXT_5);
54
    stringBuffer.append(importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName()));
71
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.common.util.URI"));
55
    stringBuffer.append(TEXT_6);
72
    stringBuffer.append(TEXT_6);
56
    stringBuffer.append(importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName()));
73
    
74
} else {
75
57
    stringBuffer.append(TEXT_7);
76
    stringBuffer.append(TEXT_7);
58
    stringBuffer.append(genModel.getModelName());
77
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IFile"));
59
    stringBuffer.append(TEXT_8);
78
    stringBuffer.append(TEXT_8);
60
    stringBuffer.append(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName());
79
    
80
}
81
61
    stringBuffer.append(TEXT_9);
82
    stringBuffer.append(TEXT_9);
62
    stringBuffer.append(genModel.getModelName());
83
    stringBuffer.append(importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName()));
63
    stringBuffer.append(TEXT_10);
84
    stringBuffer.append(TEXT_10);
64
    importManager.emitSortedImports();
85
    stringBuffer.append(importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName()));
65
    stringBuffer.append(TEXT_11);
86
    stringBuffer.append(TEXT_11);
87
    if(!isRichClientPlatform) {
88
    stringBuffer.append(TEXT_12);
89
    }
90
    stringBuffer.append(TEXT_13);
91
    
92
if (!isRichClientPlatform) {
93
94
    stringBuffer.append(TEXT_14);
95
    
96
}
97
98
    stringBuffer.append(TEXT_15);
99
    stringBuffer.append(genModel.getModelName());
100
    stringBuffer.append(TEXT_16);
101
    stringBuffer.append(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName());
102
    stringBuffer.append(TEXT_17);
103
    stringBuffer.append(genModel.getModelName());
104
    stringBuffer.append(TEXT_18);
105
    
106
if (isRichClientPlatform) {
107
108
    stringBuffer.append(TEXT_19);
109
    
110
} else {
111
112
    stringBuffer.append(TEXT_20);
113
    
114
}
115
116
    stringBuffer.append(TEXT_21);
117
    
118
if (isRichClientPlatform) {
119
120
    stringBuffer.append(TEXT_22);
121
    
122
} else {
123
124
    stringBuffer.append(TEXT_23);
125
    
126
}
127
128
    stringBuffer.append(TEXT_24);
129
    importManager.emitSortedImports();
130
    stringBuffer.append(TEXT_25);
66
    return stringBuffer.toString();
131
    return stringBuffer.toString();
67
  }
132
  }
68
}
133
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/CreationWizardPageGenerator.java (-91 / +320 lines)
Lines 17-66 Link Here
17
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
17
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18
  protected final String TEXT_1 = NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
18
  protected final String TEXT_1 = NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
19
  protected final String TEXT_2 = " extends ";
19
  protected final String TEXT_2 = " extends ";
20
  protected final String TEXT_3 = " {" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Text fileField;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI createdDiagramFileURI;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
20
  protected final String TEXT_3 = " {";
21
  protected final String TEXT_4 = "() {" + NL + "\t\tsuper(\"CreationWizardPage\"); //$NON-NLS-1$" + NL + "\t\tsetTitle(\"Create ";
21
  protected final String TEXT_4 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate Text fileField;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI createdDiagramFileURI;";
22
  protected final String TEXT_5 = " Diagram\"); //$NON-NLS-1$" + NL + "\t\tsetDescription(\"Create a new ";
22
  protected final String TEXT_5 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
23
  protected final String TEXT_6 = " diagram.\"); //$NON-NLS-1$" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void createControl(Composite parent)" + NL + "\t{" + NL + "\t\tComposite composite = new Composite(parent, SWT.NONE);" + NL + "\t\t{" + NL + "\t\t\tGridLayout layout = new GridLayout();" + NL + "\t\t\tlayout.numColumns = 1;" + NL + "\t\t\tlayout.verticalSpacing = 12;" + NL + "\t\t\tcomposite.setLayout(layout);" + NL + "" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.verticalAlignment = GridData.FILL;" + NL + "\t\t\tdata.grabExcessVerticalSpace = true;" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tcomposite.setLayoutData(data);" + NL + "\t\t}" + NL + "\t\tLabel resourceURILabel = new Label(composite, SWT.LEFT);" + NL + "\t\t{" + NL + "\t\t\tresourceURILabel.setText(\"&File\");" + NL + "" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tresourceURILabel.setLayoutData(data);" + NL + "\t\t}" + NL + "" + NL + "\t\tComposite fileComposite = new Composite(composite, SWT.NONE);" + NL + "\t\t{" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tdata.grabExcessHorizontalSpace = true;" + NL + "\t\t\tfileComposite.setLayoutData(data);" + NL + "" + NL + "\t\t\tGridLayout layout = new GridLayout();" + NL + "\t\t\tlayout.marginHeight = 0;" + NL + "\t\t\tlayout.marginWidth = 0;" + NL + "\t\t\tlayout.numColumns = 2;" + NL + "\t\t\tfileComposite.setLayout(layout);" + NL + "\t\t}" + NL + "" + NL + "\t\tfileField = new ";
23
  protected final String TEXT_6 = " createdDiagramFile;";
24
  protected final String TEXT_7 = "(fileComposite, SWT.BORDER);" + NL + "\t\t{" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tdata.grabExcessHorizontalSpace = true;" + NL + "\t\t\tdata.horizontalSpan = 1;" + NL + "\t\t\tfileField.setLayoutData(data);" + NL + "\t\t}" + NL + "" + NL + "\t\tfileField.addModifyListener(validator);" + NL + "\t\t";
24
  protected final String TEXT_7 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */";
25
  protected final String TEXT_8 = " resourceURIBrowseFileSystemButton = new ";
25
  protected final String TEXT_8 = NL + "\tpublic ";
26
  protected final String TEXT_9 = "(fileComposite, SWT.PUSH);" + NL + "\t\tresourceURIBrowseFileSystemButton.setText(\"&Browse\");" + NL + "  " + NL + "\t\tresourceURIBrowseFileSystemButton.addSelectionListener" + NL + "\t\t\t(new ";
26
  protected final String TEXT_9 = "() {" + NL + "\t\tsuper(\"CreationWizardPage\"); //$NON-NLS-1$";
27
  protected final String TEXT_10 = "() {" + NL + "\t\t\t\t public void widgetSelected(";
27
  protected final String TEXT_10 = NL + "\tpublic ";
28
  protected final String TEXT_11 = " event) {" + NL + "\t\t\t\t\t String fileExtension = \"";
28
  protected final String TEXT_11 = "(";
29
  protected final String TEXT_12 = "\";" + NL + "\t\t\t\t\t String filePath = ";
29
  protected final String TEXT_12 = " selection) {" + NL + "\t\tsuper(\"CreationWizardPage\", selection);\t//$NON-NLS-1$";
30
  protected final String TEXT_13 = ".openFilePathDialog(getShell(), \"*.\" + fileExtension, ";
30
  protected final String TEXT_13 = NL + "\t\tsetTitle(\"Create ";
31
  protected final String TEXT_14 = ".OPEN);" + NL + "\t\t\t\t\t if (filePath != null) {" + NL + "\t\t\t\t\t\t if (!filePath.endsWith(\".\" + fileExtension)) {" + NL + "\t\t\t\t\t\t\t filePath = filePath + \".\" + fileExtension;" + NL + "\t\t\t\t\t\t }" + NL + "\t\t\t\t\t\t fileField.setText(filePath);" + NL + "\t\t\t\t\t }" + NL + "\t\t\t\t }" + NL + "\t\t\t }); " + NL + "\t\tsetPageComplete(validatePage());" + NL + "\t\tsetControl(composite);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ModifyListener validator =" + NL + "\t\tnew ModifyListener() {" + NL + "\t\t\tpublic void modifyText(ModifyEvent e) {" + NL + "\t\t\t\tsetPageComplete(validatePage());" + NL + "\t\t\t}" + NL + "\t\t};" + NL + " " + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t protected boolean validatePage() {" + NL + "\t\tURI diagramFileURI = getDiagramFileURI();" + NL + "\t\tif (diagramFileURI == null || diagramFileURI.isEmpty()) {" + NL + "\t\t\tsetErrorMessage(null);" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\tString requiredExt = \"";
31
  protected final String TEXT_14 = " Diagram\"); //$NON-NLS-1$" + NL + "\t\tsetDescription(\"Create a new ";
32
  protected final String TEXT_15 = "\";" + NL + "\t\tString enteredExt = diagramFileURI.fileExtension();" + NL + "\t\tif (enteredExt == null || !enteredExt.equals(requiredExt)) {" + NL + "\t\t\tsetErrorMessage(\"The file name must end in \" + requiredExt); " + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "" + NL + "\t\tif (diagramFileURI.isFile()) {" + NL + "\t\t\tFile diagramFile = new File(diagramFileURI.toFileString());" + NL + "\t\t\tif (diagramFile.exists()) {" + NL + "\t\t\t\tsetErrorMessage(\"Diagram File already exists: \" + diagramFile);" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}";
32
  protected final String TEXT_15 = " diagram.\"); //$NON-NLS-1$" + NL + "\t}" + NL;
33
  protected final String TEXT_16 = NL + "\t\t\tURI modelFileURI = getModelFileURI();" + NL + "\t\t\tFile modelFile = new File(modelFileURI.toFileString());" + NL + "\t\t\tif (modelFile.exists()) {" + NL + "\t\t\t\tsetErrorMessage(\"Model File already exists: \" + modelFile);" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}";
33
  protected final String TEXT_16 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void createControl(Composite parent)" + NL + "\t{" + NL + "\t\tComposite composite = new Composite(parent, SWT.NONE);" + NL + "\t\t{" + NL + "\t\t\tGridLayout layout = new GridLayout();" + NL + "\t\t\tlayout.numColumns = 1;" + NL + "\t\t\tlayout.verticalSpacing = 12;" + NL + "\t\t\tcomposite.setLayout(layout);" + NL + "" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.verticalAlignment = GridData.FILL;" + NL + "\t\t\tdata.grabExcessVerticalSpace = true;" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tcomposite.setLayoutData(data);" + NL + "\t\t}" + NL + "\t\tLabel resourceURILabel = new Label(composite, SWT.LEFT);" + NL + "\t\t{" + NL + "\t\t\tresourceURILabel.setText(\"&File\");" + NL + "" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tresourceURILabel.setLayoutData(data);" + NL + "\t\t}" + NL + "" + NL + "\t\tComposite fileComposite = new Composite(composite, SWT.NONE);" + NL + "\t\t{" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tdata.grabExcessHorizontalSpace = true;" + NL + "\t\t\tfileComposite.setLayoutData(data);" + NL + "" + NL + "\t\t\tGridLayout layout = new GridLayout();" + NL + "\t\t\tlayout.marginHeight = 0;" + NL + "\t\t\tlayout.marginWidth = 0;" + NL + "\t\t\tlayout.numColumns = 2;" + NL + "\t\t\tfileComposite.setLayout(layout);" + NL + "\t\t}" + NL + "" + NL + "\t\tfileField = new ";
34
  protected final String TEXT_17 = NL + "\t\t}" + NL + "\t\tsetErrorMessage(null); " + NL + "\t\treturn true;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic URI getCreatedDiagramFileURI() {" + NL + "\t\treturn createdDiagramFileURI;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI getDiagramFileURI() {" + NL + "\t\ttry {" + NL + "\t\t\treturn URI.createFileURI(fileField.getText());" + NL + "\t\t} catch (Exception exception) {" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL;
34
  protected final String TEXT_17 = "(fileComposite, SWT.BORDER);" + NL + "\t\t{" + NL + "\t\t\tGridData data = new GridData();" + NL + "\t\t\tdata.horizontalAlignment = GridData.FILL;" + NL + "\t\t\tdata.grabExcessHorizontalSpace = true;" + NL + "\t\t\tdata.horizontalSpan = 1;" + NL + "\t\t\tfileField.setLayoutData(data);" + NL + "\t\t}" + NL + "" + NL + "\t\tfileField.addModifyListener(validator);" + NL + "\t\t";
35
  protected final String TEXT_18 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI getModelFileURI() {" + NL + "\t\tURI diagramFileURI = getDiagramFileURI();" + NL + "\t\tif (diagramFileURI == null) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn diagramFileURI.trimFileExtension().appendFileExtension(\"";
35
  protected final String TEXT_18 = " resourceURIBrowseFileSystemButton = new ";
36
  protected final String TEXT_19 = "\");" + NL + "\t}";
36
  protected final String TEXT_19 = "(fileComposite, SWT.PUSH);" + NL + "\t\tresourceURIBrowseFileSystemButton.setText(\"&Browse\");" + NL + "  " + NL + "\t\tresourceURIBrowseFileSystemButton.addSelectionListener" + NL + "\t\t\t(new ";
37
  protected final String TEXT_20 = NL + NL + "\t/**" + NL + "\t * Performs the operations necessary to create and open the diagram" + NL + "\t * @return boolean indicating whether the creation and opening the Diagram was successful " + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean finish() {" + NL + "\t\tfinal boolean[] result = new boolean[1];" + NL + "\t\t";
37
  protected final String TEXT_20 = "() {" + NL + "\t\t\t\t public void widgetSelected(";
38
  protected final String TEXT_21 = " op = new IRunnableWithProgress() {" + NL + "\t\t\tpublic void run(IProgressMonitor monitor) {" + NL + "\t\t\t\tresult[0] = doFinish(monitor);" + NL + "\t\t\t}" + NL + "\t\t};" + NL + "" + NL + "\t\ttry {" + NL + "\t\t\tgetContainer().run(false, true, op);" + NL + "\t\t} catch (InterruptedException e) {" + NL + "\t\t\treturn false;" + NL + "\t\t} catch (";
38
  protected final String TEXT_21 = " event) {" + NL + "\t\t\t\t\t String fileExtension = \"";
39
  protected final String TEXT_22 = " e) {" + NL + "\t\t\tif (e.getTargetException() instanceof CoreException) {" + NL + "\t\t\t\t";
39
  protected final String TEXT_22 = "\";" + NL + "\t\t\t\t\t String filePath = ";
40
  protected final String TEXT_23 = ".openError(" + NL + "\t\t\t\t\tgetContainer().getShell()," + NL + "\t\t\t\t\t\"Creation Problems\"," + NL + "\t\t\t\t\tnull,\t// no special message" + NL + "\t\t\t\t\t((CoreException) e.getTargetException()).getStatus());" + NL + "\t\t\t}" + NL + "\t\t\telse {" + NL + "\t\t\t\t// CoreExceptions are handled above, but unexpected runtime exceptions and errors may still occur." + NL + "\t\t\t\t";
40
  protected final String TEXT_23 = ".openFilePathDialog(getShell(), \"*.\" + fileExtension, ";
41
  protected final String TEXT_24 = ".getInstance().getLog().log(new ";
41
  protected final String TEXT_24 = ".OPEN);" + NL + "\t\t\t\t\t if (filePath != null) {" + NL + "\t\t\t\t\t\t if (!filePath.endsWith(\".\" + fileExtension)) {" + NL + "\t\t\t\t\t\t\t filePath = filePath + \".\" + fileExtension;" + NL + "\t\t\t\t\t\t }" + NL + "\t\t\t\t\t\t fileField.setText(filePath);" + NL + "\t\t\t\t\t }" + NL + "\t\t\t\t }" + NL + "\t\t\t }); " + NL + "\t\tsetPageComplete(validatePage());" + NL + "\t\tsetControl(composite);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ModifyListener validator =" + NL + "\t\tnew ModifyListener() {" + NL + "\t\t\tpublic void modifyText(ModifyEvent e) {" + NL + "\t\t\t\tsetPageComplete(validatePage());" + NL + "\t\t\t}" + NL + "\t\t};" + NL;
42
  protected final String TEXT_25 = "(";
42
  protected final String TEXT_25 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\t protected boolean validatePage() {";
43
  protected final String TEXT_26 = ".ERROR, ";
43
  protected final String TEXT_26 = NL + "\t\tURI diagramFileURI = getDiagramFileURI();" + NL + "\t\tif (diagramFileURI == null || diagramFileURI.isEmpty()) {" + NL + "\t\t\tsetErrorMessage(null);" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "" + NL + "\t\tif (diagramFileURI.isFile()) {" + NL + "\t\t\tFile diagramFile = new File(diagramFileURI.toFileString());" + NL + "\t\t\tif (diagramFile.exists()) {" + NL + "\t\t\t\tsetErrorMessage(\"Diagram File already exists: \" + diagramFile);" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}" + NL + "\t\t}";
44
  protected final String TEXT_27 = ".ID, 0, \"Creation failed\", e.getTargetException()));" + NL + "\t\t\t}" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\treturn result[0];" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @param monitor the <code>IProgressMonitor</code> to use to indicate progress and check for cancellation" + NL + "\t * @return boolean indicating whether the diagram was created and opened successfully" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean doFinish(IProgressMonitor monitor) {" + NL + "\t\tcreatedDiagramFileURI = createDiagramFile(monitor);" + NL + "\t\treturn createdDiagramFileURI != null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI createDiagramFile(IProgressMonitor monitor) {" + NL + "\t\t//TODO: Editing domain!" + NL + "\t\t";
44
  protected final String TEXT_27 = NL + "\t\tif (!super.validatePage()) {" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\tString fileName = getFileName();" + NL + "" + NL + "\t\tif (fileName == null) {" + NL + "\t\t\tsetErrorMessage(null);" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "" + NL + "\t\t";
45
  protected final String TEXT_28 = " resourceSet = new ";
45
  protected final String TEXT_28 = " path = getContainerFullPath().append(fileName);" + NL + "\t\tif (path.getFileExtension() == null) {" + NL + "\t\t\tpath = path.addFileExtension(\"";
46
  protected final String TEXT_29 = "();" + NL + "\t\tfinal ";
46
  protected final String TEXT_29 = "\");\t//$NON-NLS-1$" + NL + "\t\t}" + NL + "" + NL + "\t\tif (";
47
  protected final String TEXT_30 = " diagramResource = resourceSet.createResource(getDiagramFileURI());";
47
  protected final String TEXT_30 = ".getWorkspace().getRoot().exists(path)) {" + NL + "\t\t\tsetErrorMessage(\"Diagram File already exists: \" + path.toOSString());" + NL + "\t\t\treturn false;" + NL + "\t\t}";
48
  protected final String TEXT_31 = NL + "\t\tfinal Resource modelResource = resourceSet.createResource(getModelFileURI());";
48
  protected final String TEXT_31 = NL + "\t\tString requiredExt = \"";
49
  protected final String TEXT_32 = NL + NL + "\t\tif (diagramResource != null";
49
  protected final String TEXT_32 = "\";";
50
  protected final String TEXT_33 = " && modelResource != null";
50
  protected final String TEXT_33 = NL + "\t\tString enteredExt = diagramFileURI.fileExtension();";
51
  protected final String TEXT_34 = ") {" + NL + "\t\t\t//TODO: Editing domain!" + NL + "\t\t\t";
51
  protected final String TEXT_34 = NL + "\t\tString enteredExt = path.getFileExtension();";
52
  protected final String TEXT_35 = " model = ";
52
  protected final String TEXT_35 = NL + "\t\tif (enteredExt == null || !enteredExt.equals(requiredExt)) {" + NL + "\t\t\tsetErrorMessage(\"The file name must end in \" + requiredExt); " + NL + "\t\t\treturn false;" + NL + "\t\t}";
53
  protected final String TEXT_36 = ".eINSTANCE.create";
53
  protected final String TEXT_36 = NL + "\t\t\tURI modelFileURI = getModelFileURI();" + NL + "\t\t\tFile modelFile = new File(modelFileURI.toFileString());" + NL + "\t\t\tif (modelFile.exists()) {" + NL + "\t\t\t\tsetErrorMessage(\"Model File already exists: \" + modelFile);" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}";
54
  protected final String TEXT_37 = "();";
54
  protected final String TEXT_37 = NL + "\t\t\tpath = path.removeFileExtension().addFileExtension(\"";
55
  protected final String TEXT_38 = NL + "\t\t\tmodelResource.getContents().add(model);" + NL + "\t\t\ttry {" + NL + "\t\t\t\tmodelResource.save(";
55
  protected final String TEXT_38 = "\"); //$NON-NLS-1$" + NL + "\t\t\tif (";
56
  protected final String TEXT_39 = ".EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\thandleSaveException(e);" + NL + "\t\t\t}";
56
  protected final String TEXT_39 = ".getWorkspace().getRoot().exists(path)) {" + NL + "\t\t\t\tsetErrorMessage(\"Model File already exists: \" + path.lastSegment());" + NL + "\t\t\t\treturn false;" + NL + "\t\t\t}";
57
  protected final String TEXT_40 = NL + "\t\t\tdiagramResource.getContents().add(model);";
57
  protected final String TEXT_40 = NL + "\t\tsetErrorMessage(null);" + NL + "\t\treturn true;" + NL + "\t}" + NL;
58
  protected final String TEXT_41 = NL + "\t\t\t";
58
  protected final String TEXT_41 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic URI getCreatedDiagramFileURI() {" + NL + "\t\treturn createdDiagramFileURI;" + NL + "\t}";
59
  protected final String TEXT_42 = " diagram = ";
59
  protected final String TEXT_42 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic IFile getCreatedDiagramFile() {" + NL + "\t\treturn createdDiagramFile;" + NL + "\t}";
60
  protected final String TEXT_43 = ".eINSTANCE.createDiagram();" + NL + "\t\t\tdiagram.setElement(model);" + NL + "\t\t\t";
60
  protected final String TEXT_43 = NL;
61
  protected final String TEXT_44 = ".decorateView(diagram);" + NL + "\t\t\tdiagramResource.getContents().add(diagram);" + NL + "\t\t\ttry {" + NL + "\t\t\t\tdiagramResource.save(Collections.EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\thandleSaveException(e);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\tboolean result = ";
61
  protected final String TEXT_44 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI getDiagramFileURI() {" + NL + "\t\ttry {" + NL + "\t\t\treturn URI.createFileURI(fileField.getText());" + NL + "\t\t} catch (Exception exception) {" + NL + "\t\t}" + NL + "\t\treturn null;" + NL + "\t}" + NL;
62
  protected final String TEXT_45 = ".openEditor(getDiagramFileURI());" + NL + "\t\tif (!result) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn getDiagramFileURI();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void handleSaveException(IOException e) {" + NL + "\t\tthrow new RuntimeException(e);" + NL + "\t}" + NL + "}";
62
  protected final String TEXT_45 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate URI getModelFileURI() {" + NL + "\t\tURI diagramFileURI = getDiagramFileURI();" + NL + "\t\tif (diagramFileURI == null) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn diagramFileURI.trimFileExtension().appendFileExtension(\"";
63
  protected final String TEXT_46 = NL;
63
  protected final String TEXT_46 = "\");" + NL + "\t}";
64
  protected final String TEXT_47 = NL + NL + "\t/**" + NL + "\t * Performs the operations necessary to create and open the diagram" + NL + "\t * @return boolean indicating whether the creation and opening the Diagram was successful " + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean finish() {" + NL + "\t\tfinal boolean[] result = new boolean[1];";
65
  protected final String TEXT_48 = NL + "\t\t";
66
  protected final String TEXT_49 = " op = new IRunnableWithProgress() {" + NL + "\t\t\tpublic void run(IProgressMonitor monitor) {";
67
  protected final String TEXT_50 = NL + "\t\t";
68
  protected final String TEXT_51 = " op = new WorkspaceModifyOperation(null) {" + NL + "\t\t\tprotected void execute(IProgressMonitor monitor) {";
69
  protected final String TEXT_52 = NL + "\t\t\t\tresult[0] = doFinish(monitor);" + NL + "\t\t\t}" + NL + "\t\t};" + NL + "" + NL + "\t\ttry {" + NL + "\t\t\tgetContainer().run(false, true, op);" + NL + "\t\t} catch (InterruptedException e) {" + NL + "\t\t\treturn false;" + NL + "\t\t} catch (";
70
  protected final String TEXT_53 = " e) {" + NL + "\t\t\tif (e.getTargetException() instanceof CoreException) {" + NL + "\t\t\t\t";
71
  protected final String TEXT_54 = ".openError(" + NL + "\t\t\t\t\tgetContainer().getShell()," + NL + "\t\t\t\t\t\"Creation Problems\"," + NL + "\t\t\t\t\tnull,\t// no special message" + NL + "\t\t\t\t\t((CoreException) e.getTargetException()).getStatus());" + NL + "\t\t\t}" + NL + "\t\t\telse {" + NL + "\t\t\t\t// CoreExceptions are handled above, but unexpected runtime exceptions and errors may still occur." + NL + "\t\t\t\t";
72
  protected final String TEXT_55 = ".getInstance().getLog().log(new ";
73
  protected final String TEXT_56 = "(";
74
  protected final String TEXT_57 = ".ERROR, ";
75
  protected final String TEXT_58 = ".ID, 0, \"Creation failed\", e.getTargetException()));" + NL + "\t\t\t}" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\treturn result[0];" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @param monitor the <code>IProgressMonitor</code> to use to indicate progress and check for cancellation" + NL + "\t * @return boolean indicating whether the diagram was created and opened successfully" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic boolean doFinish(IProgressMonitor monitor) {";
76
  protected final String TEXT_59 = NL + "\t\t";
77
  protected final String TEXT_60 = " = createDiagramFile(monitor);" + NL + "\t\treturn ";
78
  protected final String TEXT_61 = " != null;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */";
79
  protected final String TEXT_62 = NL + "\tprivate URI createDiagramFile(IProgressMonitor monitor) {";
80
  protected final String TEXT_63 = NL + "\tprivate IFile createDiagramFile(IProgressMonitor monitor) {";
81
  protected final String TEXT_64 = NL + "\t\t//TODO: Editing domain!" + NL + "\t\t";
82
  protected final String TEXT_65 = " resourceSet = new ";
83
  protected final String TEXT_66 = "();";
84
  protected final String TEXT_67 = NL + "\t\tfinal ";
85
  protected final String TEXT_68 = " diagramResource = resourceSet.createResource(getDiagramFileURI());";
86
  protected final String TEXT_69 = NL + "\t\tIPath diagramFilePath = getContainerFullPath().append(getFileName());" + NL + "\t\tif (diagramFilePath.getFileExtension() == null) {" + NL + "\t\t\tdiagramFilePath = diagramFilePath.addFileExtension(\"";
87
  protected final String TEXT_70 = "\");\t\t//$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\tfinal IFile diagramFile = ResourcesPlugin.getWorkspace().getRoot().getFile(diagramFilePath);" + NL + "\t\tfinal ";
88
  protected final String TEXT_71 = " diagramResource = resourceSet.createResource(URI.createPlatformResourceURI(diagramFilePath.toString()));";
89
  protected final String TEXT_72 = NL + "\t\tfinal Resource modelResource = resourceSet.createResource(getModelFileURI());";
90
  protected final String TEXT_73 = NL + "\t\tIPath modelFilePath = diagramFilePath.removeFileExtension().addFileExtension(\"";
91
  protected final String TEXT_74 = "\"); //$NON-NLS-1$" + NL + "\t\tfinal Resource modelResource = resourceSet.createResource(URI.createPlatformResourceURI(modelFilePath.toString()));";
92
  protected final String TEXT_75 = NL + NL + "\t\tif (diagramResource != null";
93
  protected final String TEXT_76 = " && modelResource != null";
94
  protected final String TEXT_77 = ") {" + NL + "\t\t\t//TODO: Editing domain!" + NL + "\t\t\t";
95
  protected final String TEXT_78 = " model = ";
96
  protected final String TEXT_79 = ".eINSTANCE.create";
97
  protected final String TEXT_80 = "();";
98
  protected final String TEXT_81 = NL + "\t\t\tmodelResource.getContents().add(model);" + NL + "\t\t\ttry {" + NL + "\t\t\t\tmodelResource.save(";
99
  protected final String TEXT_82 = ".EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\thandleSaveException(e);" + NL + "\t\t\t}";
100
  protected final String TEXT_83 = NL + "\t\t\tdiagramResource.getContents().add(model);";
101
  protected final String TEXT_84 = NL + "\t\t\t";
102
  protected final String TEXT_85 = " diagram = ";
103
  protected final String TEXT_86 = ".eINSTANCE.createDiagram();" + NL + "\t\t\tdiagram.setElement(model);" + NL + "\t\t\t";
104
  protected final String TEXT_87 = ".decorateView(diagram);" + NL + "\t\t\tdiagramResource.getContents().add(diagram);" + NL + "\t\t\ttry {" + NL + "\t\t\t\tdiagramResource.save(Collections.EMPTY_MAP);" + NL + "\t\t\t} catch (IOException e) {" + NL + "\t\t\t\thandleSaveException(e);" + NL + "\t\t\t}" + NL + "\t\t}";
105
  protected final String TEXT_88 = NL + "\t\tboolean result = ";
106
  protected final String TEXT_89 = ".openEditor(getDiagramFileURI());" + NL + "\t\tif (!result) {" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn getDiagramFileURI();";
107
  protected final String TEXT_90 = NL + "\t\ttry {" + NL + "\t\t\t";
108
  protected final String TEXT_91 = ".openEditor(";
109
  protected final String TEXT_92 = ".getWorkbench().getActiveWorkbenchWindow().getActivePage(), diagramFile);" + NL + "\t\t} catch (";
110
  protected final String TEXT_93 = " e) {" + NL + "\t\t\t";
111
  protected final String TEXT_94 = ".getInstance().getLog().log(e.getStatus());" + NL + "\t\t\treturn null;" + NL + "\t\t}" + NL + "\t\treturn diagramFile;";
112
  protected final String TEXT_95 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate void handleSaveException(IOException e) {" + NL + "\t\tthrow new RuntimeException(e);" + NL + "\t}" + NL + "}";
113
  protected final String TEXT_96 = NL;
64
114
65
  public String generate(Object argument)
115
  public String generate(Object argument)
66
  {
116
  {
Lines 70-192 Link Here
70
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
120
final GenEditorGenerator editorGen = genDiagram.getEditorGen();
71
final GenPlugin genPlugin = editorGen.getPlugin();
121
final GenPlugin genPlugin = editorGen.getPlugin();
72
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
122
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
123
final boolean isRichClientPlatform = genDiagram.getEditorGen().getDomainGenModel().isRichClientPlatform();
73
124
74
importManager.emitPackageStatement(stringBuffer);
125
importManager.emitPackageStatement(stringBuffer);
75
importManager.markImportLocation(stringBuffer);
126
importManager.markImportLocation(stringBuffer);
76
127
77
importManager.addImport("java.io.File");
78
importManager.addImport("org.eclipse.core.runtime.IProgressMonitor");
128
importManager.addImport("org.eclipse.core.runtime.IProgressMonitor");
79
importManager.addImport("org.eclipse.core.runtime.CoreException");
129
importManager.addImport("org.eclipse.core.runtime.CoreException");
80
importManager.addImport("java.io.IOException");
130
importManager.addImport("java.io.IOException");
81
importManager.addImport("org.eclipse.swt.widgets.Text");
82
importManager.addImport("org.eclipse.emf.common.util.URI");
131
importManager.addImport("org.eclipse.emf.common.util.URI");
132
if (isRichClientPlatform) {
133
importManager.addImport("java.io.File");
83
importManager.addImport("org.eclipse.swt.widgets.Composite");
134
importManager.addImport("org.eclipse.swt.widgets.Composite");
84
importManager.addImport("org.eclipse.swt.widgets.Label");
135
importManager.addImport("org.eclipse.swt.widgets.Label");
136
importManager.addImport("org.eclipse.swt.widgets.Text");
85
importManager.addImport("org.eclipse.swt.events.ModifyListener");
137
importManager.addImport("org.eclipse.swt.events.ModifyListener");
86
importManager.addImport("org.eclipse.swt.events.ModifyEvent");
138
importManager.addImport("org.eclipse.swt.events.ModifyEvent");
87
importManager.addImport("org.eclipse.swt.layout.GridLayout");
139
importManager.addImport("org.eclipse.swt.layout.GridLayout");
88
importManager.addImport("org.eclipse.swt.layout.GridData");
140
importManager.addImport("org.eclipse.swt.layout.GridData");
141
}
89
142
90
    stringBuffer.append(TEXT_1);
143
    stringBuffer.append(TEXT_1);
91
    stringBuffer.append(genDiagram.getCreationWizardPageClassName());
144
    stringBuffer.append(genDiagram.getCreationWizardPageClassName());
92
    stringBuffer.append(TEXT_2);
145
    stringBuffer.append(TEXT_2);
93
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.wizard.WizardPage"));
146
    stringBuffer.append(importManager.getImportedName(isRichClientPlatform ? "org.eclipse.jface.wizard.WizardPage" : "org.eclipse.ui.dialogs.WizardNewFileCreationPage"));
94
    stringBuffer.append(TEXT_3);
147
    stringBuffer.append(TEXT_3);
95
    stringBuffer.append(genDiagram.getCreationWizardPageClassName());
148
    
149
if (isRichClientPlatform) {
150
96
    stringBuffer.append(TEXT_4);
151
    stringBuffer.append(TEXT_4);
97
    stringBuffer.append(editorGen.getDomainGenModel().getModelName());
152
    
153
} else {
154
98
    stringBuffer.append(TEXT_5);
155
    stringBuffer.append(TEXT_5);
99
    stringBuffer.append(editorGen.getDomainGenModel().getModelName());
156
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.IFile"));
100
    stringBuffer.append(TEXT_6);
157
    stringBuffer.append(TEXT_6);
101
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Text"));
158
    
159
}
160
102
    stringBuffer.append(TEXT_7);
161
    stringBuffer.append(TEXT_7);
103
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Button"));
162
    
163
if (isRichClientPlatform) {
164
104
    stringBuffer.append(TEXT_8);
165
    stringBuffer.append(TEXT_8);
105
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Button"));
166
    stringBuffer.append(genDiagram.getCreationWizardPageClassName());
106
    stringBuffer.append(TEXT_9);
167
    stringBuffer.append(TEXT_9);
107
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.events.SelectionAdapter"));
168
    
169
} else {
170
108
    stringBuffer.append(TEXT_10);
171
    stringBuffer.append(TEXT_10);
109
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.events.SelectionEvent"));
172
    stringBuffer.append(genDiagram.getCreationWizardPageClassName());
110
    stringBuffer.append(TEXT_11);
173
    stringBuffer.append(TEXT_11);
111
    stringBuffer.append(editorGen.getDiagramFileExtension());
174
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.viewers.IStructuredSelection"));
112
    stringBuffer.append(TEXT_12);
175
    stringBuffer.append(TEXT_12);
113
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
176
    
177
}
178
114
    stringBuffer.append(TEXT_13);
179
    stringBuffer.append(TEXT_13);
115
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.SWT"));
180
    stringBuffer.append(editorGen.getDomainGenModel().getModelName());
116
    stringBuffer.append(TEXT_14);
181
    stringBuffer.append(TEXT_14);
117
    stringBuffer.append(editorGen.getDiagramFileExtension());
182
    stringBuffer.append(editorGen.getDomainGenModel().getModelName());
118
    stringBuffer.append(TEXT_15);
183
    stringBuffer.append(TEXT_15);
119
    if (!editorGen.isSameFileForDiagramAndModel()) {
184
    
185
if (isRichClientPlatform) {
186
120
    stringBuffer.append(TEXT_16);
187
    stringBuffer.append(TEXT_16);
121
    }
188
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Text"));
122
    stringBuffer.append(TEXT_17);
189
    stringBuffer.append(TEXT_17);
123
    if (!editorGen.isSameFileForDiagramAndModel()) {
190
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Button"));
124
    stringBuffer.append(TEXT_18);
191
    stringBuffer.append(TEXT_18);
125
    stringBuffer.append(editorGen.getDomainFileExtension());
192
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Button"));
126
    stringBuffer.append(TEXT_19);
193
    stringBuffer.append(TEXT_19);
127
    }
194
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.events.SelectionAdapter"));
128
    stringBuffer.append(TEXT_20);
195
    stringBuffer.append(TEXT_20);
129
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.operation.IRunnableWithProgress"));
196
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.events.SelectionEvent"));
130
    stringBuffer.append(TEXT_21);
197
    stringBuffer.append(TEXT_21);
131
    stringBuffer.append(importManager.getImportedName("java.lang.reflect.InvocationTargetException"));
198
    stringBuffer.append(editorGen.getDiagramFileExtension());
132
    stringBuffer.append(TEXT_22);
199
    stringBuffer.append(TEXT_22);
133
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.dialogs.ErrorDialog"));
200
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
134
    stringBuffer.append(TEXT_23);
201
    stringBuffer.append(TEXT_23);
135
    stringBuffer.append(genPlugin.getActivatorClassName());
202
    stringBuffer.append(importManager.getImportedName("org.eclipse.swt.SWT"));
136
    stringBuffer.append(TEXT_24);
203
    stringBuffer.append(TEXT_24);
137
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.Status"));
204
    
205
}
206
138
    stringBuffer.append(TEXT_25);
207
    stringBuffer.append(TEXT_25);
139
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IStatus"));
208
    
209
if (isRichClientPlatform) {
210
140
    stringBuffer.append(TEXT_26);
211
    stringBuffer.append(TEXT_26);
141
    stringBuffer.append(genPlugin.getActivatorClassName());
212
    
213
} else {
214
142
    stringBuffer.append(TEXT_27);
215
    stringBuffer.append(TEXT_27);
143
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet"));
216
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IPath"));
144
    stringBuffer.append(TEXT_28);
217
    stringBuffer.append(TEXT_28);
145
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl"));
218
    stringBuffer.append(editorGen.getDiagramFileExtension());
146
    stringBuffer.append(TEXT_29);
219
    stringBuffer.append(TEXT_29);
147
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.Resource"));
220
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.ResourcesPlugin"));
148
    stringBuffer.append(TEXT_30);
221
    stringBuffer.append(TEXT_30);
149
    
222
    
150
final boolean standaloneDomainModel = !editorGen.isSameFileForDiagramAndModel() && genDiagram.getDomainDiagramElement() != null;
223
}
151
if (standaloneDomainModel) {
152
224
153
    stringBuffer.append(TEXT_31);
225
    stringBuffer.append(TEXT_31);
154
    }
226
    stringBuffer.append(editorGen.getDiagramFileExtension());
155
    stringBuffer.append(TEXT_32);
227
    stringBuffer.append(TEXT_32);
156
    if (standaloneDomainModel) {
228
    
229
if (isRichClientPlatform) {
230
157
    stringBuffer.append(TEXT_33);
231
    stringBuffer.append(TEXT_33);
158
    }
232
    
233
} else {
234
159
    stringBuffer.append(TEXT_34);
235
    stringBuffer.append(TEXT_34);
160
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
236
    
237
}
238
161
    stringBuffer.append(TEXT_35);
239
    stringBuffer.append(TEXT_35);
162
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getGenPackage().getQualifiedFactoryClassName()));
240
    
241
if (!editorGen.isSameFileForDiagramAndModel()) {
242
	if (isRichClientPlatform) {
243
163
    stringBuffer.append(TEXT_36);
244
    stringBuffer.append(TEXT_36);
164
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
245
    
246
	} else {
247
165
    stringBuffer.append(TEXT_37);
248
    stringBuffer.append(TEXT_37);
249
    stringBuffer.append(editorGen.getDomainFileExtension());
250
    stringBuffer.append(TEXT_38);
251
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.resources.ResourcesPlugin"));
252
    stringBuffer.append(TEXT_39);
253
    
254
	}
255
}
256
257
    stringBuffer.append(TEXT_40);
258
    
259
if (isRichClientPlatform) {
260
261
    stringBuffer.append(TEXT_41);
262
    
263
} else {
264
265
    stringBuffer.append(TEXT_42);
266
    
267
}
268
269
    stringBuffer.append(TEXT_43);
270
    
271
if (isRichClientPlatform) {
272
273
    stringBuffer.append(TEXT_44);
274
    
275
	if (!editorGen.isSameFileForDiagramAndModel()) {
276
277
    stringBuffer.append(TEXT_45);
278
    stringBuffer.append(editorGen.getDomainFileExtension());
279
    stringBuffer.append(TEXT_46);
280
    
281
	}
282
}
283
284
    stringBuffer.append(TEXT_47);
285
    
286
if (isRichClientPlatform) {
287
288
    stringBuffer.append(TEXT_48);
289
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.operation.IRunnableWithProgress"));
290
    stringBuffer.append(TEXT_49);
291
    
292
} else {
293
294
    stringBuffer.append(TEXT_50);
295
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.actions.WorkspaceModifyOperation"));
296
    stringBuffer.append(TEXT_51);
297
    
298
}
299
300
    stringBuffer.append(TEXT_52);
301
    stringBuffer.append(importManager.getImportedName("java.lang.reflect.InvocationTargetException"));
302
    stringBuffer.append(TEXT_53);
303
    stringBuffer.append(importManager.getImportedName("org.eclipse.jface.dialogs.ErrorDialog"));
304
    stringBuffer.append(TEXT_54);
305
    stringBuffer.append(genPlugin.getActivatorClassName());
306
    stringBuffer.append(TEXT_55);
307
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.Status"));
308
    stringBuffer.append(TEXT_56);
309
    stringBuffer.append(importManager.getImportedName("org.eclipse.core.runtime.IStatus"));
310
    stringBuffer.append(TEXT_57);
311
    stringBuffer.append(genPlugin.getActivatorClassName());
312
    stringBuffer.append(TEXT_58);
313
    
314
String createdVar = isRichClientPlatform ? "createdDiagramFileURI" : "createdDiagramFile";
315
316
    stringBuffer.append(TEXT_59);
317
    stringBuffer.append(createdVar);
318
    stringBuffer.append(TEXT_60);
319
    stringBuffer.append(createdVar);
320
    stringBuffer.append(TEXT_61);
321
    if (isRichClientPlatform) {
322
    stringBuffer.append(TEXT_62);
323
    } else {
324
    stringBuffer.append(TEXT_63);
325
    }
326
    stringBuffer.append(TEXT_64);
327
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.ResourceSet"));
328
    stringBuffer.append(TEXT_65);
329
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.impl.ResourceSetImpl"));
330
    stringBuffer.append(TEXT_66);
331
    
332
if (isRichClientPlatform) {
333
334
    stringBuffer.append(TEXT_67);
335
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.Resource"));
336
    stringBuffer.append(TEXT_68);
337
    
338
} else {
339
340
    stringBuffer.append(TEXT_69);
341
    stringBuffer.append(editorGen.getDiagramFileExtension());
342
    stringBuffer.append(TEXT_70);
343
    stringBuffer.append(importManager.getImportedName("org.eclipse.emf.ecore.resource.Resource"));
344
    stringBuffer.append(TEXT_71);
166
    
345
    
346
}
347
348
    
349
final boolean standaloneDomainModel = !editorGen.isSameFileForDiagramAndModel() && genDiagram.getDomainDiagramElement() != null;
167
if (standaloneDomainModel) {
350
if (standaloneDomainModel) {
351
	if (isRichClientPlatform) {
168
352
169
    stringBuffer.append(TEXT_38);
353
    stringBuffer.append(TEXT_72);
354
    
355
	} else {
356
357
    stringBuffer.append(TEXT_73);
358
    stringBuffer.append(editorGen.getDomainFileExtension());
359
    stringBuffer.append(TEXT_74);
360
    
361
	}
362
}
363
364
    stringBuffer.append(TEXT_75);
365
    if (standaloneDomainModel) {
366
    stringBuffer.append(TEXT_76);
367
    }
368
    stringBuffer.append(TEXT_77);
369
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getQualifiedInterfaceName()));
370
    stringBuffer.append(TEXT_78);
371
    stringBuffer.append(importManager.getImportedName(genDiagram.getDomainDiagramElement().getGenPackage().getQualifiedFactoryClassName()));
372
    stringBuffer.append(TEXT_79);
373
    stringBuffer.append(genDiagram.getDomainDiagramElement().getClassifierAccessorName());
374
    stringBuffer.append(TEXT_80);
375
    
376
if (standaloneDomainModel) {
377
378
    stringBuffer.append(TEXT_81);
170
    stringBuffer.append(importManager.getImportedName("java.util.Collections"));
379
    stringBuffer.append(importManager.getImportedName("java.util.Collections"));
171
    stringBuffer.append(TEXT_39);
380
    stringBuffer.append(TEXT_82);
172
    
381
    
173
} else {
382
} else {
174
383
175
    stringBuffer.append(TEXT_40);
384
    stringBuffer.append(TEXT_83);
176
    
385
    
177
}
386
}
178
387
179
    stringBuffer.append(TEXT_41);
388
    stringBuffer.append(TEXT_84);
180
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Diagram"));
389
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.Diagram"));
181
    stringBuffer.append(TEXT_42);
390
    stringBuffer.append(TEXT_85);
182
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationFactory"));
391
    stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationFactory"));
183
    stringBuffer.append(TEXT_43);
392
    stringBuffer.append(TEXT_86);
184
    stringBuffer.append(importManager.getImportedName(genDiagram.getNotationViewFactoryQualifiedClassName()));
393
    stringBuffer.append(importManager.getImportedName(genDiagram.getNotationViewFactoryQualifiedClassName()));
185
    stringBuffer.append(TEXT_44);
394
    stringBuffer.append(TEXT_87);
395
    
396
if (isRichClientPlatform) {
397
398
    stringBuffer.append(TEXT_88);
186
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
399
    stringBuffer.append(genDiagram.getDiagramEditorUtilClassName());
187
    stringBuffer.append(TEXT_45);
400
    stringBuffer.append(TEXT_89);
401
    
402
} else {
403
404
    stringBuffer.append(TEXT_90);
405
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.ide.IDE"));
406
    stringBuffer.append(TEXT_91);
407
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.PlatformUI"));
408
    stringBuffer.append(TEXT_92);
409
    stringBuffer.append(importManager.getImportedName("org.eclipse.ui.PartInitException"));
410
    stringBuffer.append(TEXT_93);
411
    stringBuffer.append(genPlugin.getActivatorClassName());
412
    stringBuffer.append(TEXT_94);
413
    
414
}
415
416
    stringBuffer.append(TEXT_95);
188
    importManager.emitSortedImports();
417
    importManager.emitSortedImports();
189
    stringBuffer.append(TEXT_46);
418
    stringBuffer.append(TEXT_96);
190
    return stringBuffer.toString();
419
    return stringBuffer.toString();
191
  }
420
  }
192
}
421
}
(-)src-templates/org/eclipse/gmf/codegen/templates/lite/editor/PluginPropertiesGenerator.java (-1 / +55 lines)
Lines 1-6 Link Here
1
package org.eclipse.gmf.codegen.templates.lite.editor;
1
package org.eclipse.gmf.codegen.templates.lite.editor;
2
2
3
import org.eclipse.gmf.codegen.gmfgen.*;
3
import org.eclipse.gmf.codegen.gmfgen.*;
4
import org.eclipse.emf.codegen.ecore.genmodel.*;
4
5
5
public class PluginPropertiesGenerator
6
public class PluginPropertiesGenerator
6
{
7
{
Lines 17-32 Link Here
17
  protected final String TEXT_1 = "pluginName=";
18
  protected final String TEXT_1 = "pluginName=";
18
  protected final String TEXT_2 = NL + "providerName=";
19
  protected final String TEXT_2 = NL + "providerName=";
19
  protected final String TEXT_3 = NL;
20
  protected final String TEXT_3 = NL;
21
  protected final String TEXT_4 = NL + "_UI_Menu_OpenURI_label=Open Diagram &URI..." + NL + "_UI_Menu_OpenURI_description=Opens a ";
22
  protected final String TEXT_5 = " diagram loading it from a URI" + NL + "_UI_Menu_Open_label=&Open Diagram..." + NL + "_UI_Menu_Open_description=Opens a ";
23
  protected final String TEXT_6 = " diagram" + NL + "" + NL + "_UI_";
24
  protected final String TEXT_7 = "_ActionSet_label=";
25
  protected final String TEXT_8 = " Diagram Action Set " + NL + "_UI_";
26
  protected final String TEXT_9 = "NewDiagramCommand=New ";
27
  protected final String TEXT_10 = " diagram" + NL;
28
  protected final String TEXT_11 = NL + "_UI_Perspective_label = ";
29
  protected final String TEXT_12 = " Diagram" + NL + "_UI_Application_title=";
30
  protected final String TEXT_13 = " Diagram Application " + NL + "_UI_Menu_File_label=&File" + NL + "_UI_Menu_New_label=&New" + NL + "_UI_Menu_Edit_label=&Edit" + NL + "_UI_Menu_Window_label=&Window" + NL + "_UI_Menu_Help_label=&Help" + NL + "_UI_Menu_About_label=";
31
  protected final String TEXT_14 = " Diagram &About..." + NL + "_UI_About_title = ";
32
  protected final String TEXT_15 = " Diagram Application" + NL + "_UI_About_text = ";
33
  protected final String TEXT_16 = " Diagram Application about box goes here.";
34
  protected final String TEXT_17 = NL;
20
35
21
  public String generate(Object argument)
36
  public String generate(Object argument)
22
  {
37
  {
23
    final StringBuffer stringBuffer = new StringBuffer();
38
    final StringBuffer stringBuffer = new StringBuffer();
24
    GenPlugin genPlugin = (GenPlugin) argument;
39
    
40
GenPlugin genPlugin = (GenPlugin) argument;
41
final GenDiagram genDiagram = genPlugin.getEditorGen().getDiagram();
42
final GenModel genModel = genPlugin.getEditorGen().getDomainGenModel();
43
final boolean isRichClientPlatform = genModel.isRichClientPlatform();
44
25
    stringBuffer.append(TEXT_1);
45
    stringBuffer.append(TEXT_1);
26
    stringBuffer.append(genPlugin.getName());
46
    stringBuffer.append(genPlugin.getName());
27
    stringBuffer.append(TEXT_2);
47
    stringBuffer.append(TEXT_2);
28
    stringBuffer.append(genPlugin.getProvider());
48
    stringBuffer.append(genPlugin.getProvider());
29
    stringBuffer.append(TEXT_3);
49
    stringBuffer.append(TEXT_3);
50
    if (isRichClientPlatform) {
51
    stringBuffer.append(TEXT_4);
52
    stringBuffer.append(genModel.getModelName());
53
    stringBuffer.append(TEXT_5);
54
    stringBuffer.append(genModel.getModelName());
55
    stringBuffer.append(TEXT_6);
56
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
57
    stringBuffer.append(TEXT_7);
58
    stringBuffer.append(genModel.getModelName());
59
    stringBuffer.append(TEXT_8);
60
    stringBuffer.append(genDiagram.getDiagramEditorUtilQualifiedClassName());
61
    stringBuffer.append(TEXT_9);
62
    stringBuffer.append(genModel.getModelName());
63
    stringBuffer.append(TEXT_10);
64
    
65
	boolean shouldGenerateApplication = true;	/*XXX: option in gmfgen*/
66
	if (shouldGenerateApplication) {
67
68
    stringBuffer.append(TEXT_11);
69
    stringBuffer.append(genModel.getModelName());
70
    stringBuffer.append(TEXT_12);
71
    stringBuffer.append(genModel.getModelName());
72
    stringBuffer.append(TEXT_13);
73
    stringBuffer.append(genModel.getModelName());
74
    stringBuffer.append(TEXT_14);
75
    stringBuffer.append(genModel.getModelName());
76
    stringBuffer.append(TEXT_15);
77
    stringBuffer.append(genModel.getModelName());
78
    stringBuffer.append(TEXT_16);
79
    
80
	}
81
}
82
83
    stringBuffer.append(TEXT_17);
30
    return stringBuffer.toString();
84
    return stringBuffer.toString();
31
  }
85
  }
32
}
86
}

Return to bug 114200