Java by API/org.eclipse.jface.dialogs/ErrorDialog
Версия от 17:43, 31 мая 2010; (обсуждение)
ErrorDialog: openError(Shell shell, String arg1, String arg2, IStatus arg3)
import org.eclipse.core.runtime.*;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class MainClass extends ApplicationWindow {
public MainClass() {
super(null);
}
public void run() {
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
}
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("Show Error");
shell.setSize(400, 400);
}
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
text.setLayoutData(new GridData(GridData.FILL_BOTH));
Button show = new Button(composite, SWT.PUSH);
show.setText("Show Error");
show.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
Status status = new Status(IStatus.ERROR, "My Plug-in ID", 0,
"Status Error Message", null);
ErrorDialog.openError(Display.getCurrent().getActiveShell(),
"JFace Error", text.getText(), status);
}
});
return composite;
}
public static void main(String[] args) {
new MainClass().run();
}
}