aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskovalsky2012-05-01 18:03:25 (EDT)
committermgolubev2012-05-01 21:40:36 (EDT)
commitabf93492065112762b697f7f26610535f08abbe5 (patch)
treee829bec3b4c6f4c964fb33cf1e0a0de4106fe605
parent814b227b73c1f144c5625f1e4a0677987017c846 (diff)
downloadorg.eclipse.gmf-tooling-abf93492065112762b697f7f26610535f08abbe5.zip
org.eclipse.gmf-tooling-abf93492065112762b697f7f26610535f08abbe5.tar.gz
org.eclipse.gmf-tooling-abf93492065112762b697f7f26610535f08abbe5.tar.bz2
[368169] - common API for all VisualIDRegistries is extracted and
typed adapter is generated (backport from U2T), +sample regenerated
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEVisualIDRegistry.java99
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/editor/VisualIDRegistry.xpt114
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/structure/DiagramStructure.java20
3 files changed, 233 insertions, 0 deletions
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEVisualIDRegistry.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEVisualIDRegistry.java
index 0cffb64..dfccc3d 100644
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEVisualIDRegistry.java
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEVisualIDRegistry.java
@@ -31,6 +31,7 @@ import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabelEd
import org.eclipse.gmf.examples.ocldriven.toe.diagram.expressions.TOEOCLFactory;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.structure.DiagramStructure;
/**
* This registry is used to determine which type of visual object should be
@@ -311,4 +312,102 @@ public class TOEVisualIDRegistry {
return result instanceof Boolean && ((Boolean) result).booleanValue();
}
+ /**
+ * @generated
+ */
+ public static boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
+ if (candidate == -1) {
+ //unrecognized id is always bad
+ return false;
+ }
+ int basic = getNodeVisualID(containerView, domainElement);
+ return basic == candidate;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isCompartmentVisualID(int visualID) {
+ switch (visualID) {
+ case DepartmentDepartment_staffEditPart.VISUAL_ID:
+ case DepartmentDepartment_staff2EditPart.VISUAL_ID:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isSemanticLeafVisualID(int visualID) {
+ switch (visualID) {
+ case AllHolderEditPart.VISUAL_ID:
+ return false;
+ case EmployeeEditPart.VISUAL_ID:
+ case ProjectEditPart.VISUAL_ID:
+ case ManagerEditPart.VISUAL_ID:
+ case Employee2EditPart.VISUAL_ID:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static final DiagramStructure TYPED_INSTANCE = new DiagramStructure() {
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getVisualID(View view) {
+ return org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry.getVisualID(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getModelID(View view) {
+ return org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry.getModelID(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getNodeVisualID(View containerView, EObject domainElement) {
+ return org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry.getNodeVisualID(containerView, domainElement);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
+ return org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry.checkNodeVisualID(containerView, domainElement, candidate);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isCompartmentVisualID(int visualID) {
+ return org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry.isCompartmentVisualID(visualID);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSemanticLeafVisualID(int visualID) {
+ return org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry.isSemanticLeafVisualID(visualID);
+ }
+ };
+
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/VisualIDRegistry.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/VisualIDRegistry.xpt
index 76c39e2..892be88 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/VisualIDRegistry.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/VisualIDRegistry.xpt
@@ -8,6 +8,7 @@
*
* Contributors:
* Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #372479
*/
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
@@ -15,6 +16,8 @@
«EXTENSION xpt::editor::Utils»
«EXTENSION xpt::diagram::editpolicies::LinkUtils»
+«EXTENSION xpt::diagram::updater::Utils»
+
«DEFINE VisualIDRegistry FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
@@ -48,6 +51,14 @@ public class «visualIDRegistryClassName» {
«EXPAND isDiagram-»
«EXPAND _constraintMethods-»
+
+ «EXPAND checkNodeVisualID-»
+
+ «EXPAND isCompartmentVisualID-»
+
+ «EXPAND isSemanticLeafVisualID-»
+
+ «EXPAND runtimeTypedInstance-»
«EXPAND additions-»
}
@@ -359,4 +370,107 @@ private static boolean isDiagram(«EXPAND MetaModel::QualifiedClassName FOR doma
return -1;
«ENDDEFINE»
+«DEFINE checkNodeVisualIDMethodName FOR gmfgen::GenDiagram»checkNodeVisualID«ENDDEFINE»
+«DEFINE checkNodeVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND checkNodeVisualIDMethodName»«ENDDEFINE»
+
+«DEFINE checkNodeVisualID FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static boolean «EXPAND checkNodeVisualIDMethodName»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, int candidate) {
+ if (candidate == -1){
+ //unrecognized id is always bad
+ return false;
+ }
+ «REM»For now there are only one possibility, but this may be changed in moderately near future«ENDREM»«-»
+ int basic = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodName»(containerView, domainElement);
+ return basic == candidate;
+ }
+«ENDDEFINE»
+
+«DEFINE isCompartmentVisualIDMethodName FOR gmfgen::GenDiagram»isCompartmentVisualID«ENDDEFINE»
+«DEFINE isCompartmentVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND isCompartmentVisualIDMethodName»«ENDDEFINE»
+
+«DEFINE isCompartmentVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static boolean «EXPAND isCompartmentVisualIDMethodName»(int visualID) {
+ «IF not compartments->isEmpty()-»
+ switch (visualID) {
+ «EXPAND xpt::Common::caseVisualID FOREACH compartments»
+ return true;
+ default:
+ break;
+ }
+ «ENDIF-»
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE isSemanticLeafVisualIDMethodName FOR gmfgen::GenDiagram»isSemanticLeafVisualID«ENDDEFINE»
+«DEFINE isSemanticLeafVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND isSemanticLeafVisualIDMethodName»«ENDDEFINE»
+
+«DEFINE isSemanticLeafVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static boolean «EXPAND isSemanticLeafVisualIDMethodName»(int visualID) {
+ switch (visualID) {
+ «REM»We need to ensure at last one case, this is legitimate way«ENDREM»«-»
+ «EXPAND xpt::Common::caseVisualID FOR self»
+ return false;
+ «FOREACH self.getAllNodes()->asSequence()->sortedBy(n | n.visualID) AS nextNode-»
+ «IF getSemanticChildren(nextNode)->isEmpty()-»
+ «IF not nextNode.oclIsKindOf(gmfgen::GenNode) or nextNode.oclAsType(gmfgen::GenNode).compartments->select(c | not getSemanticChildren(c)->isEmpty())->isEmpty()-»
+ «EXPAND xpt::Common::caseVisualID FOR nextNode»
+ «ENDIF-»
+ «ENDIF-»
+ «ENDFOREACH-»
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE runtimeTypedInstanceName FOR gmfgen::GenDiagram»TYPED_INSTANCE«ENDDEFINE»
+«DEFINE runtimeTypedInstanceCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND runtimeTypedInstanceName»«ENDDEFINE»
+
+«DEFINE runtimeTypedInstance FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+ public static final org.eclipse.gmf.tooling.runtime.structure.DiagramStructure «EXPAND runtimeTypedInstanceName» = new org.eclipse.gmf.tooling.runtime.structure.DiagramStructure() {
+ «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND CodeStyle::override»
+ public int «EXPAND xpt::editor::VisualIDRegistry::getVisualIdMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ return «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(view);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND CodeStyle::override»
+ public String «EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ return «EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(view);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND CodeStyle::override»
+ public int «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodName»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
+ return «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall»(containerView, domainElement);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND CodeStyle::override»
+ public boolean «EXPAND checkNodeVisualIDMethodName»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, int candidate) {
+ return «EXPAND checkNodeVisualIDMethodCall»(containerView, domainElement, candidate);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND CodeStyle::override»
+ public boolean «EXPAND isCompartmentVisualIDMethodName»(int visualID) {
+ return «EXPAND isCompartmentVisualIDMethodCall»(visualID);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND CodeStyle::override»
+ public boolean «EXPAND isSemanticLeafVisualIDMethodName»(int visualID) {
+ return «EXPAND isSemanticLeafVisualIDMethodCall»(visualID);
+ }
+ };
+«ENDDEFINE»
+
«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/structure/DiagramStructure.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/structure/DiagramStructure.java
new file mode 100644
index 0000000..05c937b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/structure/DiagramStructure.java
@@ -0,0 +1,20 @@
+package org.eclipse.gmf.tooling.runtime.structure;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.View;
+
+public abstract class DiagramStructure {
+
+ public abstract int getVisualID(View view);
+
+ public abstract String getModelID(View view);
+
+ public abstract int getNodeVisualID(View containerView, EObject domainElement);
+
+ public abstract boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate);
+
+ public abstract boolean isCompartmentVisualID(int visualID);
+
+ public abstract boolean isSemanticLeafVisualID(int visualID);
+
+}