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 230873 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/uml2/diagram/clazz/part/UMLNewDiagramFileWizard.java (-2 / +1 lines)
Lines 72-79 Link Here
72
			throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$
72
			throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$
73
		}
73
		}
74
		myFileCreationPage.setContainerFullPath(filePath);
74
		myFileCreationPage.setContainerFullPath(filePath);
75
		myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(filePath, fileName, "umlclass_diagram")); //$NON-NLS-1$
75
		myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(filePath, fileName, "umlclass")); //$NON-NLS-1$
76
77
		diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.UMLNewDiagramFileWizard_RootSelectionPageName);
76
		diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.UMLNewDiagramFileWizard_RootSelectionPageName);
78
		diagramRootElementSelectionPage.setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle);
77
		diagramRootElementSelectionPage.setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle);
79
		diagramRootElementSelectionPage.setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription);
78
		diagramRootElementSelectionPage.setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription);
(-)src/org/eclipse/uml2/diagram/clazz/part/UMLUriEditorInputTester.java (-1 / +3 lines)
Lines 16-22 Link Here
16
			return false;
16
			return false;
17
		}
17
		}
18
		URIEditorInput editorInput = (URIEditorInput) receiver;
18
		URIEditorInput editorInput = (URIEditorInput) receiver;
19
		return "umlclass_diagram".equals(editorInput.getURI().fileExtension()); //$NON-NLS-1$
19
		return "umlclass".equals(editorInput.getURI().fileExtension())//$NON-NLS-1$
20
				|| " umlclass_diagram".equals(editorInput.getURI().fileExtension())//$NON-NLS-1$
21
		;
20
	}
22
	}
21
23
22
}
24
}
(-)src/org/eclipse/uml2/diagram/clazz/part/UMLCreationWizard.java (-1 / +1 lines)
Lines 99-105 Link Here
99
	 * @generated
99
	 * @generated
100
	 */
100
	 */
