Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-05-02 11:44:15 +0000
committeratikhomirov2006-05-02 11:44:15 +0000
commitd10419d8617a229fbcc45f3a0358566d8a4aaf75 (patch)
tree4e9903d690354a25a05f88b4183c3039d11fc849 /plugins/org.eclipse.gmf.graphdef.codegen/templates
parentd1df87d283ceb73df7175d9266c9742a262c26c1 (diff)
downloadorg.eclipse.gmf-tooling-d10419d8617a229fbcc45f3a0358566d8a4aaf75.tar.gz
org.eclipse.gmf-tooling-d10419d8617a229fbcc45f3a0358566d8a4aaf75.tar.xz
org.eclipse.gmf-tooling-d10419d8617a229fbcc45f3a0358566d8a4aaf75.zip
[mgolubev] #139139 Compilation error in the generated diagram code if DiagramLabel points to the deep Label
Add getters/setters for each figure that is being used by any diagram element
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet110
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet48
7 files changed, 88 insertions, 78 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
index 7b67ccbdc..3a1192f49 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -1,43 +1,97 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureChildrenGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* java.util.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.emf.codegen.util.CodeGenUtil java.util.*"%>
<%
-Object[] args = (Object[]) argument;
-List/*<Figure>*/ figureChildren = (List) args[0];
-final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
-GraphDefDispatcher.LayoutArgs parentArgs = (GraphDefDispatcher.LayoutArgs) args[2];
+GraphDefDispatcher.LayoutArgs parentArgs = (GraphDefDispatcher.LayoutArgs) argument;
+final Figure root = parentArgs.getFigure();
+final GraphDefDispatcher dispatcher = parentArgs.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
+
+final List/*<Figure>*/ fieldsRequired = new LinkedList/*<Figure>*/();
+final Stack/*GraphDefDispatcher.LayoutArgs*/ contextStack = new Stack/*GraphDefDispatcher.LayoutArgs*/();
+final LinkedList queue = new LinkedList();
+final Object marker = new Object();
+
+class FieldSupport {
+ private final Figure myRoot;
+
+ public FieldSupport(Figure root){
+ myRoot = root;
+ }
+
+ public boolean isFieldRequired(Figure descendant){
+ return myRoot.equals(descendant.getParent()) || !descendant.getReferencingElements().isEmpty();
+ }
+}
+final FieldSupport fieldSupport = new FieldSupport(root);
+
%>
+ /**
+ * @generated
+ */
+ private void createContents(){
<%
-LinkedList l = new LinkedList();
-l.addAll(figureChildren);
-final Object marker = new Object();
-Stack figureVarNamesStack = new Stack();
+queue.addAll(root.getChildren());
int figureCount = 0;
-while (!l.isEmpty()) {
- Object _nxt = l.removeFirst();
- if (_nxt == marker) {
- parentArgs = (GraphDefDispatcher.LayoutArgs) figureVarNamesStack.pop();
+while (!queue.isEmpty()){
+ Object _nxt = queue.removeFirst();
+ if (_nxt == marker){
+ parentArgs = (GraphDefDispatcher.LayoutArgs)contextStack.pop();
continue;
}
- final FigureMarker figureMarker = (FigureMarker) _nxt;
- if (figureMarker instanceof FigureRef) {
+ if (_nxt instanceof FigureRef) {
throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
}
- final String figureVarName = "fig_" + figureCount;
- final String layoutManagerVarName = "layouter" + figureCount;
- final String layoutDataVarName = "layData" + figureCount;
+ final Figure nextChild = (Figure) _nxt;
+ final String childVarName = "fig_" + figureCount;
+ final String childLayoutManager = "layouter" + figureCount;
+ final String childConstraint = "layData" + figureCount;
figureCount++;
- // FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
- GraphDefDispatcher.LayoutArgs nextLevelArgs = dispatcher.createLayoutArgs((Figure) figureMarker, figureVarName, layoutManagerVarName, layoutDataVarName);%>
+
+ // FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
+ GraphDefDispatcher.LayoutArgs nextLevelArgs = dispatcher.createLayoutArgs(nextChild, childVarName, childLayoutManager, childConstraint);%>
<%=dispatcher.dispatch("instantiate", nextLevelArgs)%>
- <%=parentArgs.getVariableName()%>.add(<%=figureVarName%>);
- <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(nextLevelArgs, parentArgs.getManagerVariableName(), layoutDataVarName))%>
<%
-if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
- l.addFirst(marker);
- l.addAll(0, ((Figure) _nxt).getChildren());
- figureVarNamesStack.push(parentArgs);
- parentArgs = nextLevelArgs; // go on processing children of new parentFigure
-} // if
+if (fieldSupport.isFieldRequired(nextChild)){
+ fieldsRequired.add(nextChild); %>
+ setFigure<%=nextChild.getName()%>(<%=childVarName%>);
+<%}%>
+ <%=dispatcher.dispatch("createLayoutData", nextLevelArgs)%>
+ <%=parentArgs.getVariableName()%>.add(<%=childVarName%>, <%=childConstraint%>);
+<%
+ if (!nextChild.getChildren().isEmpty()) {
+ queue.addFirst(marker);
+ queue.addAll(0, nextChild.getChildren());
+ contextStack.push(parentArgs);
+ parentArgs = nextLevelArgs; // go on processing children of new parentFigure
+ }
} // while
%>
+ }
+
+<%
+ final FigureQualifiedNameSwitch fqnSwitch = dispatcher.getFQNSwitch();
+ for (Iterator fieldFigures = fieldsRequired.iterator(); fieldFigures.hasNext();){
+ Figure next = (Figure)fieldFigures.next();
+ final String nextClassName = fqnSwitch.get(next, importManager);%>
+
+ /**
+ * @generated
+ */
+ private <%=nextClassName%> f<%=CodeGenUtil.capName(next.getName())%>;
+
+ /**
+ * @generated
+ */
+ public <%=nextClassName%> getFigure<%=next.getName()%>() {
+ return f<%=CodeGenUtil.capName(next.getName())%>;
+ }
+
+ /**
+ * @generated
+ */
+ private void setFigure<%=next.getName()%>(<%=nextClassName%> fig){
+ f<%=CodeGenUtil.capName(next.getName())%> = fig;
+ }
+
+<% }%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
index 71d2d42b8..84eabfbf5 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
@@ -36,5 +36,5 @@ switch(alignment.getValue()){
throw new IllegalArgumentException("Unknown Alignment: " + gmfLayoutData.getAlignment());
}
%>
- <%=argsBundle.getManagerVariableName()%>.setConstraint(<%=figureVarName%>, <%=dispatcher.getImportManager().getImportedName("org.eclipse.draw2d.BorderLayout")%>.<%=constantName%>);
+ Object <%=argsBundle.getConstraintVariableName()%> = <%=dispatcher.getImportManager().getImportedName("org.eclipse.draw2d.BorderLayout")%>.<%=constantName%>;
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
index 8bba91d23..5708ddd79 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
@@ -8,4 +8,4 @@ final String layoutImplClassName = dispatcher.getFQNSwitch().get(layoutData, dis
%>
<%=layoutImplClassName%> <%=args.getConstraintVariableName()%> = new <%=layoutImplClassName%>();
<%=dispatcher.dispatch("customAttributes", new Object[] {layoutData, dispatcher, args.getConstraintVariableName()})%>
-<%=args.getManagerVariableName()%>.setConstraint(<%=args.getVariableName()%>, <%=args.getConstraintVariableName()%>);
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
index 66e27f267..961966d96 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
@@ -28,5 +28,4 @@ if (sizeHint != null){
<%=layoutConstraintVarName%>.verticalSpan = <%=gmfLayoutData.getVerticalSpan()%>;
<%=layoutConstraintVarName%>.grabExcessHorizontalSpace = <%=gmfLayoutData.isGrabExcessHorizontalSpace()%>;
<%=layoutConstraintVarName%>.grabExcessVerticalSpace = <%=gmfLayoutData.isGrabExcessVerticalSpace()%>;
- <%=layoutManagerVarName%>.setConstraint(<%=figureVarName%>, <%=layoutConstraintVarName%>);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet
index 46e983dff..d293f6c54 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet
@@ -30,4 +30,3 @@ if (size != null){
<%
}
%>
- <%=layoutManagerVarName%>.setConstraint(<%=figureVarName%>, <%=layoutConstraintVarName%>);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet
index b96640d3f..5fca8b7ec 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet
@@ -13,4 +13,6 @@ final Figure figureInstance = argsBundle.getFigure();
if (gmfLayoutData != null && figureInstance.eContainer() instanceof Figure && ((Figure) figureInstance.eContainer()).getLayout() != null) {%>
<%=dispatcher.dispatch(gmfLayoutData, argsBundle)%>
+<%} else {%>
+ Object <%=argsBundle.getConstraintVariableName()%> = null;
<%}%>
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 757c0f9c9..c0eafbb5e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -24,54 +24,10 @@ GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figur
%>
<%=dispatcher.dispatch("createLayout", dispatcherArgs)%>
<%=dispatcher.dispatch(figure, dispatcherArgs)%>
-<%
-for (Iterator it = figure.getChildren().iterator(); it.hasNext();) {
- Figure next = (Figure) it.next();
- final String childVarName = "child" + next.getName();%>
-
- <%=fqnSwitch.get(next, importManager)%> <%=childVarName%> = createFigure<%=next.getName()%>();
- setFigure<%=next.getName()%>(<%=childVarName%>);
- add(<%=childVarName%>);
- <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(next, childVarName, dispatcherArgs.getManagerVariableName(), "layoutData" + next.getName()))%>
-<%}%>
- }
-
-<%
-int fc = 0;
-for (Iterator it = figure.getChildren().iterator(); it.hasNext(); fc++) {
- Figure next = (Figure) it.next();
- final String nextClassName = fqnSwitch.get(next, importManager);%>
-
- /**
- * @generated
- */
- private <%=nextClassName%> f<%=next.getName()%>;
-
- /**
- * @generated
- */
- public <%=nextClassName%> getFigure<%=next.getName()%>() {
- return f<%=next.getName()%>;
- }
-
- /**
- * @generated
- */
- protected void setFigure<%=next.getName()%>(<%=nextClassName%> figure) {
- f<%=next.getName()%> = figure;
+ createContents();
}
- /**
- * @generated
- */
- private <%=nextClassName%> createFigure<%=next.getName()%>() {
-<% GraphDefDispatcher.LayoutArgs childFigureArgs = dispatcher.createLayoutArgs(next, next.getName(), "layoutManager" + next.getName(), null);%>
-<%=dispatcher.dispatch("instantiate", childFigureArgs)%>
-<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, childFigureArgs})%>
- return <%=next.getName()%>;
- }
-
-<%}%>
+<%=dispatcher.dispatch("Children", dispatcherArgs)%>
<%if (false == figure instanceof Polyline) {/*no much sense to define useLocalCoordinates for polyline and its descendants*/%>
<%@ include file="localCoordinates.jetinc"%>

Back to the top