Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2010-04-26 17:20:56 -0400
committeratikhomirov2010-04-26 17:20:56 -0400
commitf33a508780d4280a5a40fc57cc8c98a2ce579b39 (patch)
treed8decdf15b4ca00459abe2c6b5f0cdf5640d7c0b
parentf1e1bf37dd4c84db773a3d59b1808973e9aa2144 (diff)
downloadorg.eclipse.gmf-tooling-f33a508780d4280a5a40fc57cc8c98a2ce579b39.tar.gz
org.eclipse.gmf-tooling-f33a508780d4280a5a40fc57cc8c98a2ce579b39.tar.xz
org.eclipse.gmf-tooling-f33a508780d4280a5a40fc57cc8c98a2ce579b39.zip
[231330] reduce use of static fields - refactored to shorten access to the constraints methods
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt26
1 files changed, 14 insertions, 12 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
index 0c1d31610..db6f8eedb 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
@@ -300,7 +300,7 @@ protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(org.ec
«ENDDEFINE»
«DEFINE _accessLinkConstraints FOR gmfgen::GenDiagram-»
-«getBaseItemSemanticEditPolicyQualifiedClassName()».«getLinkCreationConstraintsClassName()».getInstance()«-»
+«getBaseItemSemanticEditPolicyQualifiedClassName()».getLinkConstraints()«-»
«ENDDEFINE»
«DEFINE canExistCall FOR gmfgen::GenLink-»
@@ -317,6 +317,17 @@ protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(org.ec
for e.g. Java (or Literal, which is unlikely, though) expressions
«ENDREM»
«DEFINE linkConstraints FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static «getLinkCreationConstraintsClassName()» getLinkConstraints() {
+ «getLinkCreationConstraintsClassName()» cached = «EXPAND plugin::Activator::instanceAccess FOR editorGen».getLinkConstraints();
+ if (cached == null) {
+ «EXPAND plugin::Activator::instanceAccess FOR editorGen».setLinkConstraints(cached = new «getLinkCreationConstraintsClassName()»());
+ }
+ return cached;
+ }
+
+
«EXPAND xpt::Common::generatedClassComment»
public static class «getLinkCreationConstraintsClassName()» {
@@ -337,17 +348,8 @@ public static class «getLinkCreationConstraintsClassName()» {
«ENDIF-»
«EXPAND xpt::Common::generatedMemberComment»
- private «getLinkCreationConstraintsClassName()»() {
- // use static method #getInstance() to access instance
- }
-
- «EXPAND xpt::Common::generatedMemberComment»
- public static «getLinkCreationConstraintsClassName()» getInstance() {
- «getLinkCreationConstraintsClassName()» cached = «EXPAND plugin::Activator::instanceAccess FOR editorGen».getLinkConstraints();
- if (cached == null) {
- «EXPAND plugin::Activator::instanceAccess FOR editorGen».setLinkConstraints(cached = new «getLinkCreationConstraintsClassName()»());
- }
- return cached;
+ «getLinkCreationConstraintsClassName()»() {«REM»package-local for the BaseItemSemanticEditPolicy to instantiate. Perhaps, protected is better (i.e. if someone subclasses it?)«ENDREM»
+ // use static method #getLinkConstraints() to access instance
}
«EXPAND canCreate FOREACH links-»

Back to the top