101
	public void addPages() {
101
	public void addPages() {
102
		diagramModelFilePage = new UMLCreationWizardPage("DiagramModelFile", getSelection(), "umlclass_diagram"); //$NON-NLS-1$ //$NON-NLS-2$
102
		diagramModelFilePage = new UMLCreationWizardPage("DiagramModelFile", getSelection(), "umlclass"); //$NON-NLS-1$ //$NON-NLS-2$
103
		diagramModelFilePage.setTitle(Messages.UMLCreationWizard_DiagramModelFilePageTitle);
103
		diagramModelFilePage.setTitle(Messages.UMLCreationWizard_DiagramModelFilePageTitle);
104
		diagramModelFilePage.setDescription(Messages.UMLCreationWizard_DiagramModelFilePageDescription);
104
		diagramModelFilePage.setDescription(Messages.UMLCreationWizard_DiagramModelFilePageDescription);
105
		addPage(diagramModelFilePage);
105
		addPage(diagramModelFilePage);
(-)plugin.xml (-5 / +33 lines)
Lines 257-281 Link Here
257
      <?gmfgen generated="true"?>
257
      <?gmfgen generated="true"?>
258
      <fileTypes
258
      <fileTypes
259
         type="text"
259
         type="text"
260
         extension="umlclass_diagram">
260
         extension="umlclass">
261
      </fileTypes>
262
      <fileTypes
263
         type="text"
264
         extension=" umlclass_diagram">
261
      </fileTypes>
265
      </fileTypes>
262
   </extension>
266
   </extension>
263
267
264
   <extension point="org.eclipse.emf.ecore.extension_parser">
268
   <extension point="org.eclipse.emf.ecore.extension_parser">
265
      <?gmfgen generated="true"?>
269
      <?gmfgen generated="true"?>
266
      <parser
270
      <parser
267
         type="umlclass_diagram"
271
         type="umlclass"
272
         class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
273
      </parser>
274
      <parser
275
         type=" umlclass_diagram"
268
         class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
276
         class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
269
      </parser>
277
      </parser>
270
   </extension>
278
   </extension>
271
279
272
   <extension point="org.eclipse.ui.editors">
280
   <extension point="org.eclipse.ui.editors">
273
      <?gmfgen generated="true"?>
281
      <?gmfgen generated="true"?>
282
274
      <editor
283
      <editor
275
         id="org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditorID"
284
         id="org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditorID"
276
         name="%editorName"
285
         name="%editorName"
277
         icon="icons/obj16/UMLDiagramFile.gif"
286
         icon="icons/obj16/UMLDiagramFile.gif"
278
         extensions="umlclass_diagram"
287
         extensions="umlclass"
288
         default="true"
289
         class="org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditor"
290
         matchingStrategy="org.eclipse.uml2.diagram.clazz.part.UMLMatchingStrategy"
291
         contributorClass="org.eclipse.uml2.diagram.clazz.part.UMLDiagramActionBarContributor">
292
      </editor>
293
294
      <editor
295
         id="org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditorID"
296
         name="%editorName"
297
         icon="icons/obj16/UMLDiagramFile.gif"
298
         extensions=" umlclass_diagram"
279
         default="true"
299
         default="true"
280
         class="org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditor"
300
         class="org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditor"
281
         matchingStrategy="org.eclipse.uml2.diagram.clazz.part.UMLMatchingStrategy"
301
         matchingStrategy="org.eclipse.uml2.diagram.clazz.part.UMLMatchingStrategy"
Lines 1482-1488 Link Here
1482
            <or>
1502
            <or>
1483
	           <and>
1503
	           <and>
1484
    	          <instanceof value="org.eclipse.core.resources.IFile"/>
1504
    	          <instanceof value="org.eclipse.core.resources.IFile"/>
1485
        	      <test property="org.eclipse.core.resources.extension" value="umlclass_diagram"/>
1505
        	      <test property="org.eclipse.core.resources.extension" value="umlclass"/>
1506
               </and>
1507
	           <and>
1508
    	          <instanceof value="org.eclipse.core.resources.IFile"/>
1509
        	      <test property="org.eclipse.core.resources.extension" value=" umlclass_diagram"/>
1486
               </and>
1510
               </and>
1487
               <instanceof value="org.eclipse.uml2.diagram.clazz.navigator.UMLAbstractNavigatorItem"/>
1511
               <instanceof value="org.eclipse.uml2.diagram.clazz.navigator.UMLAbstractNavigatorItem"/>
1488
           	   <adapt type="org.eclipse.gmf.runtime.notation.View">
1512
           	   <adapt type="org.eclipse.gmf.runtime.notation.View">
Lines 1505-1511 Link Here
1505
               <or>
1529
               <or>
1506
	              <and>
1530
	              <and>
1507
    	             <instanceof value="org.eclipse.core.resources.IFile"/>
1531
    	             <instanceof value="org.eclipse.core.resources.IFile"/>
1508
        	         <test property="org.eclipse.core.resources.extension" value="umlclass_diagram"/>
1532
        	         <test property="org.eclipse.core.resources.extension" value="umlclass"/>
1533
                  </and>
1534
	              <and>
1535
    	             <instanceof value="org.eclipse.core.resources.IFile"/>
1536
        	         <test property="org.eclipse.core.resources.extension" value=" umlclass_diagram"/>
1509
                  </and>
1537
                  </and>
1510
                  <instanceof value="org.eclipse.uml2.diagram.clazz.navigator.UMLAbstractNavigatorItem"/>
1538
                  <instanceof value="org.eclipse.uml2.diagram.clazz.navigator.UMLAbstractNavigatorItem"/>
1511
               </or>
1539
               </or>
(-)structures/classDiagram.gmfgen (-1 / +1 lines)
Lines 5-11 Link Here
5
    xmlns:gmfgen="http://www.eclipse.org/gmf/2006/GenModel"
5
    xmlns:gmfgen="http://www.eclipse.org/gmf/2006/GenModel"
6
    xmlns:uml2.gmfgenext="http://www.eclipse.org/uml2/diagram/gmfgenext/DiagramFigure/1.0" packageNamePrefix="org.eclipse.uml2.diagram.clazz"
6
    xmlns:uml2.gmfgenext="http://www.eclipse.org/uml2/diagram/gmfgenext/DiagramFigure/1.0" packageNamePrefix="org.eclipse.uml2.diagram.clazz"
7
    modelID="UMLClass"
7
    modelID="UMLClass"
8
    diagramFileExtension="umlclass_diagram"
8
    diagramFileExtension="umlclass, umlclass_diagram"
9
    dynamicTemplates="true"
9
    dynamicTemplates="true"
10
    templateDirectory="/org.eclipse.uml2.diagram.def/dynamic-templates/codegen">
10
    templateDirectory="/org.eclipse.uml2.diagram.def/dynamic-templates/codegen">
11
  <diagram
11
  <diagram
(-)dynamic-templates/codegen/aspects/xpt/plugin/plugin.xpt (+47 lines)
Lines 19-24 Link Here
19
19
20
«EXTENSION xpt::actions::Utils»  
20
«EXTENSION xpt::actions::Utils»  
21
«EXTENSION aspects::xpt::plugin::Utils»
21
«EXTENSION aspects::xpt::plugin::Utils»
22
«EXTENSION aspects::xpt::FileExtensionUtils»
23
24
«AROUND plugin FOR gmfgen::GenPlugin-»
25
<?xml version="1.0" encoding="UTF-8"?>
26
<?eclipse version="3.0"?>
27
«EXPAND xpt::Common::xcopyright FOR editorGen-»
28
<plugin>
29
30
   <extension point="org.eclipse.team.core.fileTypes">
31
      «EXPAND xpt::Common::xmlGeneratedTag»
32
«REM» #230873 'Make diagram file extension shorter'«ENDREM-»
33
«FOREACH editorGen.collectAllExtensions() AS dfe-»
34
      <fileTypes
35
         type="text"
36
         extension="«dfe»">
37
      </fileTypes>
38
«ENDFOREACH-»
39
«REM» End of #230873«ENDREM-»
40
   </extension>
41
42
   <extension point="org.eclipse.emf.ecore.extension_parser">
43
      «EXPAND xpt::Common::xmlGeneratedTag»
44
«REM» #230873 'Make diagram file extension shorter'«ENDREM-»
45
«FOREACH editorGen.collectAllExtensions() AS dfe-»
46
      <parser
47
         type="«dfe»"
48
         class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
49
      </parser>
50
«ENDFOREACH-»
51
«REM» End of #230873«ENDREM-»
52
   </extension>
53
54
«EXPAND xpt::editor::extensions::extensions FOR editorGen-»
55
«EXPAND xpt::plugin::plugin::menu-»
56
«EXPAND xpt::plugin::plugin::validation FOR editorGen.diagram-»
57
«EXPAND xpt::plugin::plugin::metrics FOR editorGen.metrics-»
58
«EXPAND xpt::diagram::preferences::extensions::extensions FOR editorGen.diagram-»
59
«EXPAND xpt::propsheet::extensions::extensions FOR editorGen.propertySheet-»
60
«EXPAND xpt::providers::extensions::extensions FOR editorGen.diagram-»
61
«EXPAND xpt::navigator::extensions::extensions FOR editorGen.navigator-»
62
«EXPAND xpt::application::extensions::extensions FOR editorGen.application-»
63
«EXPAND xpt::ConstraintProviders::extensions FOR editorGen-»
64
«EXPAND xpt::diagram::updater::extensions::extensions FOR editorGen.diagramUpdater-»
65
«EXPAND xpt::plugin::plugin::additions-»
66
</plugin>
67
«ENDAROUND»
68
22
69
23
«AROUND additions FOR gmfgen::GenPlugin»
70
«AROUND additions FOR gmfgen::GenPlugin»
24
«EXPAND contributionItemProviders FOREACH editorGen.diagram.topLevelNodes»
71
«EXPAND contributionItemProviders FOREACH editorGen.diagram.topLevelNodes»
(-)dynamic-templates/codegen/aspects/xpt/editor/NewDiagramFileWizard.xpt (+167 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2007 Borland Software Corporation
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Alexander Shatalin (Borland) - initial API and implementation
11
 *    Dmitry Stadnik (Borland) - rewritten in xpand
12
 *    Tatiana Fesenko (Borland) - fix for bugzilla #230873 'Make diagram file extension shorter' 
13
 */
14
15
«IMPORT "http://www.eclipse.org/gmf/2006/GenModel"»
16
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
17
18
«EXTENSION xpt::editor::Utils»
19
«EXTENSION aspects::xpt::FileExtensionUtils»
20
21
«AROUND NewDiagramFileWizard FOR gmfgen::GenDiagram-»
22
«EXPAND xpt::Common::copyright FOR editorGen-»
23
package «editorGen.editor.packageName»;
24
25
«EXPAND xpt::Common::generatedClassComment»
26
public class «EXPAND xpt::editor::NewDiagramFileWizard::className» extends org.eclipse.jface.wizard.Wizard {
27
28
	«EXPAND xpt::Common::generatedMemberComment»
29
	private «EXPAND xpt::editor::NewDiagramFileWizard::creationPage» myFileCreationPage;
30
31
	«EXPAND xpt::Common::generatedMemberComment»
32
	private «EXPAND xpt::editor::ModelElementSelectionPage::qualifiedClassName» diagramRootElementSelectionPage;
33
34
	«EXPAND xpt::Common::generatedMemberComment»
35
	private org.eclipse.emf.transaction.TransactionalEditingDomain myEditingDomain;
36
37
	«EXPAND xpt::Common::generatedMemberComment»
38
	public «EXPAND xpt::editor::NewDiagramFileWizard::className»(org.eclipse.emf.common.util.URI domainModelURI,
39
			org.eclipse.emf.ecore.EObject diagramRoot,
40
			org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) {
41
		assert domainModelURI != null : "Domain model uri must be specified"; «EXPAND xpt::Common::nonNLS»
42
	    assert diagramRoot != null : "Doagram root element must be specified"; «EXPAND xpt::Common::nonNLS»
43
	    assert editingDomain != null : "Editing domain must be specified"; «EXPAND xpt::Common::nonNLS»
44
45
		myFileCreationPage = new «EXPAND xpt::editor::NewDiagramFileWizard::creationPage»(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardCreationPage().nameKey()) FOR editorGen», org.eclipse.jface.viewers.StructuredSelection.EMPTY);
46
		myFileCreationPage.setTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardCreationPage().titleKey()) FOR editorGen»);
47
		myFileCreationPage.setDescription(org.eclipse.osgi.util.NLS.bind(
48
				«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardCreationPage().descriptionKey()) FOR editorGen», 
49
				«EXPAND xpt::editor::VisualIDRegistry::modelID»));
50
		org.eclipse.core.runtime.IPath filePath;
51
		String fileName = domainModelURI.trimFileExtension().lastSegment();
52
		if (domainModelURI.isPlatformResource()) {
53
			filePath = new org.eclipse.core.runtime.Path(domainModelURI.trimSegments(1).toPlatformString(true));
54
		} else if (domainModelURI.isFile()) {
55
			filePath = new org.eclipse.core.runtime.Path(domainModelURI.trimSegments(1).toFileString());
56
		} else {
57
			// TODO : use some default path
58
			throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); «EXPAND xpt::Common::nonNLS»
59
		}
