Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2010-03-09 21:38:40 +0000
committeratikhomirov2010-03-09 21:38:40 +0000
commit5cbe47ca58f74f7d84c2bc12190940c919d1e439 (patch)
tree2bb205f39be17f1af4f27835fba7468e95ecd5c5 /plugins/org.eclipse.gmf.graphdef.codegen
parent9a2bdf32388b53362d2584f71128c30a6bd878c8 (diff)
downloadorg.eclipse.gmf-tooling-5cbe47ca58f74f7d84c2bc12190940c919d1e439.tar.gz
org.eclipse.gmf-tooling-5cbe47ca58f74f7d84c2bc12190940c919d1e439.tar.xz
org.eclipse.gmf-tooling-5cbe47ca58f74f7d84c2bc12190940c919d1e439.zip
removed duplicating xpand string operations (length, startsWith and endsWith) and use thereof
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.qvto77
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt7
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt4
3 files changed, 48 insertions, 40 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.qvto b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.qvto
index 1cdd73c7c..8adc13bc4 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.qvto
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.qvto
@@ -1,14 +1,25 @@
+/*
+ * Copyright (c) 2007, 2010 Borland Software Corporation and others
+ *
+ * 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:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
import xpt.GlobalVarOperations;
import xpt.StreamOperations;
import xpt.StringOperations;
-modeltype graphicalDefinition uses "http://www.eclipse.org/gmf/2006/GraphicalDefinition";
+modeltype gmfgraph uses "http://www.eclipse.org/gmf/2006/GraphicalDefinition";
library Util;
-property bordersInUse : Sequence(graphicalDefinition::CustomBorder) = Sequence { };
+property bordersInUse : Sequence(gmfgraph::CustomBorder) = Sequence { };
-helper addBorder(border : graphicalDefinition::CustomBorder) : OclVoid {
+helper addBorder(border : gmfgraph::CustomBorder) : OclVoid {
bordersInUse := bordersInUse->including(border);
return null
}
@@ -18,15 +29,15 @@ helper clearBorders() : OclVoid {
return null
}
-helper getBordersInUse() : Sequence(graphicalDefinition::CustomBorder) {
+helper getBordersInUse() : Sequence(gmfgraph::CustomBorder) {
return bordersInUse;
}
-helper compilationUnitName(figure : graphicalDefinition::FigureDescriptor) : String {
+helper compilationUnitName(figure : gmfgraph::FigureDescriptor) : String {
return figure.name.firstToUpper()
}
-helper hasSourceDecoration(figure : graphicalDefinition::PolylineConnection) : Boolean {
+helper hasSourceDecoration(figure : gmfgraph::PolylineConnection) : Boolean {
return null <> figure.sourceDecoration
}
@@ -38,7 +49,7 @@ helper additionalStaticFields() : String {
return if xpandGetStreamNames()->includes('staticFields') then xpandGetStreamContents('staticFields') else '' endif
}
-helper hasTargetDecoration(figure : graphicalDefinition::PolylineConnection) : Boolean {
+helper hasTargetDecoration(figure : gmfgraph::PolylineConnection) : Boolean {
return null <> figure.targetDecoration
}
@@ -50,87 +61,87 @@ helper internalCheckRuntimeToken() : String {
return xpandGetStringGlobalVar('runtimeToken')
}
-helper needsField(figure : graphicalDefinition::RealFigure) : Boolean {
+helper needsField(figure : gmfgraph::RealFigure) : Boolean {
return figure.descriptor <> null and figure.descriptor.accessors.figure->includes(figure)
}
-helper figureVariableName(figure : graphicalDefinition::RealFigure, count : Integer) : String {
- return (if needsField(figure) then figure.figureFieldName() else (if figure.name <> null and figure.name.trim().xpandLength() > 0 then figure.name.xpandToFirstLower() + count.repr() else figure.variableNameStem() + count.repr() endif) endif)
+helper figureVariableName(figure : gmfgraph::RealFigure, count : Integer) : String {
+ return (if needsField(figure) then figure.figureFieldName() else (if figure.name <> null and figure.name.trim().size() > 0 then figure.name.xpandToFirstLower() + count.repr() else figure.variableNameStem() + count.repr() endif) endif)
}
-helper graphicalDefinition::FigureRef::nameStem() : String {
+helper gmfgraph::FigureRef::nameStem() : String {
return self.figure.variableNameStem()
}
-helper graphicalDefinition::Figure::nameStem() : String {
+helper gmfgraph::Figure::nameStem() : String {
return self.variableNameStem()
}
-helper graphicalDefinition::Figure::variableNameStem() : String {
+helper gmfgraph::Figure::variableNameStem() : String {
return 'fig'
}
-helper graphicalDefinition::RealFigure::variableNameStem() : String {
+helper gmfgraph::RealFigure::variableNameStem() : String {
return 'fig'
}
-helper graphicalDefinition::Shape::variableNameStem() : String {
+helper gmfgraph::Shape::variableNameStem() : String {
return 'shape'
}
-helper graphicalDefinition::Rectangle::variableNameStem() : String {
+helper gmfgraph::Rectangle::variableNameStem() : String {
return 'rect'
}
-helper graphicalDefinition::RoundedRectangle::variableNameStem() : String {
+helper gmfgraph::RoundedRectangle::variableNameStem() : String {
return 'rrect'
}
-helper graphicalDefinition::Ellipse::variableNameStem() : String {
+helper gmfgraph::Ellipse::variableNameStem() : String {
return 'elli'
}
-helper graphicalDefinition::Polyline::variableNameStem() : String {
+helper gmfgraph::Polyline::variableNameStem() : String {
return 'polyline'
}
-helper graphicalDefinition::Label::variableNameStem() : String {
+helper gmfgraph::Label::variableNameStem() : String {
return 'l'
}
-helper graphicalDefinition::DecorationFigure::variableNameStem() : String {
+helper gmfgraph::DecorationFigure::variableNameStem() : String {
return 'dec'
}
-helper graphicalDefinition::ConnectionFigure::variableNameStem() : String {
+helper gmfgraph::ConnectionFigure::variableNameStem() : String {
return 'conn'
}
-helper graphicalDefinition::RealFigure::figureFieldName() : String {
+helper gmfgraph::RealFigure::figureFieldName() : String {
return figureFieldName(self.descriptor.accessors->select(a | self = a.figure)->asSequence())
}
-helper figureFieldName(aaa : Sequence(graphicalDefinition::ChildAccess)) : String {
+helper figureFieldName(aaa : Sequence(gmfgraph::ChildAccess)) : String {
return aaa->collect(x | x.figureFieldName())->first()
}
-helper graphicalDefinition::ChildAccess::figureFieldName() : String {
- return 'f' + (if self.accessor.xpandStartsWith('get') and self.accessor.xpandLength() > 3 then self.accessor.xpandSubstring(3) else self.accessor endif)
+helper gmfgraph::ChildAccess::figureFieldName() : String {
+ return 'f' + (if self.accessor.startsWith('get') and self.accessor.size() > 3 then self.accessor.substringAfter('get') else self.accessor endif)
}
-helper borderLayoutConstant(layoutData : graphicalDefinition::BorderLayoutData) : String {
- return switch { case (layoutData.alignment = graphicalDefinition::Alignment::BEGINNING) (if layoutData.vertical then 'TOP' else 'LEFT' endif); case (layoutData.alignment = graphicalDefinition::Alignment::END) (if layoutData.vertical then 'BOTTOM' else 'RIGHT' endif); else 'CENTER'; }
+helper borderLayoutConstant(layoutData : gmfgraph::BorderLayoutData) : String {
+ return switch { case (layoutData.alignment = gmfgraph::Alignment::BEGINNING) (if layoutData.vertical then 'TOP' else 'LEFT' endif); case (layoutData.alignment = gmfgraph::Alignment::END) (if layoutData.vertical then 'BOTTOM' else 'RIGHT' endif); else 'CENTER'; }
}
-helper allCustomAccessors(fd : graphicalDefinition::FigureDescriptor) : Sequence(graphicalDefinition::FigureAccessor) {
+helper allCustomAccessors(fd : gmfgraph::FigureDescriptor) : Sequence(gmfgraph::FigureAccessor) {
return filterCustom(Sequence { fd.actualFigure }).customChildren
}
-helper filterCustom(figures : Sequence(graphicalDefinition::Figure)) : Sequence(graphicalDefinition::CustomFigure) {
- return (if figures->isEmpty() then Sequence { } else (figures)[graphicalDefinition::CustomFigure]->union(filterCustom((figures)[graphicalDefinition::RealFigure].children))->asOrderedSet()->asSequence() endif)->collect(it | it)->asSequence()
+helper filterCustom(figures : Sequence(gmfgraph::Figure)) : Sequence(gmfgraph::CustomFigure) {
+ return (if figures->isEmpty() then Sequence { } else (figures)[gmfgraph::CustomFigure]->union(filterCustom((figures)[gmfgraph::RealFigure].children))->asOrderedSet()->asSequence() endif)->collect(it | it)->asSequence()
}
-helper svgPropertyType(p : graphicalDefinition::SVGProperty) : String {
- return switch { case (p.type = graphicalDefinition::SVGPropertyType::COLOR) 'org.eclipse.swt.graphics.Color'; case (p.type = graphicalDefinition::SVGPropertyType::FLOAT) 'float'; else 'String'; }
+helper svgPropertyType(p : gmfgraph::SVGProperty) : String {
+ return switch { case (p.type = gmfgraph::SVGPropertyType::COLOR) 'org.eclipse.swt.graphics.Color'; case (p.type = gmfgraph::SVGPropertyType::FLOAT) 'float'; else 'String'; }
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
index c787d6469..7992ba3ad 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2010 Borland Software Corporation and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,9 +10,6 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'»
-«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«EXTENSION Util»
-«EXTENSION xpt::StringOperations»
«DEFINE figureAttrs(figureVarName : String) FOR gmfgraph::Figure-»
«EXPAND foregroundColor(self, figureVarName) FOR foregroundColor-»
@@ -88,7 +85,7 @@ org.eclipse.draw2d.ColorConstants.«value-»
/**
* @generated
*/
-static final org.eclipse.swt.graphics.Font «variableName» = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), «IF null = faceName or faceName.trim().xpandLength() = 0»org.eclipse.swt.widgets.Display.getDefault().getSystemFont().getFontData()[0].getName()«ELSE»"«faceName»"«ENDIF», «height», org.eclipse.swt.SWT.«style»);
+static final org.eclipse.swt.graphics.Font «variableName» = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), «IF null = faceName or faceName.trim().size() = 0»org.eclipse.swt.widgets.Display.getDefault().getSystemFont().getFontData()[0].getName()«ELSE»"«faceName»"«ENDIF», «height», org.eclipse.swt.SWT.«style»);
«ENDFILE»
«ENDLET»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt
index edc82e8d2..7fc50c1ab 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Borland Software Corporation
+ * Copyright (c) 2007, 2010 Borland Software Corporation and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -16,7 +16,7 @@
«EXTENSION xpt::StringOperations»
«DEFINE Top(packageStmt : String) FOR gmfgraph::FigureDescriptor»
-«IF packageStmt <> null and packageStmt.xpandLength() > 0»package «packageStmt»;
+«IF packageStmt <> null and packageStmt.size() > 0»package «packageStmt»;
«ENDIF-»
/**
* @generated

Back to the top