Author: vyemialyanchyk
Date: 2009-12-09 11:42:20 -0500 (Wed, 09 Dec 2009)
New Revision: 19158
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5431 - fixed
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF 2009-12-09
15:04:45 UTC (rev 19157)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF 2009-12-09
16:42:20 UTC (rev 19158)
@@ -8,6 +8,7 @@
Bundle-Localization: plugin
Require-Bundle: org.eclipse.jdt.ui,
org.eclipse.jdt.core,
+ org.eclipse.core.expressions,
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.ui,
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-12-09
15:04:45 UTC (rev 19157)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-12-09
16:42:20 UTC (rev 19158)
@@ -66,21 +66,36 @@
<command commandId="org.hibernate.eclipse.jdt.ui.run_jpaaction"
id="org.hibernate.eclipse.jdt.ui.run_jpaaction"
style="push">
<visibleWhen checkEnabled="false">
- <not>
- <reference
definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference>
- </not>
+ <or>
+ <with variable="activeEditorId">
+ <or>
+ <equals
value="org.eclipse.jdt.ui.CompilationUnitEditor" />
+ </or>
+ </with>
+ <with variable="selection">
+ <iterate ifEmpty="false">
+ <or>
+ <instanceof
value="org.eclipse.jdt.core.ICompilationUnit"/>
+ <instanceof
value="org.eclipse.jdt.internal.core.JavaProject"/>
+ <instanceof
value="org.eclipse.jdt.internal.core.PackageFragment"/>
+ <and>
+ <instanceof
value="org.eclipse.jdt.internal.core.JavaElement"/>
+ <not>
+ <or>
+ <instanceof
value="org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot"/>
+ <instanceof
value="org.eclipse.jdt.internal.core.JarPackageFragmentRoot"/>
+ <instanceof
value="org.eclipse.jdt.internal.core.ClassFile"/>
+ <instanceof
value="org.eclipse.jdt.internal.core.ExternalJavaProject"/>
+ </or>
+ </not>
+ </and>
+ </or>
+ </iterate>
+ </with>
+ </or>
</visibleWhen>
- </command>
+ </command>
</menuContribution>
- <!-- next section will show Hibernate/JPA menu item in case of active XML
editor -->
- <!--<menuContribution
locationURI="menu:sourceMenuId?after=additions">
- <command commandId="org.hibernate.eclipse.jdt.ui.run_jpaaction"
- id="org.hibernate.eclipse.jdt.ui.run_jpaaction1"
style="push">
- <visibleWhen checkEnabled="false">
- <reference
definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference>
- </visibleWhen>
- </command>
- </menuContribution>-->
</extension>
<extension point="org.eclipse.ui.popupMenus">
<!-- java editor context menu -->
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2009-12-09
15:04:45 UTC (rev 19157)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2009-12-09
16:42:20 UTC (rev 19158)
@@ -10,9 +10,13 @@
******************************************************************************/
package org.hibernate.eclipse.jdt.ui.internal.jpa.actions;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
@@ -82,10 +86,28 @@
return false;
}
+ @SuppressWarnings("unchecked")
public void setEnabled(Object evaluationContext) {
- boolean enable = isCUSelected();
+ boolean enable = false;
actor.setSelection(null);
actor.clearSelectionCU();
+ if (!enable && evaluationContext instanceof EvaluationContext) {
+ EvaluationContext ec = (EvaluationContext)evaluationContext;
+ Object obj = ec.getDefaultVariable();
+ if (obj instanceof List) {
+ Iterator it = ((List)obj).iterator();
+ while (it.hasNext()) {
+ obj = it.next();
+ actor.processJavaElements(obj);
+ }
+ } else {
+ actor.processJavaElements(obj);
+ }
+ enable = actor.getSelectionCUSize() > 0;
+ }
+ if (!enable) {
+ enable = isCUSelected();
+ }
setBaseEnabled(enable);
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2009-12-09
15:04:45 UTC (rev 19157)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2009-12-09
16:42:20 UTC (rev 19158)
@@ -370,7 +370,7 @@
* Process object - java element to collect all it's children CompilationUnits
* @param obj
*/
- protected void processJavaElements(Object obj) {
+ public void processJavaElements(Object obj) {
if (obj instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit)obj;
addCompilationUnit(cu);
@@ -473,4 +473,8 @@
public void setSelectionCU(Set<ICompilationUnit> selectionCU) {
this.selectionCU = selectionCU;
}
+
+ public int getSelectionCUSize() {
+ return selectionCU.size();
+ }
}