60
		myFileCreationPage.setContainerFullPath(filePath);
61
		«REM» #230873 'Make diagram file extension shorter'
62
		The only change is here. We take the first extension from the comma-separated list«ENDREM-»
63
		myFileCreationPage.setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
64
				filePath, fileName, "«editorGen.getDefaultDiagramExtension()»")); «EXPAND xpt::Common::nonNLS»
65
		«REM»End of the only change«ENDREM-»
66
		diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPage().nameKey()) FOR editorGen»);
67
		diagramRootElementSelectionPage.setTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPage().titleKey()) FOR editorGen»);
68
		diagramRootElementSelectionPage.setDescription(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPage().descriptionKey()) FOR editorGen»);
69
		diagramRootElementSelectionPage.setModelElement(diagramRoot);
70
71
	   	myEditingDomain = editingDomain;
72
	}
73
74
	«EXPAND xpt::Common::generatedMemberComment»
75
	public void addPages() {
76
		addPage(myFileCreationPage);
77
		addPage(diagramRootElementSelectionPage);
78
	}
79
80
	«EXPAND xpt::Common::generatedMemberComment»
81
	public boolean performFinish() {
82
		java.util.List affectedFiles = new java.util.LinkedList();
83
		«IF null == editorGen.application-»
84
		org.eclipse.core.resources.IFile diagramFile = myFileCreationPage.createNewFile();
85
		«EXPAND xpt::Common::setCharset("diagramFile")-»
86
		affectedFiles.add(diagramFile);
87
		org.eclipse.emf.common.util.URI diagramModelURI = org.eclipse.emf.common.util.URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
88
		«ELSE-»
89
		org.eclipse.core.runtime.IPath diagramModelPath = myFileCreationPage.getContainerFullPath().append(myFileCreationPage.getFileName());
90
		org.eclipse.emf.common.util.URI diagramModelURI = org.eclipse.emf.common.util.URI.createFileURI(diagramModelPath.toString());
91
		«ENDIF-»
92
		org.eclipse.emf.ecore.resource.ResourceSet resourceSet = myEditingDomain.getResourceSet();
93
		final org.eclipse.emf.ecore.resource.Resource diagramResource = resourceSet.createResource(diagramModelURI);
94
		org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand command =
95
			new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(
96
				myEditingDomain, «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardInitDiagramCommand()) FOR editorGen», affectedFiles) {
97
98
			protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(
99
					org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
100
						throws org.eclipse.core.commands.ExecutionException {
101
				int diagramVID = «EXPAND xpt::editor::VisualIDRegistry::getDiagramVisualIDMethodCall»(diagramRootElementSelectionPage.getModelElement());
102
				if (diagramVID != «EXPAND xpt::editor::VisualIDRegistry::visualID») {
103
					return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult(
104
						«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardIncorrectRootError()) FOR editorGen»);
105
				}
106
				org.eclipse.gmf.runtime.notation.Diagram diagram =
107
					org.eclipse.gmf.runtime.diagram.core.services.ViewService.createDiagram(
108
						diagramRootElementSelectionPage.getModelElement(), «EXPAND xpt::editor::VisualIDRegistry::modelID»,
109
						«editorGen.plugin.getActivatorQualifiedClassName()».DIAGRAM_PREFERENCES_HINT);
110
				diagramResource.getContents().add(diagram);
111
				«IF editorGen.sameFileForDiagramAndModel-»
112
				diagramResource.getContents().add(diagram.getElement());
113
				«ENDIF-»
114
				«IF !synchronized-»
115
				new «getDiagramContentInitializerQualifiedClassName()»().initDiagramContent(diagram);			
116
				«ENDIF-»
117
				return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
118
			}
119
		};
