Author: mdryakhlenkov
Date: 2007-07-31 09:30:29 -0400 (Tue, 31 Jul 2007)
New Revision: 2756
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/TextUtil.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
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/parts/DiagramEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmLabelProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java
Log:
JBIDE-628: table names handled badly in diagram
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-07-31
13:17:39 UTC (rev 2755)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-07-31
13:30:29 UTC (rev 2756)
@@ -14,10 +14,10 @@
org.eclipse.ui.editors,
org.eclipse.core.resources,
org.hibernate.eclipse,
- org.jboss.tools.hibernate.ui.view,
org.jboss.tools.common,
org.eclipse.jdt.core,
- org.jboss.tools.common.model
+ org.jboss.tools.common.model,
+ org.jboss.tools.hibernate.ui.view
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.hibernate.ui.veditor,
org.jboss.tools.hibernate.ui.veditor.editors,
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-31
13:17:39 UTC (rev 2755)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-31
13:30:29 UTC (rev 2756)
@@ -48,6 +48,7 @@
import org.hibernate.type.Type;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.hibernate.ui.veditor.VisualEditorPlugin;
+import org.jboss.tools.hibernate.ui.view.views.TextUtil;
public class OrmDiagram extends ModelElement {
@@ -143,8 +144,7 @@
} else if (ormElement instanceof Table) {
ormShape = new OrmShape(ormElement);
getChildren().add(ormShape);
- Table table = (Table)ormElement;
- elements.put(table.getSchema() + "." + table.getName(), ormShape);
+ elements.put(TextUtil.getTableName((Table)ormElement), ormShape);
} else if (ormElement instanceof Property) {
SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
ormShape = new SpecialOrmShape(specialRootClass);
@@ -163,8 +163,7 @@
if (ormElement instanceof RootClass) {
ormShape = elements.get(((RootClass)ormElement).getEntityName());
} else if (ormElement instanceof Table) {
- Table table = (Table)ormElement;
- ormShape = elements.get(table.getSchema() + "." + table.getName());
+ ormShape = elements.get(TextUtil.getTableName((Table)ormElement));
} else if (ormElement instanceof Property) {
SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
ormShape = elements.get(specialRootClass.getEntityName());
@@ -184,7 +183,7 @@
if(componentClassDatabaseTable == null && persistentClass.getTable() != null)
componentClassDatabaseTable = persistentClass.getTable();
if(componentClassDatabaseTable != null) {
- shape = elements.get(componentClassDatabaseTable.getSchema() + "." +
componentClassDatabaseTable.getName());
+ shape = elements.get(TextUtil.getTableName(componentClassDatabaseTable));
if (shape == null) shape = getOrCreateDatabaseTable(componentClassDatabaseTable);
createConnections(classShape, shape);
if(!isConnectionExist(classShape, shape)){
@@ -264,7 +263,7 @@
private OrmShape getOrCreateDatabaseTable(Table databaseTable){
OrmShape tableShape = null;
if(databaseTable != null) {
- String tableName = databaseTable.getSchema() + "." +
databaseTable.getName();
+ String tableName = TextUtil.getTableName(databaseTable);
tableShape = (OrmShape)elements.get(tableName);
if(tableShape == null) {
tableShape = createShape(databaseTable);
@@ -534,8 +533,7 @@
if (element instanceof RootClass) {
key = ((RootClass)element).getEntityName();
} else if (element instanceof Table) {
- Table table = (Table)element;
- key = table.getSchema() + "." + table.getName();
+ key = TextUtil.getTableName((Table)element);
} else if (element instanceof Property) {
Property property = (Property)element;
key = property.getPersistentClass().getEntityName() + "." +
property.getName();
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java 2007-07-31
13:17:39 UTC (rev 2755)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java 2007-07-31
13:30:29 UTC (rev 2756)
@@ -54,6 +54,7 @@
import org.jboss.tools.hibernate.ui.veditor.editors.model.Shape;
import org.jboss.tools.hibernate.ui.veditor.editors.model.SpecialOrmShape;
import org.jboss.tools.hibernate.ui.veditor.editors.model.SpecialRootClass;
+import org.jboss.tools.hibernate.ui.view.views.TextUtil;
class DiagramEditPart extends OrmEditPart implements PropertyChangeListener {
@@ -128,8 +129,7 @@
tempPoint = 40 + getChildrenFigurePreferredHeight(ormShape);
}
Table table = persistentClass.getTable();
- ormShape = (OrmShape) hashMap.remove(table.getSchema() + "."
- + table.getName());
+ ormShape = (OrmShape) hashMap.remove(TextUtil.getTableName(table));
if (ormShape != null) {
ormShape.setLocation(new Point(pointX, 20));
point = 40 + getChildrenFigurePreferredHeight(ormShape);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java 2007-07-31
13:17:39 UTC (rev 2755)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/OrmShapeEditPart.java 2007-07-31
13:30:29 UTC (rev 2756)
@@ -61,8 +61,7 @@
if (element instanceof RootClass) {
text = ormLabelProvider.getText((PersistentClass)element);
} else if (element instanceof Table) {
- Table table = (Table)element;
- text = table.getSchema() + "." + table.getName();
+ text = ormLabelProvider.getText((Table)element);
} else if (element instanceof Subclass) {
text = ormLabelProvider.getText((Subclass)element);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmLabelProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmLabelProvider.java 2007-07-31
13:17:39 UTC (rev 2755)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmLabelProvider.java 2007-07-31
13:30:29 UTC (rev 2756)
@@ -84,6 +84,13 @@
} else {
return name;
}
+ } else if (element instanceof Table) {
+ String name = (String)ormModelNameVisitor.visitTable((Table)element, null);
+ if (name == null) {
+ return "OrmElement";
+ } else {
+ return name;
+ }
} else if (element instanceof Subclass) {
String name = (String)ormModelNameVisitor.visitPersistentClass((Subclass)element,
null);
if (name == null) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java 2007-07-31
13:17:39 UTC (rev 2755)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java 2007-07-31
13:30:29 UTC (rev 2756)
@@ -13,6 +13,7 @@
import java.sql.Types;
import java.util.ResourceBundle;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.viewers.ContentViewer;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@@ -23,10 +24,6 @@
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
-/**
- * @author Tau from Minsk
- *
- */
public class OrmModelNameVisitor /*implements IOrmModelVisitor*/ {
private ContentViewer viewer;
@@ -484,7 +481,7 @@
Table table = clazz.getTable(); // upd tau 06.06.2005
//IDatabaseTable table = HibernateAutoMappingHelper.getPrivateTable(classMapping); //
upd tau 18.04.2005
if (table != null) {
- String tableName = table.getName();
+ String tableName = TextUtil.getTableName(table);
if (tableName != null) {
//name.append(" (");
name.append(POINTER);
@@ -496,6 +493,12 @@
return name.toString();
}
+ public Object visitTable(Table table, Object argument) {
+ StringBuffer name = new StringBuffer();
+ name.append(TextUtil.getTableName(table));
+ return name.toString();
+ }
+
public Object visitPersistentClass(Subclass clazz, Object argument) {
StringBuffer name = new StringBuffer();
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/TextUtil.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/TextUtil.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/TextUtil.java 2007-07-31
13:30:29 UTC (rev 2756)
@@ -0,0 +1,11 @@
+package org.jboss.tools.hibernate.ui.view.views;
+
+import org.hibernate.mapping.Table;
+
+public class TextUtil {
+ public static String getTableName(Table table) {
+ String schema = table.getSchema();
+ String catalog = table.getCatalog();
+ return (schema != null ? schema + "." : "") + (catalog != null ?
catalog + "." : "") + table.getName();
+ }
+}