Author: DartPeng
Date: 2008-08-14 23:16:10 -0400 (Thu, 14 Aug 2008)
New Revision: 9736
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/TreeItemRelationFigure.java
Log:
Change the way of calculating of connectionpointfigure's location
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/TreeItemRelationFigure.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/TreeItemRelationFigure.java 2008-08-14
21:18:56 UTC (rev 9735)
+++
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/gef/figures/TreeItemRelationFigure.java 2008-08-15
03:16:10 UTC (rev 9736)
@@ -14,6 +14,7 @@
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -44,46 +45,23 @@
graphics.popState();
}
- protected void setLocationYToTheFigure(TreeItem[] items, boolean addY,
- int addHeight) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- if (treeItem == item) {
- setLocation(new Point(-1, caculateY));
- return;
- } else {
- if (item.getItemCount() > 0) {
- if (item.getExpanded()) {
- if (addY)
- caculateY += addHeight;
- setLocationYToTheFigure(item.getItems(), true,
- addHeight);
- continue;
- } else {
- setLocationYToTheFigure(item.getItems(), false,
- addHeight);
- if(addY) caculateY += addHeight;
- continue;
- }
- } else {
- if (addY)
- caculateY += addHeight;
- }
- }
- }
- }
public void caculateLocationY() {
if (treeItem != null) {
-
- if (treeItem.getText().startsWith("quantity")) {
- System.out.println();
- }
+ int y = this.collapsedParentItemLocation(treeItem);
Tree tree = treeItem.getParent();
- caculateY = tree.getItemHeight() / 2 + tree.getBorderWidth();
- setLocationYToTheFigure(tree.getItems(), true,
- tree.getItemHeight() + 2);
+ int height = tree.getItemHeight();
+ this.setLocation(new Point(0, y + height/2));
}
}
+ protected int collapsedParentItemLocation(TreeItem item) {
+ int y = item.getBounds().y;
+ if (y == 0) {
+ if (item.getParentItem() != null)
+ return this.collapsedParentItemLocation(item.getParentItem());
+ }
+ return y;
+ }
+
}
Show replies by date