Skip to content
Snippets Groups Projects
Commit 04b2766e authored by Jens Bendisposto's avatar Jens Bendisposto
Browse files

distinguish between warnings and errors.

parent 68c83fe1
Branches
No related tags found
No related merge requests found
...@@ -78,7 +78,8 @@ public final class Logger { ...@@ -78,7 +78,8 @@ public final class Logger {
/** /**
* Check a property. The method notifies the user and throws an exception if * Check a property. The method notifies the user and throws an exception if
* the assertion fails. <br> * 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> * != null); } <br>
* {@code Logger.assertProB(this.getClass(),"x should not be null", x != null); } * {@code Logger.assertProB(this.getClass(),"x should not be null", x != null); }
* <br> * <br>
...@@ -112,7 +113,8 @@ public final class Logger { ...@@ -112,7 +113,8 @@ public final class Logger {
/** /**
* Failed assertion. The method notifies the user and throws an exception. <br> * 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; * "Called open on nonexisting file " + file;
* Logger.assertProB(EditorPlugin.class, message); } * Logger.assertProB(EditorPlugin.class, message); }
* *
...@@ -149,4 +151,8 @@ public final class Logger { ...@@ -149,4 +151,8 @@ public final class Logger {
private static void log(final IStatus status) { private static void log(final IStatus status) {
Activator.getDefault().getLog().log(status); Activator.getDefault().getLog().log(status);
} }
public static void notifyUserAboutWarningWithoutBugreport(String string) {
log(IStatus.WARNING, NOBUGREPORT, string, null);
}
} }
...@@ -70,15 +70,22 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { ...@@ -70,15 +70,22 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler {
final IEventBRoot rootElement = getRootElement(); final IEventBRoot rootElement = getRootElement();
final IFile resource = extractResource(rootElement); final IFile resource = extractResource(rootElement);
List<String> errors = checkErrorMarkers(resource); ArrayList<String> errors = new ArrayList<String>();
boolean realError = checkErrorMarkers(resource, errors);
if (!errors.isEmpty()) { 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); StringBuffer stringBuffer = new StringBuffer(message);
for (String string : errors) { for (String string : errors) {
stringBuffer.append(string); stringBuffer.append(string);
stringBuffer.append('\n'); stringBuffer.append('\n');
} }
if (realError)
Logger.notifyUserWithoutBugreport(stringBuffer.toString()); Logger.notifyUserWithoutBugreport(stringBuffer.toString());
else
Logger.notifyUserAboutWarningWithoutBugreport(stringBuffer
.toString());
} }
; ;
...@@ -99,8 +106,8 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { ...@@ -99,8 +106,8 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler {
return null; return null;
} }
private List<String> checkErrorMarkers(final IFile resource) { private boolean checkErrorMarkers(final IFile resource, List<String> errors) {
List<String> errors = new ArrayList<String>(); boolean result = false;
IProject project = resource.getProject(); IProject project = resource.getProject();
try { try {
IMarker[] markers = project.findMarkers( IMarker[] markers = project.findMarkers(
...@@ -111,12 +118,13 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { ...@@ -111,12 +118,13 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler {
+ ": " + ": "
+ iMarker + iMarker
.getAttribute(IMarker.MESSAGE, "unknown Error")); .getAttribute(IMarker.MESSAGE, "unknown Error"));
result = result
|| (Integer) iMarker.getAttribute(IMarker.SEVERITY) == IMarker.SEVERITY_ERROR;
} }
} catch (CoreException e1) { } catch (CoreException e1) {
} }
return result;
return errors;
} }
private IEventBRoot getRootElement() { private IEventBRoot getRootElement() {
......
...@@ -30,12 +30,13 @@ public final class ProBLogListener implements ILogListener { ...@@ -30,12 +30,13 @@ public final class ProBLogListener implements ILogListener {
final boolean bugreport = false; // ;code == Logger.BUGREPORT; final boolean bugreport = false; // ;code == Logger.BUGREPORT;
display.asyncExec(new Runnable() { display.asyncExec(new Runnable() {
public void run() { public void run() {
String title = (status.getSeverity() == IStatus.ERROR) ? "An Error occured"
: "Warning";
// Notice: ErrorTICKETDialog to provide Bugreport-Button // Notice: ErrorTICKETDialog to provide Bugreport-Button
ErrorTicketDialog.openError(display.getActiveShell(), ErrorTicketDialog.openError(display.getActiveShell(),
"Error", "An error occured.", status, bugreport); "ProB Problem", title, status, bugreport);
} }
} });
);
} }
display.asyncExec(new Runnable() { display.asyncExec(new Runnable() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment