diff options
3 files changed, 19 insertions, 5 deletions
diff --git a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/edit/parts/TaiPanExternalNodeLabelEditPart.java b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/edit/parts/TaiPanExternalNodeLabelEditPart.java index 7376fda99..0ddc84fad 100644 --- a/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/edit/parts/TaiPanExternalNodeLabelEditPart.java +++ b/examples/org.eclipse.gmf.examples.taipan.gmf.editor/src/org/eclipse/gmf/examples/taipan/gmf/editor/edit/parts/TaiPanExternalNodeLabelEditPart.java @@ -55,7 +55,7 @@ public class TaiPanExternalNodeLabelEditPart extends LabelEditPart { } protected Point getReferencePoint() { - return parent.getBounds().getBottom().getTranslated(0, BOTTOM_GAP); + return getLabelLocation(parent); } }); } @@ -64,6 +64,13 @@ public class TaiPanExternalNodeLabelEditPart extends LabelEditPart { * @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); } } 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();%> |