diff --git a/de.prob.core/src/de/prob/logging/Logger.java b/de.prob.core/src/de/prob/logging/Logger.java index 8780aa3023a0cd5596b3b27bcbaf5dc30151347c..678c5ddce1eba6f6d1eb83772c35177e8e8b3258 100644 --- a/de.prob.core/src/de/prob/logging/Logger.java +++ b/de.prob.core/src/de/prob/logging/Logger.java @@ -78,7 +78,8 @@ public final class Logger { /** * Check a property. The method notifies the user and throws an exception if * the assertion fails. <br> - * <b>Examples:</b><br>{@code Logger.assertProB(this.getClass(),"x != null", x + * <b>Examples:</b><br> + * {@code Logger.assertProB(this.getClass(),"x != null", x * != null); } <br> * {@code Logger.assertProB(this.getClass(),"x should not be null", x != null); } * <br> @@ -112,7 +113,8 @@ public final class Logger { /** * Failed assertion. The method notifies the user and throws an exception. <br> - * <b>Examples:</b><br>{@code if (!file.exists()) String message = + * <b>Examples:</b><br> + * {@code if (!file.exists()) String message = * "Called open on nonexisting file " + file; * Logger.assertProB(EditorPlugin.class, message); } * @@ -149,4 +151,8 @@ public final class Logger { private static void log(final IStatus status) { Activator.getDefault().getLog().log(status); } + + public static void notifyUserAboutWarningWithoutBugreport(String string) { + log(IStatus.WARNING, NOBUGREPORT, string, null); + } } diff --git a/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java b/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java index 0a33dd17302d3720d1e2da14d1872a4d036ee57e..bad71c487cf3bcc693af280eae6889e452261296 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java +++ b/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java @@ -70,15 +70,22 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { final IEventBRoot rootElement = getRootElement(); final IFile resource = extractResource(rootElement); - List<String> errors = checkErrorMarkers(resource); + ArrayList<String> errors = new ArrayList<String>(); + boolean realError = checkErrorMarkers(resource, errors); if (!errors.isEmpty()) { - String message = "A model/context in your project contains Errors or Warnings. This can lead to unexpected behavior (e.g. missing variables) when animating.\ns\nDetails:\n"; + String message = "Some components in your project contain " + + (realError ? "errors" : "warnings") + + ". This can lead to unexpected behavior (e.g. missing variables) when animating.\n\nDetails:\n"; StringBuffer stringBuffer = new StringBuffer(message); for (String string : errors) { stringBuffer.append(string); stringBuffer.append('\n'); } - Logger.notifyUserWithoutBugreport(stringBuffer.toString()); + if (realError) + Logger.notifyUserWithoutBugreport(stringBuffer.toString()); + else + Logger.notifyUserAboutWarningWithoutBugreport(stringBuffer + .toString()); } ; @@ -99,8 +106,8 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { return null; } - private List<String> checkErrorMarkers(final IFile resource) { - List<String> errors = new ArrayList<String>(); + private boolean checkErrorMarkers(final IFile resource, List<String> errors) { + boolean result = false; IProject project = resource.getProject(); try { IMarker[] markers = project.findMarkers( @@ -111,12 +118,13 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { + ": " + iMarker .getAttribute(IMarker.MESSAGE, "unknown Error")); + result = result + || (Integer) iMarker.getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR; } } catch (CoreException e1) { } - - return errors; + return result; } private IEventBRoot getRootElement() { diff --git a/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java b/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java index 41ba4f1f7cf648711e488fb4ce5753993982ecc5..c877085a3805a0b4dc296afb623a1d92db468a9d 100644 --- a/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java +++ b/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java @@ -27,15 +27,16 @@ public final class ProBLogListener implements ILogListener { final int code = status.getCode(); if (code == Logger.BUGREPORT || code == Logger.NOBUGREPORT) { - final boolean bugreport = false; //;code == Logger.BUGREPORT; + final boolean bugreport = false; // ;code == Logger.BUGREPORT; display.asyncExec(new Runnable() { public void run() { + String title = (status.getSeverity() == IStatus.ERROR) ? "An Error occured" + : "Warning"; // Notice: ErrorTICKETDialog to provide Bugreport-Button ErrorTicketDialog.openError(display.getActiveShell(), - "Error", "An error occured.", status, bugreport); + "ProB Problem", title, status, bugreport); } - } - ); + }); } display.asyncExec(new Runnable() {