Author: vyemialyanchyk
Date: 2009-07-10 12:41:55 -0400 (Fri, 10 Jul 2009)
New Revision: 16538
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4285 - junit tests fix
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-07-10
14:40:35 UTC (rev 16537)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/DiagramViewer.java 2009-07-10
16:41:55 UTC (rev 16538)
@@ -32,7 +32,6 @@
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.mapping.Column;
import org.hibernate.mapping.RootClass;
import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2009-07-10
14:40:35 UTC (rev 16537)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2009-07-10
16:41:55 UTC (rev 16538)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.ui.view;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.hibernate.MappingException;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Array;
import org.hibernate.mapping.Bag;
@@ -30,6 +31,7 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
+import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
/**
@@ -117,24 +119,32 @@
str = "Image_PersistentFieldMany-to-one"; //$NON-NLS-1$
} else if (value instanceof Any) {
str = "Image_PersistentFieldAny"; //$NON-NLS-1$
- } else if (field.getType() != null && field.getType().isCollectionType()) {
- if (value instanceof PrimitiveArray) {
- str = "Image_Collection_primitive_array"; //$NON-NLS-1$
- } else if (value instanceof Array) {
- str = "Image_Collection_array"; //$NON-NLS-1$
- } else if (value instanceof List) {
- str = "Image_Collection_list"; //$NON-NLS-1$
- } else if (value instanceof Set) {
- str = "Image_Collection_set"; //$NON-NLS-1$
- } else if (value instanceof Map) {
- str = "Image_Collection_map"; //$NON-NLS-1$
- } else if (value instanceof Bag) {
- str = "Image_Collection_bag"; //$NON-NLS-1$
- } else if (value instanceof IdentifierBag) {
- str = "Image_Collection_idbag"; //$NON-NLS-1$
- } else {
- str = "Image_Collection"; //$NON-NLS-1$
+ } else {
+ Type type = null;
+ try {
+ type = field.getType();
+ } catch (MappingException ex) {
+ // ignore it
}
+ if (type != null && type.isCollectionType()) {
+ if (value instanceof PrimitiveArray) {
+ str = "Image_Collection_primitive_array"; //$NON-NLS-1$
+ } else if (value instanceof Array) {
+ str = "Image_Collection_array"; //$NON-NLS-1$
+ } else if (value instanceof List) {
+ str = "Image_Collection_list"; //$NON-NLS-1$
+ } else if (value instanceof Set) {
+ str = "Image_Collection_set"; //$NON-NLS-1$
+ } else if (value instanceof Map) {
+ str = "Image_Collection_map"; //$NON-NLS-1$
+ } else if (value instanceof Bag) {
+ str = "Image_Collection_bag"; //$NON-NLS-1$
+ } else if (value instanceof IdentifierBag) {
+ str = "Image_Collection_idbag"; //$NON-NLS-1$
+ } else {
+ str = "Image_Collection"; //$NON-NLS-1$
+ }
+ }
}
} else if ("parent".equals(field.getName())) { //$NON-NLS-1$
str = "Image_PersistentFieldParent"; //$NON-NLS-1$
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2009-07-10
14:40:35 UTC (rev 16537)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2009-07-10
16:41:55 UTC (rev 16538)
@@ -23,6 +23,7 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
+import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
@@ -131,9 +132,18 @@
}
}
}
- sqlType = column.getSqlType(dialect, mapping);
- column.setSqlType(sqlType);
- return true;
+ if (dialect != null) {
+ try {
+ sqlType = column.getSqlType(dialect, mapping);
+ } catch (MappingException ex) {
+ // ignore it
+ }
+ }
+ if (sqlType != null) {
+ column.setSqlType(sqlType);
+ return true;
+ }
+ return false;
}
}
\ No newline at end of file
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java 2009-07-10
14:40:35 UTC (rev 16537)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java 2009-07-10
16:41:55 UTC (rev 16538)
@@ -71,7 +71,7 @@
if (persClasses.length > 0){
for (int i = 0; i < persClasses.length; i++) {
- assertTrue(persClasses[0] instanceof PersistentClass);
+ assertTrue(persClasses[i] instanceof PersistentClass);
PersistentClass persClass = (PersistentClass) persClasses[i];
IEditorPart editor = null;
@@ -81,7 +81,9 @@
} catch (PartInitException e) {
ex = e;
}
- if (ex == null ) ex = Utils.getExceptionIfItOccured(editor);
+ if (ex == null ) {
+ ex = Utils.getExceptionIfItOccured(editor);
+ }
if (ex != null) {
String out =
NLS.bind(ConsoleTestMessages.OpenMappingDiagramTest_mapping_diagram_for_not_opened,
new Object[]{persClass.getClassName(), ex.getMessage()});