Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-13 12:36:07 -0500
committeratikhomirov2006-02-13 12:36:07 -0500
commitf8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8 (patch)
treec3712afb5d03429a0b1f9a44a2694d1fb180ef5b /plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData
parent80e4035d3bf83b8a35983bc23587f49485a14d3e (diff)
downloadorg.eclipse.gmf-tooling-f8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8.tar.gz
org.eclipse.gmf-tooling-f8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8.tar.xz
org.eclipse.gmf-tooling-f8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8.zip
[mgolubev] #127252 layout support
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet40
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet31
3 files changed, 81 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
new file mode 100644
index 000000000..18525aaf2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
@@ -0,0 +1,40 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitBorderLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final BorderLayoutData gmfLayoutData = (BorderLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+%>
+
+<%
+Alignment alignment = gmfLayoutData.getAlignment();
+if (alignment == null){
+ alignment = Alignment.CENTER_LITERAL;
+}
+final String constantName;
+switch(alignment.getValue()){
+ case Alignment.CENTER:
+ case Alignment.FILL:
+ constantName = "CENTER";
+ break;
+ case Alignment.BEGINNING:
+ if (gmfLayoutData.isVertical()){
+ constantName = "TOP";
+ } else {
+ constantName = "LEFT";
+ }
+ break;
+ case Alignment.END:
+ if (gmfLayoutData.isVertical()){
+ constantName = "BOTTOM";
+ } else {
+ constantName = "RIGHT";
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown Alignment: " + gmfLayoutData.getAlignment());
+}
+%>
+ <%=figureVarName%>.getParent().getLayoutManager().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
new file mode 100644
index 000000000..4dec5729f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
@@ -0,0 +1,10 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitCustomLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs args = (GraphDefDispatcher.LayoutArgs) argument;
+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()})%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
new file mode 100644
index 000000000..362940518
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
@@ -0,0 +1,31 @@
+
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitGridLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GridLayoutData gmfLayoutData = (GridLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final String layoutConstraintVarName = argsBundle.getLayoutVariableName();
+
+final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayoutData));
+%>
+ <%=layoutImplClassName%> <%=layoutConstraintVarName%> = new <%=layoutImplClassName%>();
+ <%=layoutConstraintVarName%>.verticalAlignment = <%=gmfLayoutData.getVerticalAlignment().getValue()%>;
+ <%=layoutConstraintVarName%>.horizontalAlignment = <%=gmfLayoutData.getHorizontalAlignment().getValue()%>;
+<%
+Dimension sizeHint = gmfLayoutData.getSizeHint();
+if (sizeHint != null){
+%>
+ <%=layoutConstraintVarName%>.widthHint = <%=sizeHint.getDx()%>;
+ <%=layoutConstraintVarName%>.heightHint = <%=sizeHint.getDy()%>;
+<%
+}
+%>
+ <%=layoutConstraintVarName%>.horizontalIndent = <%=gmfLayoutData.getHorizontalIndent()%>;
+ <%=layoutConstraintVarName%>.horizontalSpan = <%=gmfLayoutData.getHorizontalSpan()%>;
+ <%=layoutConstraintVarName%>.verticalSpan = <%=gmfLayoutData.getVerticalSpan()%>;
+ <%=layoutConstraintVarName%>.grabExcessHorizontalSpace = <%=gmfLayoutData.isGrabExcessHorizontalSpace()%>;
+ <%=layoutConstraintVarName%>.grabExcessVerticalSpace = <%=gmfLayoutData.isGrabExcessVerticalSpace()%>;
+ <%=figureVarName%>.getParent().getLayoutManager().setConstraint(<%=figureVarName%>, <%=layoutConstraintVarName%>);
+

Back to the top