Author: vyemialyanchyk
Date: 2008-10-29 08:54:18 -0400 (Wed, 29 Oct 2008)
New Revision: 11281
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
Log:
fix: menu disable with StructuredSelection
Modified:
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29
12:51:47 UTC (rev 11280)
+++
branches/jbosstools-3.0.0.Beta1/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-29
12:54:18 UTC (rev 11281)
@@ -24,6 +24,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
@@ -73,13 +74,6 @@
}
return actor;
}
-
- protected org.eclipse.jdt.core.dom.CompilationUnit getCompilationUnit(ICompilationUnit
source) {
- ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setSource(source);
- org.eclipse.jdt.core.dom.CompilationUnit result =
(org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
- return result;
- }
public void clearSelectionCU() {
selectionCU.clear();
@@ -87,6 +81,15 @@
public void addCompilationUnit(ICompilationUnit cu) {
if (cu != null) {
+ IType[] types = null;
+ try {
+ types = cu.getTypes();
+ } catch (JavaModelException e) {
+ // just ignore it
+ }
+ if (types != null) {
+
+ }
selectionCU.add(cu);
}
}
@@ -96,6 +99,12 @@
updateSelectedItems(selection);
selection = null;
}
+ else {
+ if (selectionCU.size() == 0) {
+ updateOpen();
+ return;
+ }
+ }
if (selectionCU.size() == 0) {
processor.modify(null, new HashMap<String, EntityInfo>(), true);
return;
@@ -155,7 +164,8 @@
synchronized public int getSelectedSourceSize() {
int res = 0;
if (selection == null) {
- res = selectionCU.size();
+ //res = selectionCU.size();
+ res = 1;
}
else if (selection instanceof TextSelection) {
res = 1;
@@ -316,12 +326,14 @@
}
synchronized public void setSelection(ISelection selection) {
- if ((selection instanceof StructuredSelection) && selection.isEmpty()) {
- // just miss this selection
+ //System.out.println("Blah! " + selection); //$NON-NLS-1$
+ if (selection instanceof StructuredSelection) {
+ //System.out.println("This! " + this.selection); //$NON-NLS-1$
+ clearSelectionCU();
+ this.selection = null;
return;
}
this.selection = selection;
- //System.out.println("Blah! " + selection); //$NON-NLS-1$
}
}
Show replies by date