diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2008-12-11 14:57:15 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2008-12-11 14:57:15 +0000 |
| commit | 25b255d0fa0129dec105e4e2e867cf26b6af53bb (patch) | |
| tree | 433f97b81425c4ef4d32701d27fe3792e4c01031 /qpid/java | |
| parent | c933d439cbdbd243a5efa2873df3bce5b4214f48 (diff) | |
| download | qpid-python-25b255d0fa0129dec105e4e2e867cf26b6af53bb.tar.gz | |
QPID-1529 : Create a new shell for message box.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@725705 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
| -rw-r--r-- | qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java | 80 |
1 files changed, 27 insertions, 53 deletions
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java index 4f2b70f869..3245f394b5 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java @@ -411,72 +411,46 @@ public class ViewUtility ex.printStackTrace(); } } - - public static int popupInfoMessage(String title, String message) + + private static Shell getShell() { - MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_INFORMATION | SWT.OK); - messageBox.setMessage(message); - messageBox.setText(title); - int response = messageBox.open(); - - return response; + Shell shell = Display.getCurrent().getActiveShell(); + + // Under linux GTK getActiveShell returns null so we need to make a new shell for display. + // Under windows this is fine. + if (shell == null) + { + // This occurs under linux gtk + shell = new Shell(Display.getCurrent(), SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX); + } + + return shell; } - - public static int popupErrorMessage(String title, String message) + + private static int showBox(String title, String message, int icon) { - MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR | SWT.OK); + MessageBox messageBox = new MessageBox(getShell(), icon); messageBox.setMessage(message); messageBox.setText(title); - int response = messageBox.open(); - - return response; + + return messageBox.open(); } - - public static int popupConfirmationMessage(String title, String message) + + public static int popupInfoMessage(String title, String message) { - MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), - SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); - messageBox.setMessage(message); - messageBox.setText(title); - int response = messageBox.open(); - - return response; + return showBox(title, message, SWT.ICON_INFORMATION | SWT.OK); } - public static void popupError(String title, String message, Throwable ex) + public static int popupErrorMessage(String title, String message) { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.ERROR, ex.toString(), ex); - ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, message, status); - + return showBox(title, message, SWT.ICON_ERROR | SWT.OK); } - - public static void popupError(String errorMsg) + + public static int popupConfirmationMessage(String title, String message) { - Display display = Display.getCurrent(); - Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX); - shell.setText("Attribute"); - shell.setLayout(new GridLayout()); - int x = display.getBounds().width; - int y = display.getBounds().height; - int width = 500; - int height = 250; - shell.setBounds(x/4, y/4, width, height); - - Label label = new Label(shell, SWT.NONE); - label.setText(errorMsg); - label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - shell.dispose(); + return showBox(title, message,SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); } + public static Shell createPopupShell(String title, int width, int height) { |
