Skip to content

Commit

Permalink
Merge pull request #113 from dominikl/unsupported_protocol
Browse files Browse the repository at this point in the history
Provide error message if unsupported protocol was used
  • Loading branch information
jburel authored Jul 1, 2020
2 parents 73a9357 + 882258b commit 48dad36
Show file tree
Hide file tree
Showing 8 changed files with 546 additions and 511 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@
import javax.swing.JFrame;


import org.openmicroscopy.shoola.Main;
import org.openmicroscopy.shoola.env.Container;
import org.openmicroscopy.shoola.env.LookupNames;
import org.openmicroscopy.shoola.env.config.OMEROInfo;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.login.UserCredentials;
import org.openmicroscopy.shoola.util.image.geom.Factory;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
import org.openmicroscopy.shoola.util.ui.login.ScreenLogin;
import org.openmicroscopy.shoola.util.ui.login.ScreenLogo;
import org.openmicroscopy.shoola.env.ui.login.ScreenLogin;
import org.openmicroscopy.shoola.env.ui.login.ScreenLogo;

/**
* Manages the splash screen input, data and update.
Expand Down Expand Up @@ -169,7 +168,7 @@ private void initializedView(Icon splashscreen)

boolean serverAvailable = connectToServer();
view = new ScreenLogin(Container.TITLE, splashscreen, img, clientVersion,
serverAvailable);
serverAvailable, container.getRegistry());
view.setEncryptionConfiguration(info.isEncrypted(),
info.isEncryptedConfigurable());
view.setDefaultHostConfiguration(info, configurable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
import org.openmicroscopy.shoola.util.ui.MacOSMenuHandler;
import org.openmicroscopy.shoola.util.ui.MessageBox;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
import org.openmicroscopy.shoola.util.ui.login.ScreenLogin;
import org.openmicroscopy.shoola.util.ui.login.ScreenLoginDialog;
import org.openmicroscopy.shoola.env.ui.login.ScreenLogin;
import org.openmicroscopy.shoola.env.ui.login.ScreenLoginDialog;
import org.openmicroscopy.shoola.util.file.IOUtil;

import omero.gateway.model.ExperimenterData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*------------------------------------------------------------------------------
*/
package org.openmicroscopy.shoola.util.ui.login;
package org.openmicroscopy.shoola.env.ui.login;


import java.awt.Color;
Expand Down Expand Up @@ -62,6 +62,7 @@
import javax.swing.event.DocumentListener;

import org.openmicroscopy.shoola.env.config.OMEROInfo;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.login.UserCredentials;
import org.openmicroscopy.shoola.util.CommonsLangUtils;

Expand Down Expand Up @@ -227,7 +228,10 @@ public class ScreenLogin
private JButton helpButton;

private boolean configurable = true;


/** Reference to the Registry */
private Registry registry;

/** Quits the application. */
private void quit()
{
Expand Down Expand Up @@ -256,14 +260,27 @@ private void login()
if (usr != null) usr = usr.trim();
if (s != null) s = s.trim();
setControlsEnabled(false);
UserCredentials lc= new UserCredentials(usr, psw, s, speedIndex);
lc.setEncrypted(encrypted);
setUserName(usr);
setEncrypted();
setControlsEnabled(false);
loginAttempt = true;
login.setEnabled(false);
firePropertyChange(LOGIN_PROPERTY, null, lc);
try {
UserCredentials lc = new UserCredentials(usr, psw, s, speedIndex);
lc.setEncrypted(encrypted);
setUserName(usr);
setEncrypted();
setControlsEnabled(false);
loginAttempt = true;
login.setEnabled(false);
firePropertyChange(LOGIN_PROPERTY, null, lc);
} catch (IllegalArgumentException e) {
// an unsuppported server URL has been specified
if (this.registry != null) {
this.registry.getUserNotifier().notifyError("Error",
"There is a problem with the server name or URL:\n"+e.getMessage());
} else {
JOptionPane.showMessageDialog(this, e.getMessage(),
"Error", JOptionPane.ERROR_MESSAGE);
}
setControlsEnabled(true);
requestFocusOnField();
}
}

/**
Expand Down Expand Up @@ -680,17 +697,6 @@ private void enableControls()
login.setEnabled(enabled);
configButton.setEnabled(this.configurable);
if (enabled) {
ActionListener[] listeners = login.getActionListeners();
if (listeners != null) {
boolean set = false;
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == this) {
set = true;
break;
}
}
if (!set) login.addActionListener(this);
}
login.setForeground(defaultForeground);
} else {
login.setForeground(FOREGROUND_COLOR);
Expand Down Expand Up @@ -800,9 +806,10 @@ private void setProperties(Image frameIcon)
* connect to a server, <code>false</code> otherwise.
*/
public ScreenLogin(String title, Icon logo, Image frameIcon, String version,
boolean serverAvailable)
boolean serverAvailable, Registry registry)
{
super(title);
this.registry = registry;
setName("login window");
Dimension d;
if (logo != null)
Expand Down Expand Up @@ -845,7 +852,7 @@ public void mouseClicked(MouseEvent e) {
*/
public ScreenLogin(String title, Icon logo, Image frameIcon, String version)
{
this(title, logo, frameIcon, version, true);
this(title, logo, frameIcon, version, true, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* org.openmicroscopy.shoola.util.ui.login.ScreenLoginDialog
* org.openmicroscopy.shoola.env.ui.login.ScreenLoginDialog
*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2009 University of Dundee. All rights reserved.
Expand All @@ -20,7 +20,7 @@
*
*------------------------------------------------------------------------------
*/
package org.openmicroscopy.shoola.util.ui.login;
package org.openmicroscopy.shoola.env.ui.login;


import org.openmicroscopy.shoola.env.config.OMEROInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* org.openmicroscopy.shoola.util.ui.login.ScreenLogo
* org.openmicroscopy.shoola.env.ui.login.ScreenLogo
*
*------------------------------------------------------------------------------
* Copyright (C) 2006 University of Dundee. All rights reserved.
Expand All @@ -20,7 +20,7 @@
*
*------------------------------------------------------------------------------
*/
package org.openmicroscopy.shoola.util.ui.login;
package org.openmicroscopy.shoola.env.ui.login;


//Java imports
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* org.openmicroscopy.shoola.util.ui.login.ServerDialog
* org.openmicroscopy.shoola.env.ui.login.ServerDialog
*
*------------------------------------------------------------------------------
* Copyright (C) 2006 University of Dundee. All rights reserved.
Expand All @@ -20,7 +20,7 @@
*
*------------------------------------------------------------------------------
*/
package org.openmicroscopy.shoola.util.ui.login;
package org.openmicroscopy.shoola.env.ui.login;


import java.awt.BorderLayout;
Expand Down
Loading

0 comments on commit 48dad36

Please sign in to comment.