120
		try {
121
			org.eclipse.core.commands.operations.OperationHistoryFactory.getOperationHistory().execute(
122
				command, new org.eclipse.core.runtime.NullProgressMonitor(), null);
123
			diagramResource.save(«EXPAND xpt::Common::getSaveOptions»);
124
			«getDiagramEditorUtilQualifiedClassName()».openDiagram(diagramResource);
125
		} catch (org.eclipse.core.commands.ExecutionException e) {
126
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
127
				"Unable to create model and diagram", e); «EXPAND xpt::Common::nonNLS»
128
		} catch (java.io.IOException ex) {
129
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
130
				"Save operation failed for: " + diagramModelURI, ex); «EXPAND xpt::Common::nonNLS»
131
		} catch (org.eclipse.ui.PartInitException ex) {
132
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
133
				"Unable to open editor", ex); «EXPAND xpt::Common::nonNLS»
134
		}			
135
		return true;
136
	}
137
138
	«EXPAND xpt::Common::generatedClassComment»
139
	private static class DiagramRootElementSelectionPage extends «EXPAND xpt::editor::ModelElementSelectionPage::qualifiedClassName» {
140
141
		«EXPAND xpt::Common::generatedMemberComment»
142
		protected DiagramRootElementSelectionPage(String pageName) {
143
			super(pageName);
144
		}
145
146
		«EXPAND xpt::Common::generatedMemberComment»
147
		protected String getSelectionTitle() {
148
			return «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPageSelectionTitle()) FOR editorGen»;
149
		}
150
151
		«EXPAND xpt::Common::generatedMemberComment»
152
		protected boolean validatePage() {
153
			if (selectedModelElement == null) {
154
				setErrorMessage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPageNoSelectionMessage()) FOR editorGen»);
155
				return false;
156
			}
