Author: vyemialyanchyk
Date: 2009-05-27 06:53:38 -0400 (Wed, 27 May 2009)
New Revision: 15553
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
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/views/KnownConfigurationsView.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/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4363 - fix for - "Open Source File"
breaks when there are no project associated with a console configuration
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -64,7 +64,7 @@
TreePath path = paths[i];
ConsoleConfiguration consoleConfig = (ConsoleConfiguration)(path.getSegment(0));
try {
- run(path, consoleConfig);
+ run(consoleConfig, path);
} catch (JavaModelException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenMappingAction_cannot_find_mapping_file,
e);
} catch (PartInitException e) {
@@ -83,7 +83,8 @@
* @throws JavaModelException
* @throws FileNotFoundException
*/
- public static IEditorPart run(TreePath path, ConsoleConfiguration consoleConfig) throws
PartInitException, JavaModelException, FileNotFoundException {
+ public static IEditorPart run(ConsoleConfiguration consoleConfig, TreePath path)
+ throws PartInitException, JavaModelException, FileNotFoundException {
boolean isPropertySel = (path.getLastSegment().getClass() == Property.class);
if (isPropertySel) {
Property propertySel = (Property)path.getLastSegment();
@@ -92,21 +93,21 @@
|| (RootClass.class.isAssignableFrom(persClass.getClass())
&& persClass.getClass() != RootClass.class)) {
Property parentProp = (Property)path.getParentPath().getLastSegment();
- return run(propertySel, parentProp, consoleConfig);
+ return run(consoleConfig, propertySel, parentProp);
}
}
- return run(path.getLastSegment(), consoleConfig);
+ return run(consoleConfig, path.getLastSegment());
}
/**
- * @param selection
* @param consoleConfig
+ * @param selection
* @throws JavaModelException
* @throws PartInitException
* @throws PresistanceClassNotFoundException
* @throws FileNotFoundException
*/
- public static IEditorPart run(Object selection, ConsoleConfiguration consoleConfig)
throws PartInitException, JavaModelException, FileNotFoundException {
+ public static IEditorPart run(ConsoleConfiguration consoleConfig, Object selection)
throws PartInitException, JavaModelException, FileNotFoundException {
IEditorPart editorPart = null;
IFile file = null;
if (selection instanceof Property) {
@@ -140,9 +141,7 @@
if (rootClass != null){
if (OpenMappingUtils.hasConfigXMLMappingClassAnnotation(consoleConfig, rootClass)) {
String fullyQualifiedName = rootClass.getClassName();
- // TODO: get rid of this - JBIDE-4363
- IJavaProject proj = ProjectUtils.findJavaProject(consoleConfig);
- editorPart = OpenSourceAction.run(selection, proj, fullyQualifiedName);
+ editorPart = OpenSourceAction.run(consoleConfig, selection, fullyQualifiedName);
}
}
else {
@@ -154,15 +153,16 @@
}
/**
+ * @param consoleConfig
* @param compositeProperty
* @param parentProperty
- * @param consoleConfig
* @throws JavaModelException
* @throws PartInitException
* @throws FileNotFoundException
* @throws BadLocationException
*/
- public static IEditorPart run(Property compositeProperty, Property parentProperty,
ConsoleConfiguration consoleConfig) throws PartInitException, JavaModelException,
FileNotFoundException{
+ public static IEditorPart run(ConsoleConfiguration consoleConfig, Property
compositeProperty, Property parentProperty)
+ throws PartInitException, JavaModelException, FileNotFoundException {
PersistentClass rootClass = parentProperty.getPersistentClass();
IFile file = OpenMappingUtils.searchFileToOpen(consoleConfig, rootClass);
IEditorPart editorPart = null;
@@ -173,9 +173,7 @@
if (editorPart == null && parentProperty.isComposite()) {
if (OpenMappingUtils.hasConfigXMLMappingClassAnnotation(consoleConfig, rootClass)) {
String fullyQualifiedName
=((Component)parentProperty.getValue()).getComponentClassName();
- // TODO: get rid of this - JBIDE-4363
- IJavaProject proj = ProjectUtils.findJavaProject(consoleConfig);
- editorPart = OpenSourceAction.run(compositeProperty, proj, fullyQualifiedName);
+ editorPart = OpenSourceAction.run(consoleConfig, compositeProperty,
fullyQualifiedName);
}
}
if (editorPart == null) {
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 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -51,56 +51,60 @@
public void run() {
IStructuredSelection sel = getStructuredSelection();
- if (sel instanceof TreeSelection){
- for (int i = 0; i < ((TreeSelection)sel).getPaths().length; i++) {
- TreePath path = ((TreeSelection)sel).getPaths()[i];
- Object lastSegment = path.getLastSegment();
- PersistentClass persClass = getPersistentClass(lastSegment);
- ConsoleConfiguration consoleConfiguration =
(ConsoleConfiguration)(path.getSegment(0));
- IJavaProject proj = ProjectUtils.findJavaProject(consoleConfiguration);
+ if (!(sel instanceof TreeSelection)) {
+ return;
+ }
+ TreePath[] paths = ((TreeSelection)sel).getPaths();
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ Object lastSegment = path.getLastSegment();
+ PersistentClass persClass = getPersistentClass(lastSegment);
+ ConsoleConfiguration consoleConfig = (ConsoleConfiguration)(path.getSegment(0));
- String fullyQualifiedName = null;
- if (lastSegment instanceof Property){
- Object prevSegment = path.getParentPath().getLastSegment();
- if (prevSegment instanceof Property
- && ((Property)prevSegment).isComposite()){
- fullyQualifiedName =((Component)((Property)
prevSegment).getValue()).getComponentClassName();
- }
+ String fullyQualifiedName = null;
+ if (lastSegment instanceof Property){
+ Object prevSegment = path.getParentPath().getLastSegment();
+ if (prevSegment instanceof Property
+ && ((Property)prevSegment).isComposite()){
+ fullyQualifiedName =((Component)((Property)
prevSegment).getValue()).getComponentClassName();
}
- if (fullyQualifiedName == null && persClass != null){
- fullyQualifiedName = persClass.getClassName();
- }
+ }
+ if (fullyQualifiedName == null && persClass != null){
+ fullyQualifiedName = persClass.getClassName();
+ }
- try {
- run(lastSegment, proj, fullyQualifiedName);
- } catch (JavaModelException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file,
e);
- } catch (PartInitException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_open_source_file,
e);
- } catch (FileNotFoundException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file,
e);
- }
+ try {
+ run(consoleConfig, lastSegment, fullyQualifiedName);
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file,
e);
+ } catch (PartInitException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_open_source_file,
e);
+ } catch (FileNotFoundException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file,
e);
}
}
}
/**
+ * @param consoleConfig
* @param selection
- * @param proj
* @param fullyQualifiedName
* @throws JavaModelException
* @throws PartInitException
* @throws FileNotFoundException
*/
- public static IEditorPart run(Object selection, IJavaProject proj,
+ public static IEditorPart run(ConsoleConfiguration consoleConfig, Object selection,
String fullyQualifiedName) throws JavaModelException, PartInitException,
FileNotFoundException {
if (fullyQualifiedName == null) return null;
+ IJavaProject[] projs = ProjectUtils.findJavaProjects(consoleConfig);
String remainder = null;
IType type = null;
if (fullyQualifiedName.indexOf("$") > 0) { //$NON-NLS-1$
remainder = fullyQualifiedName.substring(fullyQualifiedName.indexOf("$") +
1); //$NON-NLS-1$
fullyQualifiedName = fullyQualifiedName.substring(0,
fullyQualifiedName.indexOf("$")); //$NON-NLS-1$
- type = proj.findType(fullyQualifiedName);
+ for (int i = 0; i < projs.length && type == null; i++) {
+ type = projs[i].findType(fullyQualifiedName);
+ }
while ( remainder.indexOf("$") > 0 ){ //$NON-NLS-1$
String subtype = remainder.substring(0, fullyQualifiedName.indexOf("$"));
//$NON-NLS-1$
type = type.getType(subtype);
@@ -108,7 +112,9 @@
}
type = type.getType(remainder);
} else {
- type = proj.findType(fullyQualifiedName);
+ for (int i = 0; i < projs.length && type == null; i++) {
+ type = projs[i].findType(fullyQualifiedName);
+ }
}
IEditorPart editorPart = JavaUI.openInEditor(type);
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -183,10 +183,10 @@
TreePath[] paths = ((TreeSelection)selection).getPaths();
TreePath path = paths[0];
Object last = path.getLastSegment();
- ConsoleConfiguration consoleConfiguration =
(ConsoleConfiguration)(path.getSegment(0));
+ ConsoleConfiguration consoleConfig = (ConsoleConfiguration)(path.getSegment(0));
if (last instanceof PersistentClass || last.getClass() == Property.class){
try {
- OpenMappingAction.run(path, consoleConfiguration);
+ OpenMappingAction.run(consoleConfig, path);
} catch (PartInitException e) {
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping
file.", e); //$NON-NLS-1$
} catch (JavaModelException e) {
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 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -43,9 +43,7 @@
public void run() {
ObjectEditorInput objectEditorInput =
(ObjectEditorInput)((VisualEditor)getWorkbenchPart()).getEditorInput();
- ConsoleConfiguration consoleConfiguration = objectEditorInput.getConfiguration();
- //java.io.File configXMLFile =
consoleConfiguration.getPreferences().getConfigXMLFile();
- //IJavaProject proj = objectEditorInput.getJavaProject();
+ ConsoleConfiguration consoleConfig = objectEditorInput.getConfiguration();
VisualEditor part = (VisualEditor)getWorkbenchPart();
Set selectedElements = part.getSelectedElements();
@@ -58,7 +56,7 @@
Property compositSel = ((Property)selection);
Property parentProperty =
((SpecialRootClass)((Property)selection).getPersistentClass()).getProperty();
try {
- org.hibernate.eclipse.console.actions.OpenMappingAction.run(compositSel,
parentProperty, consoleConfiguration);
+ org.hibernate.eclipse.console.actions.OpenMappingAction.run(consoleConfig,
compositSel, parentProperty);
} catch (PartInitException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(UIVEditorMessages.OpenMappingAction_canot_find_or_open_mapping_file,
e);
} catch (JavaModelException e) {
@@ -72,7 +70,7 @@
selection = ((SpecialRootClass)selection).getProperty();
}
try {
- org.hibernate.eclipse.console.actions.OpenMappingAction.run(selection,
consoleConfiguration);
+ org.hibernate.eclipse.console.actions.OpenMappingAction.run(consoleConfig,
selection);
} catch (PartInitException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(UIVEditorMessages.OpenMappingAction_open_mapping_file,
e);
} 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 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -6,7 +6,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
@@ -35,8 +34,7 @@
public void run() {
ObjectEditorInput objectEditorInput =
(ObjectEditorInput)((VisualEditor)getWorkbenchPart()).getEditorInput();
- ConsoleConfiguration consoleConfiguration = objectEditorInput.getConfiguration();
- IJavaProject proj = objectEditorInput.getJavaProject();
+ ConsoleConfiguration consoleConfig = objectEditorInput.getConfiguration();
VisualEditor part = (VisualEditor)getWorkbenchPart();
Set selectedElements = part.getSelectedElements();
@@ -58,7 +56,7 @@
fullyQualifiedName = fullyQualifiedName.substring(0,
fullyQualifiedName.indexOf("$"));
}*/
try {
- new org.hibernate.eclipse.console.actions.OpenSourceAction().run(selection, proj,
fullyQualifiedName);
+ new org.hibernate.eclipse.console.actions.OpenSourceAction().run(consoleConfig,
selection, fullyQualifiedName);
} catch (PartInitException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(UIVEditorMessages.OpenSourceAction_canot_open_source_file,
e);
} catch (JavaModelException e) {
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -85,7 +85,7 @@
IEditorPart editor = null;
Throwable ex = null;
try {
- editor = OpenMappingAction.run(compositeProperty, parentProperty, consCFG);
+ editor = OpenMappingAction.run(consCFG, compositeProperty, parentProperty);
boolean highlighted = ProjectUtil.checkHighlighting(editor);
if (!highlighted) {
String out =
NLS.bind(ConsoleTestMessages.OpenMappingFileTest_highlighted_region_for_property_is_empty_package,
@@ -118,7 +118,7 @@
IEditorPart editor = null;
Throwable ex = null;
try {
- editor = OpenMappingAction.run(selection, consCFG);
+ editor = OpenMappingAction.run(consCFG, selection);
boolean highlighted = ProjectUtil.checkHighlighting(editor);
if (!highlighted) {
String out =
NLS.bind(ConsoleTestMessages.OpenMappingFileTest_highlighted_region_for_is_empty_package,
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java 2009-05-27
10:23:40 UTC (rev 15552)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java 2009-05-27
10:53:38 UTC (rev 15553)
@@ -91,8 +91,7 @@
IEditorPart editor = null;
Throwable ex = null;
try {
- editor = OpenSourceAction.run(selection,
MappingTestProject.getTestProject().getIJavaProject(),
- fullyQualifiedName);
+ editor = OpenSourceAction.run(consCFG, selection, fullyQualifiedName);
boolean highlighted = ProjectUtil.checkHighlighting(editor);
if (!highlighted) {
String out =
NLS.bind(ConsoleTestMessages.OpenSourceFileTest_highlighted_region_for_is_empty,
selection);