Author: dgeraskov
Date: 2007-12-26 06:16:53 -0500 (Wed, 26 Dec 2007)
New Revision: 5439
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/Shape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeTreeEditPart.java
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/ShapeTreeEditPart.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1535
Get value type via console configuration loader.
Added some checks that type is accessible when we try to load it.
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-12-26
11:10:53 UTC (rev 5438)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-12-26
11:16:53 UTC (rev 5439)
@@ -13,16 +13,13 @@
import java.util.Iterator;
import org.eclipse.draw2d.geometry.Point;
-import org.hibernate.mapping.Array;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.KeyValue;
-import org.hibernate.mapping.List;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
@@ -111,11 +108,22 @@
Property field = (Property)iterator.next();
if (!field.isBackRef()) {
if (!field.isComposite()) {
- if (field.getValue().isSimpleValue()) {
+
+
+ boolean typeIsAccessible = true;
+ if (field.getValue().isSimpleValue() &&
((SimpleValue)field.getValue()).isTypeSpecified()) {
+ try {
+ field.getValue().getType();
+ } catch (Exception e) {
+ typeIsAccessible = false;
+ }
+ }
+
+ if (typeIsAccessible && field.getValue().isSimpleValue()) {
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);
@@ -132,9 +140,19 @@
Property property = (Property)iter.next();
if (!property.isBackRef()) {
if (!property.isComposite()) {
- if (property.getValue().getType().isEntityType()) {
+
+ boolean typeIsAccessible = true;
+ if (property.getValue().isSimpleValue() &&
((SimpleValue)property.getValue()).isTypeSpecified()) {
+ try {
+ property.getValue().getType();
+ } catch (Exception e) {
+ typeIsAccessible = false;
+ }
+ }
+
+ if (typeIsAccessible && property.getValue().getType().isEntityType()) {
bodyOrmShape = new ExpandeableShape(property);
- } else if (property.getValue().getType().isCollectionType()) {
+ } else if (typeIsAccessible &&
property.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(property);
} else {
bodyOrmShape = new Shape(property);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/Shape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/Shape.java 2007-12-26
11:10:53 UTC (rev 5438)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/Shape.java 2007-12-26
11:16:53 UTC (rev 5439)
@@ -186,7 +186,7 @@
return ((Property) getOrmElement()).getType().getReturnedClass().getName();
}
else if (getOrmElement() instanceof Column) {
- String type = ormModelNameVisitor.getColumnSqlType((Column) getOrmElement(),
getOrmDiagram().getConfiguration());
+ String type = ormModelNameVisitor.getColumnSqlType((Column) getOrmElement(),
getOrmDiagram().getConsoleConfiguration());
Column column = (Column) getOrmElement();
StringBuffer name = new StringBuffer();
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-12-26
11:10:53 UTC (rev 5438)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-12-26
11:16:53 UTC (rev 5439)
@@ -12,8 +12,12 @@
import java.util.Iterator;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.execution.ExecutionContext.Command;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.veditor.VisualEditorPlugin;
public class SpecialOrmShape extends OrmShape {
@@ -41,9 +45,25 @@
while (iterator.hasNext()) {
Property field = (Property)iterator.next();
try {
- if (field.getValue().getType().isEntityType()) {
+ Type type = null;
+ if (getOrmDiagram() != null){
+ ConsoleConfiguration cfg = getOrmDiagram().getConsoleConfiguration();
+ final Property fField = field;
+ type = (Type) cfg.execute(new Command(){
+ public Object execute() {
+ return fField.getValue().getType();
+ }});
+ } else {
+ try{
+ type = field.getValue().getType();
+ } catch (Exception e){
+ //type is not accessible
+ VisualEditorPlugin.getDefault().logError(e);
+ }
+ }
+ if (type != null && type.isEntityType()) {
bodyOrmShape = new ExpandeableShape(field);
- } else if (field.getValue().getType().isCollectionType()) {
+ } else if (type != null && type.isCollectionType()) {
bodyOrmShape = new ComponentShape(field);
} else {
bodyOrmShape = new Shape(field);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeTreeEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeTreeEditPart.java 2007-12-26
11:10:53 UTC (rev 5438)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeTreeEditPart.java 2007-12-26
11:16:53 UTC (rev 5439)
@@ -5,7 +5,7 @@
import java.util.List;
import org.eclipse.swt.widgets.Tree;
-import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
import org.jboss.tools.hibernate.ui.veditor.editors.model.ExpandeableShape;
import org.jboss.tools.hibernate.ui.veditor.editors.model.Shape;
import org.jboss.tools.hibernate.ui.view.views.OrmLabelProvider;
@@ -62,8 +62,7 @@
Shape model = (Shape) getModel();
Object element = model.getOrmElement();
- Configuration cfg = model.getOrmDiagram().getConsoleConfiguration()
- .getConfiguration();
+ ConsoleConfiguration cfg = model.getOrmDiagram().getConsoleConfiguration();
setWidgetImage(ormLabelProvider.getImage(element));
setWidgetText(ormLabelProvider.getText(element, cfg));
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-12-26
11:10:53 UTC (rev 5438)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeEditPart.java 2007-12-26
11:16:53 UTC (rev 5439)
@@ -32,6 +32,7 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
@@ -71,9 +72,9 @@
while (model.getParent() != null) {
model = model.getParent();
}
- Configuration cfg = null;
+ ConsoleConfiguration cfg = null;
if (model instanceof OrmDiagram) {
- cfg = ((OrmDiagram) model).getConsoleConfiguration().getConfiguration();
+ cfg = ((OrmDiagram) model).getConsoleConfiguration();
}
label.setText(ormLabelProvider.getText(getElement(), cfg));
label.setBackgroundColor(getColor());
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeTreeEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeTreeEditPart.java 2007-12-26
11:10:53 UTC (rev 5438)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ShapeTreeEditPart.java 2007-12-26
11:16:53 UTC (rev 5439)
@@ -6,7 +6,7 @@
import java.util.List;
import org.eclipse.swt.widgets.Tree;
-import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
import org.jboss.tools.hibernate.ui.veditor.editors.model.ExpandeableShape;
import org.jboss.tools.hibernate.ui.veditor.editors.model.Shape;
import org.jboss.tools.hibernate.ui.view.views.OrmLabelProvider;
@@ -62,8 +62,7 @@
Shape model = (Shape) getModel();
Object element = model.getOrmElement();
- Configuration cfg = model.getOrmDiagram().getConsoleConfiguration()
- .getConfiguration();
+ ConsoleConfiguration cfg = model.getOrmDiagram().getConsoleConfiguration();
setWidgetImage(ormLabelProvider.getImage(element));
setWidgetText(ormLabelProvider.getText(element, cfg));