157
			boolean result = org.eclipse.gmf.runtime.diagram.core.services.ViewService.getInstance().provides(
158
				new org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation(
159
					new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(selectedModelElement),
160
					«EXPAND xpt::editor::VisualIDRegistry::modelID»,
161
					«editorGen.plugin.getActivatorQualifiedClassName()».DIAGRAM_PREFERENCES_HINT));
162
			setErrorMessage(result ? null : «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPageInvalidSelectionMessage()) FOR editorGen»);
163
			return result;
164
		}
165
	}
166
}
167
«ENDAROUND»
(-)dynamic-templates/codegen/aspects/xpt/editor/UriEditorInputTester.xpt (+31 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2007 Borland Software Corporation
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Alexander Shatalin (Borland) - initial API and implementation
11
 *    Tatiana Fesenko (Borland) - fix for bugzilla #230873 'Make diagram file extension shorter' 
12
 */
13
14
«IMPORT "http://www.eclipse.org/gmf/2006/GenModel"»
15
16
«EXTENSION aspects::xpt::FileExtensionUtils»
17
18
«AROUND test FOR gmfgen::GenEditorGenerator-»
19
	«EXPAND xpt::Common::generatedMemberComment»
20
public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
21
	if (false == receiver instanceof org.eclipse.emf.common.ui.URIEditorInput) {
22
		return false;
23
	}
24
	org.eclipse.emf.common.ui.URIEditorInput editorInput = (org.eclipse.emf.common.ui.URIEditorInput) receiver;
25
«REM» #230873 'Make diagram file extension shorter'«ENDREM-»
26
«FOREACH collectAllExtensions() AS dfe ITERATOR iter-»
27
	«IF iter.isFirstIteration()»return «ELSE» || «ENDIF»"«dfe»".equals(editorInput.getURI().fileExtension())«EXPAND xpt::Common::nonNLS»
28
«ENDFOREACH»;
29
«REM» End of #230873«ENDREM-»
30
	}
