hn = hostname;
}
final String regexp = "^[,\\w.-]+$";
hostField = widgetFactory.createInstance(
Widget.GUESS_TYPE,
new StringValue(hn),
Widget.NO_ITEMS,
regexp,
FIELD_WIDTH,
Widget.NO_ABBRV,
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
Widget.NO_BUTTON);
if (hostname == null || Host.DEFAULT_HOSTNAME.equals(hostname)) {
/* so that hostname is not disabled after going back in the wizard*/
enableHostname = true;
} else {
if (!enableHostname) {
hostField.setEnabled(false);
}
}
addCheckField(hostField);
hostLabel.setLabelFor(hostField.getComponent());
inputPane.add(hostField.getComponent());
hostField.setBackground(new StringValue(getHost().getEnteredHostOrIp()),
new StringValue(getHost().getEnteredHostOrIp()),
true);
/* SSH Port */
final JLabel sshPortLabel = new JLabel(Tools.getString("Dialog.Host.NewHost.SSHPort"));
inputPane.add(sshPortLabel);
String sshPort = getHost().getSSHPort();
if (sshPort == null) {
sshPort = application.getLastEnteredSSHPort();
if (sshPort == null) {
sshPort = DEFAULT_SSH_PORT;
}
}
sshPortField = widgetFactory.createInstance(
Widget.GUESS_TYPE,
new StringValue(sshPort),
Widget.NO_ITEMS,
"^\\d+$",
50,
Widget.NO_ABBRV,
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
Widget.NO_BUTTON);
addCheckField(sshPortField);
sshPortLabel.setLabelFor(sshPortField.getComponent());
inputPane.add(sshPortField.getComponent());
sshPortField.setBackground(new StringValue(getHost().getSSHPort()),
new StringValue(getHost().getSSHPort()),
true);
/* Username */
final JLabel usernameLabel = new JLabel(Tools.getString("Dialog.Host.NewHost.EnterUsername"));
inputPane.add(usernameLabel);
String userName = getHost().getUsername();
if (userName == null) {
userName = application.getLastEnteredUser();
if (userName == null) {
userName = DEFAULT_SSH_ROOT_USER;
}
}
final List<Value> users = new ArrayList<Value>();
final String user = System.getProperty("user.name");
if (!DEFAULT_SSH_ROOT_USER.equals(user)) {
users.add(new StringValue(DEFAULT_SSH_ROOT_USER));
}
users.add(new StringValue(user));
usernameField = widgetFactory.createInstance(
Widget.GUESS_TYPE,
new StringValue(userName),
users.toArray(new Value[users.size()]),
regexp,
FIELD_WIDTH,
Widget.NO_ABBRV,
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
Widget.NO_BUTTON);
usernameField.setEditable(true);
addCheckField(usernameField);
usernameLabel.setLabelFor(usernameField.getComponent());
inputPane.add(usernameField.getComponent());
usernameField.setBackground(new StringValue(getHost().getUsername()),
new StringValue(getHost().getUsername()),
true);
/* use sudo */
final JLabel useSudoLabel = new JLabel(Tools.getString("Dialog.Host.NewHost.UseSudo"));
inputPane.add(useSudoLabel);
Boolean useSudo = getHost().isUseSudo();
if (useSudo == null) {
useSudo = application.getLastEnteredUseSudo();
if (useSudo == null) {
useSudo = false;
}
}
final Value useSudoValue = new StringValue(useSudo.toString());
useSudoField = widgetFactory.createInstance(
Widget.GUESS_TYPE,
useSudoValue,
new Value[]{new StringValue("true"), new StringValue("false")},
Widget.NO_REGEXP,
50,
Widget.NO_ABBRV,
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
Widget.NO_BUTTON);