Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-16 17:23:51 +0000
committeratikhomirov2006-02-16 17:23:51 +0000
commitfdaef33e074ef9418b9b024b3cd6c91a2c845eb1 (patch)
tree56da3bf04e08ba9ad4204e45aca0ffb73f3fc596 /plugins/org.eclipse.gmf.graphdef.codegen
parent98970de927070b41401772ea726ca865b16d0fb8 (diff)
downloadorg.eclipse.gmf-tooling-fdaef33e074ef9418b9b024b3cd6c91a2c845eb1.tar.gz
org.eclipse.gmf-tooling-fdaef33e074ef9418b9b024b3cd6c91a2c845eb1.tar.xz
org.eclipse.gmf-tooling-fdaef33e074ef9418b9b024b3cd6c91a2c845eb1.zip
[mgolubev] uncompilable code using ToolbarLayout
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitFlowLayoutGenerator.java98
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet36
2 files changed, 94 insertions, 40 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitFlowLayoutGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitFlowLayoutGenerator.java
index 5ae7994c0..16f06a75a 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitFlowLayoutGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitFlowLayoutGenerator.java
@@ -19,23 +19,25 @@ public class InitFlowLayoutGenerator
protected final String TEXT_2 = ".setStretchMinorAxis(";
protected final String TEXT_3 = ");" + NL + "\t\t";
protected final String TEXT_4 = ".setMinorAlignment(";
- protected final String TEXT_5 = ");";
- protected final String TEXT_6 = "\t\t" + NL + "\t\t";
- protected final String TEXT_7 = ".setSpacing(";
- protected final String TEXT_8 = ");" + NL + "\t\t";
- protected final String TEXT_9 = ".setVertical(";
- protected final String TEXT_10 = ");";
- protected final String TEXT_11 = NL + "\t\t";
- protected final String TEXT_12 = ".setMajorAlignment(";
- protected final String TEXT_13 = ");" + NL + "\t\t";
- protected final String TEXT_14 = ".setMajorSpacing(";
+ protected final String TEXT_5 = ".";
+ protected final String TEXT_6 = ");";
+ protected final String TEXT_7 = "\t\t" + NL + "\t\t";
+ protected final String TEXT_8 = ".setSpacing(";
+ protected final String TEXT_9 = ");" + NL + "\t\t";
+ protected final String TEXT_10 = ".setVertical(";
+ protected final String TEXT_11 = ");";
+ protected final String TEXT_12 = NL + "\t\t";
+ protected final String TEXT_13 = ".setMajorAlignment(";
+ protected final String TEXT_14 = ".";
protected final String TEXT_15 = ");" + NL + "\t\t";
- protected final String TEXT_16 = ".setMinorSpacing(";
+ protected final String TEXT_16 = ".setMajorSpacing(";
protected final String TEXT_17 = ");" + NL + "\t\t";
- protected final String TEXT_18 = ".setHorizontal(";
- protected final String TEXT_19 = ");";
- protected final String TEXT_20 = NL + NL;
- protected final String TEXT_21 = NL;
+ protected final String TEXT_18 = ".setMinorSpacing(";
+ protected final String TEXT_19 = ");" + NL + "\t\t";
+ protected final String TEXT_20 = ".setHorizontal(";
+ protected final String TEXT_21 = ");";
+ protected final String TEXT_22 = NL + NL;
+ protected final String TEXT_23 = NL;
public String generate(Object argument)
{
@@ -44,27 +46,51 @@ public class InitFlowLayoutGenerator
GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
final FlowLayout gmfLayout = (FlowLayout) argsBundle.getLayout();
final String layouterVarName = argsBundle.getManagerVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final String layouterClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayout));
class AlignmentConverter {
+ private final String myBegin;
+ private final String myCenter;
+ private final String myEnd;
+
+ public AlignmentConverter(String begin, String center, String end){
+ myBegin = begin;
+ myCenter = center;
+ myEnd = end;
+ }
+
public String convert(Alignment alignment){
if (alignment == null){
alignment = Alignment.BEGINNING_LITERAL;
}
switch (alignment.getValue()){
case Alignment.BEGINNING :
- return "ALIGN_LEFTTOP";
+ return myBegin;
case Alignment.END :
- return "ALIGN_RIGHTBOTTOM";
+ return myEnd;
case Alignment.FILL:
case Alignment.CENTER:
- return "ALIGN_CENTER";
+ return myCenter;
default:
throw new IllegalArgumentException("Unknown alignment: " + alignment);
}
}
}
-final AlignmentConverter alignmentConverter = new AlignmentConverter();
+class AlignmentFacade {
+ public String convert(FlowLayout layout, Alignment alignment){
+ return getConverter(layout).convert(alignment);
+ }
+
+ private AlignmentConverter getConverter(FlowLayout layout){
+ return layout.isForceSingleLine() ?
+ new AlignmentConverter("ALIGN_TOPLEFT", "ALIGN_CENTER", "ALIGN_BOTTOMRIGHT") :
+ new AlignmentConverter("ALIGN_LEFTTOP", "ALIGN_CENTER", "ALIGN_RIGHTBOTTOM");
+ }
+}
+
+final AlignmentFacade alignmentFacade = new AlignmentFacade();
stringBuffer.append(TEXT_1);
stringBuffer.append(layouterVarName);
@@ -73,45 +99,49 @@ final AlignmentConverter alignmentConverter = new AlignmentConverter();
stringBuffer.append(TEXT_3);
stringBuffer.append(layouterVarName);
stringBuffer.append(TEXT_4);
- stringBuffer.append(alignmentConverter.convert(gmfLayout.getMinorAlignment()));
+ stringBuffer.append(layouterClassName);
stringBuffer.append(TEXT_5);
+ stringBuffer.append(alignmentFacade.convert(gmfLayout, gmfLayout.getMinorAlignment()));
+ stringBuffer.append(TEXT_6);
if (gmfLayout.isForceSingleLine()){
- stringBuffer.append(TEXT_6);
- stringBuffer.append(layouterVarName);
stringBuffer.append(TEXT_7);
- stringBuffer.append(gmfLayout.getMajorSpacing());
- stringBuffer.append(TEXT_8);
stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(gmfLayout.getMajorSpacing());
stringBuffer.append(TEXT_9);
- stringBuffer.append(gmfLayout.isVertical());
+ stringBuffer.append(layouterVarName);
stringBuffer.append(TEXT_10);
+ stringBuffer.append(gmfLayout.isVertical());
+ stringBuffer.append(TEXT_11);
} else {
- stringBuffer.append(TEXT_11);
- stringBuffer.append(layouterVarName);
stringBuffer.append(TEXT_12);
- stringBuffer.append(alignmentConverter.convert(gmfLayout.getMajorAlignment()));
- stringBuffer.append(TEXT_13);
stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append(layouterClassName);
stringBuffer.append(TEXT_14);
- stringBuffer.append(gmfLayout.getMajorSpacing());
+ stringBuffer.append(alignmentFacade.convert(gmfLayout, gmfLayout.getMajorAlignment()));
stringBuffer.append(TEXT_15);
stringBuffer.append(layouterVarName);
stringBuffer.append(TEXT_16);
- stringBuffer.append(gmfLayout.getMinorSpacing());
+ stringBuffer.append(gmfLayout.getMajorSpacing());
stringBuffer.append(TEXT_17);
stringBuffer.append(layouterVarName);
stringBuffer.append(TEXT_18);
- stringBuffer.append(!gmfLayout.isVertical());
+ stringBuffer.append(gmfLayout.getMinorSpacing());
stringBuffer.append(TEXT_19);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_20);
+ stringBuffer.append(!gmfLayout.isVertical());
+ stringBuffer.append(TEXT_21);
}
- stringBuffer.append(TEXT_20);
- stringBuffer.append(TEXT_21);
+ stringBuffer.append(TEXT_22);
+ stringBuffer.append(TEXT_23);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet
index a2bf5e7d3..4a479943e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/FlowLayout.javajet
@@ -4,30 +4,54 @@
GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
final FlowLayout gmfLayout = (FlowLayout) argsBundle.getLayout();
final String layouterVarName = argsBundle.getManagerVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final String layouterClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayout));
class AlignmentConverter {
+ private final String myBegin;
+ private final String myCenter;
+ private final String myEnd;
+
+ public AlignmentConverter(String begin, String center, String end){
+ myBegin = begin;
+ myCenter = center;
+ myEnd = end;
+ }
+
public String convert(Alignment alignment){
if (alignment == null){
alignment = Alignment.BEGINNING_LITERAL;
}
switch (alignment.getValue()){
case Alignment.BEGINNING :
- return "ALIGN_LEFTTOP";
+ return myBegin;
case Alignment.END :
- return "ALIGN_RIGHTBOTTOM";
+ return myEnd;
case Alignment.FILL:
case Alignment.CENTER:
- return "ALIGN_CENTER";
+ return myCenter;
default:
throw new IllegalArgumentException("Unknown alignment: " + alignment);
}
}
}
-final AlignmentConverter alignmentConverter = new AlignmentConverter();
+class AlignmentFacade {
+ public String convert(FlowLayout layout, Alignment alignment){
+ return getConverter(layout).convert(alignment);
+ }
+
+ private AlignmentConverter getConverter(FlowLayout layout){
+ return layout.isForceSingleLine() ?
+ new AlignmentConverter("ALIGN_TOPLEFT", "ALIGN_CENTER", "ALIGN_BOTTOMRIGHT") :
+ new AlignmentConverter("ALIGN_LEFTTOP", "ALIGN_CENTER", "ALIGN_RIGHTBOTTOM");
+ }
+}
+
+final AlignmentFacade alignmentFacade = new AlignmentFacade();
%>
<%=layouterVarName%>.setStretchMinorAxis(<%=gmfLayout.isMatchMinorSize()%>);
- <%=layouterVarName%>.setMinorAlignment(<%=alignmentConverter.convert(gmfLayout.getMinorAlignment())%>);
+ <%=layouterVarName%>.setMinorAlignment(<%=layouterClassName%>.<%=alignmentFacade.convert(gmfLayout, gmfLayout.getMinorAlignment())%>);
<%
if (gmfLayout.isForceSingleLine()){
%>
@@ -36,7 +60,7 @@ if (gmfLayout.isForceSingleLine()){
<%
} else {
%>
- <%=layouterVarName%>.setMajorAlignment(<%=alignmentConverter.convert(gmfLayout.getMajorAlignment())%>);
+ <%=layouterVarName%>.setMajorAlignment(<%=layouterClassName%>.<%=alignmentFacade.convert(gmfLayout, gmfLayout.getMajorAlignment())%>);
<%=layouterVarName%>.setMajorSpacing(<%=gmfLayout.getMajorSpacing()%>);
<%=layouterVarName%>.setMinorSpacing(<%=gmfLayout.getMinorSpacing()%>);
<%=layouterVarName%>.setHorizontal(<%=!gmfLayout.isVertical()%>);

Back to the top