diff options
author | Aidan Skinner <aidan@apache.org> | 2008-12-19 16:07:23 +0000 |
---|---|---|
committer | Aidan Skinner <aidan@apache.org> | 2008-12-19 16:07:23 +0000 |
commit | 9d452e51c35b973a797aa2132998eb5cb29eb146 (patch) | |
tree | 19680c1b1136fe75c545168a9c7baf13fe578842 | |
parent | c35f4cf2f4a46c3f1baa6dc5225dcfb458b6ac07 (diff) | |
download | qpid-python-9d452e51c35b973a797aa2132998eb5cb29eb146.tar.gz |
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
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@728059 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 116 insertions, 13 deletions
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java index 7a36ca6160..ce7d8816ba 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java @@ -28,6 +28,8 @@ import org.apache.qpid.management.ui.views.NumberVerifyListener; 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.layout.GridLayout; 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 @@ public class AddServer extends AbstractAction implements IWorkbenchWindowActionD 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 @@ public class AddServer extends AbstractAction implements IWorkbenchWindowActionD //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 @@ public class AddServer extends AbstractAction implements IWorkbenchWindowActionD 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); } } diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java index dd9e792912..ce9d80d49b 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java @@ -34,12 +34,15 @@ import org.apache.qpid.management.ui.views.TreeObject; 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 @@ public class ReconnectServer extends AbstractAction implements IWorkbenchWindowA 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 @@ public class ReconnectServer extends AbstractAction implements IWorkbenchWindowA 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 @@ public class ReconnectServer extends AbstractAction implements IWorkbenchWindowA { 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); } } |