summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2013-07-05 14:57:45 (EDT)
committer Neil Hauge2013-07-05 14:57:45 (EDT)
commit9a01192a99c0cc500e7579884693832cfbc6ecd6 (patch)
tree8e19cac2fc1538439d4b32e3164343228fb03cf0
parent8c8c716e11480748535aa9b88d992bbc72d7d87f (diff)
downloadwebtools.dali-9a01192a99c0cc500e7579884693832cfbc6ecd6.zip
webtools.dali-9a01192a99c0cc500e7579884693832cfbc6ecd6.tar.gz
webtools.dali-9a01192a99c0cc500e7579884693832cfbc6ecd6.tar.bz2
315480 - add support for ORM XML in Target Entity links in UI.
Signed-off-by: Neil Hauge <neil.hauge@oracle.com> Signed-off-by: Nan Li <nan.n.li@oracle.com>
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityClassChooser.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityClassChooser.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityClassChooser.java
index c6e05a2..105fb64 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityClassChooser.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityClassChooser.java
@@ -9,7 +9,11 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.details;
+import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.common.core.internal.utility.JavaProjectTools;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.ui.JptCommonUiMessages;
import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserComboPane;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
@@ -18,11 +22,19 @@ import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueMode
import org.eclipse.jpt.common.utility.model.value.ListValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
+import org.eclipse.jpt.jpa.ui.selection.JpaSelectionManager;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.ide.IDE;
/**
* target entity hyperlink label, combo and browse button
@@ -132,4 +144,53 @@ public class TargetEntityClassChooser
}
return JptCommonUiMessages.DEFAULT_EMPTY;
}
+
+ /*
+ * Duplicate persistent type case is not handled so the opened mapping file could be
+ * any one of the existent mapping files that has the persistent type.
+ * User needs to solve the duplicate problem to open the mapping file he wants to open.
+ */
+ @Override
+ protected void hyperLinkSelected() {
+ String className = this.getFullyQualifiedClassName();
+ if (className != null) {
+ PersistentType pType = this.getSubject().getPersistenceUnit().getPersistentType(className);
+ if (pType instanceof OrmPersistentType) {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IFile file = ((OrmPersistentType)pType).getParent().getParent().getXmlResource().getFile();
+ openInEditor(page, file);
+ setSelectionInEditor(page, pType);
+ } else {
+ IType type = JavaProjectTools.findType(this.getJavaProject(), className);
+ if (type != null) {
+ openInEditor(type);
+ } else {
+ createType();
+ }
+ }
+ }
+ }
+
+ /**
+ * Open the file in an editor of the active workbench page
+ * @param page
+ * @param file
+ */
+ private void openInEditor(IWorkbenchPage page, IFile file) {
+ try {
+ IDE.openEditor(page, file);
+ } catch (PartInitException ex) {
+ JptJpaUiPlugin.instance().logError(ex);
+ }
+ }
+ /**
+ * Set the selection to the persistent type in the editor
+ * @param page
+ * @param persistentType
+ */
+
+ private void setSelectionInEditor(IWorkbenchPage page, PersistentType persistentType) {
+ JpaSelectionManager selectionManager = PlatformTools.getAdapter(page, JpaSelectionManager.class);
+ selectionManager.setSelection(persistentType);
+ }
} \ No newline at end of file