Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2009-02-23 14:53:57 -0500
committeratikhomirov2009-02-23 14:53:57 -0500
commit7bcc8ed79461a6fedff87fab06cf43d16dfd3aca (patch)
tree0378a6a12a1d30caa94997b3f299326c24c1e7f9
parentdfeb922d8de59069329df10e1032659973e9f10a (diff)
downloadorg.eclipse.gmf-tooling-7bcc8ed79461a6fedff87fab06cf43d16dfd3aca.tar.gz
org.eclipse.gmf-tooling-7bcc8ed79461a6fedff87fab06cf43d16dfd3aca.tar.xz
org.eclipse.gmf-tooling-7bcc8ed79461a6fedff87fab06cf43d16dfd3aca.zip
[257119] get rid of excessive ViewFactories
-rw-r--r--plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap1
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java32
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java48
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt91
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt44
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt34
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt54
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt129
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ViewProvider.xpt516
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/extensions.xpt2
13 files changed, 419 insertions, 712 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap b/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap
index 2be7d4c27..9744663a9 100644
--- a/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap
+++ b/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
<uriMap:MappingContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:uriMap="http:///www.eclipse.org/m2m/qvt/oml/MModelUriMap/1.0.0">
<mapping sourceURI="http://www.eclipse.org/gmf/2008/GenModel" targetURI="platform:/resource/org.eclipse.gmf.codegen/models/gmfgen.ecore"/>
+ <mapping sourceURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation" targetURI="platform:/resource/org.eclipse.gmf.runtime.notation/model/notation.ecore"/>
</uriMap:MappingContainer>
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
index fd9bbba0c..78bb2955e 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008 Borland Software Corporation
+ * Copyright (c) 2005, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -229,36 +229,6 @@ public class CodegenEmitters {
return newXpandEmitter("xpt::diagram::editpolicies::TextFeedback::TextNonResizableEditPolicy"); //$NON-NLS-1$
}
- // view factories
-
- public TextEmitter getDiagramViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::DiagramViewFactory"); //$NON-NLS-1$
- }
-
- public TextEmitter getNodeViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::NodeViewFactory"); //$NON-NLS-1$
- }
-
- public TextEmitter getLabelNodeViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::LabelNodeViewFactory"); //$NON-NLS-1$
- }
-
- public TextEmitter getCompartmentViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::CompartmentViewFactory"); //$NON-NLS-1$
- }
-
- public TextEmitter getLinkViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::LinkViewFactory"); //$NON-NLS-1$
- }
-
- public TextEmitter getFloatingLabelViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::FloatingLabelViewFactory"); //$NON-NLS-1$
- }
-
- public TextEmitter getLabelViewFactoryEmitter() throws UnexpectedBehaviourException {
- return getPrimaryEmitter("xpt::diagram::views::LabelViewFactory"); //$NON-NLS-1$
- }
-
// updater
public TextEmitter getDiagramUpdaterEmitter() {
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
index 9c5ee7a0f..1d47a807a 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008 Borland Software Corporation
+ * Copyright (c) 2005, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -145,13 +145,11 @@ public class Generator extends GeneratorBase implements Runnable {
for (GenCompartment compartment : myDiagram.getCompartments()) {
generateCompartmentEditPart(compartment);
generateCompartmentItemSemanticEditPolicy(compartment);
- generateCompartmentViewFactory(compartment);
if (compartment.needsCanonicalEditPolicy()) {
generateChildContainerCanonicalEditPolicy(compartment);
}
}
for (GenLink next: myDiagram.getLinks()) {
- generateLinkViewFactory(next);
generateEditSupport(next);
generateLinkEditPart(next);
generateBehaviours(next);
@@ -170,11 +168,9 @@ public class Generator extends GeneratorBase implements Runnable {
}
for (GenLinkLabel label : next.getLabels()) {
generateLinkLabelEditPart(label);
- generateLinkLabelViewFactory(label);
}
}
generateEditSupport(myDiagram);
- generateDiagramViewFactory();
generateDiagramEditPart();
generateEditPartFactory();
generateElementInitializers();
@@ -290,7 +286,6 @@ public class Generator extends GeneratorBase implements Runnable {
}
private void generateNode(GenNode node) throws UnexpectedBehaviourException, InterruptedException {
- generateNodeViewFactory(node);
generateNodeItemSemanticEditPolicy(node);
if (node.getModelFacet() != null) {
generateCreateNodeCommand(node);
@@ -308,16 +303,13 @@ public class Generator extends GeneratorBase implements Runnable {
if (label instanceof GenExternalNodeLabel) {
GenExternalNodeLabel extLabel = (GenExternalNodeLabel) label;
generateExternalNodeLabelEditPart(extLabel);
- generateExternalNodeLabelViewFactory(extLabel);
} else {
generateNodeLabelEditPart(label);
- generateNodeLabelViewFactory(label);
}
}
}
private void generateChildLabelNode(GenChildLabelNode child) throws UnexpectedBehaviourException, InterruptedException {
- generateLabelNodeViewFactory(child);
generateNodeItemSemanticEditPolicy(child);
if (child.getModelFacet() != null) {
generateCreateNodeCommand(child);
@@ -616,40 +608,6 @@ public class Generator extends GeneratorBase implements Runnable {
doGenerateJavaClass(myEmitters.getMarkerNavigationProviderEmitter(), myDiagram.getMarkerNavigationProviderQualifiedClassName(), myDiagram);
}
- // notation view factories
-
- private void generateDiagramViewFactory() throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getDiagramViewFactoryEmitter(), myDiagram.getNotationViewFactoryQualifiedClassName(), myDiagram);
- }
-
- private void generateNodeViewFactory(GenNode node) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getNodeViewFactoryEmitter(), node.getNotationViewFactoryQualifiedClassName(), node);
- }
-
- private void generateLabelNodeViewFactory(GenChildLabelNode node) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getLabelNodeViewFactoryEmitter(), node.getNotationViewFactoryQualifiedClassName(), node);
- }
-
- private void generateCompartmentViewFactory(GenCompartment compartment) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getCompartmentViewFactoryEmitter(), compartment.getNotationViewFactoryQualifiedClassName(), compartment);
- }
-
- private void generateLinkViewFactory(GenLink link) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getLinkViewFactoryEmitter(), link.getNotationViewFactoryQualifiedClassName(), link);
- }
-
- private void generateNodeLabelViewFactory(GenNodeLabel label) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getLabelViewFactoryEmitter(), label.getNotationViewFactoryQualifiedClassName(), label);
- }
-
- private void generateExternalNodeLabelViewFactory(GenExternalNodeLabel label) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getFloatingLabelViewFactoryEmitter(), label.getNotationViewFactoryQualifiedClassName(), label);
- }
-
- private void generateLinkLabelViewFactory(GenLinkLabel label) throws UnexpectedBehaviourException, InterruptedException {
- doGenerateJavaClass(myEmitters.getFloatingLabelViewFactoryEmitter(), label.getNotationViewFactoryQualifiedClassName(), label);
- }
-
// editor
private void generateValidateAction() throws UnexpectedBehaviourException, InterruptedException {
@@ -1017,8 +975,8 @@ public class Generator extends GeneratorBase implements Runnable {
c.registerFactor(GMFGenPackage.eINSTANCE.getGenChildLabelNode(), 5);
c.registerFactor(GMFGenPackage.eINSTANCE.getGenLink(), 6);
c.registerFactor(GMFGenPackage.eINSTANCE.getGenLinkLabel(), 2);
- c.registerFactor(GMFGenPackage.eINSTANCE.getGenCompartment(), 4);
- c.registerFactor(GMFGenPackage.eINSTANCE.getGenDiagram(), 40);
+ c.registerFactor(GMFGenPackage.eINSTANCE.getGenCompartment(), 3);
+ c.registerFactor(GMFGenPackage.eINSTANCE.getGenDiagram(), 30);
c.registerFactor(GMFGenPackage.eINSTANCE.getGenEditorGenerator(), 2); // i18n=2
c.registerFactor(GMFGenPackage.eINSTANCE.getGenPlugin(), 6);
c.registerFactor(GMFGenPackage.eINSTANCE.getGenNavigator(), 3);
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt
deleted file mode 100644
index fbae97bdf..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-
-«DEFINE CompartmentViewFactory FOR gmfgen::GenCompartment-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.BasicNodeViewFactory {
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- «IF canCollapse-»
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDrawerStyle());
- «ENDIF-»
- «IF needsTitle-»
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createTitleStyle());
- «ENDIF-»
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createSortingStyle());
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFilteringStyle());
- «IF isStoringChildPositions(node.getLayoutType())-»
- «EXPAND xpt::diagram::views::Utils::addShapeStyle('styles') FOR viewmap-»
- «ENDIF-»
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
- org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
- «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
- super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
- setupCompartmentTitle(view);
- setupCompartmentCollapsed(view);
- «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
- }
- «IF isStoringChildPositions(node.getLayoutType())-»
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected org.eclipse.gmf.runtime.notation.LayoutConstraint createLayoutConstraint() {
- return org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds();
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected void initializeFromPreferences(org.eclipse.gmf.runtime.notation.View view) {
- super.initializeFromPreferences(view);
- org.eclipse.jface.preference.IPreferenceStore store =
- (org.eclipse.jface.preference.IPreferenceStore) getPreferencesHint().getPreferenceStore();
- org.eclipse.swt.graphics.RGB fillRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(store,
- org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FILL_COLOR);
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(view,
- org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(),
- org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fillRGB));
- }
- «ENDIF-»
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected void setupCompartmentTitle(org.eclipse.gmf.runtime.notation.View view) {
- org.eclipse.gmf.runtime.notation.TitleStyle titleStyle = (org.eclipse.gmf.runtime.notation.TitleStyle) view.getStyle(
- org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getTitleStyle());
- if (titleStyle != null){
- titleStyle.setShowTitle(true);
- }
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected void setupCompartmentCollapsed(org.eclipse.gmf.runtime.notation.View view) {
- org.eclipse.gmf.runtime.notation.DrawerStyle drawerStyle = (org.eclipse.gmf.runtime.notation.DrawerStyle) view.getStyle(
- org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle());
- if (drawerStyle != null){
- drawerStyle.setCollapsed(false);
- }
- }
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenCompartment»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt
deleted file mode 100644
index 863064c28..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-
-«DEFINE DiagramViewFactory FOR gmfgen::GenDiagram-»
-«EXPAND xpt::Common::copyright FOR editorGen-»
-package «notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.DiagramViewFactory {
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagramStyle());
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
-«IF units <> null-»
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected org.eclipse.gmf.runtime.notation.MeasurementUnit getMeasurementUnit() {
- return org.eclipse.gmf.runtime.notation.MeasurementUnit.«units.toUpper()»_LITERAL;
- }
-«ENDIF-»
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt
deleted file mode 100644
index f50da15e8..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-
-«DEFINE FloatingLabelViewFactory FOR gmfgen::GenLabel-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractLabelViewFactory {
-
- «EXPAND xpt::Common::generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.View createView(org.eclipse.core.runtime.IAdaptable semanticAdapter,
- org.eclipse.gmf.runtime.notation.View containerView, String semanticHint, int index, boolean persisted,
- org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
- org.eclipse.gmf.runtime.notation.Node view = (org.eclipse.gmf.runtime.notation.Node) super.createView(
- semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
- «EXPAND offset-»
- return view;
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- «EXPAND xpt::diagram::views::Utils::addTextStyle('styles') FOR modelFacet-»
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE offset FOR gmfgen::GenLabel-»
-«ENDDEFINE»
-
-«DEFINE offset FOR gmfgen::GenLinkLabel-»
- «LET labelOffsetX(viewmap, 0) AS x-»
- «LET labelOffsetY(viewmap, 0) AS y-»
- «IF x <> 0 or y <> 0-»
- «EXPAND offset(x, y)-»
- «ENDIF-»
- «ENDLET-»
- «ENDLET-»
-«ENDDEFINE»
-
-«DEFINE offset FOR gmfgen::GenExternalNodeLabel-»
- «EXPAND offset(0, 5)-»
-«ENDDEFINE»
-
-«DEFINE offset(x : Integer, y : Integer) FOR gmfgen::GenLabel-»
- org.eclipse.gmf.runtime.notation.Location location = (org.eclipse.gmf.runtime.notation.Location) view.getLayoutConstraint();
- org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode mapMode =
- org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(containerView.getDiagram().getMeasurementUnit());
- location.setX(mapMode.DPtoLP(«x»));
- location.setY(mapMode.DPtoLP(«y»));
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenLabel»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt
deleted file mode 100644
index 78336e585..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-
-«DEFINE LabelNodeViewFactory FOR gmfgen::GenChildLabelNode-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractLabelViewFactory {
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- «EXPAND xpt::diagram::views::Utils::addLinkedDiagramStyle('styles')-»
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
- org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
- «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
- super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
- «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
- «EXPAND xpt::diagram::views::Utils::backgroundColour('view') FOR viewmap-»
- }
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenChildLabelNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt
deleted file mode 100644
index df5f3943b..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-
-«DEFINE LabelViewFactory FOR gmfgen::GenNodeLabel-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.BasicNodeViewFactory {
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- «EXPAND xpt::diagram::views::Utils::addTextStyle('styles') FOR modelFacet-»
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenNodeLabel»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt
deleted file mode 100644
index 654533ca3..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-
-«DEFINE LinkViewFactory FOR gmfgen::GenLink-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.ConnectionViewFactory {
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- «IF not viewmap.isFixedForeground()-»
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createConnectorStyle());
- «ELSE-»
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createRoutingStyle());
- «ENDIF-»
- «IF not viewmap.isFixedFont()-»
- styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFontStyle());
- «ENDIF-»
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
- org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
- «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
- super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
- «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
- «IF labels->size() > 0-»
- org.eclipse.core.runtime.IAdaptable eObjectAdapter = null;
- «EXPAND xpt::diagram::views::Utils::domainElementAdapter('eObjectAdapter') FOR modelFacet-»
- «EXPAND xpt::diagram::views::Utils::createChildNode FOREACH labels-»
- «ENDIF-»
- }
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt
deleted file mode 100644
index 5558f9a0f..000000000
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2007 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
-«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-
-«DEFINE NodeViewFactory FOR gmfgen::GenNode-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().notationViewFactoriesPackageName»;
-
-«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractShapeViewFactory {
-
- «EXPAND createStyles-»
-
- «EXPAND decorateView-»
- «EXPAND additions-»
-}
-«ENDDEFINE»
-
-«DEFINE createStyles FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
- java.util.List styles = new java.util.ArrayList();
- «EXPAND xpt::diagram::views::Utils::addShapeStyle('styles') FOR viewmap-»
- «EXPAND xpt::diagram::views::Utils::addLinkedDiagramStyle('styles')-»
- «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
- return styles;
- }
-«ENDDEFINE»
-
-«DEFINE decorateView FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
- org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
- «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
- super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
- «EXPAND addShortcut-»
- «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
- «EXPAND xpt::diagram::views::Utils::backgroundColour('view') FOR viewmap-»
- «IF labels->size() > 0 or compartments->size() > 0-»
- org.eclipse.core.runtime.IAdaptable eObjectAdapter = null;
- «EXPAND xpt::diagram::views::Utils::domainElementAdapter('eObjectAdapter') FOR modelFacet-»
- «EXPAND xpt::diagram::views::Utils::createChildNode FOREACH labels-»
- «EXPAND xpt::diagram::views::Utils::createChildNode FOREACH compartments-»
- «ENDIF-»
- }
-«ENDDEFINE»
-
-«DEFINE addShortcut FOR gmfgen::GenNode-»
-«ENDDEFINE»
-
-«DEFINE addShortcut FOR gmfgen::GenTopLevelNode-»
- if (!«getDiagram().getEditPartQualifiedClassName()».MODEL_ID.equals(
- «getDiagram().getVisualIDRegistryQualifiedClassName()».getModelID(containerView))) {
- «EXPAND xpt::Common::addShortcutAnnotation('view') FOR getDiagram()-»
- }
-«ENDDEFINE»
-
-«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt
index 33eba2ec3..9b1f3b256 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008 Borland Software Corporation
+ * Copyright (c) 2007, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,104 +8,79 @@
*
* Contributors:
* Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
*/
«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
«EXTENSION xpt::diagram::ViewmapAttributesUtils»
-«EXTENSION xpt::GenModelUtils»
-«DEFINE updateSemanticHint FOR gmfgen::GenCommonBase-»
- if (semanticHint == null) {
- semanticHint = «getDiagram().getVisualIDRegistryQualifiedClassName()».getType(
- «getEditPartQualifiedClassName()».VISUAL_ID);
- view.setType(semanticHint);
- }
-«ENDDEFINE»
-
-«DEFINE createChildNode FOR gmfgen::GenCommonBase-»
- getViewService().createNode(eObjectAdapter, view,
- «getDiagram().getVisualIDRegistryQualifiedClassName()».getType(«getEditPartQualifiedClassName()».VISUAL_ID),
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true, getPreferencesHint());
-«ENDDEFINE»
-
-«DEFINE domainElementAdapter(adapterVar : String) FOR gmfgen::ModelFacet-»
-«ENDDEFINE»
-
-«DEFINE domainElementAdapter(adapterVar : String) FOR gmfgen::TypeModelFacet-»
- org.eclipse.emf.ecore.EObject eObject =
- (org.eclipse.emf.ecore.EObject) semanticAdapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
- if (eObject != null) {
- «adapterVar» = new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(eObject);
- }
-«ENDDEFINE»
-
-«DEFINE foregroundColour(viewVar : String) FOR gmfgen::Viewmap-»
- «EXPAND foregroundColour(viewVar) FOREACH attributes-»
-«ENDDEFINE»
-
-«DEFINE foregroundColour(viewVar : String) FOR gmfgen::Attributes-»
-«ENDDEFINE»
-
-«DEFINE foregroundColour(viewVar : String) FOR gmfgen::ColorAttributes-»
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar»,
- org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(),
- org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger(
- org.eclipse.draw2d.ColorConstants.«foregroundColor»));
+// FIXME ColorAttributes class is deprecated
+«DEFINE foregroundColour(viewVar : String) FOR gmfgen::Viewmap»«EXPAND foregroundColour(viewVar) FOREACH attributes[gmfgen::ColorAttributes]»«ENDDEFINE»
+«DEFINE foregroundColour(viewVar : String) FOR gmfgen::ColorAttributes»org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar», org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(), org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger(org.eclipse.draw2d.ColorConstants.«foregroundColor»));
«ENDDEFINE»
-«DEFINE backgroundColour(viewVar : String) FOR gmfgen::Viewmap-»
- «EXPAND backgroundColour(viewVar) FOREACH attributes-»
+«DEFINE backgroundColour(viewVar : String) FOR gmfgen::Viewmap»«EXPAND backgroundColour(viewVar) FOREACH attributes[gmfgen::ColorAttributes]»«ENDDEFINE»
+«DEFINE backgroundColour(viewVar : String) FOR gmfgen::ColorAttributes»org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar», org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(), org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger(org.eclipse.draw2d.ColorConstants.«backgroundColor»));
«ENDDEFINE»
-«DEFINE backgroundColour(viewVar : String) FOR gmfgen::Attributes-»
+«DEFINE addFontLineFillStylesConditionally(stylesVar : String) FOR gmfgen::Viewmap-»
+«IF not self.isFixedFont()-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFontStyle());
+«ENDIF-»
+«IF not self.isFixedForeground()-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLineStyle());
+«ENDIF-»
+«IF not self.isFixedBackground()-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFillStyle());
+«ENDIF-»
«ENDDEFINE»
-«DEFINE backgroundColour(viewVar : String) FOR gmfgen::ColorAttributes-»
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar»,
- org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(),
- org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger(
- org.eclipse.draw2d.ColorConstants.«backgroundColor»));
+«DEFINE addTextStyle(stylesVar : String) FOR gmfgen::LabelModelFacet»«ENDDEFINE»
+«DEFINE addTextStyle(stylesVar : String) FOR gmfgen::DesignLabelModelFacet»«stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());
«ENDDEFINE»
-«DEFINE addShapeStyle(stylesVar : String) FOR gmfgen::Viewmap-»
- «IF isFixedFont(self)-»
- «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());
- «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFillStyle());
- «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLineStyle());
- «ELSE-»
- «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShapeStyle());
- «ENDIF-»
+«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::GenCommonBase»«EXPAND addLinkedDiagramStyle(stylesVar) FOREACH behaviour»«ENDDEFINE»
+«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::Behaviour»«ENDDEFINE»
+«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::OpenDiagramBehaviour-»
+«IF diagramKind <> null-»
+ {
+ org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle diagramFacet = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createHintedDiagramLinkStyle();
+ diagramFacet.setHint("«diagramKind»");«EXPAND xpt::Common::nonNLS»
+ «stylesVar».add(diagramFacet);
+ }
+«ELSE-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createHintedDiagramLinkStyle());
+«ENDIF-»
«ENDDEFINE»
-«DEFINE addTextStyle(stylesVar : String) FOR gmfgen::LabelModelFacet-»
+«DEFINE addCustomStyles(stylesVar : String) FOR gmfgen::GenCommonBase-»
+«FOREACH styles AS style-»
+ «stylesVar».add(«EXPAND MetaModel::NewInstance FOR style»);
+«ENDFOREACH-»
«ENDDEFINE»
-«DEFINE addTextStyle(stylesVar : String) FOR gmfgen::DesignLabelModelFacet-»
- «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());
-«ENDDEFINE»
+// external node and link labels' offset
-«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::GenCommonBase-»
- «EXPAND addLinkedDiagramStyle(stylesVar) FOREACH behaviour-»
-«ENDDEFINE»
+«DEFINE offset(String viewVar) FOR gmfgen::GenLabel»«ENDDEFINE»
-«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::Behaviour-»
+«DEFINE offset(String viewVar) FOR gmfgen::GenLinkLabel-»
+«IF labelOffsetX(viewmap, 0) <> 0 or labelOffsetY(viewmap, 0) <> 0-»
+ «EXPAND offset(viewVar, labelOffsetX(viewmap, 0), labelOffsetY(viewmap, 0))-»
+«ENDIF-»
«ENDDEFINE»
-«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::OpenDiagramBehaviour-»
- {
- org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle diagramFacet =
- org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createHintedDiagramLinkStyle();
- «IF diagramKind <> null-»
- diagramFacet.setHint("«diagramKind»"); // $NON-NLS-1$
- «ENDIF-»
- «stylesVar».add(diagramFacet);
- }
-«ENDDEFINE»
+«DEFINE offset(String viewVar) FOR gmfgen::GenExternalNodeLabel»«EXPAND offset(viewVar, 0, 5)»«ENDDEFINE»
-«DEFINE addCustomStyles(stylesVar : String) FOR gmfgen::GenCommonBase-»
- «FOREACH styles->asSequence() AS style-»
- «stylesVar».add(«EXPAND MetaModel::NewInstance FOR style»);
- «ENDFOREACH-»
+// viewVar must be already inserted into a diagram (view.getDiagram() should be meaningful)
+«DEFINE offset(String viewVar, x : Integer, y : Integer) FOR gmfgen::GenLabel-»
+ org.eclipse.gmf.runtime.notation.Location location«visualID» = (org.eclipse.gmf.runtime.notation.Location) «viewVar».getLayoutConstraint();
+«IF self.getDiagram().units <> 'Pixel'-»
+ location«visualID».setX(org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(«viewVar».getDiagram().getMeasurementUnit()).DPtoLP(«x»));
+ location«visualID».setY(org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(«viewVar».getDiagram().getMeasurementUnit()).DPtoLP(«y»));
+«ELSE-»
+ location«visualID».setX(«x»);
+ location«visualID».setY(«y»);
+«ENDIF-»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ViewProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ViewProvider.xpt
index cff29374d..539aa7536 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ViewProvider.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ViewProvider.xpt
@@ -8,6 +8,7 @@
*
* Contributors:
* Alexander Shatalin (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
*/
«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
@@ -15,211 +16,416 @@
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
«EXTENSION xpt::diagram::Utils»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+«EXTENSION xpt::diagram::editpolicies::LinkUtils»
«DEFINE ViewProvider FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
package «providersPackageName»;
«EXPAND xpt::Common::generatedClassComment»
-public class «notationViewProviderClassName» extends org.eclipse.gmf.runtime.diagram.core.providers.AbstractViewProvider {
- «EXPAND getDiagramViewClass-»
- «EXPAND getNodeViewClass-»
- «EXPAND getEdgeViewClass-»
- «EXPAND getSemanticElementType-»
- «EXPAND additions-»
-}
-«ENDDEFINE»
+public class «notationViewProviderClassName»«EXPAND extendsList»«EXPAND implementsList» {
-«DEFINE getDiagramViewClass FOR gmfgen::GenDiagram-»
-
-«EXPAND xpt::Common::generatedMemberComment»
-protected Class getDiagramViewClass(org.eclipse.core.runtime.IAdaptable semanticAdapter, String diagramKind) {
- «REM»When diagram domain element is null only diagram kind is checked«ENDREM-»
- «EXPAND defineSemanticElement FOR domainDiagramElement-»
- if («EXPAND xpt::editor::VisualIDRegistry::modelID».equals(diagramKind)«EXPAND checkSemanticElement(self) FOR domainDiagramElement») {
- return «getNotationViewFactoryQualifiedClassName()».class;
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) {
+ if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation) operation);
+ }
+ «EXPAND xpt::Common::_assert('operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation')-»
+ if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation) operation);
+ } else if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation) operation);
+ } else if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation) operation);
+ }
+ return false;
}
- return null;
-}
-«ENDDEFINE»
-
-«DEFINE defineSemanticElement FOR genmodel::GenClass-»
-org.eclipse.emf.ecore.EObject semanticElement = getSemanticElement(semanticAdapter);
-«ENDDEFINE»
-«DEFINE checkSemanticElement(diagram : gmfgen::GenDiagram) FOR genmodel::GenClass» && «EXPAND xpt::editor::VisualIDRegistry::getDiagramVisualIDMethodCall FOR diagram»(semanticElement) != -1«ENDDEFINE»
-
-«DEFINE getNodeViewClass FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation op) {
+/*
+ if (op.getViewKind() == Node.class)
+ return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ if (op.getViewKind() == Edge.class)
+ return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+*/
+ return true;
+ }
-«EXPAND xpt::Common::generatedMemberComment»
-protected Class getNodeViewClass(org.eclipse.core.runtime.IAdaptable semanticAdapter,
- org.eclipse.gmf.runtime.notation.View containerView, String semanticHint) {
- if (containerView == null) {
- return null;
+ «EXPAND xpt::Common::generatedMemberComment»«REM»When diagram domain element is null only diagram kind is checked«ENDREM»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation op) {
+ return «EXPAND xpt::editor::VisualIDRegistry::modelID».equals(op.getSemanticHint())«IF domainDiagramElement <> null» && «EXPAND xpt::editor::VisualIDRegistry::getDiagramVisualIDMethodCall»(getSemanticElement(op.getSemanticAdapter())) != -1«ENDIF»;
}
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(semanticAdapter);
- org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(semanticAdapter);
- int visualID;
- if (semanticHint == null) {
- // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
- // In this situation there should be NO elementType, visualID will be determined
- // by VisualIDRegistry.getNodeVisualID() for domainElement.
- if (elementType != null || domainElement == null) {
- return null;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation op) {
+ if (op.getContainerView() == null) {
+ return false;
}
- visualID = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(containerView, domainElement);
- } else {
- visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(semanticHint);
- if (elementType != null) {
- // Semantic hint is specified together with element type.
- // Both parameters should describe exactly the same diagram element.
- // In addition we check that visualID returned by VisualIDRegistry.getNodeVisualID() for
- // domainElement (if specified) is the same as in element type.
- if (!«getElementTypesQualifiedClassName()».isKnownElementType(elementType)
- || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
- return null; // foreign element type
- }
- String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
- if (!semanticHint.equals(elementTypeHint)) {
- return null; // if semantic hint is specified it should be the same as in element type
- }
- if (domainElement != null && visualID != «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(containerView, domainElement)) {
- return null; // visual id for node EClass should match visual id from element type
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ int visualID;
+ if (op.getSemanticHint() == null) {
+ // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
+ // In this situation there should be NO elementType, visualID will be determined
+ // by VisualIDRegistry.getNodeVisualID() for domainElement.
+ if (elementType != null || domainElement == null) {«REM»XXX Perhaps, better to fix CanonicalEP instead of this hack?«ENDREM»
+ return false;
}
+ visualID = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(op.getContainerView(), domainElement);
} else {
- // Element type is not specified. Domain element should be present (except pure design elements).
- // This method is called with EObjectAdapter as parameter from:
- // - ViewService.createNode(View container, EObject eObject, String type, PreferencesHint preferencesHint)
- // - generated ViewFactory.decorateView() for parent element
- «IF getAllTypedElements()->select(e | e.elementType <> null)->size() > 0-»
- if (!«getEditPartQualifiedClassName()».MODEL_ID.equals(«getVisualIDRegistryQualifiedClassName()».getModelID(containerView))) {
- return null; // foreign diagram
- }
- switch (visualID) {
- «IF getAllNodes().elementType[gmfgen::NotationType]->size() > 0-»
- «EXPAND caseVisualID FOREACH getAllNodes().elementType[gmfgen::NotationType]-»
- break; // pure design element
- «ENDIF-»
- «IF getAllNodes().elementType[gmfgen::MetamodelType]->size() > 0 or getAllNodes().elementType[gmfgen::SpecializationType]->size() > 0-»
- «EXPAND caseVisualID FOREACH getAllNodes().elementType[gmfgen::MetamodelType]-»
- «EXPAND caseVisualID FOREACH getAllNodes().elementType[gmfgen::SpecializationType]-»
- if (domainElement == null || visualID != «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(containerView, domainElement)) {
- return null; // visual id in semantic hint should match visual id for domain element
+ visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(op.getSemanticHint());
+ if (elementType != null) {«REM»
+ Semantic hint is specified together with element type.
+ Both parameters should describe exactly the same diagram element.
+ In addition we check that visualID returned by VisualIDRegistry.getNodeVisualID() for
+ domainElement (if specified) is the same as in element type.«ENDREM»
+ if (!«getElementTypesQualifiedClassName()».isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
+ return false; // foreign element type
}
- break;
- «ENDIF-»
- «EXPAND checkChildrenVisualIDs FOREACH getAllTypedElements()->select(e | e.elementType <> null)-»
- default:
- return null;
- }
- «ELSE-»
- return null;
+ String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
+ if (!op.getSemanticHint().equals(elementTypeHint)) {
+ return false; // if semantic hint is specified it should be the same as in element type
+ }
+ if (domainElement != null && visualID != «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(op.getContainerView(), domainElement)) {
+ return false; // visual id for node EClass should match visual id from element type
+ }
+ } else {«REM»
+ Element type is not specified. Domain element should be present (except pure design elements).
+ This method is called with EObjectAdapter as parameter from:
+ - ViewService.createNode(View container, EObject eObject, String type, PreferencesHint preferencesHint)
+ - generated ViewFactory.decorateView() for parent element«ENDREM»
+«IF getAllTypedElements()->select(e | e.elementType <> null)->size() > 0-»
+ if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(«EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(op.getContainerView()))) {
+ return false; // foreign diagram
+ }
+ switch (visualID) {
+ «IF getAllNodes().elementType[gmfgen::NotationType]->size() > 0-»
+ «EXPAND caseVisualID FOREACH getAllNodes().elementType[gmfgen::NotationType]-»
+ break; // pure design element
+ «ENDIF-»
+ «IF getAllNodes().elementType[gmfgen::MetamodelType]->size() > 0 or getAllNodes().elementType[gmfgen::SpecializationType]->size() > 0-»
+ «EXPAND caseVisualID FOREACH getAllNodes().elementType[gmfgen::MetamodelType]-»
+ «EXPAND caseVisualID FOREACH getAllNodes().elementType[gmfgen::SpecializationType]-»
+ if (domainElement == null || visualID != «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(op.getContainerView(), domainElement)) {
+ return false; // visual id in semantic hint should match visual id for domain element
+ }
+ break;«REM»FIXME: Perhaps, can return true or false right away, without any further check?«ENDREM»
«ENDIF-»
+ default:
+ return false;
+ }
+«ELSE-»
+ return false;
+«ENDIF-»
+ }
}
+ return «FOREACH getAllNodes() AS n SEPARATOR '||'»«EXPAND xpt::editor::VisualIDRegistry::visualID FOR n» == visualID«ENDFOREACH»;
}
- return getNodeViewClass(containerView, visualID);
-}
-«EXPAND xpt::Common::generatedMemberComment»
-protected Class getNodeViewClass(org.eclipse.gmf.runtime.notation.View containerView, int visualID) {
- if (containerView == null || !«EXPAND xpt::editor::VisualIDRegistry::canCreateNodeMethodCall»(containerView, visualID)) {
+ «EXPAND xpt::Common::generatedMemberComment»«REM»XXX: unlike createNode, we don't check op.containerView() for null here. On purpose?«ENDREM»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation op) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ if (!«getElementTypesQualifiedClassName()».isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
+ return false; // foreign element type
+ }
+ String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
+ if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
+ return false; // our hint is visual id and must be specified, and it should be the same as in element type
+ }
+ int visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(elementTypeHint);
+ org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ if (domainElement != null && visualID != «EXPAND xpt::editor::VisualIDRegistry::getLinkWithClassVisualIDMethodCall»(domainElement)) {
+ return false; // visual id for link EClass should match visual id from element type
+ }
+ return true; «REM»Does it make sense to check visualID here, like we did for nodes?«ENDREM»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Diagram createDiagram(org.eclipse.core.runtime.IAdaptable semanticAdapter, String diagramKind, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagram();«REM»FIXME instantiate diagramRunTimeClass instead«ENDREM»
+ diagram.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagramStyle());
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('diagram.getStyles()')-»
+ diagram.setType(«EXPAND xpt::editor::VisualIDRegistry::modelID»);
+ diagram.setElement(«IF domainDiagramElement <> null»getSemanticElement(semanticAdapter)«ELSE»null«ENDIF»);
+«IF units <> null-»
+ diagram.setMeasurementUnit(org.eclipse.gmf.runtime.notation.MeasurementUnit.«units.toUpper()»_LITERAL);
+«ENDIF-»
+«IF styles->notEmpty()-»
+ // initializeFromPreferences
+ org.eclipse.jface.preferences.IPreferenceStore store = (org.eclipse.jface.preferences.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «EXPAND initializeStyles('diagram', 'store', false, false, false)-»
+«ENDIF-»
+ return diagram;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Node createNode(org.eclipse.core.runtime.IAdaptable semanticAdapter, org.eclipse.gmf.runtime.notation.View containerView, String semanticHint, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ final org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(semanticAdapter);
+ final int visualID;
+ if (semanticHint == null) {
+ visualID = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(containerView, domainElement);
+ } else {
+ visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(semanticHint);
+ }
+ switch(visualID) {
+ «FOREACH getAllNodes() AS n-»
+ «EXPAND xpt::Common::caseVisualID FOR n» return create«n.getUniqueIdentifier()»(domainElement, containerView, index, persisted, preferencesHint);
+ «ENDFOREACH-»
+ }
+ // can't happen, provided #provides(CreateNodeViewOperation) is correct
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Edge createEdge(org.eclipse.core.runtime.IAdaptable semanticAdapter, org.eclipse.gmf.runtime.notation.View containerView, String semanticHint, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(semanticAdapter);
+ String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(elementTypeHint)) {
+ «FOREACH links AS link-»
+ «EXPAND xpt::Common::caseVisualID FOR link» return create«link.getUniqueIdentifier()»(«IF link.isTypeLink()» getSemanticElement(semanticAdapter), «ENDIF»containerView, index, persisted, preferencesHint);
+ «ENDFOREACH-»
+ }
+ // can never happen, provided #provides(CreateEdgeViewOperation) is correct
return null;
}
- switch (visualID) {
- «EXPAND caseContainerVisualID FOREACH getAllChildContainers()-»
- «EXPAND caseEntry FOREACH links.labels-»
+
+«EXPAND createNodeMethod FOREACH getAllNodes()»
+«EXPAND createEdgeMethod FOREACH links»
+
+«IF topLevelNodes->notEmpty()»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private void stampShortcut(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.Node target) {
+ if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(«EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(containerView))) {
+ «EXPAND xpt::Common::addShortcutAnnotation('target')-»
+ }
+ }
+«ENDIF-»
+
+«IF links.labels->notEmpty() or topLevelNodes.labels->notEmpty() or childNodes.labels->notEmpty()»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.Node createLabel(org.eclipse.gmf.runtime.notation.View owner, String hint) {
+ org.eclipse.gmf.runtime.notation.DecorationNode rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDecorationNode();
+ rv.setType(hint);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(owner, rv, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true);
+ return rv;
+ }
+«ENDIF-»
+
+«IF getAllNodes().compartments->notEmpty()»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.Node createCompartment(org.eclipse.gmf.runtime.notation.View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
+ //SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
+ //rv.setShowTitle(showTitle);
+ //rv.setCollapsed(isCollapsed);
+ org.eclipse.gmf.runtime.notation.Node rv;
+ if (canCollapse) {
+ rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBasicCompartment();
+ } else {
+ rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDecorationNode();
+ }
+ if (hasTitle) {
+ org.eclipse.gmf.runtime.notation.TitleStyle ts = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createTitleStyle();
+ ts.setShowTitle(true);
+ rv.getStyles().add(ts);
+ }
+ if (canSort) {
+ rv.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createSortingStyle());
+ }
+ if (canFilter) {
+ rv.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFilteringStyle());
+ }
+ rv.setType(hint);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(owner, rv, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true);
+ return rv;
}
- return null;
+«ENDIF-»
+ «EXPAND getSemanticElementMethod»
+ «EXPAND getSemanticElementTypeMethod-»
+ «EXPAND additions-»
}
«ENDDEFINE»
-«DEFINE caseVisualID FOR gmfgen::ElementType-»
- «EXPAND xpt::Common::caseVisualID FOR diagramElement»
+«DEFINE createNodeMethod FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Node create«getUniqueIdentifier()»(org.eclipse.emf.ecore.EObject domainElement, org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+«IF viewmap.canUseShapeStyle()-»
+ org.eclipse.gmf.runtime.notation.Shape node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShape();
+«ELSE-»
+ org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createNode();
+ node.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());«REM»FIXME Contionally add this style, whether toolsmith needs Notes or not«ENDREM»
+ «EXPAND xpt::diagram::views::Utils::addFontLineFillStylesConditionally('node.getStyles()') FOR viewmap-»
+«ENDIF-»
+ «EXPAND xpt::diagram::views::Utils::addLinkedDiagramStyle('node.getStyles()')-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('node.getStyles()')-»
+ node.setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds());
+ node.setType(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+«IF self.oclIsTypeOf(gmfgen::GenTopLevelNode)-»
+ stampShortcut(containerView, node);
+«ENDIF-»
+ // initializeFromPreferences «REM»XXX Perhaps, do init only once, for complete figure?«ENDREM»
+ final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «EXPAND initializeStyles('node', 'prefStore', not viewmap.isFixedForeground(), not viewmap.isFixedBackground(), not viewmap.isFixedFont())-»
+ «EXPAND initLabel('node', 'prefStore') FOREACH labels-»
+ «EXPAND initCompartment('node', 'prefStore') FOREACH compartments-»
+ return node;
+ }
«ENDDEFINE»
-«DEFINE checkChildrenVisualIDs FOR gmfgen::GenCommonBase-»
+// Location as layoutConstraint, no children
+«DEFINE createNodeMethod FOR gmfgen::GenChildLabelNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Node create«getUniqueIdentifier()»(org.eclipse.emf.ecore.EObject domainElement, org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createNode();
+ node.setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLocation());«REM»[artem] XXX not sure, why LabelNode needs location«ENDREM»
+ «EXPAND xpt::diagram::views::Utils::addLinkedDiagramStyle('node.getStyles()')-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('node.getStyles()')-»
+ node.setType(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+«IF styles->notEmpty()-»
+ final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «EXPAND initializeStyles('node', 'prefStore', false, false, false)-»
+«ENDIF-»
+ return node;
+ }
«ENDDEFINE»
-«DEFINE checkChildrenVisualIDs FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::caseVisualID FOREACH labels-»
- «EXPAND xpt::Common::caseVisualID FOREACH compartments-»
- «IF not labels->isEmpty() or not compartments->isEmpty()-»
-if («EXPAND xpt::editor::VisualIDRegistry::visualID» != «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(containerView)
- || containerView.getElement() != domainElement) {
- return null; // wrong container
-}
-break;
+// looks for Font/Line/Fill styles in customStyles and initializes, if any (may be forced with boolean params)
+// params has*Style are to force respective style initialization (when callee knows certain style was added)
+«DEFINE initializeStyles(String viewVar, String prefStoreVar, Boolean hasLineStyle, Boolean hasFillStyle, Boolean hasFontStyle) FOR gmfgen::GenCommonBase-»
+«IF hasLineStyle or self.hasLineStyleInCustom()-»
+ «REM»FIXME ColorAttributes is deprecated, should remove and clean the second branch of the disjunction«ENDREM»
+ «IF viewmap.isFixedForeground() or viewmap.attributes[gmfgen::ColorAttributes]->notEmpty()-»
+ «EXPAND xpt::diagram::views::Utils::foregroundColour(viewVar) FOR viewmap-»
+ «ELSE-»
+ «EXPAND initForegroundFromPrefs(viewVar, prefStoreVar)-»
+ «ENDIF-»
+«ENDIF-»
+«IF (hasFontStyle or self.hasFontStyleInCustom()) and not viewmap.isFixedFont()-»
+ «EXPAND initFontFromPrefs(viewVar, prefStoreVar)-»
+«ENDIF-»
+«IF hasFillStyle or self.hasFillStyleInCustom()-»
+ «IF viewmap.isFixedBackground() or viewmap.attributes[gmfgen::ColorAttributes]->notEmpty()-»
+ «EXPAND xpt::diagram::views::Utils::backgroundColour(viewVar) FOR viewmap-»
+ «ELSE-»
+ «EXPAND initBackgroundFromPrefs(viewVar, prefStoreVar)-»
«ENDIF-»
+«ENDIF-»
«ENDDEFINE»
-«DEFINE checkChildrenVisualIDs FOR gmfgen::GenLink-»
- «EXPAND xpt::Common::caseVisualID FOREACH labels-»
- «IF not labels->isEmpty()-»
-if («EXPAND xpt::editor::VisualIDRegistry::visualID» != «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(containerView)
- || containerView.getElement() != domainElement) {
- return null; // wrong container
-}
-break;
+// FIXME check if there's need for a variable name, see initCompartment for a hint
+«DEFINE initLabel(String nodeVar, String prefStoreVar) FOR gmfgen::GenLabel-»
+ org.eclipse.gmf.runtime.notation.Node «getUniqueIdentifier()» = createLabel(«nodeVar», «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»);
+ «EXPAND xpt::diagram::views::Utils::addTextStyle(getUniqueIdentifier() + '.getStyles()') FOR modelFacet-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles(getUniqueIdentifier() + '.getStyles()')-»
+«IF self.oclIsKindOf(gmfgen::GenExternalNodeLabel) or self.oclIsKindOf(gmfgen::GenLinkLabel)-»
+ «getUniqueIdentifier()».setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLocation());
+ «EXPAND xpt::diagram::views::Utils::offset(getUniqueIdentifier())-»
+«ENDIF-»
+ «EXPAND initializeStyles(getUniqueIdentifier(), prefStoreVar, false, false, false)-»
+«ENDDEFINE»
+
+«DEFINE initCompartment(String nodeVar, String prefStoreVar) FOR gmfgen::GenCompartment-»
+ «IF styles->notEmpty() or isStoringChildPositions(getLayoutType())»org.eclipse.gmf.runtime.notation.Node «getUniqueIdentifier()» = «ENDIF»createCompartment(«nodeVar», «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall», «canCollapse», «needsTitle», «listLayout», «listLayout»);
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles(getUniqueIdentifier() + '.getStyles()')-»
+«IF isStoringChildPositions(getLayoutType())-»
+ «IF viewmap.canUseShapeStyle()-»
+ «getUniqueIdentifier()».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShapeStyle());
+ «ELSE-»
+«REM»Intentionally not adding Description style, as it deemed to be useless for compartments (can't avoid for ShapeStyle - benefits of a single style overwheight drawbacks of Description presence)«ENDREM»
+ «EXPAND xpt::diagram::views::Utils::addFontLineFillStylesConditionally(getUniqueIdentifier() + '.getStyles()') FOR viewmap-»
«ENDIF-»
+ «getUniqueIdentifier()».setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds());
+ «EXPAND initializeStyles(getUniqueIdentifier(), prefStoreVar, not viewmap.isFixedForeground(), not viewmap.isFixedBackground(), not viewmap.isFixedFont())-»
+«ELSE-»
+ «EXPAND initializeStyles(getUniqueIdentifier(), prefStoreVar, false, false, false)-»
+«ENDIF-»
«ENDDEFINE»
-«DEFINE caseContainerVisualID FOR gmfgen::GenChildContainer-»
- «EXPAND caseEntry-»
+«DEFINE initForegroundFromPrefs(String viewVar, String prefStoreVar) FOR gmfgen::GenCommonBase-»
+ org.eclipse.swt.graphics.RGB lineRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_COLOR);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar», org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(), org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(lineRGB));
«ENDDEFINE»
-«DEFINE caseContainerVisualID FOR gmfgen::GenNode-»
- «EXPAND caseEntry-»
- «EXPAND caseEntry FOREACH labels-»
+«DEFINE initBackgroundFromPrefs(String viewVar, String prefStoreVar) FOR gmfgen::GenCommonBase-»
+ org.eclipse.swt.graphics.RGB fillRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FILL_COLOR);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar», org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(), org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fillRGB));
«ENDDEFINE»
-«DEFINE caseEntry FOR gmfgen::GenCommonBase-»
- «EXPAND xpt::Common::caseVisualID» return «getNotationViewFactoryQualifiedClassName()».class;
+«DEFINE initFontFromPrefs(String viewVar, String prefStoreVar) FOR gmfgen::GenCommonBase-»
+ org.eclipse.gmf.runtime.notation.FontStyle «viewVar»FontStyle = (org.eclipse.gmf.runtime.notation.FontStyle) «viewVar».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.Literals.FONT_STYLE);
+ if («viewVar»FontStyle != null) {«REM»Given this template is invoked only when FontStyle is present, no need to check fontStyle for null, but at least this gives a scope for fontData var«ENDREM»
+ org.eclipse.swt.graphics.FontData fontData = org.eclipse.jface.preference.PreferenceConverter.getFontData(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_DEFAULT_FONT);
+ «viewVar»FontStyle.setFontName(fontData.getName());
+ «viewVar»FontStyle.setFontHeight(fontData.getHeight());
+ «viewVar»FontStyle.setBold((fontData.getStyle() & org.eclipse.swt.SWT.BOLD) != 0);
+ «viewVar»FontStyle.setItalic((fontData.getStyle() & org.eclipse.swt.SWT.ITALIC) != 0);
+ org.eclipse.swt.graphics.RGB fontRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FONT_COLOR);
+ «viewVar»FontStyle.setFontColor(org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fontRGB).intValue());
+ }
«ENDDEFINE»
-«DEFINE getEdgeViewClass FOR gmfgen::GenDiagram-»
-«EXPAND xpt::Common::generatedMemberComment»
-protected Class getEdgeViewClass(org.eclipse.core.runtime.IAdaptable semanticAdapter,
- org.eclipse.gmf.runtime.notation.View containerView, String semanticHint) {
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(semanticAdapter);
- if (!«getElementTypesQualifiedClassName()».isKnownElementType(elementType)
- || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
- return null; // foreign element type
- }
- String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
- if (elementTypeHint == null) {
- return null; // our hint is visual id and must be specified
- }
- if (semanticHint != null && !semanticHint.equals(elementTypeHint)) {
- return null; // if semantic hint is specified it should be the same as in element type
- }
- int visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(elementTypeHint);
- org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(semanticAdapter);
- if (domainElement != null && visualID != «EXPAND xpt::editor::VisualIDRegistry::getLinkWithClassVisualIDMethodCall»(domainElement)) {
- return null; // visual id for link EClass should match visual id from element type
- }
- return getEdgeViewClass(visualID);
-}
-
-«EXPAND xpt::Common::generatedMemberComment»
-protected Class getEdgeViewClass(int visualID) {
- switch (visualID) {
- «EXPAND caseEntry FOREACH links-»
+«DEFINE createEdgeMethod FOR gmfgen::GenLink-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Edge create«getUniqueIdentifier()»(«IF isTypeLink()»org.eclipse.emf.ecore.EObject domainElement, «ENDIF»org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ «IF viewmap.isFixedForeground()-»
+ org.eclipse.gmf.runtime.notation.Edge edge = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createEdge();
+ edge.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createRoutingStyle());
+ «ELSE-»
+ org.eclipse.gmf.runtime.notation.Connector edge = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createConnector();
+ «ENDIF-»
+ «IF not viewmap.isFixedFont()-»
+ edge.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFontStyle());
+ «ENDIF-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('edge.getStyles()')-»
+ org.eclipse.gmf.runtime.notation.RelativeBendpoints bendpoints = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createRelativeBendpoints();
+ java.util.ArrayList points = new java.util.ArrayList(2);
+ points.add(new org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint());
+ points.add(new org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»);
+ edge.setElement(«IF isTypeLink()»domainElement«ELSE»null«ENDIF»);
+ // initializePreferences
+ final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «EXPAND initializeStyles('edge', 'prefStore', not viewmap.isFixedForeground(), false, not viewmap.isFixedFont())-»
+«EXPAND initLabel('edge', 'prefStore') FOREACH labels-»
+ return edge;
}
- return null;
-}
«ENDDEFINE»
-«DEFINE getSemanticElementType FOR gmfgen::GenDiagram-»
+«DEFINE extendsList FOR gmfgen::GenDiagram» extends org.eclipse.gmf.runtime.common.core.service.AbstractProvider«ENDDEFINE»
+«DEFINE implementsList FOR gmfgen::GenDiagram» implements org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider«ENDDEFINE»
+
+«DEFINE caseVisualID FOR gmfgen::ElementType»«EXPAND xpt::Common::caseVisualID FOR diagramElement»«ENDDEFINE»
+
+«DEFINE getSemanticElementMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.ecore.EObject getSemanticElement(org.eclipse.core.runtime.IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ org.eclipse.emf.ecore.EObject eObject = (org.eclipse.emf.ecore.EObject) semanticAdapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ if (eObject != null) {
+ return org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.resolve(org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(eObject), eObject);
+ }
+ return null;
+ }
+«ENDDEFINE»
+«DEFINE getSemanticElementTypeMethod FOR gmfgen::GenDiagram»
«EXPAND xpt::Common::generatedMemberComment»
-private org.eclipse.gmf.runtime.emf.type.core.IElementType getSemanticElementType(
- org.eclipse.core.runtime.IAdaptable semanticAdapter) {
+private org.eclipse.gmf.runtime.emf.type.core.IElementType getSemanticElementType(org.eclipse.core.runtime.IAdaptable semanticAdapter) {
if (semanticAdapter == null) {
return null;
}
- return (org.eclipse.gmf.runtime.emf.type.core.IElementType) semanticAdapter.getAdapter(
- org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
+ return (org.eclipse.gmf.runtime.emf.type.core.IElementType) semanticAdapter.getAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
}
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/extensions.xpt
index da8f3494f..2475edde8 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/extensions.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/extensions.xpt
@@ -22,7 +22,7 @@
<viewProvider class="«getNotationViewProviderQualifiedClassName()»">
<Priority name="«notationViewProviderPriority»"/>
<context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="«editorGen.modelID»"/>
- <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="«FOREACH getAllNodes()->asSequence() /*XXX can further improve selection using containerViews attribute, however, when top-node is created, provider is activated and this xml is not consulted any longer (same applies to compartments)*/ AS n SEPARATOR ','»«n.visualID»«ENDFOREACH»"/>
+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="«FOREACH getAllNodes()->asSequence() /*XXX can further improve selection using containerViews attribute, however, when top-node is created, provider is activated and this xml is not consulted any longer*/ AS n SEPARATOR ','»«n.visualID»«ENDFOREACH»"/>
<context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="«FOREACH links->asSequence() AS l SEPARATOR ','»«l.visualID»«ENDFOREACH»"/>
</viewProvider>
</extension>

Back to the top