diff options
Diffstat (limited to 'java/src')
3 files changed, 123 insertions, 49 deletions
diff --git a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java index 91714edde11..e5b95df54e0 100644 --- a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java @@ -1240,8 +1240,7 @@ public class Coordinator void login(final SessionKeeper sessionKeeper, final SessionKeeper.ConnectionInfo info, - final JDialog parent, - final Cursor oldCursor) + final JDialog parent) { // // Keep certificates arround for connection retry @@ -1266,7 +1265,7 @@ public class Coordinator { JOptionPane.showMessageDialog(parent, e.toString(), "Failed to access data directory", JOptionPane.ERROR_MESSAGE); - parent.setCursor(oldCursor); + _sessionKeeper.loginFailed(); return; } if(info.getKeyPassword() != null) @@ -1292,7 +1291,7 @@ public class Coordinator e.toString(), "Communicator initialization failed", JOptionPane.ERROR_MESSAGE); - parent.setCursor(oldCursor); + _sessionKeeper.loginFailed(); return; } @@ -1654,7 +1653,7 @@ public class Coordinator JOptionPane.showMessageDialog(parent, ex.toString(), "Error creating certificate verifier", JOptionPane.ERROR_MESSAGE); - parent.setCursor(oldCursor); + _sessionKeeper.loginFailed(); }); break; } @@ -1708,18 +1707,17 @@ public class Coordinator _newApplicationWithDefaultTemplates.setEnabled(true); _acquireExclusiveWriteAccess.setEnabled(true); _mainPane.setSelectedComponent(_liveDeploymentPane); - _sessionKeeper.loginSuccess(parent, oldCursor, _sessionTimeout, _acmTimeout, _session, info); + _sessionKeeper.loginSuccess(parent, _sessionTimeout, _acmTimeout, _session, info); } synchronized public void loginFailed() { - parent.setCursor(oldCursor); + _sessionKeeper.loginFailed(); _failed = true; } synchronized public void permissionDenied(String msg) { - parent.setCursor(oldCursor); _failed = true; _sessionKeeper.permissionDenied(parent, info, msg); } diff --git a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/SessionKeeper.java index 02024a5142f..ddc7263882b 100644 --- a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/SessionKeeper.java @@ -1221,11 +1221,14 @@ public class SessionKeeper { if(e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { - Object obj = _directDiscoveryLocatorModel.getElementAt( - _directDiscoveryLocatorList.locationToIndex(e.getPoint())); - if(obj != null && obj instanceof com.zeroc.Ice.LocatorPrx) + int index = _directDiscoveryLocatorList.locationToIndex(e.getPoint()); + if(index != -1) { - _nextButton.doClick(0); + Object obj = _directDiscoveryLocatorModel.getElementAt(index); + if(obj != null && obj instanceof com.zeroc.Ice.LocatorPrx) + { + _nextButton.doClick(0); + } } } } @@ -2478,11 +2481,14 @@ public class SessionKeeper inf.setUseX509Certificate(true); } - ConnectionWizardDialog.this.dispose(); if(_connectNow) { login(parent, inf); } + else + { + ConnectionWizardDialog.this.dispose(); + } } }; _finishButton.setAction(finishAction); @@ -3319,6 +3325,7 @@ public class SessionKeeper public void actionPerformed(ActionEvent e) { JDialog dialog = new ConnectionWizardDialog(ConnectionManagerDialog.this); + setConnectionWizard(dialog); Utils.addEscapeListener(dialog); dialog.setLocationRelativeTo(ConnectionManagerDialog.this); dialog.setVisible(true); @@ -3533,12 +3540,15 @@ public class SessionKeeper { if(e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { - Object obj = _connectionListModel.getElementAt( - _connectionList.locationToIndex(e.getPoint())); - if(obj != null && obj instanceof ConnectionInfo) + int index = _connectionList.locationToIndex(e.getPoint()); + if(index != -1) { - ConnectionInfo inf = (ConnectionInfo)obj; - login(ConnectionManagerDialog.this, inf); + Object obj = _connectionListModel.getElementAt(index); + if(obj != null && obj instanceof ConnectionInfo) + { + ConnectionInfo inf = (ConnectionInfo)obj; + login(ConnectionManagerDialog.this, inf); + } } } } @@ -3654,6 +3664,15 @@ public class SessionKeeper } } + public void setConnectionWizard(JDialog dialog) + { + if(_connectionWizard != null) + { + _connectionWizard.dispose(); + } + _connectionWizard = dialog; + } + class ConnectionListModel extends DefaultListModel { public void setDefault() @@ -3703,6 +3722,8 @@ public class SessionKeeper private JButton _setDefaultConnectionButton; private JButton _removeConnectionButton; + private JDialog _connectionWizard; + private JButton _connectButton; } @@ -4713,6 +4734,26 @@ public class SessionKeeper } } + class StoredPasswordAuthDialog extends AuthDialog + { + StoredPasswordAuthDialog(JDialog parent) + { + super(parent, "Login - IceGrid GUI"); + + Container contentPane = getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + + + FormLayout layout = new FormLayout("pref:grow", ""); + DefaultFormBuilder builder = new DefaultFormBuilder(layout); + builder.border(Borders.DIALOG); + builder.append(new JLabel("Connecting please wait")); + contentPane.add(builder.getPanel()); + pack(); + setResizable(false); + } + } + private void login(final JDialog parent, final ConnectionInfo info) { if(_authDialog != null) @@ -4823,6 +4864,8 @@ public class SessionKeeper } JButton okButton = new JButton(); + JButton cancelButton = new JButton(); + AbstractAction okAction = new AbstractAction("OK") { @Override @@ -4852,16 +4895,17 @@ public class SessionKeeper } else { - Cursor oldCursor = parent.getCursor(); - parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - dispose(); - _coordinator.login(SessionKeeper.this, info,parent, oldCursor); + _authDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + _authDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + Utils.removeEscapeListener(_authDialog); + okButton.setEnabled(false); + cancelButton.setEnabled(false); + _coordinator.login(SessionKeeper.this, info,parent); } } }; okButton.setAction(okAction); - JButton cancelButton = new JButton(); AbstractAction cancelAction = new AbstractAction("Cancel") { @Override @@ -4917,13 +4961,15 @@ public class SessionKeeper } else { - Cursor oldCursor = parent.getCursor(); - parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor); + _authDialog = new StoredPasswordAuthDialog(parent); + _authDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + _authDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + _coordinator.login(SessionKeeper.this, info, parent); + _authDialog.showDialog(); } } } - else // Auth dialog + else // X509CertificateAuthDialog dialog { class X509CertificateAuthDialog extends AuthDialog { @@ -4973,6 +5019,8 @@ public class SessionKeeper } JButton okButton = new JButton(); + JButton cancelButton = new JButton(); + AbstractAction okAction = new AbstractAction("OK") { @Override @@ -4994,16 +5042,17 @@ public class SessionKeeper } else { - Cursor oldCursor = parent.getCursor(); - parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - dispose(); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor); + _authDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + _authDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + Utils.removeEscapeListener(_authDialog); + okButton.setEnabled(false); + cancelButton.setEnabled(false); + _coordinator.login(SessionKeeper.this, info, parent); } } }; okButton.setAction(okAction); - JButton cancelButton = new JButton(); AbstractAction cancelAction = new AbstractAction("Cancel") { @Override @@ -5054,16 +5103,18 @@ public class SessionKeeper } else { - Cursor oldCursor = parent.getCursor(); - parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor); + _authDialog = new StoredPasswordAuthDialog(parent); + _authDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + _authDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + _coordinator.login(SessionKeeper.this, info, parent); + _authDialog.showDialog(); } } } } - public void loginSuccess(final JDialog parent, final Cursor oldCursor, final long sessionTimeout, - final int acmTimeout, final AdminSessionPrx session, final ConnectionInfo info) + public void loginSuccess(final JDialog parent, final long sessionTimeout, final int acmTimeout, + final AdminSessionPrx session, final ConnectionInfo info) { try { @@ -5126,18 +5177,31 @@ public class SessionKeeper } catch(java.lang.Throwable e) { - SwingUtilities.invokeLater(() -> _connectionManagerDialog.setCursor(oldCursor)); return; } SwingUtilities.invokeLater(() -> { - _connectionManagerDialog.setCursor(oldCursor); + if(_authDialog != null) + { + _authDialog.dispose(); + _authDialog = null; + } + _connectionManagerDialog.setConnectionWizard(null); _connectionManagerDialog.setVisible(false); }); }).start(); } + public void loginFailed() + { + if(_authDialog != null) + { + _authDialog.dispose(); + _authDialog = null; + } + } + public void permissionDenied(final JDialog parent, final ConnectionInfo info, final String msg) { class PermissionDeniedAuthDialog extends AuthDialog @@ -5247,7 +5311,11 @@ public class SessionKeeper contentPane.add(builder.getPanel()); } - JButton okButton = new JButton(new AbstractAction("OK") + JButton okButton = new JButton(); + JButton editConnectionButton = new JButton(); + JButton cancelButton = new JButton(); + + AbstractAction okAction = new AbstractAction("OK") { @Override public void actionPerformed(ActionEvent e) @@ -5279,15 +5347,18 @@ public class SessionKeeper } else { - Cursor oldCursor = parent.getCursor(); - parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - dispose(); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor); + _authDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + okButton.setEnabled(false); + editConnectionButton.setEnabled(false); + cancelButton.setEnabled(false); + Utils.removeEscapeListener(_authDialog); + _authDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + _coordinator.login(SessionKeeper.this, info, parent); } } - }); + }; - JButton editConnectionButton = new JButton(new AbstractAction("Edit Connection") + AbstractAction editAction = new AbstractAction("Edit Connection") { @Override public void actionPerformed(ActionEvent e) @@ -5300,9 +5371,9 @@ public class SessionKeeper dialog.setLocationRelativeTo(parent); dialog.setVisible(true); } - }); + }; - JButton cancelButton = new JButton(new AbstractAction("Cancel") + AbstractAction cancelAction = new AbstractAction("Cancel") { @Override public void actionPerformed(ActionEvent e) @@ -5311,7 +5382,7 @@ public class SessionKeeper dispose(); _authDialog = null; } - }); + }; JComponent buttonBar = new ButtonBarBuilder().addGlue().addButton(okButton, editConnectionButton, cancelButton).addGlue().build(); diff --git a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Utils.java b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Utils.java index 492e1b33e0c..47e52641597 100644 --- a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Utils.java +++ b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Utils.java @@ -84,6 +84,11 @@ public class Utils JComponent.WHEN_IN_FOCUSED_WINDOW); } + static public void removeEscapeListener(JDialog dialog) + { + dialog.getRootPane().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); + } + // // Extract Ice version in the form XXYYZZ, e.g. 030201 (for 3.2.1) // 0 == empty string |