Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2006-03-31 18:08:33 +0000
committerashatalin2006-03-31 18:08:33 +0000
commit0c217c01b62afc57beafb89e86358b977100028d (patch)
tree2f59954b9b6e61973938d0a1eece23b23731bae4 /plugins/org.eclipse.gmf.graphdef.codegen/templates
parentcd81033f47108425d056371513707afc186c108f (diff)
downloadorg.eclipse.gmf-tooling-0c217c01b62afc57beafb89e86358b977100028d.tar.gz
org.eclipse.gmf-tooling-0c217c01b62afc57beafb89e86358b977100028d.tar.xz
org.eclipse.gmf-tooling-0c217c01b62afc57beafb89e86358b977100028d.zip
[mgolubev] 134249 Generate all Figure/Shape properties
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CompoundBorder.javajet17
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet34
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/MarginBorder.javajet24
4 files changed, 87 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
index 68195f895..3062fbbde 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
@@ -20,8 +20,20 @@ if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())
<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Size())) {
Point p = figureInstance.getSize();%>
<%=figureVarName%>.setSize(<%=dispatcher.DPtoLP(p.getX())%>, <%=dispatcher.DPtoLP(p.getY())%>);
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MaximumSize())) {
+ Dimension d = figureInstance.getMaximumSize();%>
+ <%=figureVarName%>.setMaximumSize(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(<%=dispatcher.DPtoLP(d.getDx())%>, <%=dispatcher.DPtoLP(d.getDy())%>));
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MinimumSize())) {
+ Dimension d = figureInstance.getMinimumSize();%>
+ <%=figureVarName%>.setMinimumSize(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(<%=dispatcher.DPtoLP(d.getDx())%>, <%=dispatcher.DPtoLP(d.getDy())%>));
<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Font())) {
// XXX possible CCE when fonts other than Basic added to model
BasicFont font = (BasicFont) figureInstance.getFont();%>
<%=figureVarName%>.setFont(new <%=importManager.getImportedName("org.eclipse.swt.graphics.Font")%>(<%=importManager.getImportedName("org.eclipse.swt.widgets.Display")%>.getCurrent(), "<%=font.getFaceName()%>", <%=font.getHeight()%>, <%=importManager.getImportedName("org.eclipse.swt.SWT")%>.<%=font.getStyle().getLiteral()%>));
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Insets())) {
+ Insets insets = figureInstance.getInsets();%>
+ <%=figureVarName%>.setBorder(new <%=importManager.getImportedName("org.eclipse.draw2d.MarginBorder")%>(<%=dispatcher.DPtoLP(insets.getTop())%>, <%=dispatcher.DPtoLP(insets.getLeft())%>, <%=dispatcher.DPtoLP(insets.getBottom())%>, <%=dispatcher.DPtoLP(insets.getRight())%>));
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Border())) {
+ Border border = figureInstance.getBorder();%>
+ <%=figureVarName%>.setBorder(<%=dispatcher.dispatch(border, new Object[] {border, dispatcher})%>);
<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CompoundBorder.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CompoundBorder.javajet
new file mode 100644
index 000000000..b0c1953d3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/CompoundBorder.javajet
@@ -0,0 +1,17 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewCompoundBorderExpressionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.ImportAssistant"%>
+<%
+Object[] args = (Object[]) argument;
+final CompoundBorder border = (CompoundBorder)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.
+%>
+ <% Border outer = border.getOuter();
+ Border inner = border.getInner();
+ %>
+new <%=importManager.getImportedName("org.eclipse.draw2d.CompoundBorder")%>(
+ <%= (outer == null) ? "null" : dispatcher.dispatch(outer, new Object[]{outer, dispatcher})%>,
+ <%= (inner == null) ? "null" : dispatcher.dispatch(inner, new Object[]{inner, dispatcher})%>
+)
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet
new file mode 100644
index 000000000..9a1e9de42
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet
@@ -0,0 +1,34 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewLineBorderExpressionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.ImportAssistant"%>
+<%
+Object[] args = (Object[]) argument;
+final LineBorder border = (LineBorder)args[0];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1];
+final ImportAssistant importManager = dispatcher.getImportManager();
+
+//We do not want to insert any names into the scope.
+//We want to provide EXPRESSION instead of statement
+%>
+<%
+ String borderClazz = importManager.getImportedName("org.eclipse.draw2d.LineBorder");
+ boolean hasColor = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Color());
+ boolean hasWidth = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Width());
+ Color colorVal = (hasColor) ? border.getColor() : null;
+ if (hasColor && hasWidth){
+%>
+new <%=borderClazz%>(<%@ include file="../Color.jetinc"%>, <%=dispatcher.DPtoLP(border.getWidth())%>)
+<%
+ } else if (hasColor && !hasWidth) {
+%>
+new <%=borderClazz%>(<%@ include file="../Color.jetinc"%>)
+<%
+ } else if (!hasColor && hasWidth){
+%>
+new <%=borderClazz%>(<%=dispatcher.DPtoLP(border.getWidth())%>)
+<%
+ } else {
+%>
+new <%=borderClazz%>()
+<%
+ }
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/MarginBorder.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/MarginBorder.javajet
new file mode 100644
index 000000000..30a8c2a76
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/MarginBorder.javajet
@@ -0,0 +1,24 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewMarginBorderExpressionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.ImportAssistant"%>
+<%
+Object[] args = (Object[]) argument;
+final MarginBorder border = (MarginBorder)args[0];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1];
+final ImportAssistant importManager = dispatcher.getImportManager();
+
+//Produces EXPRESSION instead of statement
+%>
+<%
+ int top = 0;
+ int left = 0;
+ int bottom = 0;
+ int right = 0;
+ if (border.eIsSet(GMFGraphPackage.eINSTANCE.getMarginBorder_Insets())){
+ Insets insets = border.getInsets();
+ top = insets.getTop();
+ left = insets.getLeft();
+ bottom = insets.getBottom();
+ right = insets.getRight();
+ }
+%>
+new <%=importManager.getImportedName("org.eclipse.draw2d.MarginBorder")%>(<%=dispatcher.DPtoLP(top)%>, <%=dispatcher.DPtoLP(left)%>, <%=dispatcher.DPtoLP(bottom)%>, <%=dispatcher.DPtoLP(right)%>)

Back to the top