Author: mdryakhlenkov
Date: 2007-10-10 11:18:47 -0400 (Wed, 10 Oct 2007)
New Revision: 4098
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HTConstants.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.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/OpenMappingActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
Log:
JBIDE-983: Objects on diagram must have context menu
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.veditor;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -52,4 +53,10 @@
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
return window.getActivePage();
}
+
+ public static Shell getShell(){
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ return window.getShell();
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -53,7 +53,7 @@
if (resource == null) {
if (OpenFileActionUtils.rootClassHasAnnotations(consoleConfiguration,
configXMLFile, rootClass)) {
- String fullyQualifiedName =
HibernateUtils.getPersistentClassName(rootClass.getClassName());
+ String fullyQualifiedName = HibernateUtils.getPersistentClassName(rootClass);
try {
resource = proj.findType(fullyQualifiedName).getResource();
} catch (JavaModelException e) {
@@ -76,7 +76,7 @@
while (classMappingsIterator.hasNext()) {
PersistentClass elem = (PersistentClass) classMappingsIterator.next();
if
(HibernateUtils.getTableName(elem.getTable()).equals(HibernateUtils.getTableName(table)))
{
- String fullyQualifiedName =
HibernateUtils.getPersistentClassName(elem.getClassName());
+ String fullyQualifiedName = HibernateUtils.getPersistentClassName(elem);
try {
resource = proj.findType(fullyQualifiedName).getResource();
} catch (JavaModelException e) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -7,7 +7,9 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.hibernate.console.ConsoleConfiguration;
@@ -43,12 +45,13 @@
PersistentClass rootClass = (PersistentClass) iterator.next();
IResource resource = null;
- String fullyQualifiedName =
HibernateUtils.getPersistentClassName(rootClass.getClassName());
+ String fullyQualifiedName = HibernateUtils.getPersistentClassName(rootClass);
if (fullyQualifiedName.indexOf("$") > 0) {
fullyQualifiedName = fullyQualifiedName.substring(0,
fullyQualifiedName.indexOf("$"));
}
try {
- resource = proj.findType(fullyQualifiedName).getResource();
+ IType type = proj.findType(fullyQualifiedName);
+ if (type != null) resource = type.getResource();
} catch (JavaModelException e) {
VisualEditorPlugin.getDefault().logError("Can't find source file.",
e);
}
@@ -60,6 +63,9 @@
VisualEditorPlugin.getDefault().logError("Can't open source
file.", e);
}
}
+ if (resource == null) {
+ MessageDialog.openInformation(VisualEditorPlugin.getShell(), "Open Source
File", "Source file for class '" + fullyQualifiedName + "' not
found.");
+ }
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HTConstants.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HTConstants.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HTConstants.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -3,8 +3,11 @@
public class HTConstants {
public static String HIBERNATE_TAG_CLASS = "class";
public static String HIBERNATE_TAG_TABLE = "table";
- public static String HIBERNATE_TAG_SUBCLASS = "subclass";
+ public static String HIBERNATE_TAG_SUBCLASS = "subclass";
+ public static String HIBERNATE_TAG_JOINED_SUBCLASS = "joined-subclass";
+ public static String HIBERNATE_TAG_UNION_SUBCLASS = "union-subclass";
public static String HIBERNATE_TAG_NAME = "name";
+ public static String HIBERNATE_TAG_ENTITY_NAME = "entity-name";
public static String HIBERNATE_TAG_SESSION_FACTORY = "session-factory";
public static String HIBERNATE_TAG_MAPPING = "mapping";
public static String HIBERNATE_TAG_RESOURCE = "resource";
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -18,6 +18,14 @@
return getTableName(table.getCatalog(), table.getSchema(), table.getName());
}
+ public static String getPersistentClassName(PersistentClass rootClass) {
+ if (rootClass == null) {
+ return "";
+ } else {
+ return rootClass.getEntityName() != null ? rootClass.getEntityName() :
rootClass.getClassName();
+ }
+ }
+
public static String getPersistentClassName(String className) {
if (className == null) {
return "";
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-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenFileActionUtils.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -72,7 +72,7 @@
public static boolean rootClassHasAnnotations(ConsoleConfiguration consoleConfiguration,
java.io.File configXMLFile, RootClass rootClass) {
Document doc = getDocument(consoleConfiguration, configXMLFile);
- return getElements(doc, HTConstants.HIBERNATE_TAG_MAPPING,
HTConstants.HIBERNATE_TAG_CLASS,
HibernateUtils.getPersistentClassName(rootClass.getClassName())).hasNext();
+ return getElements(doc, HTConstants.HIBERNATE_TAG_MAPPING,
HTConstants.HIBERNATE_TAG_CLASS,
HibernateUtils.getPersistentClassName(rootClass)).hasNext();
}
private static boolean elementInResource(ConsoleConfiguration consoleConfiguration,
IResource resource, Object element) {
@@ -89,16 +89,30 @@
public static boolean rootClassInResource(ConsoleConfiguration consoleConfiguration,
IResource resource, RootClass persistentClass) {
Document doc = getDocument(consoleConfiguration, resource.getLocation().toFile());
- return getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
HTConstants.HIBERNATE_TAG_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass.getClassName()))).hasNext()
||
- getElements(doc, HTConstants.HIBERNATE_TAG_CLASS, HTConstants.HIBERNATE_TAG_NAME,
HibernateUtils.getPersistentClassName(persistentClass.getClassName())).hasNext() ||
- getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass.getClassName()))).hasNext()
||
- getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
HibernateUtils.getPersistentClassName(persistentClass.getClassName())).hasNext();
+ return getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
HTConstants.HIBERNATE_TAG_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_CLASS, HTConstants.HIBERNATE_TAG_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+ getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+ getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_CLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext();
}
public static boolean subclassInResource(ConsoleConfiguration consoleConfiguration,
IResource resource, Subclass persistentClass) {
Document doc = getDocument(consoleConfiguration, resource.getLocation().toFile());
- return getElements(doc, HTConstants.HIBERNATE_TAG_SUBCLASS,
HTConstants.HIBERNATE_TAG_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass.getClassName()))).hasNext()
||
- getElements(doc, HTConstants.HIBERNATE_TAG_SUBCLASS, HTConstants.HIBERNATE_TAG_NAME,
HibernateUtils.getPersistentClassName(persistentClass.getClassName())).hasNext();
+ return getElements(doc, HTConstants.HIBERNATE_TAG_SUBCLASS,
HTConstants.HIBERNATE_TAG_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_SUBCLASS, HTConstants.HIBERNATE_TAG_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+ getElements(doc, HTConstants.HIBERNATE_TAG_SUBCLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_SUBCLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+
+ getElements(doc, HTConstants.HIBERNATE_TAG_JOINED_SUBCLASS,
HTConstants.HIBERNATE_TAG_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_JOINED_SUBCLASS,
HTConstants.HIBERNATE_TAG_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+ getElements(doc, HTConstants.HIBERNATE_TAG_JOINED_SUBCLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_JOINED_SUBCLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+
+ getElements(doc, HTConstants.HIBERNATE_TAG_UNION_SUBCLASS,
HTConstants.HIBERNATE_TAG_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_UNION_SUBCLASS,
HTConstants.HIBERNATE_TAG_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext() ||
+ getElements(doc, HTConstants.HIBERNATE_TAG_UNION_SUBCLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
StringHelper.unqualify(HibernateUtils.getPersistentClassName(persistentClass))).hasNext()
||
+ getElements(doc, HTConstants.HIBERNATE_TAG_UNION_SUBCLASS,
HTConstants.HIBERNATE_TAG_ENTITY_NAME,
HibernateUtils.getPersistentClassName(persistentClass)).hasNext();
}
public static boolean tableInResource(ConsoleConfiguration consoleConfiguration,
IResource resource, Table table) {
@@ -128,8 +142,15 @@
}
Attribute classNameAttr = element.attribute( HTConstants.HIBERNATE_TAG_NAME );
- String physicalTableName =
consoleConfiguration.getConfiguration().getNamingStrategy().classToTableName(classNameAttr.getValue());
- if (table.getName().equals(physicalTableName)) {
+ if (classNameAttr == null) classNameAttr = element.attribute(
HTConstants.HIBERNATE_TAG_ENTITY_NAME);
+ if (classNameAttr != null) {
+ String physicalTableName =
consoleConfiguration.getConfiguration().getNamingStrategy().classToTableName(classNameAttr.getValue());
+ if (table.getName().equals(physicalTableName)) {
+ return true;
+ }
+ }
+
+ if (getElements(doc, HTConstants.HIBERNATE_TAG_TABLE, table.getName()).hasNext()) {
return true;
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -70,7 +70,7 @@
IResource resource = OpenFileActionUtils.getResource(consoleConfiguration, proj,
configXMLFile, rootClass);
if (resource == null) {
- String fullyQualifiedName =
HibernateUtils.getPersistentClassName(rootClass.getClassName());
+ String fullyQualifiedName = HibernateUtils.getPersistentClassName(rootClass);
try {
resource = proj.findType(fullyQualifiedName).getResource();
} catch (JavaModelException e) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java 2007-10-10
15:03:43 UTC (rev 4097)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java 2007-10-10
15:18:47 UTC (rev 4098)
@@ -13,8 +13,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.internal.ObjectPluginAction;
@@ -31,9 +33,10 @@
IJavaProject proj = OpenFileActionUtils.findJavaProject(consoleConfiguration);
IResource resource = null;
- String fullyQualifiedName =
HibernateUtils.getPersistentClassName(rootClass.getClassName());
+ String fullyQualifiedName = HibernateUtils.getPersistentClassName(rootClass);
try {
- resource = proj.findType(fullyQualifiedName).getResource();
+ IType type = proj.findType(fullyQualifiedName);
+ if (type != null) resource = type.getResource();
} catch (JavaModelException e) {
ViewPlugin.getDefault().logError("Can't find source file.", e);
}
@@ -45,5 +48,8 @@
ViewPlugin.getDefault().logError("Can't open source file.", e);
}
}
+ if (resource == null) {
+ MessageDialog.openInformation(ViewPlugin.getActiveWorkbenchShell(), "Open Source
File", "Source file for class '" + fullyQualifiedName + "' not
found.");
+ }
}
}
\ No newline at end of file