1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

SSH: Add the SSH port to the terminal title if different from the

default SSH port

Signed-off-by: Max Weninger <max.weninger@windriver.com>
This commit is contained in:
Max Weninger 2015-05-06 16:24:27 +02:00 committed by Uwe Stieber
parent 60e547451c
commit 71e04c4a86
7 changed files with 18 additions and 7 deletions

View file

@ -15,6 +15,9 @@ package org.eclipse.tm.terminal.connector.ssh.connector;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
public interface ISshSettings { public interface ISshSettings {
public static int DEFAULT_SSH_PORT = 22;
/** /**
* Get the host name or IP address of remote system to connect. * Get the host name or IP address of remote system to connect.
* @return host name or IP address of the remote system. * @return host name or IP address of the remote system.

View file

@ -98,7 +98,7 @@ public class SshConnection extends Thread {
public void run() { public void run() {
boolean connectSucceeded = false; boolean connectSucceeded = false;
String host = ""; //$NON-NLS-1$ String host = ""; //$NON-NLS-1$
int port = 22; int port = ISshSettings.DEFAULT_SSH_PORT;
try { try {
int nTimeout = fConn.getSshSettings().getTimeout() * 1000; int nTimeout = fConn.getSshSettings().getTimeout() * 1000;
int nKeepalive = fConn.getSshSettings().getKeepalive() * 1000; int nKeepalive = fConn.getSshSettings().getKeepalive() * 1000;
@ -110,7 +110,7 @@ public class SshConnection extends Thread {
////Giving a connectionId could be the index into a local ////Giving a connectionId could be the index into a local
////Store where passwords are stored ////Store where passwords are stored
//String connectionId = host; //String connectionId = host;
//if (port!=22) { //if (port!=ISshSettings.DEFAULT_SSH_PORT) {
// connectionId += ':' + port; // connectionId += ':' + port;
//} //}
//UserInfo ui=new MyUserInfo(connectionId, user, password); //UserInfo ui=new MyUserInfo(connectionId, user, password);
@ -175,7 +175,7 @@ public class SshConnection extends Thread {
} }
if (!connectSucceeded) { if (!connectSucceeded) {
String hostPort = host; String hostPort = host;
if (port != 22) { if (port != ISshSettings.DEFAULT_SSH_PORT) {
hostPort = hostPort + ':' + port; hostPort = hostPort + ':' + port;
} }
msg = NLS.bind(SshMessages.ERROR_CONNECTING, hostPort, msg); msg = NLS.bind(SshMessages.ERROR_CONNECTING, hostPort, msg);

View file

@ -35,7 +35,7 @@ public class SshSettings implements ISshSettings {
@Override @Override
public String getSummary() { public String getSummary() {
String settings = getUser()+'@'+getHost(); String settings = getUser()+'@'+getHost();
if(getPort()!=22) { if(getPort()!=ISshSettings.DEFAULT_SSH_PORT) {
settings += ':' + getPort(); settings += ':' + getPort();
} }
return settings; return settings;
@ -49,7 +49,7 @@ public class SshSettings implements ISshSettings {
// the password is not saved in some as plain text // the password is not saved in some as plain text
// on disk. [bug 313991] // on disk. [bug 313991]
fPassword = store.get("Password", "");//$NON-NLS-1$ //$NON-NLS-2$ fPassword = store.get("Password", "");//$NON-NLS-1$ //$NON-NLS-2$
fPort = store.get("Port", "22");//$NON-NLS-1$ //$NON-NLS-2$ fPort = store.get("Port", String.valueOf(ISshSettings.DEFAULT_SSH_PORT));//$NON-NLS-1$
fTimeout = store.get("Timeout", "0");//$NON-NLS-1$ //$NON-NLS-2$ fTimeout = store.get("Timeout", "0");//$NON-NLS-1$ //$NON-NLS-2$
fKeepalive = store.get("Keepalive", "300");//$NON-NLS-1$ //$NON-NLS-2$ fKeepalive = store.get("Keepalive", "300");//$NON-NLS-1$ //$NON-NLS-2$
} }
@ -112,7 +112,7 @@ public class SshSettings implements ISshSettings {
try { try {
return Integer.parseInt(fPort); return Integer.parseInt(fPort);
} catch (NumberFormatException numberFormatException) { } catch (NumberFormatException numberFormatException) {
return 22; return ISshSettings.DEFAULT_SSH_PORT;
} }
} }

View file

@ -54,7 +54,7 @@ public class SshSettingsPage extends AbstractSettingsPage {
fTimeout.setText(get(fTerminalSettings.getTimeoutString(),"0"));//$NON-NLS-1$ fTimeout.setText(get(fTerminalSettings.getTimeoutString(),"0"));//$NON-NLS-1$
fKeepalive.setText(get(fTerminalSettings.getKeepaliveString(),"300"));//$NON-NLS-1$ fKeepalive.setText(get(fTerminalSettings.getKeepaliveString(),"300"));//$NON-NLS-1$
fUser.setText(get(fTerminalSettings.getUser(),""));//$NON-NLS-1$ fUser.setText(get(fTerminalSettings.getUser(),""));//$NON-NLS-1$
fPort.setText(get(fTerminalSettings.getPortString(),"22"));//$NON-NLS-1$ fPort.setText(get(fTerminalSettings.getPortString(), String.valueOf(ISshSettings.DEFAULT_SSH_PORT)));
fPassword.setText(get(fTerminalSettings.getPassword(),""));//$NON-NLS-1$ fPassword.setText(get(fTerminalSettings.getPassword(),""));//$NON-NLS-1$
} }
} }

View file

@ -19,6 +19,7 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension; import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
import org.eclipse.tm.terminal.connector.ssh.connector.ISshSettings;
import org.eclipse.tm.terminal.connector.ssh.connector.SshSettings; import org.eclipse.tm.terminal.connector.ssh.connector.SshSettings;
import org.eclipse.tm.terminal.connector.ssh.controls.SshWizardConfigurationPanel; import org.eclipse.tm.terminal.connector.ssh.controls.SshWizardConfigurationPanel;
import org.eclipse.tm.terminal.connector.ssh.nls.Messages; import org.eclipse.tm.terminal.connector.ssh.nls.Messages;
@ -92,10 +93,15 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
private String getTerminalTitle(Map<String, Object> properties) { private String getTerminalTitle(Map<String, Object> properties) {
String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST); String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
String user = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER); String user = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER);
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
String port = value != null ? value.toString() : null;
if (host != null && user!= null) { if (host != null && user!= null) {
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
String date = format.format(new Date(System.currentTimeMillis())); String date = format.format(new Date(System.currentTimeMillis()));
if (port != null && Integer.valueOf(port).intValue() != ISshSettings.DEFAULT_SSH_PORT) {
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle_port, new String[]{user, host, port, date});
}
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle, new String[]{user, host, date}); return NLS.bind(Messages.SshLauncherDelegate_terminalTitle, new String[]{user, host, date});
} }
return Messages.SshLauncherDelegate_terminalTitle_default; return Messages.SshLauncherDelegate_terminalTitle_default;

View file

@ -31,6 +31,7 @@ public class Messages extends NLS {
// **** Declare externalized string id's down here ***** // **** Declare externalized string id's down here *****
public static String SshLauncherDelegate_terminalTitle; public static String SshLauncherDelegate_terminalTitle;
public static String SshLauncherDelegate_terminalTitle_port;
public static String SshLauncherDelegate_terminalTitle_default; public static String SshLauncherDelegate_terminalTitle_default;
public static String SshWizardConfigurationPanel_saveUser; public static String SshWizardConfigurationPanel_saveUser;
public static String SshWizardConfigurationPanel_savePassword; public static String SshWizardConfigurationPanel_savePassword;

View file

@ -9,6 +9,7 @@
############################################################################### ###############################################################################
SshLauncherDelegate_terminalTitle=SSH {0}@{1} ({2}) SshLauncherDelegate_terminalTitle=SSH {0}@{1} ({2})
SshLauncherDelegate_terminalTitle_port=SSH {0}@{1}:{2} ({3})
SshLauncherDelegate_terminalTitle_default=SSH Terminal SshLauncherDelegate_terminalTitle_default=SSH Terminal
SshWizardConfigurationPanel_saveUser=Save user SshWizardConfigurationPanel_saveUser=Save user
SshWizardConfigurationPanel_savePassword=Save password SshWizardConfigurationPanel_savePassword=Save password