use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class GraphicsExample method checkAdvancedGraphics.
boolean checkAdvancedGraphics() {
if (advanceGraphicsInit)
return advanceGraphics;
advanceGraphicsInit = true;
Display display = parent.getDisplay();
try {
Path path = new Path(display);
path.dispose();
} catch (SWTException e) {
Shell shell = display.getActiveShell(), newShell = null;
if (shell == null)
shell = newShell = new Shell(display);
MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
// $NON-NLS-1$
dialog.setText(RESOURCE_BUNDLE.getString("Warning"));
// $NON-NLS-1$
dialog.setMessage(RESOURCE_BUNDLE.getString("LibNotFound"));
dialog.open();
if (newShell != null)
newShell.dispose();
return false;
}
return advanceGraphics = true;
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class ImageAnalyzer method showErrorDialog.
/*
* Open an error dialog displaying the specified information.
*/
void showErrorDialog(String operation, String filename, Throwable e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
String message = createMsg(bundle.getString("Error"), new String[] { operation, filename });
String errorMessage = "";
if (e != null) {
if (e instanceof SWTException) {
SWTException swte = (SWTException) e;
errorMessage = swte.getMessage();
if (swte.throwable != null) {
errorMessage += ":\n" + swte.throwable.toString();
}
} else if (e instanceof SWTError) {
SWTError swte = (SWTError) e;
errorMessage = swte.getMessage();
if (swte.throwable != null) {
errorMessage += ":\n" + swte.throwable.toString();
}
} else {
errorMessage = e.toString();
}
}
box.setMessage(message + errorMessage);
box.open();
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class ImageAnalyzer method menuPrint.
void menuPrint() {
if (image == null)
return;
try {
// Ask the user to specify the printer.
PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
if (printerData != null)
dialog.setPrinterData(printerData);
printerData = dialog.open();
if (printerData == null)
return;
Printer printer = new Printer(printerData);
Point screenDPI = display.getDPI();
Point printerDPI = printer.getDPI();
int scaleFactor = printerDPI.x / screenDPI.x;
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
if (printer.startJob(currentName)) {
if (printer.startPage()) {
GC gc = new GC(printer);
int transparentPixel = imageData.transparentPixel;
if (transparentPixel != -1 && !transparent) {
imageData.transparentPixel = -1;
}
Image printerImage = new Image(printer, imageData);
gc.drawImage(printerImage, 0, 0, imageData.width, imageData.height, -trim.x, -trim.y, scaleFactor * imageData.width, scaleFactor * imageData.height);
if (transparentPixel != -1 && !transparent) {
imageData.transparentPixel = transparentPixel;
}
printerImage.dispose();
gc.dispose();
printer.endPage();
}
printer.endJob();
}
printer.dispose();
} catch (SWTError e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
box.setMessage(bundle.getString("Printing_error") + e.getMessage());
box.open();
}
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class JavaViewer method displayError.
void displayError(String msg) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
box.setMessage(msg);
box.open();
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class StyledTextContentSpec method run.
public void run() {
if (contentClassName.isEmpty()) {
MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
// $NON-NLS-1$
box.setMessage("Content class must be specified as an execution argument.");
box.open();
return;
}
if (contentClass == null) {
try {
contentClass = Class.forName(contentClassName);
} catch (ClassNotFoundException e) {
MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
// $NON-NLS-1$
box.setMessage("Content class:\n" + contentClassName + "\nnot found");
box.open();
return;
}
}
try {
contentInstance = (StyledTextContent) contentClass.newInstance();
} catch (IllegalAccessException e) {
MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
// $NON-NLS-1$
box.setMessage("Unable to access content class:\n" + contentClassName);
box.open();
return;
} catch (InstantiationException e) {
MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
// $NON-NLS-1$
box.setMessage("Unable to instantiate content class:\n" + contentClassName);
box.open();
return;
}
Class<?> clazz;
clazz = this.getClass();
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
setUp();
currentMethod = methods[i];
failed = false;
try {
if (currentMethod.getName().startsWith("test_")) {
System.out.println();
System.out.println(currentMethod.getName() + "...");
currentMethod.invoke(this);
if (!failed) {
System.out.println("PASSED.");
} else {
System.out.println("FAILED");
}
}
} catch (InvocationTargetException ex) {
System.out.println("\t" + currentMethod.getName() + " ERROR ==> " + ex.getTargetException().toString());
System.out.println("FAILED");
errorCount++;
} catch (Exception ex) {
System.out.println("\t" + currentMethod.getName() + " ERROR ==> " + ex.toString());
System.out.println("FAILED");
errorCount++;
}
if (verify != 0) {
verify = 0;
contentInstance.removeTextChangeListener(this);
}
tearDown();
}
}
Aggregations