31
«ENDAROUND»
(-)dynamic-templates/codegen/aspects/xpt/navigator/extensions.xpt (+135 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2007 Borland Software Corporation
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Dmitry Stadnik (Borland) - initial API and implementation
11
 *    Tatiana Fesenko (Borland) - fix for bugzilla #230873 'Make diagram file extension shorter' 
12
 */
13
14
«IMPORT "http://www.eclipse.org/gmf/2006/GenModel"»
15
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
16
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
17
18
«EXTENSION aspects::xpt::FileExtensionUtils»
19
20
«AROUND extensions FOR gmfgen::GenNavigator-»
21
	«EXPAND xpt::navigator::extensions::editorInputPropertyTester("URIEditorInput", "org.eclipse.emf.common.ui.URIEditorInput", getUriInputTesterQualifiedClassName())-»
22
«IF editorGen.diagram.generateShortcutIcon()-»
23
24
	«EXPAND xpt::navigator::extensions::editorInputPropertyTester("Shortcut", "org.eclipse.gmf.runtime.notation.View", editorGen.diagram.getShortcutPropertyTesterQualifiedClassName())-»
25
«ENDIF-»
26
«IF generateDomainModelNavigator && null != editorGen.domainGenModel-»
27
28
	«EXPAND xpt::navigator::extensions::editorInputPropertyTester("DomainModelElement", "org.eclipse.emf.ecore.EObject", getDomainModelElementTesterQualifiedClassName())-»
29
«ENDIF-»
30
31
	«EXPAND xpt::navigator::extensions::registerBindings-»
32
33
   <extension point="org.eclipse.ui.navigator.navigatorContent">
34
      «EXPAND xpt::Common::xmlGeneratedTag»
35
      <navigatorContent
36
            id="«contentExtensionID»" 
37
            name="«contentExtensionName»" 
38
            priority="«contentExtensionPriority»" 
39
            contentProvider="«getContentProviderQualifiedClassName()»" 
40
            labelProvider="«getLabelProviderQualifiedClassName()»"
41
            icon="«editorGen.editor.iconPathX»"
42
            activeByDefault="true">
43
         <triggerPoints>
44
            <or>
45
«REM» #230873 'Make diagram file extension shorter'«ENDREM-»
46
«FOREACH editorGen.collectAllExtensions() AS dfe-»
47
	           <and>
48
    	          <instanceof value="org.eclipse.core.resources.IFile"/>
49
        	      <test property="org.eclipse.core.resources.extension" value="«dfe»"/>
50
               </and>
51
«ENDFOREACH-»
52
«REM» End of #230873«ENDREM-»
53
               <instanceof value="«getAbstractNavigatorItemQualifiedClassName()»"/>
54
«IF editorGen.diagram.generateShortcutIcon()-»
55
           	   <adapt type="org.eclipse.gmf.runtime.notation.View">
56
           	      <test property="«editorGen.plugin.iD».isShortcut"/>
57
           	   </adapt>
58
«ENDIF-»
59
            </or>
60
         </triggerPoints>
61
         <possibleChildren>
62
            <or>
63
         	   <instanceof value="«getAbstractNavigatorItemQualifiedClassName()»"/>
64
«IF editorGen.diagram.generateShortcutIcon()-»
65
           	   <adapt type="org.eclipse.gmf.runtime.notation.View">
66
           	      <test property="«editorGen.plugin.iD».isShortcut"/>
67
           	   </adapt>
68
«ENDIF-»
69
            </or>
70
         </possibleChildren>
71
         <commonSorter 
72
               id="«sorterExtensionID»" 
73
               class="«getSorterQualifiedClassName()»">
74
            <parentExpression>
75
               <or>
76
«REM» #230873 'Make diagram file extension shorter'«ENDREM-»
77
«FOREACH editorGen.collectAllExtensions() AS dfe-»
78
	              <and>
79
    	             <instanceof value="org.eclipse.core.resources.IFile"/>
80
        	         <test property="org.eclipse.core.resources.extension" value="«dfe»"/>
81
                  </and>
82
«ENDFOREACH-»
83
«REM» End of #230873«ENDREM-»
84
                  <instanceof value="«getAbstractNavigatorItemQualifiedClassName()»"/>
85
               </or>
86
            </parentExpression>
87
         </commonSorter>
88
      </navigatorContent>
89
«IF generateDomainModelNavigator && null != editorGen.domainGenModel-»
90
      <navigatorContent
91
            id="«domainContentExtensionID»" 
92
            name="«domainContentExtensionName»" 
93
            priority="«domainContentExtensionPriority»" 
94
            contentProvider="«getDomainContentProviderQualifiedClassName()»" 
95
            labelProvider="«getDomainLabelProviderQualifiedClassName()»"
96
            icon="«editorGen.editor.iconPathX»"
97
            activeByDefault="true">
98
         <triggerPoints>
99
            <or>
100
	           <and>
101
    	          <instanceof value="org.eclipse.core.resources.IFile"/>
102
        	      <test property="org.eclipse.core.resources.extension" value="«editorGen.domainFileExtension»"/>
103
               </and>
104
               <and>
105
                  <instanceof value="org.eclipse.emf.ecore.EObject"/>
106
                  <test property="«editorGen.plugin.iD».isDomainModelElement"/>
107
               </and>
108
            </or>
109
         </triggerPoints>
110
         <possibleChildren>
111
            <and>
112
       	       <instanceof value="org.eclipse.emf.ecore.EObject"/>
113
       	       <test property="«editorGen.plugin.iD».isDomainModelElement"/>
114
       	    </and>
115
         </possibleChildren>
116
      </navigatorContent>
117
«ENDIF-»
118
      <actionProvider
119
            id="«actionProviderID»"
120
            class="«getActionProviderQualifiedClassName()»">
121
         <enablement>
122
            <or>
123
               <instanceof value="«getAbstractNavigatorItemQualifiedClassName()»"/>
124
«IF editorGen.diagram.generateShortcutIcon()-»
125
           	   <adapt type="org.eclipse.gmf.runtime.notation.View">
126
           	      <test property="«editorGen.plugin.iD».isShortcut"/>
127
           	   </adapt>
128
«ENDIF-»
129
            </or>
130
         </enablement>
131
      </actionProvider>
132
   </extension>
133
   
134
	«EXPAND xpt::navigator::extensions::registerLinkHelper-»
135
«ENDAROUND»
(-)dynamic-templates/codegen/aspects/xpt/editor/CreationWizard.xpt (+150 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2007 Borland Software Corporation
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Dmitry Stadnik (Borland) - initial API and implementation
11
 *    Tatiana Fesenko (Borland) - fix for bugzilla #230873 'Make diagram file extension shorter' 
12
 */
13
 
14
«IMPORT "http://www.eclipse.org/gmf/2006/GenModel"»
15
16
«EXTENSION xpt::editor::Utils»
17
«EXTENSION aspects::xpt::FileExtensionUtils»
18
19
«AROUND xpt::editor::CreationWizard::CreationWizard FOR gmfgen::GenDiagram-»
20
«EXPAND xpt::Common::copyright FOR editorGen-»
21
package «editorGen.editor.packageName»;
22
23
«EXPAND xpt::Common::generatedClassComment»
24
public class «creationWizardClassName»
25
		extends org.eclipse.jface.wizard.Wizard implements org.eclipse.ui.INewWizard {
26
27
	«EXPAND xpt::Common::generatedMemberComment»
28
	private org.eclipse.ui.IWorkbench workbench;
29
30
	«EXPAND xpt::Common::generatedMemberComment»
31
    protected org.eclipse.jface.viewers.IStructuredSelection selection;
32
33
	«EXPAND xpt::Common::generatedMemberComment»
34
	protected «getCreationWizardPageQualifiedClassName()» diagramModelFilePage;
35
	«IF isStandaloneDomainModel()-»
36
37
	«EXPAND xpt::Common::generatedMemberComment»
38
	protected «getCreationWizardPageQualifiedClassName()» domainModelFilePage;
39
	«ENDIF-»
40
41
	«EXPAND xpt::Common::generatedMemberComment»
42
	protected org.eclipse.emf.ecore.resource.Resource diagram;
43
44
	«EXPAND xpt::Common::generatedMemberComment»
45
	private boolean openNewlyCreatedDiagramEditor = true;
46
47
	«EXPAND xpt::Common::generatedMemberComment»
48
    public org.eclipse.ui.IWorkbench getWorkbench() {
49
        return workbench;
50
    }
51
52
	«EXPAND xpt::Common::generatedMemberComment»
53
	public org.eclipse.jface.viewers.IStructuredSelection getSelection() {
54
        return selection;
55
    }
56
57
	«EXPAND xpt::Common::generatedMemberComment»
58
	public final org.eclipse.emf.ecore.resource.Resource getDiagram() {
59
		return diagram;
60
	}
61
62
	«EXPAND xpt::Common::generatedMemberComment»
63
	public final boolean isOpenNewlyCreatedDiagramEditor() {
64
		return openNewlyCreatedDiagramEditor;
65
	}
66
67
	«EXPAND xpt::Common::generatedMemberComment»
68
	public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) {
69
		this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
70
	}
71
72
	«EXPAND xpt::Common::generatedMemberComment»
73
	public void init(org.eclipse.ui.IWorkbench workbench, org.eclipse.jface.viewers.IStructuredSelection selection) {
74
        this.workbench = workbench;
75
        this.selection = selection;
76
		setWindowTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizard().titleKey()) FOR editorGen»);
77
		setDefaultPageImageDescriptor(«editorGen.plugin.getActivatorQualifiedClassName()».getBundledImageDescriptor(
78
				"icons/wizban/New«IF domainDiagramElement != null»«domainDiagramElement.genPackage.prefix»«ENDIF»Wizard.gif")); //$NON-NLS-1$
79
		setNeedsProgressMonitor(true);
80
	}
