1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +02:00

Adapt fix for Bug 469415 (Allow user set the title explicitly) for all

existing connectors
This commit is contained in:
Uwe Stieber 2015-06-09 11:40:51 +02:00
parent 1489103f23
commit 468e07f062
6 changed files with 31 additions and 33 deletions

View file

@ -220,12 +220,17 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
* @return The terminal title string or <code>null</code>. * @return The terminal title string or <code>null</code>.
*/ */
private String getTerminalTitle(Map<String, Object> properties) { 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 { try {
String hostname = InetAddress.getLocalHost().getHostName(); String hostname = InetAddress.getLocalHost().getHostName();
if (hostname != null && !"".equals(hostname.trim())) { //$NON-NLS-1$ if (hostname != null && !"".equals(hostname.trim())) { //$NON-NLS-1$
return hostname; return hostname;
} }
} catch (UnknownHostException e) { /* ignored on purpose */ } } catch (UnknownHostException e) { /* ignored on purpose */ }
return "Local"; //$NON-NLS-1$ return "Local"; //$NON-NLS-1$
} }

View file

@ -43,9 +43,7 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
// The Remote terminal connection memento handler // The Remote terminal connection memento handler
private final IMementoHandler mementoHandler = new RemoteMementoHandler(); private final IMementoHandler mementoHandler = new RemoteMementoHandler();
/* /* (non-Javadoc)
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#needsUserConfiguration() * @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#needsUserConfiguration()
*/ */
@Override @Override
@ -53,22 +51,16 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
return true; return true;
} }
/* /* (non-Javadoc)
* (non-Javadoc) * @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.terminal.view.ui.interfaces.
* IConfigurationPanelContainer)
*/ */
@Override @Override
public IConfigurationPanel getPanel(IConfigurationPanelContainer container) { public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
return new RemoteWizardConfigurationPanel(container); return new RemoteWizardConfigurationPanel(container);
} }
/* /* (non-Javadoc)
* (non-Javadoc) * @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#execute(java.util.Map, org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#execute(java.util.Map,
* org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done)
*/ */
@Override @Override
public void execute(Map<String, Object> properties, ITerminalService.Done done) { 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>. * @return The terminal title string or <code>null</code>.
*/ */
private String getTerminalTitle(Map<String, Object> properties) { 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); String connection = (String) properties.get(IRemoteSettings.CONNECTION_NAME);
if (connection != null) { if (connection != null) {
@ -97,12 +93,11 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
String date = format.format(new Date(System.currentTimeMillis())); String date = format.format(new Date(System.currentTimeMillis()));
return NLS.bind(Messages.RemoteLauncherDelegate_terminalTitle, new String[] { connection, date }); return NLS.bind(Messages.RemoteLauncherDelegate_terminalTitle, new String[] { connection, date });
} }
return Messages.RemoteLauncherDelegate_terminalTitle_default; return Messages.RemoteLauncherDelegate_terminalTitle_default;
} }
/* /* (non-Javadoc)
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
@ -114,9 +109,7 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }
/* /* (non-Javadoc)
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map) * @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
*/ */
@Override @Override

View file

@ -83,6 +83,10 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate {
* @return The terminal title string or <code>null</code>. * @return The terminal title string or <code>null</code>.
*/ */
private String getTerminalTitle(Map<String, Object> properties) { 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); String device = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DEVICE);
if (device != null) { if (device != null) {
@ -90,6 +94,7 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate {
String date = format.format(new Date(System.currentTimeMillis())); String date = format.format(new Date(System.currentTimeMillis()));
return NLS.bind(Messages.SerialLauncherDelegate_terminalTitle, new String[]{device, date}); return NLS.bind(Messages.SerialLauncherDelegate_terminalTitle, new String[]{device, date});
} }
return Messages.SerialLauncherDelegate_terminalTitle_default; return Messages.SerialLauncherDelegate_terminalTitle_default;
} }

View file

@ -91,11 +91,9 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
* @return The terminal title string or <code>null</code>. * @return The terminal title string or <code>null</code>.
*/ */
private String getTerminalTitle(Map<String, Object> properties) { 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); String title = getDefaultTerminalTitle(properties);
if(title!=null){ if (title != null) return title;
return title;
}
//No title,try to calculate the title //No title,try to calculate the title
String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST); 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 NLS.bind(Messages.SshLauncherDelegate_terminalTitle, new String[]{user, host, date});
} }
return Messages.SshLauncherDelegate_terminalTitle_default; return Messages.SshLauncherDelegate_terminalTitle_default;
} }

View file

@ -85,16 +85,14 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
/** /**
* Returns the terminal title string. * Returns the terminal title string.
* <p> * <p>
* The default implementation constructs a title like &quot;SSH @ host (Start time) &quot;. * The default implementation constructs a title like &quot;Telnet @ host (Start time) &quot;.
* *
* @return The terminal title string or <code>null</code>. * @return The terminal title string or <code>null</code>.
*/ */
private String getTerminalTitle(Map<String, Object> properties) { 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); String title = getDefaultTerminalTitle(properties);
if(title!=null){ if (title != null) return title;
return title;
}
//No title,try to calculate the title //No title,try to calculate the title
String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST); 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())); String date = format.format(new Date(System.currentTimeMillis()));
return NLS.bind(Messages.TelnetLauncherDelegate_terminalTitle, new String[]{host, date}); return NLS.bind(Messages.TelnetLauncherDelegate_terminalTitle, new String[]{host, date});
} }
return Messages.TelnetLauncherDelegate_terminalTitle_default; return Messages.TelnetLauncherDelegate_terminalTitle_default;
} }

View file

@ -146,15 +146,12 @@ public abstract class AbstractLauncherDelegate extends PlatformObject implements
/** /**
* Get the title from the settings, and use it as the default title. * Get the title from the settings, and use it as the default title.
*
* @param properties the setting properties map. * @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. * @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) { protected String getDefaultTerminalTitle(Map<String, Object> properties) {
String title = (String)properties.get(ITerminalsConnectorConstants.PROP_TITLE); String title = (String)properties.get(ITerminalsConnectorConstants.PROP_TITLE);
return title != null ? title : null;
if (title != null) {
return title;
}
return null;
} }
} }