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 /org.eclipse.m2e.core.ui
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>
Diffstat (limited to 'org.eclipse.m2e.core.ui')
-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
2 files changed, 6 insertions, 26 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) {

Back to the top