mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
Adapt fix for Bug 469415 (Allow user set the title explicitly) for all
existing connectors
This commit is contained in:
parent
1489103f23
commit
468e07f062
6 changed files with 31 additions and 33 deletions
|
@ -220,12 +220,17 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
|||
* @return The terminal title string or <code>null</code>.
|
||||
*/
|
||||
private String getTerminalTitle(Map<String, Object> properties) {
|
||||
// Try to see if the user set a title explicitly via the properties map.
|
||||
String title = getDefaultTerminalTitle(properties);
|
||||
if (title != null) return title;
|
||||
|
||||
try {
|
||||
String hostname = InetAddress.getLocalHost().getHostName();
|
||||
if (hostname != null && !"".equals(hostname.trim())) { //$NON-NLS-1$
|
||||
return hostname;
|
||||
}
|
||||
} catch (UnknownHostException e) { /* ignored on purpose */ }
|
||||
|
||||
return "Local"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
|||
// The Remote terminal connection memento handler
|
||||
private final IMementoHandler mementoHandler = new RemoteMementoHandler();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#needsUserConfiguration()
|
||||
*/
|
||||
@Override
|
||||
|
@ -53,22 +51,16 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.terminal.view.ui.interfaces.
|
||||
* IConfigurationPanelContainer)
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer)
|
||||
*/
|
||||
@Override
|
||||
public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
|
||||
return new RemoteWizardConfigurationPanel(container);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#execute(java.util.Map,
|
||||
* org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done)
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#execute(java.util.Map, org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done)
|
||||
*/
|
||||
@Override
|
||||
public void execute(Map<String, Object> properties, ITerminalService.Done done) {
|
||||
|
@ -90,6 +82,10 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
|||
* @return The terminal title string or <code>null</code>.
|
||||
*/
|
||||
private String getTerminalTitle(Map<String, Object> properties) {
|
||||
// Try to see if the user set a title explicitly via the properties map.
|
||||
String title = getDefaultTerminalTitle(properties);
|
||||
if (title != null) return title;
|
||||
|
||||
String connection = (String) properties.get(IRemoteSettings.CONNECTION_NAME);
|
||||
|
||||
if (connection != null) {
|
||||
|
@ -97,12 +93,11 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
|||
String date = format.format(new Date(System.currentTimeMillis()));
|
||||
return NLS.bind(Messages.RemoteLauncherDelegate_terminalTitle, new String[] { connection, date });
|
||||
}
|
||||
|
||||
return Messages.RemoteLauncherDelegate_terminalTitle_default;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
|
@ -114,9 +109,7 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
|||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -83,6 +83,10 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate {
|
|||
* @return The terminal title string or <code>null</code>.
|
||||
*/
|
||||
private String getTerminalTitle(Map<String, Object> properties) {
|
||||
// Try to see if the user set a title explicitly via the properties map.
|
||||
String title = getDefaultTerminalTitle(properties);
|
||||
if (title != null) return title;
|
||||
|
||||
String device = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DEVICE);
|
||||
|
||||
if (device != null) {
|
||||
|
@ -90,6 +94,7 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate {
|
|||
String date = format.format(new Date(System.currentTimeMillis()));
|
||||
return NLS.bind(Messages.SerialLauncherDelegate_terminalTitle, new String[]{device, date});
|
||||
}
|
||||
|
||||
return Messages.SerialLauncherDelegate_terminalTitle_default;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,11 +91,9 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
|||
* @return The terminal title string or <code>null</code>.
|
||||
*/
|
||||
private String getTerminalTitle(Map<String, Object> properties) {
|
||||
//Try to see if the user set a title explicitly via the properties map.
|
||||
// Try to see if the user set a title explicitly via the properties map.
|
||||
String title = getDefaultTerminalTitle(properties);
|
||||
if(title!=null){
|
||||
return title;
|
||||
}
|
||||
if (title != null) return title;
|
||||
|
||||
//No title,try to calculate the title
|
||||
String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||
|
@ -111,6 +109,7 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
|||
}
|
||||
return NLS.bind(Messages.SshLauncherDelegate_terminalTitle, new String[]{user, host, date});
|
||||
}
|
||||
|
||||
return Messages.SshLauncherDelegate_terminalTitle_default;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,16 +85,14 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
|||
/**
|
||||
* Returns the terminal title string.
|
||||
* <p>
|
||||
* The default implementation constructs a title like "SSH @ host (Start time) ".
|
||||
* The default implementation constructs a title like "Telnet @ host (Start time) ".
|
||||
*
|
||||
* @return The terminal title string or <code>null</code>.
|
||||
*/
|
||||
private String getTerminalTitle(Map<String, Object> properties) {
|
||||
//Try to see if the user set a title explicitly via the properties map.
|
||||
// Try to see if the user set a title explicitly via the properties map.
|
||||
String title = getDefaultTerminalTitle(properties);
|
||||
if(title!=null){
|
||||
return title;
|
||||
}
|
||||
if (title != null) return title;
|
||||
|
||||
//No title,try to calculate the title
|
||||
String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
|
||||
|
@ -104,6 +102,7 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
|||
String date = format.format(new Date(System.currentTimeMillis()));
|
||||
return NLS.bind(Messages.TelnetLauncherDelegate_terminalTitle, new String[]{host, date});
|
||||
}
|
||||
|
||||
return Messages.TelnetLauncherDelegate_terminalTitle_default;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,15 +146,12 @@ public abstract class AbstractLauncherDelegate extends PlatformObject implements
|
|||
|
||||
/**
|
||||
* Get the title from the settings, and use it as the default title.
|
||||
*
|
||||
* @param properties the setting properties map.
|
||||
* @return the value retrieved via the @see {@link ITerminalsConnectorConstants#PROP_TITLE}, or null if the key hasn't been set.
|
||||
*/
|
||||
protected String getDefaultTerminalTitle(Map<String, Object> properties) {
|
||||
String title = (String)properties.get(ITerminalsConnectorConstants.PROP_TITLE);
|
||||
|
||||
if (title != null) {
|
||||
return title;
|
||||
}
|
||||
return null;
|
||||
return title != null ? title : null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue