diff options
author | dstadnik | 2006-04-05 15:07:40 +0000 |
---|---|---|
committer | dstadnik | 2006-04-05 15:07:40 +0000 |
commit | b4f092e6637a8b76bbc577831aa670ddaf2bcf67 (patch) | |
tree | 96d874904a9c8b525006f4295096781c21a2cce3 /plugins/org.eclipse.gmf.codegen | |
parent | 2a8a7a2f6f2bbaacb616ddac3d7d6ea4307e27ec (diff) | |
download | org.eclipse.gmf-tooling-b4f092e6637a8b76bbc577831aa670ddaf2bcf67.tar.gz org.eclipse.gmf-tooling-b4f092e6637a8b76bbc577831aa670ddaf2bcf67.tar.xz org.eclipse.gmf-tooling-b4f092e6637a8b76bbc577831aa670ddaf2bcf67.zip |
#133328 Refactor code that calculates external node label location
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen')
2 files changed, 10 insertions, 3 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/parts/DiagramExternalNodeLabelEditPartGenerator.java b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/parts/DiagramExternalNodeLabelEditPartGenerator.java index 4e5bb3f6a..a5585f0dc 100644 --- a/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/parts/DiagramExternalNodeLabelEditPartGenerator.java +++ b/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/parts/DiagramExternalNodeLabelEditPartGenerator.java @@ -23,7 +23,7 @@ public class DiagramExternalNodeLabelEditPartGenerator protected final String TEXT_6 = NL + "import org.eclipse.draw2d.IFigure;" + NL + "import org.eclipse.draw2d.geometry.Dimension;" + NL + "import org.eclipse.draw2d.geometry.Point;" + NL + "import org.eclipse.gef.GraphicalEditPart;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;" + NL + "import org.eclipse.gmf.runtime.diagram.ui.figures.LabelLocator;" + NL + "import org.eclipse.gmf.runtime.notation.NotationPackage;" + NL + "import org.eclipse.gmf.runtime.notation.View;"; protected final String TEXT_7 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class "; protected final String TEXT_8 = " extends LabelEditPart {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final int BOTTOM_GAP = 5;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic "; - protected final String TEXT_9 = "(View view) {" + NL + "\t\tsuper(view);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void refreshBounds() {" + NL + "\t\tIFigure refFigure = ((GraphicalEditPart) getParent()).getFigure();" + NL + "\t\tint dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();" + NL + "\t\tint dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();" + NL + "\t\tPoint offset = new Point(dx, dy);" + NL + "\t\tgetFigure().getParent().setConstraint(getFigure(), new LabelLocator(refFigure, offset, getKeyPoint()) {" + NL + "" + NL + "\t\t\tpublic void relocate(IFigure target) {" + NL + "\t\t\t\tPoint location = getReferencePoint().getTranslated(getOffset());" + NL + "\t\t\t\tlocation.translate(-target.getBounds().width / 2, 0);" + NL + "\t\t\t\ttarget.setLocation(location);" + NL + "\t\t\t\ttarget.setSize(new Dimension(target.getPreferredSize().width, target.getPreferredSize().height));" + NL + "\t\t\t}" + NL + "" + NL + "\t\t\tprotected Point getReferencePoint() {" + NL + "\t\t\t\treturn parent.getBounds().getBottom().getTranslated(0, BOTTOM_GAP);" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Point getReferencePoint() {" + NL + "\t\treturn ((GraphicalEditPart) getParent()).getFigure().getBounds().getBottom().getTranslated(0, BOTTOM_GAP);" + NL + "\t}" + NL + "}"; + protected final String TEXT_9 = "(View view) {" + NL + "\t\tsuper(view);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void refreshBounds() {" + NL + "\t\tIFigure refFigure = ((GraphicalEditPart) getParent()).getFigure();" + NL + "\t\tint dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();" + NL + "\t\tint dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();" + NL + "\t\tPoint offset = new Point(dx, dy);" + NL + "\t\tgetFigure().getParent().setConstraint(getFigure(), new LabelLocator(refFigure, offset, getKeyPoint()) {" + NL + "" + NL + "\t\t\tpublic void relocate(IFigure target) {" + NL + "\t\t\t\tPoint location = getReferencePoint().getTranslated(getOffset());" + NL + "\t\t\t\tlocation.translate(-target.getBounds().width / 2, 0);" + NL + "\t\t\t\ttarget.setLocation(location);" + NL + "\t\t\t\ttarget.setSize(new Dimension(target.getPreferredSize().width, target.getPreferredSize().height));" + NL + "\t\t\t}" + NL + "" + NL + "\t\t\tprotected Point getReferencePoint() {" + NL + "\t\t\t\treturn getLabelLocation(parent);" + NL + "\t\t\t}" + NL + "\t\t});" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Point getReferencePoint() {" + NL + "\t\treturn getLabelLocation(((GraphicalEditPart) getParent()).getFigure());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected Point getLabelLocation(IFigure parent) {" + NL + "\t\treturn parent.getBounds().getBottom().getTranslated(0, BOTTOM_GAP);" + NL + "\t}" + NL + "}"; protected final String TEXT_10 = NL; public String generate(Object argument) diff --git a/plugins/org.eclipse.gmf.codegen/templates/parts/DiagramExternalNodeLabelEditPart.javajet b/plugins/org.eclipse.gmf.codegen/templates/parts/DiagramExternalNodeLabelEditPart.javajet index 68c25beb0..4f998efc6 100644 --- a/plugins/org.eclipse.gmf.codegen/templates/parts/DiagramExternalNodeLabelEditPart.javajet +++ b/plugins/org.eclipse.gmf.codegen/templates/parts/DiagramExternalNodeLabelEditPart.javajet @@ -52,7 +52,7 @@ public class <%=genDiagram.getBaseExternalNodeLabelEditPartClassName()%> extends } protected Point getReferencePoint() { - return parent.getBounds().getBottom().getTranslated(0, BOTTOM_GAP); + return getLabelLocation(parent); } }); } @@ -61,7 +61,14 @@ public class <%=genDiagram.getBaseExternalNodeLabelEditPartClassName()%> extends * @generated */ public Point getReferencePoint() { - return ((GraphicalEditPart) getParent()).getFigure().getBounds().getBottom().getTranslated(0, BOTTOM_GAP); + return getLabelLocation(((GraphicalEditPart) getParent()).getFigure()); + } + + /** + * @generated + */ + protected Point getLabelLocation(IFigure parent) { + return parent.getBounds().getBottom().getTranslated(0, BOTTOM_GAP); } } <%importManager.emitSortedImports();%> |