*/
public void beginDisplay(UserData data)
{
TreeSet<ServerDescriptor> array = orderServers(
data.getRemoteWithNoReplicationPort().keySet());
AuthenticationData authData =
data.getReplicationOptions().getAuthenticationData();
String newServerDisplay;
if (authData != null)
{
newServerDisplay = authData.getHostName()+":"+authData.getPort();
}
else
{
newServerDisplay = "";
}
if (!array.equals(orderedServers) ||
!newServerDisplay.equals(serverToConnectDisplay))
{
serverToConnectDisplay = newServerDisplay;
/**
* Adds the required focus listeners to the fields.
*/
final FocusListener l = new FocusListener()
{
public void focusGained(FocusEvent e)
{
lastFocusComponent = e.getComponent();
}
public void focusLost(FocusEvent e)
{
}
};
lastFocusComponent = null;
HashMap<String, String> hmOldValues = new HashMap<String, String>();
for (String id : hmFields.keySet())
{
hmOldValues.put(id, hmFields.get(id).getText());
}
HashMap<String, Boolean> hmOldSecureValues =
new HashMap<String, Boolean>();
for (String id : hmCbs.keySet())
{
hmOldSecureValues.put(id, hmCbs.get(id).isSelected());
}
orderedServers.clear();
orderedServers.addAll(array);
hmFields.clear();
hmCbs.clear();
hmLabels.clear();
for (ServerDescriptor server : orderedServers)
{
String serverDisplay;
if (server.getHostPort(false).equalsIgnoreCase(serverToConnectDisplay))
{
serverDisplay = serverToConnectDisplay;
}
else
{
serverDisplay = server.getHostPort(true);
}
LabelFieldDescriptor desc = new LabelFieldDescriptor(
Message.raw(serverDisplay),
INFO_REPLICATION_PORT_TOOLTIP.get(),
LabelFieldDescriptor.FieldType.TEXTFIELD,
LabelFieldDescriptor.LabelType.PRIMARY,
UIFactory.PORT_FIELD_SIZE);
AuthenticationData auth =
data.getRemoteWithNoReplicationPort().get(server);
JTextComponent field = UIFactory.makeJTextComponent(desc,
String.valueOf(auth.getPort()));
String oldValue = hmOldValues.get(server.getId());
if (oldValue != null)
{
field.setText(oldValue);
}
JLabel label = UIFactory.makeJLabel(desc);
hmFields.put(server.getId(), field);
label.setLabelFor(field);
field.addFocusListener(l);
if (lastFocusComponent == null)
{
lastFocusComponent = field;
}
hmLabels.put(server.getId(), label);
JCheckBox cb = UIFactory.makeJCheckBox(
INFO_SECURE_REPLICATION_LABEL.get(),
INFO_SECURE_REPLICATION_TOOLTIP.get(),
UIFactory.TextStyle.SECONDARY_FIELD_VALID);
cb.setSelected(auth.useSecureConnection());
Boolean oldSecureValue = hmOldSecureValues.get(server.getId());
if (oldSecureValue != null)
{
cb.setSelected(oldSecureValue);
}