Author: mdryakhlenkov
Date: 2007-07-19 11:29:32 -0400 (Thu, 19 Jul 2007)
New Revision: 2526
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java
Log:
EXIN-366: Adding elements on the diagram by double-click on fields of classes which have
additional information in mapping files
Adding inner class bug fixed
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-19
14:46:22 UTC (rev 2525)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-19
15:29:32 UTC (rev 2526)
@@ -225,7 +225,8 @@
if (componentClassShape == null && persistentClass instanceof RootClass) {
componentClassShape =
getOrCreateComponentClass(((RootClass)persistentClass).getIdentifierProperty());
OrmShape tableShape = getOrCreateDatabaseTable(identifier.getTable());
- createConnections(componentClassShape, tableShape);
+ if (componentClassShape != null)
+ createConnections(componentClassShape, tableShape);
}
}
}
@@ -446,28 +447,30 @@
public OrmShape getOrCreateComponentClass(Property property) {
OrmShape classShape = null;
- if (property.getValue() instanceof Collection) {
- Component component = (Component)((Collection)property.getValue()).getElement();
- if (component != null) {
+ if (property != null) {
+ if (property.getValue() instanceof Collection) {
+ Component component = (Component)((Collection)property.getValue()).getElement();
+ if (component != null) {
+ classShape = createShape(property);
+ OrmShape tableShape = (OrmShape)elements.get(component.getTable().getSchema() +
"." + component.getTable().getName());
+ if (tableShape == null) tableShape =
getOrCreateDatabaseTable(component.getTable());
+ createConnections(classShape, tableShape);
+ if(!isConnectionExist(classShape, tableShape)){
+ new Connection(classShape, tableShape);
+ classShape.firePropertyChange(REFRESH, null, null);
+ tableShape.firePropertyChange(REFRESH, null, null);
+ }
+ Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
+ OrmShape parentClassShape =
(OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getEntityName());
+ if(!isConnectionExist(parentShape, parentClassShape)){
+ new Connection(parentShape, parentClassShape);
+ parentShape.firePropertyChange(REFRESH, null, null);
+ parentClassShape.firePropertyChange(REFRESH, null, null);
+ }
+ }
+ } else if (property.getValue() instanceof Component) {
classShape = createShape(property);
- OrmShape tableShape = (OrmShape)elements.get(component.getTable().getSchema() +
"." + component.getTable().getName());
- if (tableShape == null) tableShape = getOrCreateDatabaseTable(component.getTable());
- createConnections(classShape, tableShape);
- if(!isConnectionExist(classShape, tableShape)){
- new Connection(classShape, tableShape);
- classShape.firePropertyChange(REFRESH, null, null);
- tableShape.firePropertyChange(REFRESH, null, null);
- }
- Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
- OrmShape parentClassShape =
(OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getEntityName());
- if(!isConnectionExist(parentShape, parentClassShape)){
- new Connection(parentShape, parentClassShape);
- parentShape.firePropertyChange(REFRESH, null, null);
- parentClassShape.firePropertyChange(REFRESH, null, null);
- }
}
- } else if (property.getValue() instanceof Component) {
- classShape = createShape(property);
}
return classShape;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-19
14:46:22 UTC (rev 2525)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-19
15:29:32 UTC (rev 2526)
@@ -62,13 +62,21 @@
while (iterator.hasNext()) {
Property field = (Property)iterator.next();
if (!field.isComposite()) {
+ boolean typeIsAccessible = true;
+ if (field.getValue().isSimpleValue() &&
((SimpleValue)field.getValue()).isTypeSpecified()) {
+ try {
+ field.getValue().getType();
+ } catch (Exception e) {
+ typeIsAccessible = false;
+ }
+ }
/* if (field.isComposite()) {
bodyOrmShape = new ExpandeableShape(field);
} else */if (field.getValue().isSimpleValue() &&
!((SimpleValue)field.getValue()).isTypeSpecified()) {
bodyOrmShape = new Shape(field);
- } else if (field.getValue().getType().isEntityType()) {
+ } else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
bodyOrmShape = new ExpandeableShape(field);
- } else if (field.getValue().getType().isCollectionType()) {
+ } else if (typeIsAccessible &&
field.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(field);
} else {
bodyOrmShape = new Shape(field);
@@ -79,11 +87,13 @@
Iterator iter = component.getPropertyIterator();
while (iter.hasNext()) {
Property property = (Property)iter.next();
-/* if (property.getValue().isSimpleValue()) {
- bodyOrmShape = new Shape(property);
- } else */if (property.getValue().getType().isEntityType()) {
+ boolean typeIsAccesible = true;
+ try {property.getValue().getType();} catch (Exception e) {typeIsAccesible =
false;}
+/* if (property.isComposite()) {
bodyOrmShape = new ExpandeableShape(property);
- } else if (property.getValue().getType().isCollectionType()) {
+ } else */if (typeIsAccesible &&
property.getValue().getType().isEntityType()) {
+ bodyOrmShape = new ExpandeableShape(property);
+ } else if (typeIsAccesible &&
property.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(property);
} else {
bodyOrmShape = new Shape(property);