Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbblajer2007-04-04 11:04:45 +0000
committerbblajer2007-04-04 11:04:45 +0000
commit024a88ed240a6a199334452c547f578d987ed579 (patch)
tree1dc54959f44cbc3f84f3d53dc29aec35a428f821 /plugins/org.eclipse.gmf.runtime.lite/src/org
parenta3e3f7e0ecfb17ccf60330dc2554cd9c0fdaa3ec (diff)
downloadorg.eclipse.gmf-tooling-024a88ed240a6a199334452c547f578d987ed579.tar.gz
org.eclipse.gmf-tooling-024a88ed240a6a199334452c547f578d987ed579.tar.xz
org.eclipse.gmf-tooling-024a88ed240a6a199334452c547f578d987ed579.zip
Rewrite editpart templates in xpt;
Unify what is refreshed for each edit part type; Preparation for side-affixed elements.
Diffstat (limited to 'plugins/org.eclipse.gmf.runtime.lite/src/org')
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/labels/BaseExternalNodeLabelEditPart.java59
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/tree/BaseTreeEditPart.java2
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/services/DefaultDiagramLayouter.java32
3 files changed, 90 insertions, 3 deletions
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/labels/BaseExternalNodeLabelEditPart.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/labels/BaseExternalNodeLabelEditPart.java
new file mode 100644
index 000000000..ca364236c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/labels/BaseExternalNodeLabelEditPart.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * bblajer - initial API and implementation
+ */
+package org.eclipse.gmf.runtime.lite.edit.parts.labels;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+
+public abstract class BaseExternalNodeLabelEditPart extends AbstractGraphicalEditPart {
+ public BaseExternalNodeLabelEditPart(org.eclipse.gmf.runtime.notation.View view) {
+ setModel(view);
+ }
+
+ public void refreshBounds() {
+ org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) getModel();
+ if (node.getLayoutConstraint() == null) {
+ return;
+ }
+ assert node.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Location;
+ final org.eclipse.gmf.runtime.notation.Location location = (org.eclipse.gmf.runtime.notation.Location) node.getLayoutConstraint();
+ getFigure().getParent().setConstraint(getFigure(), new org.eclipse.draw2d.AbstractLocator() {
+ protected org.eclipse.draw2d.geometry.Point getReferencePoint() {
+ return getLabelLocation(((org.eclipse.gef.GraphicalEditPart) getParent()).getFigure()).translate(location.getX(), location.getY());
+ }
+ public int getRelativePosition() {
+ return org.eclipse.draw2d.PositionConstants.SOUTH;
+ }
+ });
+ }
+
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+
+ protected org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher boundsRefresher = new org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart.Refresher() {
+ public void refresh() {
+ refreshBounds();
+ }
+ };
+
+ public org.eclipse.draw2d.geometry.Point getReferencePoint() {
+ return getLabelLocation(((org.eclipse.gef.GraphicalEditPart) getParent()).getFigure());
+ }
+
+ protected org.eclipse.draw2d.geometry.Point getLabelLocation(org.eclipse.draw2d.IFigure parent) {
+ org.eclipse.draw2d.geometry.Point result = parent.getBounds().getBottom();
+ parent.translateToAbsolute(result);
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/tree/BaseTreeEditPart.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/tree/BaseTreeEditPart.java
index 3bcfa918c..d8beb3e06 100644
--- a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/tree/BaseTreeEditPart.java
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/edit/parts/tree/BaseTreeEditPart.java
@@ -86,7 +86,7 @@ public class BaseTreeEditPart extends AbstractTreeEditPart implements IUpdatable
}
protected List getModelChildren() {
- return getNotationView().getChildren();
+ return getNotationView().getVisibleChildren();
}
protected Image getImage() {
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/services/DefaultDiagramLayouter.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/services/DefaultDiagramLayouter.java
index 228f0af87..aaeb489e7 100644
--- a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/services/DefaultDiagramLayouter.java
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/services/DefaultDiagramLayouter.java
@@ -128,12 +128,40 @@ public class DefaultDiagramLayouter implements IDiagramLayouter {
}
protected org.eclipse.draw2d.graph.Node createNode(org.eclipse.draw2d.graph.Subgraph parent, GraphicalEditPart next) {
- if (next.getChildren().isEmpty()) {
- return new org.eclipse.draw2d.graph.Node(next, parent);
+ boolean hasChildren = hasChildren(next);
+ if (!hasChildren) {
+ if (isValidElementForLayout(next)) {
+ return new org.eclipse.draw2d.graph.Node(next, parent);
+ }
+ return null;
}
return new org.eclipse.draw2d.graph.Subgraph(next, parent);
}
+ protected boolean hasChildren(GraphicalEditPart gep) {
+ for (Iterator it = gep.getChildren().iterator(); it.hasNext(); ) {
+ GraphicalEditPart next = (GraphicalEditPart) it.next();
+ if (isValidElementForLayout(next)) {
+ return true;
+ }
+ if (hasChildren(next)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected boolean isValidElementForLayout(GraphicalEditPart gep) {
+ if (false == gep.getModel() instanceof Node) {
+ return false;
+ }
+ Node view = (Node) gep.getModel();
+ if (!view.isSetElement()) {
+ return false;
+ }
+ return view.getLayoutConstraint() instanceof Bounds;
+ }
+
protected void setNodePosition(org.eclipse.draw2d.graph.Node node) {
GraphicalEditPart editPart = (GraphicalEditPart) node.data;
Node notationalNode = (Node) editPart.getModel();

Back to the top