Author: vyemialyanchyk
Date: 2009-10-30 12:23:36 -0400 (Fri, 30 Oct 2009)
New Revision: 18370
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramElementInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/LinkInfo.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Group.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/GroupArranger.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Groups.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Item.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Items.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5104 - fixed
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IDiagramInfo.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/IItemInfo.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -19,6 +19,7 @@
*/
public String getID();
public boolean isComment();
+ public boolean isVisible();
/**
* gets shape vertices
*/
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramElementInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramElementInfo.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramElementInfo.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.data;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IItemInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
+
+/**
+ * @author some modifications from Vitali
+ */
+public class DiagramElementInfo implements IItemInfo {
+
+ protected OrmShape element;
+ protected List<ILinkInfo> links = new ArrayList<ILinkInfo>();
+ protected int cxFigure, cyFigure;
+
+ /**
+ *
+ * @param element
+ */
+ public DiagramElementInfo(OrmShape element, int cxFigure, int cyFigure) {
+ this.element = element;
+ this.cxFigure = cxFigure;
+ this.cyFigure = cyFigure;
+ ILinkInfo link;
+ for (Connection connection : element.getSourceConnections()) {
+ if (connection.isVisible()) {
+ link = new LinkInfo(connection);
+ addLink(link);
+ }
+ }
+ Iterator<Shape> it = element.getChildrenIterator();
+ while (it.hasNext()) {
+ Shape child = it.next();
+ if (!child.isVisible()) {
+ continue;
+ }
+ final List<Connection> sourceConnections = child.getSourceConnections();
+ if (sourceConnections.size() == 0) {
+ link = new LinkInfo(getID());
+ addLink(link);
+ }
+ for (Connection connection : sourceConnections) {
+ if (connection.isVisible()) {
+ link = new LinkInfo(connection);
+ addLink(link);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public String getID() {
+ return element.toString();
+ }
+
+ /**
+ * there are no comments on Diagram Viewer!!!
+ */
+ public boolean isComment() {
+ return false;
+ }
+
+ public boolean isVisible() {
+ return element.isVisible();
+ }
+
+ /**
+ * gets shape vertices
+ */
+ public int[] getShape() {
+ int[] shape = new int[4];
+ shape[0] = element.getLocation().x;
+ shape[1] = element.getLocation().y;
+ shape[2] = cxFigure;
+ shape[3] = cyFigure;
+ return shape;
+ }
+
+ /**
+ * setup OrmShape up-left point location, using s[0] and s[1]
+ */
+ public void setShape(int[] s) {
+ element.setLocation(new Point(s[0], s[1]));
+ }
+
+ /**
+ *
+ */
+ public ILinkInfo[] getLinks() {
+ return links.toArray(new ILinkInfo[0]);
+ }
+
+ /**
+ *
+ * @param link
+ */
+ public void addLink(ILinkInfo link) {
+ links.add(link);
+ }
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramInfo.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/DiagramInfo.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.data;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPartViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IDiagramInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IItemInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
+import org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmShapeEditPart;
+
+/**
+ * @author some modifications from Vitali
+ */
+public class DiagramInfo implements IDiagramInfo {
+
+ protected List<IItemInfo> items = new ArrayList<IItemInfo>();
+ protected OrmDiagram diagram;
+ protected EditPartViewer viewer;
+
+ public DiagramInfo(EditPartViewer viewer, OrmDiagram diagram) {
+ this.viewer = viewer;
+ this.diagram = diagram;
+ Iterator<Shape> it = diagram.getChildrenIterator();
+ while (it.hasNext()) {
+ Shape child = it.next();
+ if (!(child instanceof OrmShape)) {
+ continue;
+ }
+ OrmShape ormShape = (OrmShape)child;
+ if (child.isVisible()) {
+ OrmShapeEditPart part = (OrmShapeEditPart)viewer
+ .getEditPartRegistry().get(ormShape);
+ // default values - indicate refresh model error
+ int cxFigure = 6000;
+ int cyFigure = 1000;
+ if (part != null) {
+ IFigure fig = part.getFigure();
+ //cxFigure = fig.getSize().width;
+ //cyFigure = fig.getSize().height;
+ // use preferred size for correct autolayout
+ cxFigure = fig.getPreferredSize().width;
+ cyFigure = fig.getPreferredSize().height;
+ }
+ IItemInfo item = new DiagramElementInfo(ormShape, cxFigure, cyFigure);
+ addItem(item);
+ } else {
+ // move invisible shapes to upper-left corner
+ ormShape.setLocation(new Point(0, 0));
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public IItemInfo[] getItems() {
+ return items.toArray(new IItemInfo[0]);
+ }
+
+ /**
+ *
+ * @param item
+ */
+ public void addItem(IItemInfo item) {
+ items.add(item);
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/LinkInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/LinkInfo.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/data/LinkInfo.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.data;
+
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
+
+/**
+ * @author some modifications from Vitali
+ */
+public class LinkInfo implements ILinkInfo {
+
+ protected Connection link = null;
+
+ protected String id = null;
+
+ /**
+ *
+ * @param link
+ */
+ public LinkInfo(Connection link) {
+ this.link = link;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public LinkInfo(String id) {
+ this.id = id;
+ }
+
+ public String getTargetID() {
+ if (id != null) {
+ return id;
+ }
+ if (link.getTarget() != null) {
+ return link.getTarget().toString();
+ }
+ return ""; //$NON-NLS-1$
+ }
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/AutoLayoutImpl.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -56,7 +56,11 @@
if (is[i].isSet()) {
continue;
}
- IItemInfo o = is[i].itemInfo;
+ IItemInfo itemInfo = is[i].getItemInfo();
+ if (!is[i].isVisible()) {
+ itemInfo.setShape(new int[]{0, 0, 0, 0});
+ continue;
+ }
int x = is[i].ix * constants.deltaX + constants.indentX;
int y = is[i].iy * constants.deltaY + constants.indentY;
if (is[i].ix % 2 == 1) {
@@ -64,7 +68,7 @@
}
x += is[i].group.xDeltas[is[i].ix] * constants.incX;
y += yDeltas[is[i].iy] * constants.incY + is[i].yIndent;
- o.setShape(new int[]{x, y, 0, 0});
+ itemInfo.setShape(new int[]{x, y, 0, 0});
}
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Group.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Group.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Group.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -13,6 +13,9 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * @author ?
+ */
public class Group {
LayoutConstants constants;
int number;
@@ -259,7 +262,7 @@
if (c >= xDeltas.length) {
continue;
}
- int[] shape = getItem(i).getObject().getShape();
+ int[] shape = getItem(i).getItemInfo().getShape();
if (shape == null || shape.length < 4) {
continue;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/GroupArranger.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/GroupArranger.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/GroupArranger.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl;
+/**
+ * @author ?
+ */
public class GroupArranger {
Group group;
int mgi = 0; // items with indefinite gravity
@@ -116,7 +119,7 @@
Item i2 = group.allitems[item.inputs[input]];
int[] is = i2.outputs;
for (int i = 0; i < is.length; i++) {
- if (is[i] == item.n) {
+ if (is[i] == item.getId()) {
i2.outputActivities[i] = b;
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Groups.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Groups.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Groups.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -12,6 +12,9 @@
import java.util.*;
+/**
+ * @author ?
+ */
public class Groups {
protected LayoutConstants constants;
static int FX = 30, FY = 120;
@@ -79,7 +82,7 @@
}
}
for (int i = 0; i < items.length; i++) {
- if (items[i].isSet()) {
+ if (items[i].isSet() && items[i].isVisible()) {
field[items[i].ix][items[i].iy] = 1;
}
}
@@ -195,7 +198,7 @@
if (c >= xDeltas.length) {
continue;
}
- int[] shape = item.getObject().getShape();
+ int[] shape = item.getItemInfo().getShape();
if (shape == null || shape.length < 4) {
continue;
}
@@ -231,7 +234,7 @@
if (sz > yDeltas[c]) {
yDeltas[c] = sz;
}
- int[] shape = items[i].getObject().getShape();
+ int[] shape = items[i].getItemInfo().getShape();
if (shape == null || shape.length < 4) {
continue;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Item.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Item.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Item.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -15,10 +15,14 @@
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IItemInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
-
+/**
+ * Auto layout item.
+ */
public class Item {
- protected IItemInfo itemInfo;
- protected int n;
+
+ private int nId;
+ private IItemInfo itemInfo;
+
protected int x = 0;
protected int y = 0;
protected int ix = -1;
@@ -35,9 +39,21 @@
protected boolean isSet = false;
protected boolean yAssigned = false;
- public Item() {}
+ public Item(int nId, IItemInfo itemInfo) {
+ this.nId = nId;
+ this.itemInfo = itemInfo;
+ if (itemInfo != null && !itemInfo.isVisible()) {
+ isSet = true;
+ ix = 0;
+ iy = 0;
+ }
+ }
- public IItemInfo getObject() {
+ public int getId() {
+ return nId;
+ }
+
+ public IItemInfo getItemInfo() {
return itemInfo;
}
@@ -77,6 +93,10 @@
public boolean isComment() {
return itemInfo != null && itemInfo.isComment();
}
+
+ public boolean isVisible() {
+ return itemInfo != null && itemInfo.isVisible();
+ }
int gravity;
boolean[] outputActivities;
@@ -85,11 +105,11 @@
public void initActivities() {
outputActivities = new boolean[outputs.length];
for (int i = 0; i < outputActivities.length; i++) {
- outputActivities[i] = (outputs[i] != n);
+ outputActivities[i] = (outputs[i] != nId);
}
inputActivities = new boolean[inputs.length];
for (int i = 0; i < inputActivities.length; i++) {
- inputActivities[i] = (inputs[i] != n);
+ inputActivities[i] = (inputs[i] != nId);
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Items.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Items.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/Items.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -16,6 +16,9 @@
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IDiagramInfo;
+/**
+ * @author ?
+ */
public class Items {
protected LayoutConstants constants;
protected IDiagramInfo process;
@@ -55,11 +58,9 @@
IItemInfo[] is = process.getItems();
items = new Item[is.length];
for (int i = 0; i < is.length; i++) {
- Item item = new Item();
+ Item item = new Item(i, is[i]);
items[i] = item;
paths.put(is[i].getID(), item);
- item.n = i;
- item.itemInfo = is[i];
int[] shape = is[i].getShape();
if (!override && shape != null && shape.length > 1) {
item.x = shape[0];
@@ -107,8 +108,8 @@
private void buildBinds() {
for (int i = 0; i < items.length; i++) {
- ILinkInfo[] ts = (items[i].itemInfo instanceof ILinkInfo) ? new ILinkInfo[] {
(ILinkInfo) items[i].itemInfo }
- : getOutput(items[i].itemInfo);
+ ILinkInfo[] ts = (items[i].getItemInfo() instanceof ILinkInfo) ? new ILinkInfo[] {
(ILinkInfo) items[i].getItemInfo() }
+ : getOutput(items[i].getItemInfo());
for (int j = 0; j < ts.length; j++) {
String target = ts[j].getTargetID();
if (target == null || target.length() == 0) {
@@ -119,13 +120,13 @@
continue;
}
if (items[i].isComment()) {
- item2.addComment(items[i].n);
+ item2.addComment(items[i].getId());
items[i].isOwned = true;
} else if (item2.weight < 0) {
continue;
} else {
- item2.addInput(items[i].n, ts[j]);
- items[i].addOutput(item2.n);
+ item2.addInput(items[i].getId(), ts[j]);
+ items[i].addOutput(item2.getId());
}
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/autolayout/impl/TransitionArranger.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java 2009-10-30
16:19:46 UTC (rev 18369)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts/DiagramEditPart.java 2009-10-30
16:23:36 UTC (rev 18370)
@@ -23,7 +23,6 @@
import org.eclipse.draw2d.ManhattanConnectionRouter;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.XYLayout;
-import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.CompoundSnapToHelper;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.EditPart;
@@ -35,14 +34,11 @@
import org.eclipse.gef.SnapToHelper;
import org.eclipse.gef.rulers.RulerProvider;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IItemInfo;
-import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.ILinkInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.IDiagramInfo;
+import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.data.DiagramInfo;
import org.jboss.tools.hibernate.ui.diagram.editors.autolayout.impl.AutoLayoutImpl;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.Connection;
import org.jboss.tools.hibernate.ui.diagram.editors.model.BaseElement;
import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
-import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Shape;
/**
@@ -62,6 +58,9 @@
ConnectionLayer connLayer = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
connLayer.setConnectionRouter(new ManhattanConnectionRouter());
+ //connLayer.setConnectionRouter(new ShortestPathConnectionRouter());
+ //connLayer.setConnectionRouter(new BendpointConnectionRouter());
+ //connLayer.setConnectionRouter(new FanRouter());
return f;
}
@@ -112,7 +111,7 @@
}
public void autolayout() {
- IDiagramInfo process = new DiagramInfo(getOrmDiagram());
+ IDiagramInfo process = new DiagramInfo(getViewer(), getOrmDiagram());
AutoLayoutImpl layout = new AutoLayoutImpl();
layout.setGridStep(5);
layout.setOverride(true);
@@ -136,172 +135,6 @@
}
}
- class DiagramInfo implements IDiagramInfo {
-
- List<IItemInfo> items = new ArrayList<IItemInfo>();
- OrmDiagram diagram;
-
- public DiagramInfo(OrmDiagram diagram) {
- this.diagram = diagram;
- Iterator<Shape> it = diagram.getChildrenIterator();
- while (it.hasNext()) {
- Shape child = it.next();
- if (child.isVisible() && (child instanceof OrmShape)) {
- IItemInfo item = new DiagramElementInfo((OrmShape)child);
- addItem(item);
- }
- }
- }
-
- /**
- *
- */
- public IItemInfo[] getItems() {
- return items.toArray(new IItemInfo[0]);
- }
-
- /**
- *
- * @param item
- */
- public void addItem(IItemInfo item) {
- items.add(item);
- }
- }
-
- class DiagramElementInfo implements IItemInfo {
- OrmShape element;
-
- List<ILinkInfo> links = new ArrayList<ILinkInfo>();
-
- /**
- *
- * @param element
- */
- public DiagramElementInfo(OrmShape element) {
- ILinkInfo link;
- this.element = element;
- for (Connection connection : element.getSourceConnections()) {
- if (connection.isVisible()) {
- link = new LinkInfo(connection);
- addLink(link);
- }
- }
- Iterator<Shape> it = element.getChildrenIterator();
- while (it.hasNext()) {
- Shape child = it.next();
- if (!child.isVisible()) {
- continue;
- }
- final List<Connection> sourceConnections = child.getSourceConnections();
- if (sourceConnections.size() == 0) {
- link = new LinkInfo(getID());
- addLink(link);
- }
- for (Connection connection : sourceConnections) {
- if (connection.isVisible()) {
- link = new LinkInfo(connection);
- addLink(link);
- }
- }
- }
- }
-
- /**
- *
- */
- public String getID() {
- return element.toString();
- }
-
- /**
- *
- */
- public boolean isComment() {
- return false;
- }
-
- /**
- * gets shape vertices
- */
- public int[] getShape() {
- int[] shape = new int[4];
- shape[0] = element.getLocation().x;
- shape[1] = element.getLocation().y;
- OrmShapeEditPart part = (OrmShapeEditPart) getViewer()
- .getEditPartRegistry().get(element);
- if (part != null) {
- IFigure fig = part.getFigure();
- //shape[2] = fig.getSize().width;
- //shape[3] = fig.getSize().height;
- // use preferred size for correct autolayout
- shape[2] = fig.getPreferredSize().width;
- shape[3] = fig.getPreferredSize().height;
- } else {
- // indicate refresh model error
- shape[2] = 6000;
- shape[3] = 1000;
- }
- return shape;
- }
-
- /**
- * setup OrmShape up-left point location, using s[0] and s[1]
- */
- public void setShape(int[] s) {
- element.setLocation(new Point(s[0], s[1]));
- }
-
- /**
- *
- */
- public ILinkInfo[] getLinks() {
- return links.toArray(new ILinkInfo[0]);
- }
-
- /**
- *
- * @param link
- */
- public void addLink(ILinkInfo link) {
- links.add(link);
- }
-
- }
-
- class LinkInfo implements ILinkInfo {
- Connection link = null;
-
- String id = null;
-
- /**
- *
- * @param link
- */
- public LinkInfo(Connection link) {
- this.link = link;
- }
-
- /**
- *
- * @param id
- */
- public LinkInfo(String id) {
- this.id = id;
- }
-
- public String getTargetID() {
- if (id != null) {
- return id;
- }
- if (link.getTarget() != null) {
- return link.getTarget().toString();
- }
- return ""; //$NON-NLS-1$
- }
- }
-
-
/**
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/