Author: dazarov
Date: 2007-07-02 10:56:20 -0400 (Mon, 02 Jul 2007)
New Revision: 2236
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ComponentShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ExpandeableShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ModelElement.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/SpecialOrmShape.java
Log:
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ComponentShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ComponentShape.java 2007-07-02
12:47:49 UTC (rev 2235)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ComponentShape.java 2007-07-02
14:56:20 UTC (rev 2236)
@@ -36,22 +36,22 @@
Collection collection = (Collection)((Property)ioe).getValue();
bodyOrmShape = new Shape(collection.getKey());
bodyOrmShape.setIndent(20);
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
bodyOrmShape = new Shape(collection.getElement());
bodyOrmShape.setIndent(20);
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
}
}
protected void setChildsHiden(boolean hiden) {
- for (int i = 0; i < shapes.size(); i++)
- ((Shape)shapes.get(i)).setHiden(hiden);
+ for (int i = 0; i < getChildren().size(); i++)
+ ((Shape)getChildren().get(i)).setHiden(hiden);
}
public void refreshChildsHiden(OrmDiagram ormDiagram) {
childsHiden = !childsHiden;
- for (int i = 0; i < shapes.size(); i++)
- ((Shape)shapes.get(i)).setHiden(childsHiden);
+ for (int i = 0; i < getChildren().size(); i++)
+ ((Shape)getChildren().get(i)).setHiden(childsHiden);
firePropertyChange(SET_CHILDS_HIDEN, null, new Boolean(childsHiden));
ormDiagram.refreshComponentReferences(this);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ExpandeableShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ExpandeableShape.java 2007-07-02
12:47:49 UTC (rev 2235)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ExpandeableShape.java 2007-07-02
14:56:20 UTC (rev 2236)
@@ -27,12 +27,7 @@
public static final String SHOW_REFERENCES = "show references";
private boolean refHide = false;
- protected List<Shape> shapes = new ArrayList<Shape>();
- public List<Shape> getChildren() {
- return shapes;
- }
-
public ExpandeableShape(Object ioe) {
super(ioe);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ModelElement.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ModelElement.java 2007-07-02
12:47:49 UTC (rev 2235)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/ModelElement.java 2007-07-02
14:56:20 UTC (rev 2236)
@@ -12,6 +12,8 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Konstantin Mishin
@@ -39,5 +41,36 @@
pcsDelegate.removePropertyChangeListener(l);
}
}
+
+ private List children = new OList();
+ private ModelElement parent;
+
+ public List getChildren(){
+ return children;
+ }
+
+ public ModelElement getParent(){
+ return parent;
+ }
+
+ public void setParent(ModelElement element){
+ parent = element;
+ }
+
+ class OList extends ArrayList{
+ public OList(){
+
+ }
+
+ public boolean add(Object item){
+ if(item instanceof ModelElement)((ModelElement)item).setParent(ModelElement.this);
+ return super.add(item);
+ }
+
+ public boolean remove(Object item){
+ if(item instanceof ModelElement)((ModelElement)item).setParent(null);
+ return super.remove(item);
+ }
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java 2007-07-02
12:47:49 UTC (rev 2235)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java 2007-07-02
14:56:20 UTC (rev 2236)
@@ -57,7 +57,6 @@
private boolean dirty = false;
private String childrenLocations[];
private IResource resource = null;
- private List<Shape> shapes = new ArrayList<Shape>();
private HashMap<String,OrmShape> elements = new HashMap<String,OrmShape>();
private RootClass ormElement;
private Configuration configuration;
@@ -89,10 +88,6 @@
}
- public List getChildren() {
- return shapes;
- }
-
public HashMap getCloneElements() {
return (HashMap)elements.clone();
}
@@ -103,7 +98,7 @@
public void refresh() {
saveHelper();
- shapes.clear();
+ getChildren().clear();
elements.clear();
// if(
((IPersistentClass)ormElement).getProjectMapping().findClass(ormElement.getName()) !=
null)
/// getOrCreatePersistentClass((IPersistentClass)ormElement, null);
@@ -130,9 +125,9 @@
}
private void saveHelper() {
- childrenLocations = new String[shapes.size()];
- for (int i = 0; i < shapes.size(); i++) {
- OrmShape shape = (OrmShape) shapes.get(i);
+ childrenLocations = new String[getChildren().size()];
+ for (int i = 0; i < getChildren().size(); i++) {
+ OrmShape shape = (OrmShape) getChildren().get(i);
Object ormElement = shape.getOrmElement();
if (ormElement instanceof RootClass) {
childrenLocations[i] = ((RootClass)ormElement).getClassName() + "@";
@@ -149,24 +144,24 @@
OrmShape ormShape = null;
if (ormElement instanceof RootClass) {
ormShape = new OrmShape(ormElement);
- shapes.add(ormShape);
+ getChildren().add(ormShape);
elements.put(((RootClass)ormElement).getClassName(), ormShape);
} else if (ormElement instanceof Table) {
ormShape = new OrmShape(ormElement);
- shapes.add(ormShape);
+ getChildren().add(ormShape);
Table table = (Table)ormElement;
elements.put(table.getSchema() + "." + table.getName(), ormShape);
} else if (ormElement instanceof Property) {
// ormShape = new OrmShape(ormElement);
SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
ormShape = new SpecialOrmShape(specialRootClass);
- shapes.add(ormShape);
+ getChildren().add(ormShape);
// Property property = (Property)ormElement;
// elements.put(property.getPersistentClass().getEntityName() + "." +
property.getName(), ormShape);
elements.put(specialRootClass.getClassName(), ormShape);
} else if (ormElement instanceof SingleTableSubclass) {
ormShape = new OrmShape(ormElement);
- shapes.add(ormShape);
+ getChildren().add(ormShape);
elements.put(((SingleTableSubclass)ormElement).getEntityName(), ormShape);
}
return ormShape;
@@ -334,10 +329,10 @@
} else if (collection.isMap()) {
Map map = (Map)collection;
OrmShape childShape = getOrCreateDatabaseTable(map.getCollectionTable());
- Shape keyShape =
childShape.getChild(((DependantValue)componentShape.getChildren().get(0).getOrmElement()).getColumnIterator().next());
- new Connection(componentShape.getChildren().get(0), keyShape);
- Shape elementShape =
childShape.getChild(((SimpleValue)componentShape.getChildren().get(1).getOrmElement()).getColumnIterator().next());
- new Connection(componentShape.getChildren().get(1), elementShape);
+ Shape keyShape =
childShape.getChild(((DependantValue)((Shape)componentShape.getChildren().get(0)).getOrmElement()).getColumnIterator().next());
+ new Connection((Shape)componentShape.getChildren().get(0), keyShape);
+ Shape elementShape =
childShape.getChild(((SimpleValue)((Shape)componentShape.getChildren().get(1)).getOrmElement()).getColumnIterator().next());
+ new Connection((Shape)componentShape.getChildren().get(1), elementShape);
}
setDirty(true);
firePropertyChange(REFRESH, null, null);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmShape.java 2007-07-02
12:47:49 UTC (rev 2235)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmShape.java 2007-07-02
14:56:20 UTC (rev 2236)
@@ -46,7 +46,7 @@
RootClass rootClass = (RootClass)getOrmElement();
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- shapes.add(new Shape(identifierProperty));
+ getChildren().add(new Shape(identifierProperty));
}
KeyValue identifier = rootClass.getIdentifier();
@@ -54,7 +54,7 @@
Iterator iterator = ((Component)identifier).getPropertyIterator();
while (iterator.hasNext()) {
Property property = (Property) iterator.next();
- shapes.add(new Shape(property));
+ getChildren().add(new Shape(property));
}
}
@@ -69,7 +69,7 @@
} else {
bodyOrmShape = new Shape(field);
}
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
} else {
Component component = (Component)field.getValue();
Iterator iter = component.getPropertyIterator();
@@ -82,7 +82,7 @@
} else {
bodyOrmShape = new Shape(property);
}
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
}
}
}
@@ -98,7 +98,7 @@
} else {
bodyOrmShape = new Shape(field);
}
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
} else {
Component component = (Component)field.getValue();
Iterator iter = component.getPropertyIterator();
@@ -111,7 +111,7 @@
} else {
bodyOrmShape = new Shape(property);
}
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
}
}
}
@@ -120,7 +120,7 @@
while (iterator.hasNext()) {
Column column = (Column)iterator.next();
bodyOrmShape = new Shape(column);
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
}
}
}
@@ -140,14 +140,14 @@
protected void setHiden(boolean hiden) {
super.setHiden(hiden);
- for (int i = 0; i < shapes.size(); i++)
- ((Shape)shapes.get(i)).setHiden(hiden);
+ for (int i = 0; i < getChildren().size(); i++)
+ ((Shape)getChildren().get(i)).setHiden(hiden);
}
public void refreshHiden() {
hiden = !hiden;
- for (int i = 0; i < shapes.size(); i++)
- ((Shape)shapes.get(i)).setHiden(hiden);
+ for (int i = 0; i < getChildren().size(); i++)
+ ((Shape)getChildren().get(i)).setHiden(hiden);
firePropertyChange(SET_HIDEN, null, new Boolean(hiden));
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/SpecialOrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/SpecialOrmShape.java 2007-07-02
12:47:49 UTC (rev 2235)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/SpecialOrmShape.java 2007-07-02
14:56:20 UTC (rev 2236)
@@ -26,12 +26,12 @@
Shape bodyOrmShape;
RootClass rootClass = (RootClass)getOrmElement();
Property identifierProperty = rootClass.getIdentifierProperty();
- if (identifierProperty != null) shapes.add(new Shape(identifierProperty));
+ if (identifierProperty != null) getChildren().add(new Shape(identifierProperty));
SpecialRootClass src = (SpecialRootClass)getOrmElement();
if (src.getParentProperty() != null) {
bodyOrmShape = new Shape(src.getParentProperty());
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
parentShape = bodyOrmShape;
}
@@ -45,7 +45,7 @@
} else {
bodyOrmShape = new Shape(field);
}
- shapes.add(bodyOrmShape);
+ getChildren().add(bodyOrmShape);
}
}