Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PropertiesAccessService.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java70
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java25
6 files changed, 92 insertions, 24 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java
index d76c785e2..b06d05959 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java
@@ -54,7 +54,12 @@ public interface IPropertiesAccessServiceConstants {
public static String PROP_PROXIES = "proxies"; //$NON-NLS-1$
/**
- * The user name to use to log into the target.
+ * The default user name to use to log into the target.
*/
- public static String PROP_USER = "user"; //$NON-NLS-1$
+ public static String PROP_DEFAULT_USER = "defaultUser"; //$NON-NLS-1$
+
+ /**
+ * The default encoding to use.
+ */
+ public static String PROP_DEFAULT_ENCODING = "defaultEncoding"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PropertiesAccessService.java
index d97102a00..2497a4377 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PropertiesAccessService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PropertiesAccessService.java
@@ -88,7 +88,7 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s
*/
@Override
public Object getProperty(Object context, String key) {
- return super.getProperty(context, IPropertiesAccessServiceConstants.PROP_USER.equals(key) ? IPeer.ATTR_USER_NAME : key);
+ return super.getProperty(context, IPropertiesAccessServiceConstants.PROP_DEFAULT_USER.equals(key) ? IPeer.ATTR_USER_NAME : key);
}
/* (non-Javadoc)
@@ -96,7 +96,7 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s
*/
@Override
public boolean setProperty(Object context, String key, Object value) {
- return super.setProperty(context, IPropertiesAccessServiceConstants.PROP_USER.equals(key) ? IPeer.ATTR_USER_NAME : key, value);
+ return super.setProperty(context, IPropertiesAccessServiceConstants.PROP_DEFAULT_USER.equals(key) ? IPeer.ATTR_USER_NAME : key, value);
}
/* (non-Javadoc)
@@ -104,6 +104,6 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s
*/
@Override
public boolean isProperty(Object context, String key, Object value) {
- return super.isProperty(context, IPropertiesAccessServiceConstants.PROP_USER.equals(key) ? IPeer.ATTR_USER_NAME : key, value);
+ return super.isProperty(context, IPropertiesAccessServiceConstants.PROP_DEFAULT_USER.equals(key) ? IPeer.ATTR_USER_NAME : key, value);
}
}
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 aa9a6fcff..582e3e5bd 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
@@ -50,10 +50,12 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
@SuppressWarnings("restriction")
public class SshWizardConfigurationPanel extends AbstractConfigurationPanel implements IDataExchangeNode {
+ private static final String SAVE_USER = "saveUser"; //$NON-NLS-1$
private static final String SAVE_PASSWORD = "savePassword"; //$NON-NLS-1$
private SshSettings sshSettings;
private ISettingsPage sshSettingsPage;
+ private Button userButton;
private Button passwordButton;
/**
@@ -103,8 +105,8 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
// Create the encoding selection combo
createEncodingUI(panel, true);
- // if password for host should be saved or no
- createPasswordUI(panel, true);
+ // if user and password for host should be saved or not
+ createSaveButtonsUI(panel, true);
setControl(panel);
}
@@ -159,8 +161,8 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
Object element = ((IStructuredSelection) selection).getFirstElement();
IPropertiesAccessService service = ServiceManager.getInstance().getService(element, IPropertiesAccessService.class);
if (service != null) {
- Object user = service.getProperty(element, IPropertiesAccessServiceConstants.PROP_USER);
- if (user instanceof String) return (String) user;
+ Object user = service.getProperty(element, IPropertiesAccessServiceConstants.PROP_DEFAULT_USER);
+ if (user instanceof String) return ((String) user).trim();
}
}
@@ -192,7 +194,8 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
* @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
*/
@Override
- protected void fillSettingsForHost(String host){
+ protected void fillSettingsForHost(String host) {
+ boolean saveUser = true;
boolean savePassword = false;
if (host != null && host.length() != 0){
if (hostSettingsMap.containsKey(host)){
@@ -225,15 +228,20 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
}
String encoding = hostSettings.get(ITerminalsConnectorConstants.PROP_ENCODING);
- if (encoding == null || "null".equals(encoding)) encoding = "ISO-8859-1"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (encoding == null || "null".equals(encoding)) { //$NON-NLS-1$
+ String defaultEncoding = getSelectionEncoding();
+ encoding = defaultEncoding != null && !"".equals(defaultEncoding.trim()) ? defaultEncoding.trim() : "ISO-8859-1"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
setEncoding(encoding);
} else {
sshSettings.setHost(getSelectionHost());
sshSettings.setUser(getDefaultUser());
+ saveUser = true;
savePassword = false;
}
// set settings in page
sshSettingsPage.loadSettings();
+ userButton.setSelection(saveUser);
passwordButton.setSelection(savePassword);
}
}
@@ -251,7 +259,8 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
* @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
*/
@Override
- protected void saveSettingsForHost(boolean add){
+ protected void saveSettingsForHost(boolean add) {
+ boolean saveUser = userButton.getSelection();
boolean savePassword = passwordButton.getSelection();
String host = getHostFromSettings();
if (host != null && host.length() != 0) {
@@ -261,8 +270,27 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
- hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
- hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
+ if (saveUser) {
+ String defaultUser = getDefaultUser();
+ if (defaultUser == null || !defaultUser.equals(sshSettings.getUser())) {
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
+ } else {
+ hostSettings.remove(ITerminalsConnectorConstants.PROP_SSH_USER);
+ }
+ }
+ else {
+ hostSettings.remove(ITerminalsConnectorConstants.PROP_SSH_USER);
+ }
+
+ String encoding = getEncoding();
+ if (encoding != null) {
+ String defaultEncoding = getSelectionEncoding();
+ if (defaultEncoding != null && defaultEncoding.trim().equals(encoding)) {
+ encoding = null;
+ }
+ }
+ hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, encoding);
+ hostSettings.put(SAVE_USER, Boolean.toString(saveUser));
hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
@@ -270,17 +298,21 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
}
// maybe unchecked the password button - so try to remove a saved password - if any
- if (!savePassword){
- removeSecurePassword(host);
- }
+ if (!savePassword) removeSecurePassword(host);
} 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, Integer.toString(sshSettings.getPort()));
hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
- hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
+ if (saveUser) {
+ String defaultUser = getDefaultUser();
+ if (defaultUser == null || !defaultUser.equals(sshSettings.getUser())) {
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
+ }
+ }
hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
+ hostSettings.put(SAVE_USER, Boolean.toString(saveUser));
hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
hostSettingsMap.put(host, hostSettings);
@@ -380,7 +412,7 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
return sshSettings.getHost();
}
- private void createPasswordUI(final Composite parent, boolean separator) {
+ private void createSaveButtonsUI(final Composite parent, boolean separator) {
Assert.isNotNull(parent);
if (separator) {
@@ -389,14 +421,18 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
}
Composite panel = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, false);
+ GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
panel.setLayout(layout);
panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ userButton = new Button(panel, SWT.CHECK);
+ userButton.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
+ userButton.setText(Messages.SshWizardConfigurationPanel_saveUser);
+
passwordButton = new Button(panel, SWT.CHECK);
- passwordButton.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, true, false));
- passwordButton.setText(Messages.SshWizardConfigurationPanel_savePasword);
+ passwordButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ passwordButton.setText(Messages.SshWizardConfigurationPanel_savePassword);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java
index 5f57cd56d..436f8d58e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java
@@ -32,5 +32,6 @@ public class Messages extends NLS {
public static String SshLauncherDelegate_terminalTitle;
public static String SshLauncherDelegate_terminalTitle_default;
- public static String SshWizardConfigurationPanel_savePasword;
+ public static String SshWizardConfigurationPanel_saveUser;
+ public static String SshWizardConfigurationPanel_savePassword;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties
index c2d6e5b58..3cec1998b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties
@@ -10,4 +10,5 @@
SshLauncherDelegate_terminalTitle=SSH {0}@{1} ({2})
SshLauncherDelegate_terminalTitle_default=SSH Terminal
-SshWizardConfigurationPanel_savePasword=Save password
+SshWizardConfigurationPanel_saveUser=Save user
+SshWizardConfigurationPanel_savePassword=Save password
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java
index 7f88bdb52..46499b3bd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java
@@ -121,6 +121,25 @@ public abstract class AbstractConfigurationPanel extends AbstractWizardConfigura
return null;
}
+ /**
+ * Returns the default encoding based on the current selection.
+ *
+ * @return The default encoding or <code>null</code>.
+ */
+ public String getSelectionEncoding() {
+ ISelection selection = getSelection();
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ IPropertiesAccessService service = ServiceManager.getInstance().getService(element, IPropertiesAccessService.class);
+ if (service != null) {
+ Object encoding = service.getProperty(element, IPropertiesAccessServiceConstants.PROP_DEFAULT_ENCODING);
+ if (encoding instanceof String) return ((String) encoding).trim();
+ }
+ }
+
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
*/
@@ -508,6 +527,12 @@ public abstract class AbstractConfigurationPanel extends AbstractWizardConfigura
});
fillEncodingCombo();
+
+ // Apply any default encoding derived from the current selection
+ String defaultEncoding = getSelectionEncoding();
+ if (defaultEncoding != null && !"".equals(defaultEncoding)) { //$NON-NLS-1$
+ setEncoding(defaultEncoding);
+ }
}
/**

Back to the top