Author: max.andersen(a)jboss.com
Date: 2008-02-01 21:34:37 -0500 (Fri, 01 Feb 2008)
New Revision: 6097
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java
Log:
Fix JBIDE-1722 by using JDT api to use java editor for types.
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java 2008-02-02
02:10:15 UTC (rev 6096)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java 2008-02-02
02:34:37 UTC (rev 6097)
@@ -19,6 +19,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
@@ -103,24 +104,19 @@
} else {
type = proj.findType(fullyQualifiedName);
}
- IResource resource = null;
- if (type != null) resource = type.getResource();
- IEditorPart editorPart = null;
- if (resource instanceof IFile){
- editorPart =
OpenFileActionUtils.openEditor(HibernateConsolePlugin.getDefault().getActiveWorkbenchWindow().getActivePage(),
(IFile) resource);
- if (editorPart instanceof JavaEditor) {
- IJavaElement jElement = null;
- if (selection instanceof Property){
- jElement = type.getField(((Property)selection).getName());
- } else {
- jElement = type;
- }
- JavaEditor jEditor = (JavaEditor) editorPart;
- selectionToEditor(jElement, jEditor);
- }
- }
-
+ IEditorPart editorPart = JavaUI.openInEditor(type);
+ if (editorPart instanceof JavaEditor) {
+ IJavaElement jElement = null;
+ if (selection instanceof Property){
+ jElement = type.getField(((Property)selection).getName());
+ } else {
+ jElement = type;
+ }
+ JavaEditor jEditor = (JavaEditor) editorPart;
+ selectionToEditor(jElement, jEditor);
+ }
+
if (editorPart == null) {
throw new FileNotFoundException("Source file for class '" +
fullyQualifiedName + "' not found.");
}
Show replies by date