summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2009-06-23 09:55:31 +0000
committerRobert Gemmell <robbie@apache.org>2009-06-23 09:55:31 +0000
commit92fd1cccda1034c731665448fc1519f919bd7b98 (patch)
tree6c3418a750b9cfffc0ff6f42a2112fd4b49db4ca
parent539be0129e41383fb5fd4d8f4950ba9573750dc2 (diff)
downloadqpid-python-92fd1cccda1034c731665448fc1519f919bd7b98.tar.gz
QPID-1930: add utility method for creating modal dialog shells, and augment previous result window generator to allow ESC to act as close
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/jmx_mc_gsoc09@787614 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java37
1 files changed, 36 insertions, 1 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 16bae07e48..c836ef578e 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
@@ -54,7 +54,9 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ScrollBar;
@@ -775,16 +777,49 @@ public class ViewUtility
public static Shell createPopupShell(String title, int width, int height)
{
Display display = Display.getCurrent();
- Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN |SWT.MAX);
+ final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN |SWT.MAX);
shell.setText(title);
shell.setLayout(new GridLayout());
int x = display.getBounds().width;
int y = display.getBounds().height;
shell.setBounds(x/4, y/4, width, height);
+ shell.addListener(SWT.Traverse, new Listener () {
+ public void handleEvent (Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ shell.close ();
+ event.detail = SWT.TRAVERSE_NONE;
+ event.doit = false;
+ break;
+ }
+ }
+ });
+
return shell;
}
+ public static Shell createModalDialogShell(Shell parent, String title)
+ {
+ final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+ shell.setText(title);
+ shell.setLayout(new GridLayout());
+
+ shell.addListener(SWT.Traverse, new Listener () {
+ public void handleEvent (Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ shell.close ();
+ event.detail = SWT.TRAVERSE_NONE;
+ event.doit = false;
+ break;
+ }
+ }
+ });
+
+ return shell;
+ }
+
/**
* Creates a List widget for displaying array of strings
* @param compositeHolder