public boolean editSettings(SshToolsConnectionProfile profile) {
final SshToolsConnectionPanel panel = new SshToolsConnectionPanel(false);
SshToolsConnectionTab[] tabs = getAdditionalConnectionTabs();
for (int i = 0; (tabs != null) && (i < tabs.length); i++) {
tabs[i].setConnectionProfile(profile);
panel.addTab(tabs[i]);
}
panel.setConnectionProfile(profile);
final Option ok = new Option("Ok",
"Apply the settings and close this dialog", 'o");
final Option cancel = new Option("Cancel",
"Close this dialog without applying the settings", 'c");
OptionCallback callback = new OptionCallback() {
public boolean canClose(OptionsDialog dialog, Option option) {
if (option == ok) {
return panel.validateTabs();
}
return true;
}
};
OptionsDialog od = OptionsDialog.createOptionDialog(SshToolsApplicationSessionPanel.this,
new Option[] { ok, cancel }, panel, "Connection Settings", ok,
callback, null);
od.pack();
UIUtil.positionComponent(SwingConstants.CENTER, od);
od.setVisible(true);
if (od.getSelectedOption() == ok) {
// Apply the changes to the profile
panel.applyTabs();
// Ask the session manager to apply them to persistence
manager.applyProfileChanges(profile);
return true;
}
return false;
}
|