qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r728059 - in /qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions: AddServer.java ReconnectServer.java
Date Fri, 19 Dec 2008 16:07:23 GMT
Author: aidan
Date: Fri Dec 19 08:07:23 2008
New Revision: 728059

URL: http://svn.apache.org/viewvc?rev=728059&view=rev
Log:
QPID-1010 patch from gemmellr@dcs.gla.ac.uk


This addresses the button visibility issue in a slightly different way, by ensuring ensuring
the dialog increases its size to match the contents if the (now increased ) default is not
large enough. It also centre's the dialog correctly, and does not allow it to be resized by
the user. The same approach is applied to the Reconnect dialog, which suffers similar issues.

In addition, the patch incorporates Enter/Escape keyboard functionality in the dialogs, as
per QPID-1531

Modified:
    qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
    qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java

Modified: qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java?rev=728059&r1=728058&r2=728059&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
(original)
+++ qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
Fri Dec 19 08:07:23 2008
@@ -28,6 +28,8 @@
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
@@ -35,6 +37,7 @@
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
@@ -106,11 +109,24 @@
         shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE));
         shell.setLayout(new GridLayout());
         
-        int x = display.getBounds().width;
-        int y = display.getBounds().height;
-        shell.setBounds(x/3, y/3, 425, 275);
-        
         createWidgets(shell);
+        shell.pack();
+        
+        //get current size dialog, and screen size
+        int displayWidth = display.getBounds().width;
+        int displayHeight = display.getBounds().height;        
+        int currentShellWidth = shell.getSize().x;
+        int currentShellHeight = shell.getSize().y;
+        
+        //default sizes for the dialog
+        int minShellWidth = 425;
+        int minShellHeight= 290;        
+        //ensure this is large enough, increase it if its not
+        int newShellWidth =  currentShellWidth > minShellWidth ? currentShellWidth : minShellWidth;
+        int newShellHeight = currentShellHeight > minShellHeight ? currentShellHeight
: minShellHeight;
+        
+        //set the final size and centre the dialog
+        shell.setBounds((displayWidth - newShellWidth)/2 , (displayHeight - newShellHeight)/2,
newShellWidth, newShellHeight);
         
         shell.open();
         _window.getShell().setEnabled(false);
@@ -201,11 +217,27 @@
         //textPwd.setEchoChar('*');
         textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
         
+        //Get the text widgets
+        Control[] widgets = composite.getChildren();
+        for (int i=0; i < widgets.length; i++)
+        {
+            widgets[i].addKeyListener(new KeyAdapter()
+            {
+                public void keyPressed(KeyEvent event)
+                {
+                    if (event.character == SWT.ESC)
+                    {
+                      //Escape key acts as cancel on all widgets
+                        shell.close();
+                    }
+                }
+            });
+        }
+        
         Composite buttonsComposite  = new Composite(composite, SWT.NONE);
         buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
         buttonsComposite.setLayout(new GridLayout(2, true));
         
-        
         final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER);
      
         connectButton.setText(BUTTON_CONNECT);
         GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true);
@@ -263,12 +295,32 @@
         gridData.widthHint = 100;
         cancelButton.setLayoutData(gridData);
         cancelButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
-        cancelButton.addSelectionListener(new SelectionAdapter(){
+        cancelButton.addSelectionListener(new SelectionAdapter()
+        {
             public void widgetSelected(SelectionEvent event)
             {
                 shell.dispose();
             }
         });
+        
+        //Get the ok/cancel button widgets and add a new key listener
+        widgets = buttonsComposite.getChildren();
+        for (int i=0; i < widgets.length; i++)
+        {
+            widgets[i].addKeyListener(new KeyAdapter()
+            {
+                public void keyPressed(KeyEvent event)
+                {
+                    if (event.character == SWT.ESC)
+                    {
+                        //Escape key acts as cancel on all widgets
+                        shell.close();
+                    }
+                }
+            });
+        }
+        
+        shell.setDefaultButton(connectButton);
     }
 
 }

Modified: qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java?rev=728059&r1=728058&r2=728059&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
(original)
+++ qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
Fri Dec 19 08:07:23 2008
@@ -34,12 +34,15 @@
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 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.Label;
 import org.eclipse.swt.widgets.Shell;
@@ -102,11 +105,24 @@
         shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE));
         shell.setLayout(new GridLayout());
         
-        int x = display.getBounds().width;
-        int y = display.getBounds().height;
-        shell.setBounds(x/3, y/3, 350, 200);
-
-        createWidgets(shell);
+        createWidgets(shell);        
+        shell.pack();
+        
+        //get current size dialog, and screen size
+        int displayWidth = display.getBounds().width;
+        int displayHeight = display.getBounds().height;        
+        int currentShellWidth = shell.getSize().x;
+        int currentShellHeight = shell.getSize().y;
+        
+        //default sizes for the dialog
+        int minShellWidth = 350;
+        int minShellHeight= 200;        
+        //ensure this is large enough, increase it if its not
+        int newShellWidth =  currentShellWidth > minShellWidth ? currentShellWidth : minShellWidth;
+        int newShellHeight = currentShellHeight > minShellHeight ? currentShellHeight
: minShellHeight;
+        
+        //set the final size and centre the dialog
+        shell.setBounds((displayWidth - newShellWidth)/2 , (displayHeight - newShellHeight)/2,
newShellWidth, newShellHeight);
         
         shell.open();
         _window.getShell().setEnabled(false);
@@ -155,11 +171,27 @@
         textPwd.setText("");
         textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
         
+        //Get the text widgets
+        Control[] widgets = composite.getChildren();
+        for (int i=0; i < widgets.length; i++)
+        {
+            widgets[i].addKeyListener(new KeyAdapter()
+            {
+                public void keyPressed(KeyEvent event)
+                {
+                    if (event.character == SWT.ESC)
+                    {
+                      //Escape key acts as cancel on all widgets
+                        shell.close();
+                    }
+                }
+            });
+        }
+        
         Composite buttonsComposite  = new Composite(composite, SWT.NONE);
         buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
         buttonsComposite.setLayout(new GridLayout(2, true));
         
-        
         final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER);
      
         connectButton.setText(Constants.BUTTON_CONNECT);
         GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true);
@@ -203,7 +235,26 @@
             {
                 shell.dispose();
             }
-        });  
+        });
+        
+        //Get the ok/cancel button widgets and add a new key listener
+        widgets = buttonsComposite.getChildren();
+        for (int i=0; i < widgets.length; i++)
+        {
+            widgets[i].addKeyListener(new KeyAdapter()
+            {
+                public void keyPressed(KeyEvent event)
+                {
+                    if (event.character == SWT.ESC)
+                    {
+                        //Escape key acts as cancel on all widgets
+                        shell.close();
+                    }
+                }
+            });
+        }
+        
+        shell.setDefaultButton(connectButton);
     }
     
 }



Mime
View raw message