Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-23 09:31:37 -0500
committerMilos Kleint2010-12-23 09:31:37 -0500
commitb57d1935bc615ba9045ad6d06c0ac0e54470a922 (patch)
treec39a5fda72a9dbb54c52d151c67e73f055eb4bb6
parent893f50feeb3c762001e5e8bdd2e20ac29ba42e3b (diff)
downloadm2e-core-b57d1935bc615ba9045ad6d06c0ac0e54470a922.tar.gz
m2e-core-b57d1935bc615ba9045ad6d06c0ac0e54470a922.tar.xz
m2e-core-b57d1935bc615ba9045ad6d06c0ac0e54470a922.zip
MNGECLIPSE-2677 from markers on the pom file, select one with highest severity for display in the form header. also make sure we update the error on each switch to the page (and not only on the first one as done before)
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java102
1 files changed, 65 insertions, 37 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
index af917712..7cacb19c 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditorPage.java
@@ -173,49 +173,78 @@ public abstract class MavenPomEditorPage extends FormPage implements Adapter {
}
private void doLoadData(boolean active) {
- if(active && !dataLoaded) {
- dataLoaded = true;
+ try {
+ if(active && !dataLoaded) {
+ dataLoaded = true;
// new Job("Loading pom.xml") {
// protected IStatus run(IProgressMonitor monitor) {
- try {
- model = pomEditor.readProjectDocument();
- if(model != null) {
- if (getPartControl() != null) {
- getPartControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- updatingModel = true;
- try {
- loadData();
- updateParentAction();
- registerListeners();
- } catch(Throwable e) {
- MavenLogger.log("Error loading data", e); //$NON-NLS-1$
- } finally {
- updatingModel = false;
- }
- }
- });
+ model = pomEditor.readProjectDocument();
+ if(model != null) {
+ if(getPartControl() != null) {
+ getPartControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updatingModel = true;
+ try {
+ loadData();
+ updateParentAction();
+ registerListeners();
+ } catch(Throwable e) {
+ MavenLogger.log("Error loading data", e); //$NON-NLS-1$
+ } finally {
+ updatingModel = false;
+ }
}
+ });
+ }
+ }
+
+ }
+
+ //error markers have to be always updated..
+ IFile pomFile = pomEditor.getPomFile();
+ if(pomFile != null) {
+ IMarker[] markers = pomFile.findMarkers(IMavenConstants.MARKER_ID, true, IResource.DEPTH_ZERO);
+ IMarker max = null;
+ int maxSev = -1;
+ if(markers != null) {
+ for(IMarker mark : markers) {
+ int sev = mark.getAttribute(IMarker.SEVERITY, -1);
+ if(sev > maxSev) {
+ max = mark;
+ maxSev = sev;
}
-
- IFile pomFile = pomEditor.getPomFile();
- if(pomFile!=null) {
- IMarker[] markers = pomFile.findMarkers(IMavenConstants.MARKER_ID, true, IResource.DEPTH_ZERO);
- if(markers != null && markers.length > 0) {
- int severity = markers[0].getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO) == IMarker.SEVERITY_WARNING ? IMessageProvider.WARNING : IMessageProvider.ERROR;
- setErrorMessage(markers[0].getAttribute(IMarker.MESSAGE, Messages.MavenPomEditorPage_error_unknown), severity);
- } else {
- setErrorMessage(null, IMessageProvider.NONE);
- }
+ }
+ }
+ if(max != null) {
+ int severity;
+ switch(max.getAttribute(IMarker.SEVERITY, -1)) {
+ case IMarker.SEVERITY_ERROR: {
+ severity = IMessageProvider.ERROR;
+ break;
+ }
+ case IMarker.SEVERITY_WARNING: {
+ severity = IMessageProvider.WARNING;
+ break;
+ }
+ case IMarker.SEVERITY_INFO: {
+ severity = IMessageProvider.INFORMATION;
+ break;
+ }
+ default: {
+ severity = IMessageProvider.NONE;
}
-
- } catch(final CoreException ex) {
- MavenLogger.log(ex);
- final String msg = ex.getMessage();
- setErrorMessage(msg, IMessageProvider.ERROR);
}
-
+ setErrorMessage(max.getAttribute(IMarker.MESSAGE, Messages.MavenPomEditorPage_error_unknown), severity);
+ } else {
+ setErrorMessage(null, IMessageProvider.NONE);
+ }
+ }
+ } catch(final CoreException ex) {
+ MavenLogger.log(ex);
+ final String msg = ex.getMessage();
+ setErrorMessage(msg, IMessageProvider.ERROR);
}
+
}
public void setErrorMessage(final String msg, final int severity) {
@@ -223,7 +252,6 @@ public abstract class MavenPomEditorPage extends FormPage implements Adapter {
getPartControl().getDisplay().asyncExec(new Runnable() {
public void run() {
if (!getManagedForm().getForm().isDisposed()) {
-
FormUtils.setMessage(getManagedForm().getForm(), msg, severity);
}
}

Back to the top