81
82
	«EXPAND xpt::Common::generatedMemberComment»
83
	public void addPages() {
84
		«REM» #230873 'Make diagram file extension shorter'
85
		The only change is here. We take the first extension from the comma-separated list«ENDREM-»
86
		diagramModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
87
				"DiagramModelFile", getSelection(), "«editorGen.getDefaultDiagramExtension()»"); //$NON-NLS-1$ //$NON-NLS-2$
88
		«REM»End of the only change«ENDREM-»
89
		diagramModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardDiagramPage().titleKey()) FOR editorGen»);
90
		diagramModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardDiagramPage().descriptionKey()) FOR editorGen»);
91
		addPage(diagramModelFilePage);
92
	«IF isStandaloneDomainModel()-»
93
94
		domainModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
95
				"DomainModelFile", getSelection(), "«editorGen.domainFileExtension»"); //$NON-NLS-1$ //$NON-NLS-2$
96
		domainModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardDomainPage().titleKey()) FOR editorGen»);
97
		domainModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardDomainPage().descriptionKey()) FOR editorGen»);
98
		addPage(domainModelFilePage);
99
	«ENDIF-»
100
	}
101
102
	«EXPAND xpt::Common::generatedMemberComment»
103
	public boolean performFinish() {
104
		org.eclipse.jface.operation.IRunnableWithProgress op =
105
	«IF editorGen.application == null-»
106
				new org.eclipse.ui.actions.WorkspaceModifyOperation(null) {
107
108
			protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor)
109
					throws org.eclipse.core.runtime.CoreException, InterruptedException {
110
	«ELSE-»
111
				new org.eclipse.jface.operation.IRunnableWithProgress() {
112
113
			public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
114
					throws InvocationTargetException, InterruptedException {
115
	«ENDIF-»
116
				diagram = «getDiagramEditorUtilQualifiedClassName()».createDiagram(diagramModelFilePage.getURI(),
117
	«IF isStandaloneDomainModel()-»
118
						domainModelFilePage.getURI(),
119
	«ENDIF-»
120
						monitor);
121
				if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
122
					try {
123
						«getDiagramEditorUtilQualifiedClassName()».openDiagram(diagram);
124
					} catch (org.eclipse.ui.PartInitException e) {
125
						org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(),
126
								«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardOpenEditorError()) FOR editorGen», null, e.getStatus());
127
					}
128
				}
129
			}
130
		};
131
		try {
132
			getContainer().run(false, true, op);
133
		} catch (InterruptedException e) {
134
			return false;
135
		} catch (java.lang.reflect.InvocationTargetException e) {
136
			if (e.getTargetException() instanceof org.eclipse.core.runtime.CoreException) {
137
				org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(),
138
						«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardCreationError()) FOR editorGen», null,
139
						((org.eclipse.core.runtime.CoreException) e.getTargetException()).getStatus());
140
			} else {
141
				«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
142
						"Error creating diagram", e.getTargetException()); //$NON-NLS-1$
143
			}
144
			return false;
145
		}
146
		return diagram != null;
147
	}
148
	«EXPAND xpt::editor::CreationWizard::additions-»
