Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Weninger2012-01-18 07:46:56 -0500
committerUwe Stieber2012-01-18 07:47:57 -0500
commitdaa0cf9cb87622c7f1e77d7b1e65f09a2438c667 (patch)
treebbfda0ae24b84d20caff59ef4c60e660aa213693 /target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh
parentd08c5f6ba4c2f4d3975692104576f7f836425678 (diff)
downloadorg.eclipse.tcf-daa0cf9cb87622c7f1e77d7b1e65f09a2438c667.tar.gz
org.eclipse.tcf-daa0cf9cb87622c7f1e77d7b1e65f09a2438c667.tar.xz
org.eclipse.tcf-daa0cf9cb87622c7f1e77d7b1e65f09a2438c667.zip
Target Explorer: Bug 361354 [TERMINALS] Add terminals quick launch button to the global toolbar
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java106
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java4
2 files changed, 79 insertions, 31 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
index edc9c03f4..114cf41c0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.ssh.controls;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
@@ -58,13 +61,17 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
panel.setLayoutData(data);
+ if(isWithoutSelection()){
+ createHostsUI(panel);
+ }
+
SshConnector conn = new SshConnector();
sshSettings = (SshSettings) conn.getSshSettings();
sshSettings.setHost(getSelectionHost());
sshSettings.setUser(getDefaultUser());
sshSettingsPage = conn.makeSettingsPage();
sshSettingsPage.createControl(panel);
-
+
setControl(panel);
}
@@ -113,15 +120,13 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ * @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
*/
@Override
- public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
- String host = getSelectionHost();
- if (host != null) {
- // is there a section for this host
- IDialogSettings hostSettings = settings.getSection(host);
- if (hostSettings != null) {
+ protected void fillSettingsForHost(String host){
+ if(host!=null && host.length()!=0){
+ if(hostSettingsMap.containsKey(host)){
+ Map<String, String> hostSettings=hostSettingsMap.get(host);
if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
sshSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
}
@@ -141,12 +146,12 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
if (password != null) {
sshSettings.setPassword(password);
}
- // set settings in page
- sshSettingsPage.loadSettings();
+ } else {
+ sshSettings.setHost(getSelectionHost());
+ sshSettings.setUser(getDefaultUser());
}
- }
- else {
- // MWE TODO combo for all hosts
+ // set settings in page
+ sshSettingsPage.loadSettings();
}
}
@@ -154,24 +159,39 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
* @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
*/
@Override
- public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
- // make sure the values are saved
- // actually not needed since this is done before in extractData
- sshSettingsPage.saveSettings();
- String host = sshSettings.getHost();
- IDialogSettings hostSection=settings.getSection(host);
- if(hostSection==null){
- hostSection=settings.addNewSection(host);
- }
+ public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
+ saveSettingsForHost(true);
+ super.doSaveWidgetValues(settings, idPrefix);
+ }
+
+ @Override
+ protected void saveSettingsForHost(boolean add){
+ String host=getHostFromSettings();
+ if(host!=null && host.length()!=0){
+ if(hostSettingsMap.containsKey(host)){
+ Map<String, String> hostSettings=hostSettingsMap.get(host);
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, new Integer(sshSettings.getPort()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, new Integer(sshSettings.getTimeout()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, new Integer(sshSettings.getKeepalive()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
- hostSection.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
- hostSection.put(ITerminalsConnectorConstants.PROP_IP_PORT, sshSettings.getPort());
- hostSection.put(ITerminalsConnectorConstants.PROP_TIMEOUT, sshSettings.getTimeout());
- hostSection.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, sshSettings.getKeepalive());
- hostSection.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
+ if(sshSettings.getPassword()!=null && sshSettings.getPassword().length()!=0){
+ saveSecurePassword(host, sshSettings.getPassword());
+ }
+ } else if(add){
+ Map<String, String> hostSettings=new HashMap<String, String>();
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, new Integer(sshSettings.getPort()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, new Integer(sshSettings.getTimeout()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, new Integer(sshSettings.getKeepalive()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
+ hostSettingsMap.put(host, hostSettings);
- if(sshSettings.getPassword()!=null && sshSettings.getPassword().length()!=0){
- saveSecurePassword(host, sshSettings.getPassword());
+ if(sshSettings.getPassword()!=null && sshSettings.getPassword().length()!=0){
+ saveSecurePassword(host, sshSettings.getPassword());
+ }
+ }
}
}
@@ -229,10 +249,38 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
}
/* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#removeSecurePassword(java.lang.String)
+ */
+ @Override
+ protected void removeSecurePassword(String host) {
+ Assert.isNotNull(host);
+
+ // To access the secure storage, we need the preference instance
+ ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
+ if (preferences != null) {
+ // Construct the secure preferences node key
+ String nodeKey = "/Target Explorer SSH Password/" + host; //$NON-NLS-1$
+ ISecurePreferences node = preferences.node(nodeKey);
+ if (node != null) {
+ node.remove("password"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#isValid()
*/
@Override
public boolean isValid(){
return sshSettingsPage.validateSettings();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#getHostFromSettings()
+ */
+ @Override
+ protected String getHostFromSettings() {
+ sshSettingsPage.saveSettings();
+ return sshSettings.getHost();
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java
index 0281ea235..6a3dde91c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java
@@ -14,8 +14,6 @@ import java.text.DateFormat;
import java.util.Date;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.ui.terminals.ssh.controls.SshWizardConfigurationPanel;
-import org.eclipse.tcf.te.ui.terminals.ssh.nls.Messages;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
@@ -24,6 +22,8 @@ import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnec
import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate;
+import org.eclipse.tcf.te.ui.terminals.ssh.controls.SshWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.terminals.ssh.nls.Messages;
/**
* SSH launcher delegate implementation.

Back to the top