Author: dgeraskov
Date: 2008-01-22 09:25:15 -0500 (Tue, 22 Jan 2008)
New Revision: 5867
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenQueryEditorAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1665
select ConsoleConfiguration in combobox
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenQueryEditorAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenQueryEditorAction.java 2008-01-22
12:58:28 UTC (rev 5866)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenQueryEditorAction.java 2008-01-22
14:25:15 UTC (rev 5867)
@@ -1,8 +1,14 @@
package org.hibernate.eclipse.console.actions;
+import java.io.FileNotFoundException;
import java.util.Iterator;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.SelectionListenerAction;
import org.hibernate.HibernateException;
import org.hibernate.console.ConsoleConfiguration;
@@ -20,17 +26,19 @@
protected void doRun() {
boolean showed = false;
- for (Iterator i = getSelectedNonResources().iterator(); i.hasNext();) {
- try {
- Object node = i.next();
- if(node instanceof ConsoleConfiguration) {
- final ConsoleConfiguration config = (ConsoleConfiguration) node;
- openQueryEditor( config, "" );
- showed = true;
- }
- } catch(HibernateException he) {
- HibernateConsolePlugin.getDefault().showError(null, "Exception while trying to
open HQL editor", he);
- }
+ IStructuredSelection sel = getStructuredSelection();
+ if (sel instanceof TreeSelection){
+ TreePath[] paths = ((TreeSelection)sel).getPaths();
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ ConsoleConfiguration config = (ConsoleConfiguration) path.getSegment(0);
+ try {
+ openQueryEditor( config, "" );
+ } catch(HibernateException he) {
+ HibernateConsolePlugin.getDefault().showError(null, "Exception while trying to
open HQL editor", he);
+ }
+ showed = true;
+ }
}
if(!showed) {