Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-15 14:44:26 +0000
committeratikhomirov2006-02-15 14:44:26 +0000
commited546bf950368f714ec119305262c3fe2bf6eae1 (patch)
tree28ed04de293110e5f221ff35895a8abe2b607b8a /plugins/org.eclipse.gmf.graphdef.codegen/templates
parentbcde3e55601c71bba82a19b2f2cdc83a8c8566f3 (diff)
downloadorg.eclipse.gmf-tooling-ed546bf950368f714ec119305262c3fe2bf6eae1.tar.gz
org.eclipse.gmf-tooling-ed546bf950368f714ec119305262c3fe2bf6eae1.tar.xz
org.eclipse.gmf-tooling-ed546bf950368f714ec119305262c3fe2bf6eae1.zip
[mgolubev] #127252 layout support
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet47
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet2
-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.javajet5
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet5
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet33
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet4
12 files changed, 99 insertions, 15 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 eb76ac6cc..48265eb87 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -24,13 +24,15 @@ while (!l.isEmpty()) {
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;
figureCount++;%>
// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
- <%GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);%>
- <%=dispatcher.dispatch("instantiate", dargs)%>
+ <%GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);
+ GraphDefDispatcher.LayoutArgs layoutAwareArgs = dispatcher.createLayoutArgs(dargs, layoutManagerVarName, layoutDataVarName);%>
+ <%=dispatcher.dispatch("instantiate", layoutAwareArgs)%>
<%=parentFigureVarName%>.add(<%=figureVarName%>);
- <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(dargs, layoutDataVarName))%>
+ <%=dispatcher.dispatch("createLayoutData", layoutAwareArgs)%>
<%
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
l.addFirst(marker);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet
index f86fb4889..f52f0e27c 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet
@@ -3,7 +3,7 @@
<%
GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
final BorderLayout gmfLayout = (BorderLayout) argsBundle.getLayout();
-final String layouterVarName = argsBundle.getLayoutVariableName();
+final String layouterVarName = argsBundle.getManagerVariableName();
%>
<%
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet
index 0345832a6..dd81216f0 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet
@@ -5,4 +5,4 @@ GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argum
final CustomLayout layout = (CustomLayout) argsBundle.getLayout();
final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
%>
-<%=dispatcher.dispatch("customAttributes", new Object[] {layout, dispatcher, argsBundle.getLayoutVariableName()} )%>
+<%=dispatcher.dispatch("customAttributes", new Object[] {layout, dispatcher, argsBundle.getManagerVariableName()} )%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet
new file mode 100644
index 000000000..a2bf5e7d3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet
@@ -0,0 +1,47 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitFlowLayoutGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final FlowLayout gmfLayout = (FlowLayout) argsBundle.getLayout();
+final String layouterVarName = argsBundle.getManagerVariableName();
+
+class AlignmentConverter {
+ public String convert(Alignment alignment){
+ if (alignment == null){
+ alignment = Alignment.BEGINNING_LITERAL;
+ }
+ switch (alignment.getValue()){
+ case Alignment.BEGINNING :
+ return "ALIGN_LEFTTOP";
+ case Alignment.END :
+ return "ALIGN_RIGHTBOTTOM";
+ case Alignment.FILL:
+ case Alignment.CENTER:
+ return "ALIGN_CENTER";
+ default:
+ throw new IllegalArgumentException("Unknown alignment: " + alignment);
+ }
+ }
+}
+
+final AlignmentConverter alignmentConverter = new AlignmentConverter();
+%>
+ <%=layouterVarName%>.setStretchMinorAxis(<%=gmfLayout.isMatchMinorSize()%>);
+ <%=layouterVarName%>.setMinorAlignment(<%=alignmentConverter.convert(gmfLayout.getMinorAlignment())%>);
+<%
+if (gmfLayout.isForceSingleLine()){
+%>
+ <%=layouterVarName%>.setSpacing(<%=gmfLayout.getMajorSpacing()%>);
+ <%=layouterVarName%>.setVertical(<%=gmfLayout.isVertical()%>);
+<%
+} else {
+%>
+ <%=layouterVarName%>.setMajorAlignment(<%=alignmentConverter.convert(gmfLayout.getMajorAlignment())%>);
+ <%=layouterVarName%>.setMajorSpacing(<%=gmfLayout.getMajorSpacing()%>);
+ <%=layouterVarName%>.setMinorSpacing(<%=gmfLayout.getMinorSpacing()%>);
+ <%=layouterVarName%>.setHorizontal(<%=!gmfLayout.isVertical()%>);
+<%
+}
+%>
+
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet
index 4f162a721..52c7ec1cd 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet
@@ -3,7 +3,7 @@
<%
GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
final GridLayout gmfLayout = (GridLayout) argsBundle.getLayout();
-final String layouterVarName = argsBundle.getLayoutVariableName();
+final String layouterVarName = argsBundle.getManagerVariableName();
%>
<%=layouterVarName%>.numColumns = <%=gmfLayout.getNumColumns()%>;
<%=layouterVarName%>.makeColumnsEqualWidth = <%=gmfLayout.isEqualWidth()%>;
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 18525aaf2..71d2d42b8 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());
}
%>
- <%=figureVarName%>.getParent().getLayoutManager().setConstraint(<%=figureVarName%>, <%=dispatcher.getImportManager().getImportedName("org.eclipse.draw2d.BorderLayout")%>.<%=constantName%>);
+ <%=argsBundle.getManagerVariableName()%>.setConstraint(<%=figureVarName%>, <%=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 4dec5729f..64a0f1997 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
@@ -6,5 +6,6 @@ final CustomLayoutData layoutData = (CustomLayoutData) args.getData();
final GraphDefDispatcher dispatcher = args.getDispatcher();
final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(layoutData));
%>
-<%=layoutImplClassName%> <%=args.getLayoutVariableName()%> = new <%=layoutImplClassName%>();
-<%=dispatcher.dispatch("customAttributes", new Object[] {layoutData, dispatcher, args.getLayoutVariableName()})%>
+<%=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 362940518..79de453ba 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
@@ -6,7 +6,8 @@ GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argum
final GridLayoutData gmfLayoutData = (GridLayoutData) argsBundle.getData();
final String figureVarName = argsBundle.getVariableName();
final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
-final String layoutConstraintVarName = argsBundle.getLayoutVariableName();
+final String layoutConstraintVarName = argsBundle.getConstraintVariableName();
+final String layoutManagerVarName = argsBundle.getManagerVariableName();
final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayoutData));
%>
@@ -27,5 +28,5 @@ if (sizeHint != null){
<%=layoutConstraintVarName%>.verticalSpan = <%=gmfLayoutData.getVerticalSpan()%>;
<%=layoutConstraintVarName%>.grabExcessHorizontalSpace = <%=gmfLayoutData.isGrabExcessHorizontalSpace()%>;
<%=layoutConstraintVarName%>.grabExcessVerticalSpace = <%=gmfLayoutData.isGrabExcessVerticalSpace()%>;
- <%=figureVarName%>.getParent().getLayoutManager().setConstraint(<%=figureVarName%>, <%=layoutConstraintVarName%>);
+ <%=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
new file mode 100644
index 000000000..fa042a300
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/XYLayoutData.javajet
@@ -0,0 +1,33 @@
+
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitXYLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final XYLayoutData gmfLayoutData = (XYLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final String layoutConstraintVarName = argsBundle.getConstraintVariableName();
+final String layoutManagerVarName = argsBundle.getManagerVariableName();
+
+final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayoutData));
+%>
+ <%=layoutImplClassName%> <%=layoutConstraintVarName%> = new <%=layoutImplClassName%>();
+<%
+Point topLeft = gmfLayoutData.getTopLeft();
+if (topLeft != null){
+%>
+ <%=layoutConstraintVarName%>.x = <%=topLeft.getX()%>;
+ <%=layoutConstraintVarName%>.y = <%=topLeft.getY()%>;
+<%
+}
+%>
+<%
+Dimension size = gmfLayoutData.getSize();
+if (size != null){
+%>
+ <%=layoutConstraintVarName%>.width = <%=size.getDx()%>;
+ <%=layoutConstraintVarName%>.height = <%=size.getDy()%>;
+<%
+}
+%>
+ <%=layoutManagerVarName%>.setConstraint(<%=figureVarName%>, <%=layoutConstraintVarName%>);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
index 39bff0a20..493aeb620 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
@@ -11,4 +11,4 @@ final String figureClassName = dispatcher.getImportManager().getImportedName((St
%>
<%=figureClassName%> <%=figureVarName%> = new <%=figureClassName%>();
<%=args.getDispatcher().dispatch(figureInstance, args)%>
-<%=args.getDispatcher().dispatch("createLayout", dispatcher.createLayoutArgs(args))%>
+<%=args.getDispatcher().dispatch("createLayout", dispatcher.getLayoutArgsFor(args))%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet
index ac8bd568b..e4c1b82b2 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet
@@ -4,7 +4,7 @@
GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
final FigureMarker figureMarker = argsBundle.getFigure();
final String figureVarName = argsBundle.getVariableName();
-final String layouterVarName = argsBundle.getLayoutVariableName();
+final String layouterVarName = argsBundle.getManagerVariableName();
final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
index c5854561c..4b37a73e5 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
@@ -19,7 +19,7 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName((Str
*/
public <%=figure.getName()%>() {
<%
-GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "myGenLayoutManager");
+GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "myGenLayoutManager", null);
%>
<%=dispatcher.dispatch("createLayout", dispatcherArgs)%>
<%=dispatcher.dispatch(figure, dispatcherArgs)%>
@@ -31,7 +31,7 @@ for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
org.eclipse.draw2d.IFigure <%=childVarName%> = createFigure<%=next.getName()%>();
setFigure<%=next.getName()%>(<%=childVarName%>);
add(<%=childVarName%>);
- <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(next, childVarName, "layout" + next.getName()))%>
+ <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(next, childVarName, dispatcherArgs.getManagerVariableName(), "layoutData" + next.getName()))%>
<%}%>
}

Back to the top