Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2009-02-23 13:27:27 -0500
committeratikhomirov2009-02-23 13:27:27 -0500
commit64cc497aad2a97a48bcc4a5ab6cd59d3b181d80d (patch)
treee56155cb9211844d1838948612aec3ed3c5c1ada
parentfe4370a56dc7f1222bfe5aaf79b6ab0b2821d015 (diff)
downloadorg.eclipse.gmf-tooling-64cc497aad2a97a48bcc4a5ab6cd59d3b181d80d.tar.gz
org.eclipse.gmf-tooling-64cc497aad2a97a48bcc4a5ab6cd59d3b181d80d.tar.xz
org.eclipse.gmf-tooling-64cc497aad2a97a48bcc4a5ab6cd59d3b181d80d.zip
refactored to use context helpers, simplified queries
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt2
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto29
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto16
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto46
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt2
8 files changed, 69 insertions, 38 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt
index ce1172f91..29f199cdb 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt
@@ -528,7 +528,7 @@
«DEFINE getFontStyleOwnerView(viewmap : gmfgen::Viewmap) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.notation.View getFontStyleOwnerView() {
- «IF isFixedFont(viewmap)-»
+ «IF viewmap.isFixedFont()-»
return (org.eclipse.gmf.runtime.notation.View) getModel();
«ELSE-»
return getPrimaryView();
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto
index 2a0d21726..b7ef6ca8c 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto
@@ -13,16 +13,17 @@ import xpt.NativeGenModelUtils;
import xpt.GenModelUtils;
-modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype gmfgen uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype notation uses "http://www.eclipse.org/gmf/runtime/1.0.2/notation";
library Utils;
-- all elements that may have element type: diagram, nodes and links
-helper GenDiagram::getAllTypedElements() : Sequence(genModel::GenCommonBase) {
- return Sequence { self }[genModel::GenCommonBase]->union(self.getAllNodes()->asSequence())->union(self.links->asSequence());
+helper GenDiagram::getAllTypedElements() : Sequence(gmfgen::GenCommonBase) {
+ return Sequence { self }[gmfgen::GenCommonBase]->union(self.getAllNodes()->asSequence())->union(self.links->asSequence());
}
-helper hasExplicitChildFeature(facet : genModel::TypeModelFacet) : Boolean {
+helper hasExplicitChildFeature(facet : gmfgen::TypeModelFacet) : Boolean {
return not isDerived(facet.childMetaFeature) and facet.childMetaFeature <> facet.containmentMetaFeature
}
@@ -33,14 +34,28 @@ helper hasExplicitChildFeature(facet : genModel::TypeModelFacet) : Boolean {
-- "N1" and "N2". "N1" has a reference to "L" which is being used as childMetaFeature. Hence, link's container, "C"
-- is different from link's source, "N1". As nothing can prevent "C" from subclassing "N1", there's no sure way to
-- tell if container is really different from the source or not, and we'd better assume they are different.
-helper hasContainerOtherThanSource(facet : genModel::TypeLinkModelFacet) : Boolean {
+helper hasContainerOtherThanSource(facet : gmfgen::TypeLinkModelFacet) : Boolean {
return facet.sourceMetaFeature <> null or facet.childMetaFeature <> facet.containmentMetaFeature
}
-helper allPreferencePages(genDiagram : genModel::GenDiagram) : Sequence(genModel::GenPreferencePage) {
+helper allPreferencePages(genDiagram : gmfgen::GenDiagram) : Sequence(gmfgen::GenPreferencePage) {
return recursePages(genDiagram.preferencePages->asSequence())
}
-helper recursePages(pages : Sequence(genModel::GenPreferencePage)) : Sequence(genModel::GenPreferencePage) {
+helper recursePages(pages : Sequence(gmfgen::GenPreferencePage)) : Sequence(gmfgen::GenPreferencePage) {
return (if pages->isEmpty() then pages else pages->union(recursePages(pages.children))->asOrderedSet()->asSequence() endif)
}
+
+-- check if there's notation::FontStyle among diagram element's custom styles
+-- XXX the reason this is not inlined mostly because of troubles importing notation model into xpt
+helper gmfgen::GenCommonBase::hasFontStyleInCustom() : Boolean {
+ return self.styles->exists(s | s.ecoreClass.oclIsKindOf(notation::FontStyle));
+}
+
+helper gmfgen::GenCommonBase::hasLineStyleInCustom() : Boolean {
+ return self.styles->exists(s | s.ecoreClass.oclIsKindOf(notation::LineStyle));
+}
+
+helper gmfgen::GenCommonBase::hasFillStyleInCustom() : Boolean {
+ return self.styles->exists(s | s.ecoreClass.oclIsKindOf(notation::FillStyle));
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto
index 777bf93ca..78c53ddcc 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto
@@ -17,16 +17,20 @@ helper isStoringChildPositions(layoutType : gmfgen::ViewmapLayoutType) : Boolean
return gmfgen::ViewmapLayoutType::XY_LAYOUT = layoutType
}
-helper isFixedFont(viewmap : gmfgen::Viewmap) : Boolean {
- return viewmap.attributes[gmfgen::StyleAttributes]->exists(fixedFont)
+helper gmfgen::Viewmap::isFixedFont() : Boolean {
+ return self.attributes[gmfgen::StyleAttributes]->exists(fixedFont)
}
-helper isFixedForeground(viewmap : gmfgen::Viewmap) : Boolean {
- return viewmap.attributes[gmfgen::StyleAttributes]->exists(fixedForeground)
+helper gmfgen::Viewmap::isFixedForeground() : Boolean {
+ return self.attributes[gmfgen::StyleAttributes]->exists(fixedForeground)
}
-helper isFixedBackground(viewmap : gmfgen::Viewmap) : Boolean {
- return viewmap.attributes[gmfgen::StyleAttributes]->exists(fixedBackground)
+helper gmfgen::Viewmap::isFixedBackground() : Boolean {
+ return self.attributes[gmfgen::StyleAttributes]->exists(fixedBackground)
+}
+
+helper gmfgen::Viewmap::canUseShapeStyle() : Boolean {
+ return not (self.isFixedFont() or self.isFixedForeground() or self.isFixedBackground());
}
helper getResizeConstraints(viewmap : gmfgen::Viewmap) : gmfgen::ResizeConstraints {
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
index cd6ae4aec..e03b33e36 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
@@ -32,9 +32,7 @@ public class «itemSemanticEditPolicyClassName» extends «diagram.getBaseItemSeman
«DEFINE classBody FOR gmfgen::GenLink-»
«EXPAND getDestroySemanticCommand(self) FOR modelFacet -»
- «IF isTypeLink(self)-»
- «EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands -»
- «ENDIF-»
+ «IF isTypeLink()»«EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands»«ENDIF-»
«ENDDEFINE»
«DEFINE getDestroySemanticCommand(gmfgen::GenLink genLink) FOR gmfgen::LinkModelFacet-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
index 1726ee0d5..9a0bec4d9 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
@@ -1,40 +1,54 @@
-modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
-modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+/*
+ * Copyright (c) 2007, 2009 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+modeltype gmfgen uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genmodel uses "http://www.eclipse.org/emf/2002/GenModel";
library LinkUtils;
-helper isTypeLink(link : genModel::GenLink) : Boolean {
- return (Sequence { link.modelFacet })[genModel::TypeLinkModelFacet]->size() > 0
+helper gmfgen::GenLink::isTypeLink() : Boolean {
+ return self.modelFacet.oclIsKindOf(gmfgen::TypeLinkModelFacet)
}
-helper isRefLink(link : genModel::GenLink) : Boolean {
- return (Sequence { link.modelFacet })[genModel::FeatureLinkModelFacet]->size() > 0
+helper gmfgen::GenLink::isRefLink() : Boolean {
+ return self.modelFacet.oclIsKindOf(gmfgen::FeatureLinkModelFacet)
}
-helper canBeSource(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+helper canBeSource(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean {
return link.sources->includes(linkEnd)
}
-helper canBeTarget(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+helper canBeTarget(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean {
return link.targets->includes(linkEnd)
}
-helper canBeContainer(link : genModel::GenLink, metaClass : genModel_1::GenClass) : Boolean {
+helper canBeContainer(link : gmfgen::GenLink, metaClass : genmodel::GenClass) : Boolean {
return null <> link.modelFacet and isCompatible(link.modelFacet.getContainerClass(), metaClass)
}
-
-helper genModel::LinkModelFacet::getContainerClass() : genModel_1::GenClass {
+-- MODIFIERS: private
+helper gmfgen::LinkModelFacet::getContainerClass() : genmodel::GenClass {
return null
}
-
-helper genModel::TypeLinkModelFacet::getContainerClass() : genModel_1::GenClass {
+-- MODIFIERS: private
+helper gmfgen::TypeLinkModelFacet::getContainerClass() : genmodel::GenClass {
return self.childMetaFeature.genClass
}
-
-helper genModel::FeatureLinkModelFacet::getContainerClass() : genModel_1::GenClass {
+-- MODIFIERS: private
+helper gmfgen::FeatureLinkModelFacet::getContainerClass() : genmodel::GenClass {
return self.getSourceType()
}
-helper isCompatible(desiredType : genModel_1::GenClass, actualClass : genModel_1::GenClass) : Boolean {
+-- MODIFIERS: private
+helper isCompatible(desiredType : genmodel::GenClass, actualClass : genmodel::GenClass) : Boolean {
return null <> desiredType and desiredType.ecoreClass.isSuperTypeOf(actualClass.ecoreClass)
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
index 85b86ffda..b31bf14e8 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
@@ -34,11 +34,11 @@ helper getAllPotentialLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel:
}
helper getReroutableTypeLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
- return getAllRelatedReroutableLinks(linkEnd)->select(link | isTypeLink(link))
+ return getAllRelatedReroutableLinks(linkEnd)->select(isTypeLink())
}
helper getReroutableRefLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
- return getAllRelatedReroutableLinks(linkEnd)->select(link | isRefLink(link))
+ return getAllRelatedReroutableLinks(linkEnd)->select(isRefLink())
}
--XXX[MG]: again, it would be better to use linkEnd.incomingLinks.union(linkEnd.outgoingLinks).toList()
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
index 636555d30..654533ca3 100644
--- 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
@@ -23,12 +23,12 @@ public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diag
«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 isFixedForeground(viewmap)-»
+ «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 isFixedFont(viewmap)-»
+ «IF not viewmap.isFixedFont()-»
styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFontStyle());
«ENDIF-»
«EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt
index d64ea5314..79c072420 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt
@@ -278,7 +278,7 @@ public static int «EXPAND getLinkWithClassVisualIDMethodName»(org.eclipse.emf.ec
if (domainElement == null) {
«EXPAND unrecognizedVID-»
}
- «EXPAND returnVisualID FOREACH links->select(link | isTypeLink(link))-»
+ «EXPAND returnVisualID FOREACH links->select(isTypeLink())-»
«EXPAND unrecognizedVID-»
}
«ENDDEFINE»

Back to the top