sheet = (Sheet)sheetSerializer.readObject("pivot/tools/net/setAuthentication.wtkx");
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Button okButton = (Button)sheetSerializer.getObjectByID("okButton");
okButton.getButtonPressListeners().add(new ButtonPressListener() {
public void buttonPressed(Button button) {
sheet.close(true);
}
});
Button cancelButton = (Button)sheetSerializer.getObjectByID("cancelButton");
cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
public void buttonPressed(Button button) {
sheet.close(false);
}
});
if (credentials != null) {
TextInput usernameTextInput = (TextInput)sheetSerializer.getObjectByID("username");
TextInput passwordTextInput = (TextInput)sheetSerializer.getObjectByID("password");
usernameTextInput.setText(credentials.getUsername());
passwordTextInput.setText(credentials.getPassword());
}
sheet.getSheetStateListeners().add(new SheetStateListener() {
public Vote previewSheetClose(Sheet sheet, boolean result) {
return Vote.APPROVE;
}
public void sheetCloseVetoed(Sheet sheet, Vote reaso) {
// No-op
}
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
TextInput usernameTextInput = (TextInput)
sheetSerializer.getObjectByID("username");
TextInput passwordTextInput = (TextInput)
sheetSerializer.getObjectByID("password");
String username = usernameTextInput.getText();
String password = passwordTextInput.getText();
if (username.length() == 0 && password.length() == 0) {
credentials = null;
} else {
credentials = new Credentials(username, password);
}
}
}
});
sheet.open(window);
}
};
new Action("toggleHostnameVerificationAction") {
public String getDescription() {
return "Toggles lenient hostname verification";
}
public void perform() {
lenientHostnameVerification = !lenientHostnameVerification;
}
};
new Action("setKeystoreAction") {
private String keystorePath = null;
private String keystorePassword = null;
public String getDescription() {
return "Sets a trusted keystore";
}
public void perform() {
final WTKXSerializer sheetSerializer = new WTKXSerializer();
final Sheet sheet;
try {
sheet = (Sheet)sheetSerializer.readObject("pivot/tools/net/setKeystore.wtkx");
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Button okButton = (Button)sheetSerializer.getObjectByID("okButton");
okButton.getButtonPressListeners().add(new ButtonPressListener() {
public void buttonPressed(Button button) {
sheet.close(true);
}
});
Button cancelButton = (Button)sheetSerializer.getObjectByID("cancelButton");
cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
public void buttonPressed(Button button) {
sheet.close(false);
}
});