Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-05-21 22:40:49 -0400
committerIgor Fedorenko2011-05-24 17:22:06 -0400
commit07ade30212d3d27c405a28d1d24dad850c9dbd12 (patch)
tree462109e0968c2927691e8f0c97022d4ad3a00df4
parentbe241dfb99b18f07e7209cb048edf40e149c63ff (diff)
downloadm2e-core-07ade30212d3d27c405a28d1d24dad850c9dbd12.tar.gz
m2e-core-07ade30212d3d27c405a28d1d24dad850c9dbd12.tar.xz
m2e-core-07ade30212d3d27c405a28d1d24dad850c9dbd12.zip
346794 maven launch actions enabled for any selection
Maven launch shortcuts were configured to enable for any IAdaptable for which org.eclipse.m2e.launchable property evaluated to true. Although not obvious from <launchShortcuts/> extension point description, properties defined in non-active bundles are simply ignored. This effectively meant that Maven launch shortcuts were enabled for any single IAdaptable selection if m2e.core.ui bundle was not enabled. Reworked configuration to enable Maven launch shortcuts for any single selection of IFile with name=pom.xml or IProject with Maven nature enabled. This slightly different from original logic, but does not use property testers defined by m2e bundles and should behave correctly regardless of m2e bundle activation state. Also removed org.eclipse.m2e.launchable property tester implementation. It is not used any more and there is no way to use it safely in the future. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/plugin.xml4
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java28
-rw-r--r--org.eclipse.m2e.launching/plugin.xml120
3 files changed, 72 insertions, 80 deletions
diff --git a/org.eclipse.m2e.core.ui/plugin.xml b/org.eclipse.m2e.core.ui/plugin.xml
index 06f215a1..82708f87 100644
--- a/org.eclipse.m2e.core.ui/plugin.xml
+++ b/org.eclipse.m2e.core.ui/plugin.xml
@@ -355,10 +355,10 @@
id="org.eclipse.m2e.core.MavenPropertyTester"
class="org.eclipse.m2e.core.ui.internal.actions.MavenPropertyTester"
namespace="org.eclipse.m2e"
- properties="launchable,workspaceResulutionEnable,hasArtifactKey,hasProjectArtifactKey"
+ properties="workspaceResulutionEnable,hasArtifactKey,hasProjectArtifactKey"
type="org.eclipse.core.runtime.IAdaptable"/>
<propertyTester
- id="org.eclipse.m2e.core.MavenPropertyTester"
+ id="org.eclipse.m2e.core.MavenPropertyTester2"
class="org.eclipse.m2e.core.ui.internal.actions.MavenPropertyTester"
namespace="org.eclipse.m2e"
properties="isTransitiveDependencyTreeNode,isDirectDependencyTreeNode"
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java
index 93c9d347..0f69603f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java
@@ -12,18 +12,17 @@
package org.eclipse.m2e.core.ui.internal.actions;
import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.sonatype.aether.graph.DependencyNode;
+
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
-import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.project.ResolverConfiguration;
-import org.sonatype.aether.graph.DependencyNode;
/**
* Helper IPropertyTester implementation to check if receiver can be launched with Maven.
@@ -39,28 +38,8 @@ public class MavenPropertyTester extends PropertyTester {
private static final String HAS_PROJECT_ARTIFACT_KEY = "hasProjectArtifactKey"; //$NON-NLS-1$
private static final String HAS_ARTIFACT_KEY = "hasArtifactKey"; //$NON-NLS-1$
private static final String WORKSPACE_RESULUTION_ENABLE = "workspaceResulutionEnable"; //$NON-NLS-1$
- private static final String LAUNCHABLE = "launchable"; //$NON-NLS-1$
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (LAUNCHABLE.equals(property)) {
- IAdaptable adaptable = (IAdaptable) receiver;
-
- IProject projectAdapter = (IProject) adaptable.getAdapter(IProject.class);
- if(projectAdapter!=null) {
- return projectAdapter.getFile(IMavenConstants.POM_FILE_NAME).exists();
- }
-
- IFolder folderAdapter = (IFolder) adaptable.getAdapter(IFolder.class);
- if(folderAdapter!=null) {
- return folderAdapter.getFile(IMavenConstants.POM_FILE_NAME).exists();
- }
-
- IFile fileAdapter = (IFile) adaptable.getAdapter(IFile.class);
- if(fileAdapter!=null) {
- return fileAdapter.exists() && IMavenConstants.POM_FILE_NAME.equals(fileAdapter.getName());
- }
- return false;
- }
if (WORKSPACE_RESULUTION_ENABLE.equals(property)) {
boolean enableWorkspaceResolution = true;
IAdaptable adaptable = (IAdaptable) receiver;
@@ -81,6 +60,7 @@ public class MavenPropertyTester extends PropertyTester {
ArtifactKey ak = SelectionUtil.getType(receiver, ArtifactKey.class);
return ak != null;
}
+
if (HAS_PROJECT_ARTIFACT_KEY.equals(property)) {
ArtifactKey key = SelectionUtil.getType(receiver, ArtifactKey.class);
if(key != null) {
diff --git a/org.eclipse.m2e.launching/plugin.xml b/org.eclipse.m2e.launching/plugin.xml
index 68cbb39a..a75d4e88 100644
--- a/org.eclipse.m2e.launching/plugin.xml
+++ b/org.eclipse.m2e.launching/plugin.xml
@@ -52,15 +52,17 @@
<contextLabel label="%m2.popup.pomFile.label" mode="run"/>
<contextLabel label="%m2.popup.pomFile.label" mode="debug"/>
<enablement>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <and>
- <test property="org.eclipse.m2e.launchable"/>
- <adapt type="org.eclipse.core.runtime.IAdaptable"/>
- </and>
- </iterate>
- </with>
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFile">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ </or>
+ </iterate>
</enablement>
</contextualLaunch>
</shortcut>
@@ -73,15 +75,17 @@
<contextLabel label="%m2.popup.pomFileWithDialog.label" mode="run"/>
<contextLabel label="%m2.popup.pomFileWithDialog.label" mode="debug"/>
<enablement>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <and>
- <test property="org.eclipse.m2e.launchable"/>
- <adapt type="org.eclipse.core.runtime.IAdaptable"/>
- </and>
- </iterate>
- </with>
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFile">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ </or>
+ </iterate>
</enablement>
</contextualLaunch>
</shortcut>
@@ -94,15 +98,17 @@
<contextLabel label="%m2.popup.lifecycle.install" mode="run"/>
<contextLabel label="%m2.popup.lifecycle.install" mode="debug"/>
<enablement>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <and>
- <test property="org.eclipse.m2e.launchable"/>
- <adapt type="org.eclipse.core.runtime.IAdaptable"/>
- </and>
- </iterate>
- </with>
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFile">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ </or>
+ </iterate>
</enablement>
</contextualLaunch>
</shortcut>
@@ -115,15 +121,17 @@
<contextLabel label="%m2.popup.lifecycle.test" mode="run"/>
<contextLabel label="%m2.popup.lifecycle.test" mode="debug"/>
<enablement>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <and>
- <test property="org.eclipse.m2e.launchable"/>
- <adapt type="org.eclipse.core.runtime.IAdaptable"/>
- </and>
- </iterate>
- </with>
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFile">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ </or>
+ </iterate>
</enablement>
</contextualLaunch>
</shortcut>
@@ -136,15 +144,17 @@
<contextLabel label="%m2.popup.lifecycle.generate-sources" mode="run"/>
<contextLabel label="%m2.popup.lifecycle.generate-sources" mode="debug"/>
<enablement>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <and>
- <test property="org.eclipse.m2e.launchable"/>
- <adapt type="org.eclipse.core.runtime.IAdaptable"/>
- </and>
- </iterate>
- </with>
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFile">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ </or>
+ </iterate>
</enablement>
</contextualLaunch>
</shortcut>
@@ -157,15 +167,17 @@
<contextLabel label="%m2.popup.lifecycle.clean" mode="run"/>
<contextLabel label="%m2.popup.lifecycle.clean" mode="debug"/>
<enablement>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <and>
- <test property="org.eclipse.m2e.launchable"/>
- <adapt type="org.eclipse.core.runtime.IAdaptable"/>
- </and>
- </iterate>
- </with>
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFile">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ </or>
+ </iterate>
</enablement>
</contextualLaunch>
</shortcut>

Back to the top