149
}
150
«ENDAROUND»
(-)dynamic-templates/codegen/aspects/xpt/editor/extensions.xpt (+126 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2007 Borland Software Corporation
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Dmitry Stadnik (Borland) - initial API and implementation
11
 *    Tatiana Fesenko (Borland) - fix for bugzilla #230873 'Make diagram file extension shorter' 
12
 */
13
14
«IMPORT "http://www.eclipse.org/gmf/2006/GenModel"»
15
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
16
17
«EXTENSION aspects::xpt::FileExtensionUtils»
18
19
«AROUND extensions FOR gmfgen::GenEditorGenerator-»
20
   <extension point="org.eclipse.ui.editors">
21
      «EXPAND xpt::Common::xmlGeneratedTag»
22
«REM» #230873 'Make diagram file extension shorter'
23
Change: We iterate over diagramFileExtension _list_ here«ENDREM-»
24
«FOREACH collectAllExtensions() AS dfe-»
25
«REM» End of #230873«ENDREM»
26
      <editor
27
         id="«editor.iD»"
28
         name="%editorName"
29
         icon="«editor.iconPathX»"
30
«REM» #230873: list item is taken here«ENDREM-»
31
         extensions="«dfe»"
32
«REM» End of #230873«ENDREM-»
33
         default="true"
34
         class="«editor.getQualifiedClassName()»"
35
         matchingStrategy="«diagram.getMatchingStrategyQualifiedClassName()»"
36
         contributorClass="«editor.getActionBarContributorQualifiedClassName()»">
37
      </editor>
38
«ENDFOREACH»
39
   </extension>
40
   
41
   <extension point="org.eclipse.ui.contexts">
42
      «EXPAND xpt::Common::xmlGeneratedTag»
43
      <context
44
         description="%context.description"
45
         id="«editor.contextID»"
46
         name="%context.name"
47
         parentId="org.eclipse.gmf.runtime.diagram.ui.diagramContext">
48
      </context>
49
   </extension>
50
51
   <extension point="org.eclipse.ui.newWizards">
52
      «EXPAND xpt::Common::xmlGeneratedTag»
53
  	  <wizard
54
  	     name="%newWizardName"
55
  	     icon="«diagram.creationWizardIconPathX»"
56
  	     category="«diagram.creationWizardCategoryID»"
57
  	     class="«diagram.getCreationWizardQualifiedClassName()»"
58
  	     id="«diagram.getCreationWizardQualifiedClassName()»ID">
59
  	  	 <description>%newWizardDesc</description>  
60
      </wizard>
61
   </extension>
62
63
   <extension point="org.eclipse.ui.popupMenus">
64
      «EXPAND xpt::Common::xmlGeneratedTag»
65
«IF diagram.generateCreateShortcutAction()-»
66
      <objectContribution
67
            adaptable="false"
68
            id="«plugin.iD».CreateShortcut"
69
            objectClass="«diagram.getEditPartQualifiedClassName()»">
70
         <action
71
               class="«diagram.getCreateShortcutActionQualifiedClassName()»"
72
               enablesFor="1"
73
               id="«plugin.iD».CreateShortcutAction"
74
               label="%createShortcutActionLabel"
75
               menubarPath="additions">
76
         </action>
77
      </objectContribution>                      
78
«ENDIF-»
79
      <objectContribution
80
            adaptable="false"
81
            id="«plugin.iD».LoadResource"
82
            objectClass="«diagram.getEditPartQualifiedClassName()»">
83
         <action
84
               class="«diagram.getLoadResourceActionQualifiedClassName()»"
85
               enablesFor="1"
86
               id="«plugin.iD».LoadResourceAction"
87
               label="%loadResourceActionLabel"
88
               menubarPath="additions">
89
         </action>
90
      </objectContribution>           
91
   </extension>
92
«IF diagram.generateInitDiagramAction()-»
93
94
   «IF null == application»<extension point="org.eclipse.ui.popupMenus">
95
      «EXPAND xpt::Common::xmlGeneratedTag»
96
      <objectContribution
97
            id="«plugin.iD».InitDiagram"
98
            nameFilter="*.«domainFileExtension»"
99
            objectClass="org.eclipse.core.resources.IFile">
100
         <action
101
               label="%initDiagramActionLabel"
102
               class="«diagram.getInitDiagramFileActionQualifiedClassName()»"
103
               menubarPath="additions"
104
               enablesFor="1"
105
               id="«plugin.iD».InitDiagramAction">
106
         </action>
107
      </objectContribution>
108
   </extension>
109
	«ELSE-»
110
   <extension point="org.eclipse.ui.actionSets">
111
      «EXPAND xpt::Common::xmlGeneratedTag»
112
      <actionSet
113
            label="%initDiagramActionLabel"
114
            visible="true"
115
            id="«plugin.iD».InitDiagram">
116
         <action
117
               label="%initDiagramActionLabel"
118
               class="«diagram.getInitDiagramFileActionQualifiedClassName()»"
119
               menubarPath="file/additions"
120
               id="«plugin.iD».InitDiagramAction">
121
         </action>
122
      </actionSet>
123
   </extension>
124
	«ENDIF-»
125
«ENDIF-»
126
«ENDAROUND»
(-)dynamic-templates/codegen/aspects/xpt/FileExtensionUtils.ext (+25 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2008 Borland Software Corporation
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 */
10
11
import "http://www.eclipse.org/emf/2002/Ecore";
12
import "http://www.eclipse.org/gmf/2006/GenModel";
13
14
String getDefaultDiagramExtension(GenEditorGenerator generator) :
15
	let extensions = collectAllExtensions(generator):
16
	extensions.isEmpty() ? null : extensions.get(0) 
17
;
18
19
List[String] collectAllExtensions(GenEditorGenerator generator) :
20
	collectAllExtensions(generator.diagramFileExtension)
21
;
22
23
private List[String] collectAllExtensions(String extensionList) :
24
	extensionList.split(",")
25
;

Return to bug 230873