Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-02-09 04:22:12 -0500
committerMilos Kleint2011-02-09 04:24:51 -0500
commit669341e14247b627a0d39628723f3b6a1123ee71 (patch)
tree91a2432012e4c9c6891e86752ac34b216b8df282 /org.eclipse.m2e.discovery/src
parent681d24add5d563c8e8bdf99748177af91e2f4ba2 (diff)
downloadm2e-core-669341e14247b627a0d39628723f3b6a1123ee71.tar.gz
m2e-core-669341e14247b627a0d39628723f3b6a1123ee71.tar.xz
m2e-core-669341e14247b627a0d39628723f3b6a1123ee71.zip
335299, 335490 have a more prominent place for the discover quick fix proposal, show only once on one line in editor and when invoked, take all markers in the same file into consideration
Diffstat (limited to 'org.eclipse.m2e.discovery/src')
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java22
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java17
2 files changed, 33 insertions, 6 deletions
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
index 5c3b5c7b..6415115b 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
@@ -18,25 +18,37 @@ import java.util.List;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.core.MavenLogger;
import org.eclipse.m2e.internal.discovery.MavenDiscovery;
import org.eclipse.m2e.internal.discovery.MavenDiscoveryIcons;
import org.eclipse.m2e.internal.discovery.Messages;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
+//IMPORANT: if you decide to rename the class please correct code in PomQuickAssistProcessor as well..
class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
- private IMarker marker;
-
- public DiscoveryWizardProposal(IMarker marker) {
- this.marker = marker;
+ public DiscoveryWizardProposal() {
}
@SuppressWarnings("unchecked")
public void run(IMarker marker) {
+ //by default we want save people some time by resolving discovery issues in one project/file in one shot..
+ try {
+ IMarker[] fileMarkers = marker.getResource().findMarkers(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID,
+ true, IResource.DEPTH_INFINITE);
+ run(fileMarkers, new NullProgressMonitor());
+ return;
+ } catch(CoreException e) {
+ //doesn't matter, as a fallback run the one marker variant only
+ }
+
String type = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
if(IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING.equals(type)) {
MavenDiscovery.launchWizard(Collections.singleton(getPackageType(marker)), Collections.EMPTY_LIST,
@@ -117,7 +129,7 @@ class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
public IMarker[] findOtherMarkers(IMarker[] markers) {
List<IMarker> handled = new ArrayList<IMarker>();
for(IMarker marker : markers) {
- if(marker != this.marker && MavenDiscoveryMarkerResolutionGenerator.canResolve(marker)) {
+ if(MavenDiscoveryMarkerResolutionGenerator.canResolve(marker)) {
handled.add(marker);
}
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java
index 76633e0c..61420a76 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java
@@ -12,6 +12,8 @@
package org.eclipse.m2e.internal.discovery.markers;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;
@@ -20,13 +22,26 @@ import org.eclipse.ui.IMarkerResolutionGenerator2;
public class MavenDiscoveryMarkerResolutionGenerator implements IMarkerResolutionGenerator, IMarkerResolutionGenerator2 {
+ private static QualifiedName QUALIFIED = new QualifiedName("org.eclipse.m2e.discovery", "discoveryResolution");
+
public boolean hasResolutions(IMarker marker) {
return canResolve(marker);
}
public IMarkerResolution[] getResolutions(IMarker marker) {
if(canResolve(marker)) {
- return new IMarkerResolution[] {new DiscoveryWizardProposal(marker)};
+ try {
+ //for each file have just one instance of the discover proposal array.
+ //important for 335299
+ IMarkerResolution[] cached = (IMarkerResolution[]) marker.getResource().getSessionProperty(QUALIFIED);
+ if (cached == null) {
+ cached = new IMarkerResolution[] {new DiscoveryWizardProposal()};
+ marker.getResource().setSessionProperty(QUALIFIED, cached);
+ }
+ return cached;
+ } catch(CoreException e) {
+ return new IMarkerResolution[] {new DiscoveryWizardProposal()};
+ }
}
return new IMarkerResolution[0];
}

Back to the top