Author: vyemialyanchyk
Date: 2009-04-23 13:26:56 -0400 (Thu, 23 Apr 2009)
New Revision: 14875
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
Log:
JBIDE-4230
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-04-23
17:17:15 UTC (rev 14874)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-04-23
17:26:56 UTC (rev 14875)
@@ -148,6 +148,9 @@
public void run() {
// TODO: make action dependent on having a connected console configuration!
ISelection selection = viewer.getSelection();
+ if (selection == null || selection.isEmpty()) {
+ return;
+ }
Object firstElement = ( (IStructuredSelection)selection).getFirstElement();
if(firstElement instanceof ConsoleConfiguration) {
new EditConsoleConfiguration((ConsoleConfiguration)firstElement).run();
@@ -161,7 +164,8 @@
}
}
} else if (selection instanceof TreeSelection){
- TreePath path = ((TreeSelection)selection).getPaths()[0];
+ TreePath[] paths = ((TreeSelection)selection).getPaths();
+ TreePath path = paths[0];
Object last = path.getLastSegment();
ConsoleConfiguration consoleConfiguration =
(ConsoleConfiguration)(path.getSegment(0));
if (last instanceof PersistentClass || last.getClass() == Property.class){
@@ -170,7 +174,17 @@
} catch (Exception e) {
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping
file.", e); //$NON-NLS-1$
}
- }
+ }
+ else {
+ for (int i = 0; i < paths.length; i++) {
+ if (viewer.getExpandedState(paths[i])) {
+ viewer.collapseToLevel(paths[i], 1);
+ }
+ else {
+ viewer.expandToLevel(paths[i], 1);
+ }
+ }
+ }
}
}
};
Show replies by date