Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-08-24 13:13:36 +0000
committeratikhomirov2006-08-24 13:13:36 +0000
commit602bd6b0125c6564436cf870100d413d0e0f6bd7 (patch)
tree42a39366e32d491ffc5bc0635acf7dd0f6d82983 /plugins/org.eclipse.gmf.graphdef.codegen/templates
parent4000ac816f4a9f03d43ad13ce3eacca4868565bc (diff)
downloadorg.eclipse.gmf-tooling-602bd6b0125c6564436cf870100d413d0e0f6bd7.tar.gz
org.eclipse.gmf-tooling-602bd6b0125c6564436cf870100d413d0e0f6bd7.tar.xz
org.eclipse.gmf-tooling-602bd6b0125c6564436cf870100d413d0e0f6bd7.zip
[154683] mgolubev - Handle custom borders.
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet9
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/customBorderFactoryMethods.jetinc38
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CustomBorder.javajet11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet4
5 files changed, 64 insertions, 6 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
index fa176f2d8..afd9d391e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
@@ -4,9 +4,12 @@
final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
final String varName = (String) ((Object[]) argument)[2];
-final boolean hasAttributes = !instance.getAttributes().isEmpty();
+boolean insertingArbitraryCode = false;
+for (Iterator attributes = instance.getAttributes().iterator(); !insertingArbitraryCode && attributes.hasNext();){
+ insertingArbitraryCode = ((CustomAttribute)attributes.next()).isMultiStatementValue();
+}
%>
-<% if (hasAttributes) {%>
+<% if (insertingArbitraryCode) {%>
{
<% }%>
<%
@@ -34,7 +37,7 @@ for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attr
<%
} //for
%>
-<% if (hasAttributes) {%>
+<% if (insertingArbitraryCode) {%>
}
<% }%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/customBorderFactoryMethods.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/customBorderFactoryMethods.jetinc
new file mode 100644
index 000000000..78d4422f3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/customBorderFactoryMethods.jetinc
@@ -0,0 +1,38 @@
+<%
+//input: [oeg].common.codegen.ImportAssistant importManager
+//input: [oeg].graphdef.codegen GraphDefDispatcher dispatcher
+//input: [oeg].gmfgraph.Figure figure
+
+{ //namespace -- use "bfm" (stands for BorderFactoryMethod) to avoid name clashes
+ int bfmNextIndex = 1;
+ String bfmLastFigureName = "";
+ for (Iterator bfmAllCustomBorders = EcoreUtil.getAllContents(figure, false); bfmAllCustomBorders.hasNext();){
+ EObject bfmNext = (EObject)bfmAllCustomBorders.next();
+ if (GMFGraphPackage.eINSTANCE.getFigure().isSuperTypeOf(bfmNext.eClass())){
+ bfmLastFigureName = (String)bfmNext.eGet(GMFGraphPackage.eINSTANCE.getIdentity_Name());
+ if (bfmLastFigureName == null){
+ bfmLastFigureName = "";
+ }
+ }
+ // XXX [artem] why not do this with ((Figure) bfmNext).getBorder()?
+ if (bfmNext.eClass().getClassifierID() != GMFGraphPackage.CUSTOM_BORDER){
+ continue;
+ }
+
+ String bfmNextImplClass = dispatcher.getFQNSwitch().get(bfmNext, importManager);
+ String bfmNextMethodName = "createBorder_" + CodeGenUtil.capName(bfmLastFigureName) + "_" + (bfmNextIndex++);
+
+%>
+ /**
+ * @generated
+ */
+ private <%=importManager.getImportedName("org.eclipse.draw2d.Border")%> <%=bfmNextMethodName%>() {
+ <%=bfmNextImplClass%> result = new <%=bfmNextImplClass%>();
+ <%=dispatcher.dispatch("customAttributes", new Object[] {bfmNext, dispatcher, "result"} )%>
+ return result;
+ }
+<%
+ dispatcher.getAuxiliaryDataStorage().registerData(bfmNext, bfmNextMethodName);
+ }
+} //end of namespace
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CustomBorder.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CustomBorder.javajet
new file mode 100644
index 000000000..e77fec827
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CustomBorder.javajet
@@ -0,0 +1,11 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewCustomBorderExpressionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+Object[] args = (Object[]) argument;
+final CustomBorder border = (CustomBorder)args[0];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1];
+//final ImportAssistant importManager = dispatcher.getImportManager();
+
+//We want NEITHER insert any names into the scope NOR produce statement. We need expression instead.
+//@see customBorderFactoryMethod.jetinc
+%><%=dispatcher.getAuxiliaryDataStorage().getRegisteredData(border)%>()
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
index aa4f4dba1..ffb3a645f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -1,11 +1,13 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* java.util.Iterator;"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.emf.ecore.* java.util.Iterator org.eclipse.emf.ecore.util.EcoreUtil org.eclipse.emf.codegen.util.CodeGenUtil; "%>
<%
Object[] args = (Object[]) argument;
Figure figure = (Figure) args[0];
final ImportAssistant importManager = (ImportAssistant) args[1];
final FigureQualifiedNameSwitch fqnSwitch = (FigureQualifiedNameSwitch) args[2];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
+
+//[MG] FIXME: Why we need this? Is it in use somewhere?
final boolean isInnerClass = ((Boolean) args[4]).booleanValue();
%>
<%importManager.emitPackageStatement(stringBuffer);%>
@@ -17,13 +19,15 @@ final boolean isInnerClass = ((Boolean) args[4]).booleanValue();
*/
public class <%=importManager.getCompilationUnitName()%> extends <%=fqnSwitch.get(figure, importManager)%> {
+<%@ include file="../customBorderFactoryMethods.jetinc"%>
+
/**
* @generated
*/
public <%=figure.getName()%>() {
<%
GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "myGenLayoutManager", null);
-%>
+%>
<%=dispatcher.dispatch("createLayout", dispatcherArgs)%>
<%=dispatcher.dispatch(figure, dispatcherArgs)%>
createContents();
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
index c20e4c0c8..4be7ba54c 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
@@ -1,5 +1,5 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopConnectionGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* java.util.Iterator"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.emf.ecore.* java.util.Iterator org.eclipse.emf.ecore.util.EcoreUtil org.eclipse.emf.codegen.util.CodeGenUtil;"%>
<%
Object[] args = (Object[]) argument;
PolylineConnection figure = (PolylineConnection) args[0];
@@ -17,6 +17,8 @@ final boolean isInnerClass = ((Boolean) args[4]).booleanValue();
*/
public class <%=importManager.getCompilationUnitName()%> extends <%=fqnSwitch.get(figure, importManager)%> {
+<%@ include file="../customBorderFactoryMethods.jetinc"%>
+
/**
* @generated
*/

Back to the top