From: Patrick Plitzner Date: Tue, 25 Oct 2016 06:47:12 +0000 (+0200) Subject: Add key listener to remote login dialog X-Git-Tag: 4.4.0^2~78 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/c15014c2b6e78e9e26b27cce8f8557127798cc71?ds=sidebyside Add key listener to remote login dialog - pressing enter in the password field or selecting the connect button with the keyboard only will now also connect --- diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java index ff0f87457..fe8fefb0e 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java @@ -26,6 +26,8 @@ import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionAdapter; @@ -340,19 +342,23 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError { gd_txtPassword.heightHint = 15; txtPassword.setLayoutData(gd_txtPassword); new Label(loginComposite, SWT.NONE); + txtPassword.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if(e.character==SWT.CR){ + connectButtonPressed(); + } + } + }); btnConnect = new Button(loginComposite, SWT.FLAT); btnConnect.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); - btnConnect.addMouseListener(new MouseAdapter() { - @Override - public void mouseUp(MouseEvent e) { - if(selectedCsii.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) { - startManagedServer(); - } else { - connect(); - } - } - }); + btnConnect.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + connectButtonPressed(); + } + }); btnConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT); btnRememberMe = new Button(loginComposite, SWT.CHECK); @@ -468,7 +474,13 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError { } - + private void connectButtonPressed() { + if(selectedCsii.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) { + startManagedServer(); + } else { + connect(); + } + } private void populateCdmServerCombo() { Job job = new Job(Messages.RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES) {