-
Notifications
You must be signed in to change notification settings - Fork 56
Some Eclipse Tips & Tricks
Ori Roth edited this page Apr 2, 2017
·
3 revisions
appendix - http://gnuarmeclipse.github.io/developer/eclipse/tips-tricks/
class ErrorMessageDialog implements Runnable {
public int retCode = 0;
@Override
public void run() {
String[] buttons = new String[] { "Retry", "Ignore", "Abort" };
MessageDialog dialog = new MessageDialog(shell,
"Read error", null, sourceUrl.toString() + "\n"
+ e.getMessage(), MessageDialog.ERROR,
buttons, 0);
retCode = dialog.open();
}
}
ErrorMessageDialog messageDialog = new ErrorMessageDialog();
Display.getDefault().syncExec(messageDialog);
if (messageDialog.retCode == 2) {
throw e; // Abort
} else if (messageDialog.retCode == 1) {
return false; // Ignore
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// Do something
}
});
URL url = Platform.getInstallLocation().getURL();
IPath path = new Path(url.getPath());
Bundle bundle = Platform.getBundle(bundleId);
URL url = FileLocator.find(bundle, new Path(relativePath), null);
String location;
try {
location = FileLocator.resolve(url).getPath();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
public static void reportInfo(String message) {
try {
IMarker marker = ResourcesPlugin.getWorkspace().getRoot()
.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
marker.setAttribute(IMarker.LOCATION, "-");
} catch (CoreException e) {
System.out.println(message);
}
}