Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbblajer2007-04-24 14:16:48 +0000
committerbblajer2007-04-24 14:16:48 +0000
commitf3a592a0c1fa16cb37f43cba1c1dca1fb8bfdccb (patch)
treebf0cc9710d96506479bd1264eeea5de88d20dfe3
parent7fd91d60b406796868ee5a7a79961fd6c7ec2691 (diff)
downloadorg.eclipse.gmf-tooling-f3a592a0c1fa16cb37f43cba1c1dca1fb8bfdccb.tar.gz
org.eclipse.gmf-tooling-f3a592a0c1fa16cb37f43cba1c1dca1fb8bfdccb.tar.xz
org.eclipse.gmf-tooling-f3a592a0c1fa16cb37f43cba1c1dca1fb8bfdccb.zip
CanonicalStyle is taken into account while refreshing notational model to reflect changes in underlying domain model;
Update is now centralized and transactional; Changes to visibility are dispatched to the parent of the affected view as well (was: only to the view itself); Save options are not reused, for easy modification of the generated code; Side-affixed children are not considered direct children; Empty edit-patterns are treated the same way as null patterns (view pattern is used instead).
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/Helper.ext6
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/ChildNodeEditPart.xpt2
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.ext21
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.xpt15
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/CompartmentEditPart.xpt1
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/DiagramEditPart.xpt26
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LabelController.xpt34
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkEditPart.xpt3
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkNotationModelRefresher.xpt18
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.ext5
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.xpt5
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NotationModelRefresher.xpt18
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/TreeEditPart.xpt23
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/domainModelRefresher.xpt13
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/refresh.xpt205
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/DiagramEditorUtil.xpt15
-rw-r--r--plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/Editor.xpt15
17 files changed, 242 insertions, 183 deletions
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/Helper.ext b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/Helper.ext
index 81a055901..2e81de673 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/Helper.ext
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/Helper.ext
@@ -18,7 +18,11 @@ boolean isXYLayout(gmfgen::GenNode node) :
;
boolean hasDirectChildren(gmfgen::GenNode node) :
- node.childNodes.size() > 0
+ node.getDirectChildren().size() > 0
+;
+
+Collection[gmfgen::GenNode] getDirectChildren(gmfgen::GenNode node) :
+ node.childNodes.select(e| {e}.typeSelect(gmfgen::GenChildSideAffixedNode).size() == 0)
;
boolean needsXYLayout(gmfgen::GenContainerBase container) :
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/ChildNodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/ChildNodeEditPart.xpt
index a48a57800..55a3ac3e5 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/ChildNodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/ChildNodeEditPart.xpt
@@ -42,7 +42,7 @@ public class «editPartClassName» «EXPAND supertypes» {
«EXPAND xpt::diagram::parts::Common::activate-»
«EXPAND xpt::diagram::parts::Common::deactivate-»
- «EXPAND xpt::diagram::parts::domainModelRefresher::field-»
+ «EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
«EXPAND xpt::diagram::parts::refresh::refresher-»
«EXPAND xpt::diagram::parts::refresh::externalRefreshers-»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.ext b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.ext
index e31c64100..020c7acd8 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.ext
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.ext
@@ -14,6 +14,9 @@ import "http://www.eclipse.org/emf/2002/Ecore";
import "http://www.eclipse.org/emf/2002/GenModel";
import "http://www.eclipse.org/gmf/2005/GenModel/2.0";
+extension xpt::diagram::parts::NotationModelRefresher;
+extension xpt::diagram::parts::LinkNotationModelRefresher;
+
boolean isSelectable(gmfgen::GenCommonBase gcb) :
true
;
@@ -30,6 +33,18 @@ boolean isSelectable(gmfgen::GenCompartment compartment) :
false
;
+boolean needsTransactionalUpdateManager(gmfgen::GenCommonBase gcb) :
+ gcb.needsDomainModelRefresher()
+;
+
+boolean needsTransactionalUpdateManager(gmfgen::GenDiagram diagram) :
+ true //Force for the diagram, used by activate/deactivate
+;
+
+boolean needsTransactionalUpdateManager(gmfgen::GenContainerBase gcb) :
+ gcb.needsDomainModelRefresher() || gcb.needsNotationModelRefresher() || gcb.needsLinkNotationModelRefresher()
+;
+
boolean needsDomainModelRefresher(gmfgen::GenCommonBase gcb) :
false
;
@@ -43,15 +58,15 @@ boolean needsDomainModelRefresher(gmfgen::LinkModelFacet facet) :
;
boolean needsDomainModelRefresher(gmfgen::TypeLinkModelFacet facet) :
- true
+ facet.metaClass != null
;
boolean needsDomainModelRefresher(gmfgen::GenDiagram diagram) :
- true
+ !diagram.sansDomain
;
boolean needsDomainModelRefresher(gmfgen::GenNode node) :
- true
+ !node.sansDomain
;
gmfgen::GenLabel getPrimaryLabel(gmfgen::GenCommonBase gcb) :
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.xpt
index f39b974cb..4ddd7c6d1 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/Common.xpt
@@ -225,6 +225,15 @@ public boolean isSelectable() {
«ENDIF-»
«ENDDEFINE»
+«DEFINE getTransactionalUpdateManager FOR gmfgen::GenCommonBase-»
+«IF needsTransactionalUpdateManager()-»
+«EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager getTransactionalUpdateManager() {
+ return (org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager) getViewer().getProperty(org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager.class.getName());
+}
+«ENDIF-»
+«ENDDEFINE»
+
«DEFINE activate FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
public void activate() {
@@ -253,15 +262,13 @@ public void deactivate() {
«ENDDEFINE»
«DEFINE activateAdditions FOR gmfgen::GenDiagram-»
-if (!«EXPAND getViewCode».eAdapters().contains(getUpdateManager())) {
- «EXPAND getViewCode».eAdapters().add(getUpdateManager());
-}
«EXPAND activateRefreshers-»
+getTransactionalUpdateManager().install(org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(«EXPAND getViewCode»));
«ENDDEFINE»
«DEFINE deactivateAdditions FOR gmfgen::GenDiagram-»
+getTransactionalUpdateManager().uninstall();
«EXPAND deactivateRefreshers-»
-«EXPAND getViewCode».eAdapters().remove(getUpdateManager());
«ENDDEFINE»
«DEFINE activateAdditions FOR gmfgen::GenChildLabelNode-»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/CompartmentEditPart.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/CompartmentEditPart.xpt
index 101d188d6..c901e8445 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/CompartmentEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/CompartmentEditPart.xpt
@@ -38,6 +38,7 @@ public class «editPartClassName» «EXPAND supertypes» {
«EXPAND setupCompartmentHolder-»
«EXPAND xpt::diagram::parts::Common::activate-»
«EXPAND xpt::diagram::parts::Common::deactivate-»
+ «EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
«EXPAND xpt::diagram::parts::NotationModelRefresher::all-»
«EXPAND xpt::diagram::parts::refresh::refresher-»
«EXPAND additions-»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/DiagramEditPart.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/DiagramEditPart.xpt
index a93f610ee..dc2dad641 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/DiagramEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/DiagramEditPart.xpt
@@ -28,7 +28,6 @@ public class «editPartClassName» «EXPAND supertypes» {
«EXPAND xpt::diagram::parts::Common::declareViewCode-»
«EXPAND xpt::diagram::parts::Common::registerModel-»
- «EXPAND addNotify-»
«EXPAND createEditPolicies-»
«EXPAND createFigure-»
«EXPAND xpt::diagram::parts::Common::getAdapter-»
@@ -39,8 +38,7 @@ public class «editPartClassName» «EXPAND supertypes» {
«EXPAND xpt::diagram::parts::Common::deactivate-»
«EXPAND xpt::diagram::parts::NotationModelRefresher::all-»
«EXPAND xpt::diagram::parts::LinkNotationModelRefresher::all-»
- «EXPAND xpt::diagram::parts::domainModelRefresher::field-»
- «EXPAND getUpdateManager-»
+ «EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
«EXPAND xpt::diagram::parts::TreeEditPart::TreeEditPart-»
«EXPAND additions-»
}
@@ -58,19 +56,6 @@ protected org.eclipse.draw2d.IFigure createFigure() {
}
«ENDDEFINE»
-«DEFINE getUpdateManager FOR gmfgen::GenDiagram-»
-«EXPAND xpt::Common::generatedMemberComment»
-private org.eclipse.gmf.runtime.lite.edit.parts.update.UpdateManager updateManager;
-
-«EXPAND xpt::Common::generatedMemberComment»
-private org.eclipse.gmf.runtime.lite.edit.parts.update.UpdateManager getUpdateManager() {
- if (updateManager == null) {
- updateManager = new org.eclipse.gmf.runtime.lite.edit.parts.update.UpdateManager(getViewer());
- }
- return updateManager;
-}
-«ENDDEFINE»
-
«DEFINE createEditPolicies FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
protected void createEditPolicies() {
@@ -82,14 +67,5 @@ protected void createEditPolicies() {
}
«ENDDEFINE»
-«DEFINE addNotify FOR gmfgen::GenDiagram-»
-«EXPAND xpt::Common::generatedMemberComment»
-public void addNotify() {
- super.addNotify();
- «EXPAND xpt::diagram::parts::Common::getViewCode».eAdapters().add(getUpdateManager());
- «EXPAND xpt::diagram::parts::Common::getViewCode».getElement().eAdapters().add(domainModelRefresher);
-}
-«ENDDEFINE»
-
«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LabelController.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LabelController.xpt
index 7957fe6f4..2e82ce426 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LabelController.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LabelController.xpt
@@ -75,7 +75,7 @@ return null;
«ENDDEFINE»
«DEFINE createLabelTextDisplayer(Boolean isReadOnly) FOR gmfgen::FeatureLabelModelFacet-»
-return new org.eclipse.gmf.runtime.lite.edit.parts.labels.SimpleLabelTextDisplayer("«viewPattern»"«IF !isReadOnly», "«editPattern == null ? viewPattern : editPattern»"«ENDIF», «EXPAND features»);
+return new org.eclipse.gmf.runtime.lite.edit.parts.labels.SimpleLabelTextDisplayer("«viewPattern»"«IF !isReadOnly», "«(editPattern == null || editPattern.length() == 0) ? viewPattern : editPattern»"«ENDIF», «EXPAND features»);
«ENDDEFINE»
«DEFINE features FOR gmfgen::FeatureLabelModelFacet-»
@@ -232,11 +232,8 @@ It is thus referenced from the common activate/deactivate mechanism.
«getLabelHostQualifiedClassName()» updatableParent = getUpdatableParent();
if (updatableParent != null) {
«IF !viewmap.isFixedFont()-»
- updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor(), fontColorRefresher);
- updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontHeight(), fontRefresher);
- updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontName(), fontRefresher);
- updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Bold(), fontRefresher);
- updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Italic(), fontRefresher);
+ updatableParent.addExternalRefresher(fontColorRefresher);
+ updatableParent.addExternalRefresher(fontRefresher);
«ENDIF-»
updatableParent.addExternalRefresher(getLabelRefresher());
«EXPAND activateMore-»
@@ -247,11 +244,8 @@ if (updatableParent != null) {
«getLabelHostQualifiedClassName()» updatableParent = getUpdatableParent();
if (updatableParent != null) {
«IF !viewmap.isFixedFont()-»
- updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor(), fontColorRefresher);
- updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontHeight(), fontRefresher);
- updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontName(), fontRefresher);
- updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Bold(), fontRefresher);
- updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Italic(), fontRefresher);
+ updatableParent.removeExternalRefresher(fontColorRefresher);
+ updatableParent.removeExternalRefresher(fontRefresher);
«ENDIF-»
updatableParent.removeExternalRefresher(getLabelRefresher());
«EXPAND deactivateMore-»
@@ -262,27 +256,17 @@ if (updatableParent != null) {
«DEFINE deactivateMore FOR gmfgen::GenLabel»«ENDDEFINE»
«DEFINE activateMore FOR gmfgen::GenExternalNodeLabel-»
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X(), boundsRefresher);
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y(), boundsRefresher);
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width(), boundsRefresher);
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height(), boundsRefresher);
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getNode_LayoutConstraint(), boundsRefresher);
+updatableParent.addExternalRefresher(boundsRefresher);
«ENDDEFINE»
«DEFINE deactivateMore FOR gmfgen::GenExternalNodeLabel-»
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X(), boundsRefresher);
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y(), boundsRefresher);
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width(), boundsRefresher);
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height(), boundsRefresher);
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getNode_LayoutConstraint(), boundsRefresher);
+updatableParent.removeExternalRefresher(boundsRefresher);
«ENDDEFINE»
«DEFINE activateMore FOR gmfgen::GenLinkLabel-»
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X(), locationRefresher);
-updatableParent.addRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y(), locationRefresher);
+updatableParent.addExternalRefresher(locationRefresher);
«ENDDEFINE»
«DEFINE deactivateMore FOR gmfgen::GenLinkLabel-»
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X(), locationRefresher);
-updatableParent.removeRefresher(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y(), locationRefresher);
+updatableParent.removeExternalRefresher(locationRefresher);
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkEditPart.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkEditPart.xpt
index 038f41754..d74465625 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkEditPart.xpt
@@ -39,10 +39,9 @@ public class «editPartClassName» «EXPAND supertypes» {
«EXPAND xpt::diagram::parts::TreeEditPart::getTreeEditPartAdapter-»
«EXPAND xpt::diagram::parts::Common::activate-»
«EXPAND xpt::diagram::parts::Common::deactivate-»
- «EXPAND xpt::diagram::parts::domainModelRefresher::field-»
+ «EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
«EXPAND xpt::diagram::parts::refresh::refresher-»
«EXPAND xpt::diagram::parts::refresh::externalRefreshers-»
- «EXPAND xpt::diagram::parts::refresh::addRemove-»
«EXPAND addNotify-»
«EXPAND createFigure-»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkNotationModelRefresher.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkNotationModelRefresher.xpt
index 16f53fc01..1cc419b1c 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkNotationModelRefresher.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/LinkNotationModelRefresher.xpt
@@ -46,19 +46,15 @@ uninstallLinkNotationModelRefresher();
«EXPAND xpt::Common::generatedMemberComment»
private void installLinkNotationModelRefresher() {
«EXPAND className» refresher = getLinkNotationModelRefresher();
- if (refresher.isInstalled()) {
- return;
- }
- org.eclipse.emf.transaction.TransactionalEditingDomain domainModelEditDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(«EXPAND xpt::diagram::parts::Common::getDiagramElementCode»);
- refresher.install(domainModelEditDomain);
- refreshLinkNotationModel();
+ getTransactionalUpdateManager().addNotationModelRefresher(refresher);
}
«ENDDEFINE»
«DEFINE uninstall FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void uninstallLinkNotationModelRefresher() {
- getLinkNotationModelRefresher().uninstall();
+ «EXPAND className» refresher = getLinkNotationModelRefresher();
+ getTransactionalUpdateManager().removeNotationModelRefresher(refresher);
}
«ENDDEFINE»
@@ -279,10 +275,14 @@ protected org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand g
«DEFINE shouldCreateView FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment("Returns whether a notational edge should be created for the given domain element. \n" +
- "The generated code always returns " + (getDiagram().synchronized ? "true" : "false") + ". \n" +
+ "The generated code respects canonical style. If the canonycal style is not present, " + (getDiagram().synchronized ? "true" : "false") + " is always returned. \n" +
"User can change implementation of this method to handle a more sophisticated logic.")»
protected boolean shouldCreateView(org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor descriptor) {
- return «getDiagram().synchronized»;
+ org.eclipse.gmf.runtime.notation.CanonicalStyle style = (org.eclipse.gmf.runtime.notation.CanonicalStyle) «EXPAND xpt::diagram::parts::Common::getViewCode».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getCanonicalStyle());
+ if (style == null) {
+ return «getDiagram().synchronized»;
+ }
+ return style.isCanonical();
}
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.ext b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.ext
index a149182c5..1902fec1d 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.ext
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.ext
@@ -33,3 +33,8 @@ String primaryShapeQualifiedClassName(gmfgen::FigureViewmap viewmap) :
String primaryShapeQualifiedClassName(gmfgen::InnerClassViewmap viewmap) :
viewmap.className
;
+
+List[gmfgen::GenChildSideAffixedNode] getSideAffixedChildren(gmfgen::GenNode node) :
+ node.childNodes.typeSelect(gmfgen::GenChildSideAffixedNode)
+;
+
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.xpt
index a57882cb6..1510a0a55 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NodeEditPart.xpt
@@ -84,10 +84,9 @@ public class «editPartClassName» «EXPAND supertypes» {
«EXPAND xpt::diagram::parts::Common::deactivate-»
«EXPAND xpt::diagram::parts::NotationModelRefresher::all-»
«EXPAND xpt::diagram::parts::LinkNotationModelRefresher::all-»
- «EXPAND xpt::diagram::parts::domainModelRefresher::field-»
+ «EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
«EXPAND xpt::diagram::parts::refresh::refresher-»
«EXPAND xpt::diagram::parts::refresh::externalRefreshers-»
- «EXPAND xpt::diagram::parts::refresh::addRemove-»
«EXPAND xpt::diagram::parts::Common::viewmap FOR viewmap-»
«EXPAND xpt::diagram::parts::TreeEditPart::TreeEditPart-»
@@ -341,7 +340,7 @@ public boolean isExternalLabel(org.eclipse.gef.EditPart childEditPart) {
«DEFINE isDirectChild FOR gmfgen::GenNode-»
«EXPAND xpt::Common::generatedMemberComment»
public boolean isDirectChild(org.eclipse.gef.EditPart childEditPart) {
-«EXPAND returnInstanceof("childEditPart") FOREACH childNodes-»
+«EXPAND returnInstanceof("childEditPart") FOREACH getDirectChildren()-»
return false;
}
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NotationModelRefresher.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NotationModelRefresher.xpt
index b81dbdb99..16d6360ac 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NotationModelRefresher.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/NotationModelRefresher.xpt
@@ -43,19 +43,15 @@ uninstallNotationModelRefresher();
«EXPAND xpt::Common::generatedMemberComment»
private void installNotationModelRefresher() {
org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher refresher = getNotationModelRefresher();
- if (refresher.isInstalled()) {
- return;
- }
- org.eclipse.emf.transaction.TransactionalEditingDomain domainModelEditDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(«EXPAND xpt::diagram::parts::Common::getDiagramElementCode»);
- refresher.install(domainModelEditDomain);
- refreshNotationModel();
+ getTransactionalUpdateManager().addNotationModelRefresher(refresher);
}
«ENDDEFINE»
«DEFINE uninstall FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void uninstallNotationModelRefresher() {
- getNotationModelRefresher().uninstall();
+ org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher refresher = getNotationModelRefresher();
+ getTransactionalUpdateManager().removeNotationModelRefresher(refresher);
}
«ENDDEFINE»
@@ -156,10 +152,14 @@ protected java.util.List getSemanticChildNodes() {
«DEFINE shouldCreateView FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment("Returns whether a notational element should be created for the given domain element. \n" +
- "The generated code always returns " + (getDiagram().synchronized ? "true" : "false") + ". \n" +
+ "The generated code respects canonical style. If the canonycal style is not present, " + (getDiagram().synchronized ? "true" : "false") + " is always returned. \n" +
"User can change implementation of this method to handle a more sophisticated logic.")»
protected boolean shouldCreateView(org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor descriptor) {
- return «getDiagram().synchronized»;
+ org.eclipse.gmf.runtime.notation.CanonicalStyle style = (org.eclipse.gmf.runtime.notation.CanonicalStyle) «EXPAND xpt::diagram::parts::Common::getViewCode».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getCanonicalStyle());
+ if (style == null) {
+ return «getDiagram().synchronized»;
+ }
+ return style.isCanonical();
}
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/TreeEditPart.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/TreeEditPart.xpt
index 661ca3d47..a5a0d52ee 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/TreeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/TreeEditPart.xpt
@@ -101,29 +101,22 @@ installEditPolicy(org.eclipse.gef.EditPolicy.DIRECT_EDIT_ROLE, new org.eclipse.g
«DEFINE listeners FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
+ protected void register() {
+ super.register();
+ getViewer().setProperty(org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager.class.getName(), new org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager(getViewer()));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
public void activate() {
super.activate();
- if (!getNotationView().eAdapters().contains(getTreeUpdateManager())) {
- getNotationView().eAdapters().add(getTreeUpdateManager());
- }
+ getTransactionalUpdateManager().install(org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(getNotationView()));
}
«EXPAND xpt::Common::generatedMemberComment»
public void deactivate() {
- getNotationView().eAdapters().remove(getTreeUpdateManager());
+ getTransactionalUpdateManager().uninstall();
super.deactivate();
}
-
- «EXPAND xpt::Common::generatedMemberComment»
- private org.eclipse.gmf.runtime.lite.edit.parts.update.UpdateManager getTreeUpdateManager() {
- if (treeUpdateManager == null) {
- treeUpdateManager = new org.eclipse.gmf.runtime.lite.edit.parts.update.UpdateManager(getViewer());
- }
- return treeUpdateManager;
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- private org.eclipse.gmf.runtime.lite.edit.parts.update.UpdateManager treeUpdateManager;
«ENDDEFINE»
«REM»Nodes and links share the same template«ENDREM»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/domainModelRefresher.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/domainModelRefresher.xpt
index 1026c7dfa..2a98e5a06 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/domainModelRefresher.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/domainModelRefresher.xpt
@@ -15,24 +15,15 @@
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::diagram::parts::Common»
-«DEFINE field FOR gmfgen::GenCommonBase-»
-«IF needsDomainModelRefresher()-»
- «EXPAND xpt::Common::generatedMemberComment»
- private org.eclipse.gmf.runtime.lite.edit.parts.update.RefreshAdapter domainModelRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.RefreshAdapter(this);
-«ENDIF-»
-«ENDDEFINE»
-
«DEFINE activate FOR gmfgen::GenCommonBase-»
«IF needsDomainModelRefresher()-»
-if (!«EXPAND xpt::diagram::parts::Common::getViewCode».getElement().eAdapters().contains(domainModelRefresher)) {
- «EXPAND xpt::diagram::parts::Common::getViewCode».getElement().eAdapters().add(domainModelRefresher);
-}
+getTransactionalUpdateManager().addUpdatableEditPart(«EXPAND xpt::diagram::parts::Common::getViewCode».getElement(), this);
«ENDIF-»
«ENDDEFINE»
«DEFINE deactivate FOR gmfgen::GenCommonBase-»
«IF needsDomainModelRefresher()-»
-«EXPAND xpt::diagram::parts::Common::getViewCode».getElement().eAdapters().remove(domainModelRefresher);
+getTransactionalUpdateManager().removeUpdatableEditPart(«EXPAND xpt::diagram::parts::Common::getViewCode».getElement(), this);
«ENDIF-»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/refresh.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/refresh.xpt
index 58a95d558..0d0471511 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/refresh.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/diagram/parts/refresh.xpt
@@ -25,19 +25,19 @@
«DEFINE updatableEditPartRefresher FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
-private java.util.HashMap structuralFeatures2Refresher;
+private org.eclipse.gmf.runtime.lite.edit.parts.update.RefreshersRegistry myRefreshersRegistry;
«EXPAND xpt::Common::generatedMemberComment»
public Refresher getRefresher(org.eclipse.emf.ecore.EStructuralFeature feature, org.eclipse.emf.common.notify.Notification msg) {
- if (structuralFeatures2Refresher == null) {
+ if (myRefreshersRegistry == null) {
createRefreshers();
}
- return (Refresher) structuralFeatures2Refresher.get(feature);
+ return myRefreshersRegistry.getRefresher(feature, msg);
}
«EXPAND xpt::Common::generatedMemberComment»
private void createRefreshers() {
- structuralFeatures2Refresher = new java.util.HashMap();
+ myRefreshersRegistry = new org.eclipse.gmf.runtime.lite.edit.parts.update.RefreshersRegistry();
«EXPAND fillRefreshers-»
}
«ENDDEFINE»
@@ -68,7 +68,6 @@ private void createRefreshers() {
«ENDDEFINE»
«DEFINE fillRefreshers FOR gmfgen::GenChildLabelNode-»
-«EXPAND children-»
«EXPAND visibility-»
«EXPAND font-»
«EXPAND fontColor-»
@@ -84,110 +83,180 @@ private void createRefreshers() {
«ENDDEFINE»
«DEFINE children FOR gmfgen::GenCommonBase-»
-Refresher childrenRefresher = new Refresher() {
+Refresher childrenRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshChildren();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_PersistedChildren() == msg.getFeature() ||
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_TransientChildren() == msg.getFeature() ||
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle_Collapsed() == msg.getFeature()) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle());
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible() == msg.getFeature()) {
+ return msg.getNotifier() != «EXPAND xpt::diagram::parts::Common::getViewCode»;
+ }
+ return false;
+ }
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_PersistedChildren(), childrenRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_TransientChildren(), childrenRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles(), childrenRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle_Collapsed(), childrenRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_PersistedChildren(), childrenRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_TransientChildren(), childrenRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles(), childrenRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle_Collapsed(), childrenRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible(), childrenRefresher);
«ENDDEFINE»
«DEFINE visibility FOR gmfgen::GenCommonBase-»
-Refresher visibilityRefresher = new Refresher() {
+Refresher visibilityRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshVisibility();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible() == msg.getFeature()) {
+ return msg.getNotifier() == «EXPAND xpt::diagram::parts::Common::getViewCode»;
+ }
+ return false;
+ }
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible(), visibilityRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible(), visibilityRefresher);
«ENDDEFINE»
«DEFINE bendpoints FOR gmfgen::GenLink-»
Refresher bendpointsRefresher = new Refresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshBendpoints();
}
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getEdge_Bendpoints(), bendpointsRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRelativeBendpoints_Points(), bendpointsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getEdge_Bendpoints(), bendpointsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRelativeBendpoints_Points(), bendpointsRefresher);
«ENDDEFINE»
«DEFINE bounds FOR gmfgen::GenCommonBase-»
Refresher boundsRefresher = new Refresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshBounds();
}
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getNode_LayoutConstraint(), boundsRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width(), boundsRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height(), boundsRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X(), boundsRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y(), boundsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getNode_LayoutConstraint(), boundsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width(), boundsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height(), boundsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X(), boundsRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y(), boundsRefresher);
«ENDDEFINE»
«DEFINE sourceEdges FOR gmfgen::GenCommonBase-»
Refresher sourceEdgesRefresher = new Refresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshSourceConnections();
}
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_SourceEdges(), sourceEdgesRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_SourceEdges(), sourceEdgesRefresher);
«ENDDEFINE»
«DEFINE targetEdges FOR gmfgen::GenCommonBase-»
Refresher targetEdgesRefresher = new Refresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshTargetConnections();
}
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_TargetEdges(), targetEdgesRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_TargetEdges(), targetEdgesRefresher);
«ENDDEFINE»
«DEFINE fillColor FOR gmfgen::GenCommonBase-»
«IF !viewmap.isFixedBackground()-»
-Refresher backgroundColorRefresher = new Refresher() {
+Refresher backgroundColorRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshBackgroundColor();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor() == msg.getFeature()) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle());
+ }
+ return false;
+ }
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(), backgroundColorRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(), backgroundColorRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles(), backgroundColorRefresher);
«ENDIF-»
«ENDDEFINE»
«DEFINE lineColor FOR gmfgen::GenCommonBase-»
«IF !viewmap.isFixedForeground()-»
-Refresher foregroundColorRefresher = new Refresher() {
+Refresher foregroundColorRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshForegroundColor();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor() == msg.getFeature()) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle());
+ }
+ return false;
+ }
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(), foregroundColorRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(), foregroundColorRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles(), foregroundColorRefresher);
«ENDIF-»
«ENDDEFINE»
«DEFINE font FOR gmfgen::GenCommonBase-»
«IF !viewmap.isFixedFont()-»
-Refresher fontRefresher = new Refresher() {
+Refresher fontRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshFont();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle().getEStructuralFeatures().contains(msg.getFeature())) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ }
+ return false;
+ }
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontHeight(), fontRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontName(), fontRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Bold(), fontRefresher);
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Italic(), fontRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontHeight(), fontRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontName(), fontRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Bold(), fontRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Italic(), fontRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles(), fontRefresher);
«ENDIF-»
«ENDDEFINE»
«DEFINE fontColor FOR gmfgen::GenCommonBase-»
Refresher fontColorRefresher = new Refresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshFontColor();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor() == msg.getFeature()) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ }
+ return false;
+ }
};
-structuralFeatures2Refresher.put(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor(), fontColorRefresher);
+myRefreshersRegistry.add(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor(), fontColorRefresher);
«ENDDEFINE»
«DEFINE labelRefresher FOR gmfgen::GenCommonBase-»
@@ -254,28 +323,59 @@ protected org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEdi
«DEFINE externalFontRefresher FOR gmfgen::GenLabel-»
«IF !viewmap.isFixedFont()-»
«EXPAND xpt::Common::generatedMemberComment»
-private org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher fontRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher() {
+private org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher fontRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshFont();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor() == msg.getFeature()) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ }
+ return false;
+ }
};
«ENDIF-»
«ENDDEFINE»
«DEFINE externalFontColorRefresher FOR gmfgen::GenLabel-»
«EXPAND xpt::Common::generatedMemberComment»
-private org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher fontColorRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher() {
+private org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher fontColorRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshFontColor();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle().getEStructuralFeatures().contains(msg.getFeature())) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Styles() == msg.getFeature()) {
+ return org.eclipse.gmf.runtime.lite.edit.parts.update.UpdaterUtil.affects(msg, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ }
+ return false;
+ }
};
«ENDDEFINE»
«DEFINE externalLocationRefresher FOR gmfgen::GenLinkLabel-»
-private org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher locationRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher() {
+«EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher locationRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IExternallyUpdatableEditPart.ExternalRefresher() {
public void refresh() {
+ «EXPAND ignoreIfInactive-»
refreshLocation();
}
+ public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification msg) {
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation().getEStructuralFeatures().contains(msg.getFeature())) {
+ return true;
+ }
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getNode_LayoutConstraint() == msg.getFeature()) {
+ return true;
+ }
+ return false;
+ }
};
«ENDDEFINE»
@@ -604,39 +704,14 @@ public void removeExternalRefresher(org.eclipse.gmf.runtime.lite.edit.parts.upda
}
«ENDDEFINE»
-«DEFINE addRemove FOR gmfgen::GenCommonBase-»
-«EXPAND xpt::Common::generatedMemberComment»
-public void addRefresher(org.eclipse.emf.ecore.EStructuralFeature feature, Refresher refresher) {
- CompositeRefresher compositeRefresher = getCompositeRefresher(feature);
- compositeRefresher.addRefresher(refresher);
-}
-
-«EXPAND xpt::Common::generatedMemberComment»
-public void removeRefresher(org.eclipse.emf.ecore.EStructuralFeature feature, Refresher refresher) {
- CompositeRefresher compositeRefresher = getCompositeRefresher(feature);
- compositeRefresher.removeRefresher(refresher);
-}
-
-«EXPAND xpt::Common::generatedMemberComment»
-private CompositeRefresher getCompositeRefresher(org.eclipse.emf.ecore.EStructuralFeature feature) {
- if (structuralFeatures2Refresher == null) {
- createRefreshers();
- }
- Refresher refresher = (Refresher) structuralFeatures2Refresher.get(feature);
- if (refresher instanceof CompositeRefresher) {
- return (CompositeRefresher) refresher;
- }
- CompositeRefresher result = new CompositeRefresher();
- if (refresher != null) {
- result.addRefresher(refresher);
- }
- structuralFeatures2Refresher.put(feature, result);
- return result;
-}
-«ENDDEFINE»
-
«DEFINE getStyleHolderCode FOR gmfgen::GenCommonBase»«EXPAND xpt::diagram::parts::Common::getViewCode»«ENDDEFINE»
«DEFINE getStyleHolderCode FOR gmfgen::GenNodeLabel»getUpdatableParent().«EXPAND xpt::diagram::parts::Common::getViewCode FOR node»«ENDDEFINE»
«DEFINE getStyleHolderCode FOR gmfgen::GenLinkLabel»getUpdatableParent().«EXPAND xpt::diagram::parts::Common::getViewCode FOR link»«ENDDEFINE»
+
+«DEFINE ignoreIfInactive FOR GenCommonBase-»
+if (!isActive()) {
+ return;
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/DiagramEditorUtil.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/DiagramEditorUtil.xpt
index 5613dd758..61145d628 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/DiagramEditorUtil.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/DiagramEditorUtil.xpt
@@ -182,17 +182,12 @@ public static void setCharset(org.eclipse.core.resources.IFile file) {
«DEFINE saveOptions FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
-private static java.util.Map ourSaveOptions = null;
-
-«EXPAND xpt::Common::generatedMemberComment»
public static java.util.Map getSaveOptions() {
- if (ourSaveOptions == null) {
- ourSaveOptions = new java.util.HashMap();
- ourSaveOptions.put(org.eclipse.emf.ecore.xmi.XMIResource.OPTION_ENCODING, "UTF-8"); «EXPAND xpt::Common::nonNLS»
- ourSaveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
- ourSaveOptions.put(org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED, org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
- }
- return ourSaveOptions;
+ java.util.Map saveOptions = new java.util.HashMap();
+ saveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_ENCODING, "UTF-8"); «EXPAND xpt::Common::nonNLS»
+ saveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
+ saveOptions.put(org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED, org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ return saveOptions;
}
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/Editor.xpt b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/Editor.xpt
index fa621b7a7..c69f5d7aa 100644
--- a/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/Editor.xpt
+++ b/plugins/org.eclipse.gmf.codegen.lite/templates/xpt/editor/Editor.xpt
@@ -347,6 +347,7 @@ public class «className» extends org.eclipse.gmf.runtime.lite.parts.DiagramViewP
public void dispose() {
«EXPAND unhookResourceTracker-»
«EXPAND unhookValidation-»
+«EXPAND disposeTransactionalUpdateManager-»
// important: always call super implementation of dispose
super.dispose();
}
@@ -358,11 +359,19 @@ public class «className» extends org.eclipse.gmf.runtime.lite.parts.DiagramViewP
myActionBarContributor.dispose();
myActionBarContributor = null;
«EXPAND unhookValidation-»
+«EXPAND disposeTransactionalUpdateManager-»
// important: always call super implementation of dispose
super.dispose();
}
«ENDDEFINE»
+«DEFINE disposeTransactionalUpdateManager FOR GenEditorView-»
+org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager updateManager = (org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager) getGraphicalViewer().getProperty(org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager.class.getName());
+if (updateManager != null) {
+ updateManager.dispose();
+}
+«ENDDEFINE»
+
«DEFINE save FOR gmfgen::GenEditorView-»
«EXPAND xpt::Common::generatedMemberComment»
public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor) {
@@ -607,9 +616,15 @@ public class «className» extends org.eclipse.gmf.runtime.lite.parts.DiagramViewP
org.eclipse.gef.editparts.ScalableFreeformRootEditPart root = new org.eclipse.gef.editparts.ScalableFreeformRootEditPart();
getGraphicalViewer().setRootEditPart(root);
getGraphicalViewer().setEditPartFactory(new «editorGen.diagram.getEditPartFactoryQualifiedClassName()»());
+ org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager updateManager = new org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager(getGraphicalViewer());
+ getGraphicalViewer().setProperty(org.eclipse.gmf.runtime.lite.edit.parts.update.TransactionalUpdateManager.class.getName(), updateManager);
«EXPAND addLayers-»
getGraphicalViewer().setContents(getDiagram());
+ org.eclipse.emf.common.command.Command updateCommand = updateManager.buildRefreshNotationModelCommand();
+ if (updateCommand != null && updateCommand.canExecute()) {
+ getCommandStack().execute(new org.eclipse.gmf.runtime.lite.commands.WrappingCommand(getEditingDomain(), updateCommand));
+ }
}
«ENDDEFINE»

Back to the top