Author: mdryakhlenkov
Date: 2007-10-17 08:10:43 -0400 (Wed, 17 Oct 2007)
New Revision: 4286
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/ObjectEditorInput.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenFileActionUtils.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelImageVisitor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java
Log:
JBIDE-1067: Mapping Diagram crashes with enum Attributes
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeEditPart.java 2007-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeEditPart.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -57,7 +57,7 @@
OrmEditPart implements PropertyChangeListener, NodeEditPart {
static protected OrmLabelProvider ormLabelProvider =
- new OrmLabelProvider(new OrmModelImageVisitor(), new OrmModelNameVisitor(null));
+ new OrmLabelProvider(new OrmModelImageVisitor(), new OrmModelNameVisitor());
protected void createEditPolicies() {
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new
ShapesSelectionEditPolicy());
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/ObjectEditorInput.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/ObjectEditorInput.java 2007-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/ObjectEditorInput.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -12,6 +12,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.hibernate.console.ConsoleConfiguration;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java 2007-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -16,10 +16,16 @@
import org.eclipse.ui.IWorkbenchPart;
public abstract class OpenActionDelegate implements IObjectActionDelegate {
+ private IWorkbenchPart part;
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ this.part = targetPart;
}
public void selectionChanged(IAction action, ISelection selection) {
}
+
+ public IWorkbenchPart getPart() {
+ return part;
+ }
}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -19,6 +19,7 @@
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ObjectPluginAction;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.views.KnownConfigurationsView;
import org.jboss.tools.hibernate.ui.view.ViewPlugin;
public class OpenDiagramActionDelegate extends OpenActionDelegate {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenFileActionUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenFileActionUtils.java 2007-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenFileActionUtils.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -71,6 +71,7 @@
}
public static boolean rootClassHasAnnotations(ConsoleConfiguration consoleConfiguration,
java.io.File configXMLFile, RootClass rootClass) {
+ if (configXMLFile == null) return true;
Document doc = getDocument(consoleConfiguration, configXMLFile);
return getElements(doc, HTConstants.HIBERNATE_TAG_MAPPING,
HTConstants.HIBERNATE_TAG_CLASS,
HibernateUtils.getPersistentClassName(rootClass)).hasNext();
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelImageVisitor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelImageVisitor.java 2007-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelImageVisitor.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -142,7 +142,7 @@
return ViewPlugin.getImageDescriptor(BUNDLE
.getString("OrmModelImageVisitor.Collection"));
}
- } catch (MappingException e) {
+ } catch (Exception e) {
return ViewPlugin.getImageDescriptor(BUNDLE
.getString("OrmModelImageVisitor.PersistentFieldNot_mapped"));
}
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-10-17
12:02:50 UTC (rev 4285)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OrmModelNameVisitor.java 2007-10-17
12:10:43 UTC (rev 4286)
@@ -12,10 +12,13 @@
import java.sql.Types;
import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.viewers.ContentViewer;
import org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper;
+import org.hibernate.eclipse.console.workbench.TypeNameValueVisitor;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
@@ -25,24 +28,21 @@
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
+import org.hibernate.mapping.Value;
import org.hibernate.type.EntityType;
import org.hibernate.type.ManyToOneType;
public class OrmModelNameVisitor /*implements IOrmModelVisitor*/ {
- private ContentViewer viewer;
-
static private String SPACE = " ";
-
static private String POINTER = " -> ";
private ResourceBundle BUNDLE = ResourceBundle
.getBundle(OrmModelNameVisitor.class.getPackage().getName()
+ ".views");
- public OrmModelNameVisitor(ContentViewer viewer) {
+ public OrmModelNameVisitor() {
super();
- this.viewer = viewer;
}
public Object visitDatabaseColumn(Column column, Object argument) {
@@ -100,25 +100,56 @@
name.append(field.getName());
name.append(BUNDLE.getString("OrmModelNameVisitor.Colon"));
String typeString = null;
+
try {
- if (field.getType().isEntityType()) {
- typeString = ((EntityType)field.getType()).getAssociatedEntityName();
- } else {
- typeString = field.getType().getReturnedClass().getName();
- }
+ typeString = field.getType().getReturnedClass().getName();
} catch (Exception e) {
if (field.getValue() instanceof Component) {
typeString = ((Component)field.getValue()).getComponentClassName();
+ } else if (field.getValue().isSimpleValue()) {
+ typeString = ((SimpleValue)field.getValue()).getTypeName();
}
}
+
+
+
if (typeString != null) {
+ typeString = correctTypeString(typeString);
+ name.append(SPACE);
name.append(typeString);
}
- return name.toString();
+// return name.toString();
+ Value value = field.getValue();
+ String typeName = (String) value.accept(new TypeNameValueVisitor(false));
+
+ if (typeName!=null) {
+ return field.getName() + " : " + typeName;
+ }
+
+ return field.getName();
}
+ private String correctTypeString(String str) {
+ String ret = str;
+ while (ret.startsWith("[")) {
+ ret = ret.substring(1).concat("[]");
+ }
+ switch (ret.toCharArray()[0]) {
+ case 'Z': ret = "boolean".concat(ret.substring(1));break;
+ case 'B': ret = "byte".concat(ret.substring(1));break;
+ case 'C': ret = "char".concat(ret.substring(1));break;
+ case 'L': ret = ret.substring(1);break;
+ case 'D': ret = "double".concat(ret.substring(1));break;
+ case 'F': ret = "float".concat(ret.substring(1));break;
+ case 'I': ret = "int".concat(ret.substring(1));break;
+ case 'J': ret = "long".concat(ret.substring(1));break;
+ case 'S': ret = "short".concat(ret.substring(1));break;
+ }
+ return ret;
+ }
+
public Object visitCollectionKeyMapping(DependantValue mapping, Object argument) {
return "key";
}
Show replies by date