mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Terminal: Remove makeSettingsPage from ITerminalConnection interface
This commit is contained in:
parent
0a2f67ae84
commit
51b6685321
28 changed files with 164 additions and 407 deletions
|
@ -391,7 +391,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
|||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.makeSettingsPage();
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ import org.eclipse.osgi.util.NLS;
|
|||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
|
||||
import org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.terminal.connector.process.nls.Messages;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ILineSeparatorConstants;
|
||||
|
@ -256,11 +256,11 @@ public class ProcessConnector extends AbstractStreamsConnector {
|
|||
// ***** Process Connector settings handling *****
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#makeSettingsPage()
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#setDefaultSettings()
|
||||
*/
|
||||
@Override
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new ProcessSettingsPage(settings);
|
||||
public void setDefaultSettings() {
|
||||
settings.load(new NullSettingsStore());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -122,7 +122,7 @@ public class ProcessLauncherDelegate extends AbstractLauncherDelegate {
|
|||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.makeSettingsPage();
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ import java.io.OutputStream;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.terminal.connector.serial.activator.UIPlugin;
|
||||
|
@ -225,8 +225,8 @@ public class SerialConnector extends TerminalConnectorImpl {
|
|||
return fSettings;
|
||||
}
|
||||
@Override
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new SerialSettingsPage(fSettings);
|
||||
public void setDefaultSettings() {
|
||||
fSettings.load(new NullSettingsStore());
|
||||
}
|
||||
@Override
|
||||
public String getSettingsSummary() {
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2013 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following Wind River employees contributed to the Terminal component
|
||||
* that contains this file: Chris Thew, Fran Litterio, Stephen Lamb,
|
||||
* Helmut Haigermoser and Ted Williams.
|
||||
*
|
||||
* Contributors:
|
||||
* Michael Scharf (Wind River) - extracted from TerminalSettingsDlg
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.connector.serial.connector;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class SerialSettingsPage extends AbstractSettingsPage {
|
||||
private final SerialSettings fTerminalSettings;
|
||||
|
||||
public SerialSettingsPage(SerialSettings settings) {
|
||||
fTerminalSettings=settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSettings() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateSettings() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -144,7 +144,7 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate {
|
|||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.makeSettingsPage();
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
|
|
@ -9,17 +9,17 @@
|
|||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Martin Oberhuber (Wind River) - [225792] Rename SshConnector.getTelnetSettings() to getSshSettings()
|
||||
* Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
|
||||
* Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.connector.ssh.connector;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||
|
||||
import com.jcraft.jsch.ChannelShell;
|
||||
|
@ -40,15 +40,18 @@ public class SshConnector extends TerminalConnectorImpl {
|
|||
public SshConnector(SshSettings settings) {
|
||||
fSettings=settings;
|
||||
}
|
||||
public void initialize() throws Exception {
|
||||
@Override
|
||||
public void initialize() throws Exception {
|
||||
fJsch=new JSch();
|
||||
}
|
||||
public void connect(ITerminalControl control) {
|
||||
@Override
|
||||
public void connect(ITerminalControl control) {
|
||||
super.connect(control);
|
||||
fConnection = new SshConnection(this,control);
|
||||
fConnection.start();
|
||||
}
|
||||
synchronized public void doDisconnect() {
|
||||
@Override
|
||||
synchronized public void doDisconnect() {
|
||||
fConnection.disconnect();
|
||||
if (getInputStream() != null) {
|
||||
try {
|
||||
|
@ -66,7 +69,8 @@ public class SshConnector extends TerminalConnectorImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
@Override
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
if(fChannel!=null && (newWidth!=fWidth || newHeight!=fHeight)) {
|
||||
//avoid excessive communications due to change size requests by caching previous size
|
||||
fChannel.setPtySize(newWidth, newHeight, 8*newWidth, 8*newHeight);
|
||||
|
@ -77,7 +81,8 @@ public class SshConnector extends TerminalConnectorImpl {
|
|||
public InputStream getInputStream() {
|
||||
return fInputStream;
|
||||
}
|
||||
public OutputStream getTerminalToRemoteStream() {
|
||||
@Override
|
||||
public OutputStream getTerminalToRemoteStream() {
|
||||
return fOutputStream;
|
||||
}
|
||||
void setInputStream(InputStream inputStream) {
|
||||
|
@ -95,16 +100,20 @@ public class SshConnector extends TerminalConnectorImpl {
|
|||
public ISshSettings getSshSettings() {
|
||||
return fSettings;
|
||||
}
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new SshSettingsPage(fSettings);
|
||||
@Override
|
||||
public void setDefaultSettings() {
|
||||
fSettings.load(new NullSettingsStore());
|
||||
}
|
||||
public String getSettingsSummary() {
|
||||
@Override
|
||||
public String getSettingsSummary() {
|
||||
return fSettings.getSummary();
|
||||
}
|
||||
public void load(ISettingsStore store) {
|
||||
@Override
|
||||
public void load(ISettingsStore store) {
|
||||
fSettings.load(store);
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
@Override
|
||||
public void save(ISettingsStore store) {
|
||||
fSettings.save(store);
|
||||
}
|
||||
protected JSch getJsch() {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2015 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Mikhail Kalugin <fourdman@xored.com> - [201867] Improve Terminal SSH connection summary string
|
||||
|
@ -23,7 +23,8 @@ public class SshSettings implements ISshSettings {
|
|||
protected String fPort;
|
||||
protected String fTimeout;
|
||||
protected String fKeepalive;
|
||||
public String getHost() {
|
||||
@Override
|
||||
public String getHost() {
|
||||
return fHost;
|
||||
}
|
||||
|
||||
|
@ -31,7 +32,8 @@ public class SshSettings implements ISshSettings {
|
|||
fHost = strHost;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
@Override
|
||||
public String getSummary() {
|
||||
String settings = getUser()+'@'+getHost();
|
||||
if(getPort()!=22) {
|
||||
settings += ':' + getPort();
|
||||
|
@ -39,20 +41,21 @@ public class SshSettings implements ISshSettings {
|
|||
return settings;
|
||||
}
|
||||
|
||||
public void load(ISettingsStore store) {
|
||||
fHost = store.get("Host");//$NON-NLS-1$
|
||||
fUser = store.get("User");//$NON-NLS-1$
|
||||
@Override
|
||||
public void load(ISettingsStore store) {
|
||||
fHost = store.get("Host", "");//$NON-NLS-1$ //$NON-NLS-2$
|
||||
fUser = store.get("User", "");//$NON-NLS-1$ //$NON-NLS-2$
|
||||
// ISettingsStore providers have to make sure that
|
||||
// the password is not saved in some as plain text
|
||||
// on disk. [bug 313991]
|
||||
fPassword = store.get("Password");//$NON-NLS-1$
|
||||
fPort = store.get("Port");//$NON-NLS-1$
|
||||
fTimeout = store.get("Timeout");//$NON-NLS-1$
|
||||
fKeepalive = store.get("Keepalive");//$NON-NLS-1$
|
||||
// on disk. [bug 313991]
|
||||
fPassword = store.get("Password", "");//$NON-NLS-1$ //$NON-NLS-2$
|
||||
fPort = store.get("Port", "22");//$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$
|
||||
}
|
||||
|
||||
|
||||
public void save(ISettingsStore store) {
|
||||
@Override
|
||||
public void save(ISettingsStore store) {
|
||||
store.put("Host", fHost);//$NON-NLS-1$
|
||||
store.put("User", fUser);//$NON-NLS-1$
|
||||
store.put("Port", fPort);//$NON-NLS-1$
|
||||
|
@ -64,7 +67,8 @@ public class SshSettings implements ISshSettings {
|
|||
}
|
||||
|
||||
|
||||
public int getTimeout() {
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
try {
|
||||
return Integer.parseInt(fTimeout);
|
||||
} catch (NumberFormatException numberFormatException) {
|
||||
|
@ -78,8 +82,9 @@ public class SshSettings implements ISshSettings {
|
|||
public void setTimeout(String timeout) {
|
||||
fTimeout = timeout;
|
||||
}
|
||||
|
||||
public int getKeepalive() {
|
||||
|
||||
@Override
|
||||
public int getKeepalive() {
|
||||
try {
|
||||
return Integer.parseInt(fKeepalive);
|
||||
} catch (NumberFormatException numberFormatException) {
|
||||
|
@ -94,14 +99,16 @@ public class SshSettings implements ISshSettings {
|
|||
fKeepalive = keepalive;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
@Override
|
||||
public String getUser() {
|
||||
return fUser;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
fUser = user;
|
||||
}
|
||||
public int getPort() {
|
||||
@Override
|
||||
public int getPort() {
|
||||
try {
|
||||
return Integer.parseInt(fPort);
|
||||
} catch (NumberFormatException numberFormatException) {
|
||||
|
@ -117,7 +124,8 @@ public class SshSettings implements ISshSettings {
|
|||
fPort = port;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return fPassword;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
|
|||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.terminal.connector.ssh.connector.SshConnector;
|
||||
import org.eclipse.tm.terminal.connector.ssh.connector.SshSettings;
|
||||
import org.eclipse.tm.terminal.connector.ssh.connector.SshSettingsPage;
|
||||
import org.eclipse.tm.terminal.connector.ssh.nls.Messages;
|
||||
import org.eclipse.tm.terminal.view.core.TerminalContextPropertiesProviderFactory;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.ITerminalContextPropertiesProvider;
|
||||
|
@ -80,7 +81,7 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa
|
|||
sshSettings.setHost(getSelectionHost());
|
||||
sshSettings.setUser(getDefaultUser());
|
||||
|
||||
sshSettingsPage = conn.makeSettingsPage();
|
||||
sshSettingsPage = new SshSettingsPage(sshSettings);
|
||||
if (sshSettingsPage instanceof AbstractSettingsPage) {
|
||||
((AbstractSettingsPage)sshSettingsPage).setHasControlDecoration(true);
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
|
|||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.makeSettingsPage();
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,10 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||
|
||||
|
@ -47,7 +47,8 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
|||
public TelnetConnector(TelnetSettings settings) {
|
||||
fSettings=settings;
|
||||
}
|
||||
public void connect(ITerminalControl control) {
|
||||
@Override
|
||||
public void connect(ITerminalControl control) {
|
||||
super.connect(control);
|
||||
fWidth=-1;
|
||||
fHeight=-1;
|
||||
|
@ -56,7 +57,8 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
|||
TelnetConnectWorker worker = new TelnetConnectWorker(this,control);
|
||||
worker.start();
|
||||
}
|
||||
public void doDisconnect() {
|
||||
@Override
|
||||
public void doDisconnect() {
|
||||
if (getSocket() != null) {
|
||||
try {
|
||||
getSocket().close();
|
||||
|
@ -82,12 +84,14 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
|||
}
|
||||
cleanSocket();
|
||||
}
|
||||
public boolean isLocalEcho() {
|
||||
@Override
|
||||
public boolean isLocalEcho() {
|
||||
if(fTelnetConnection==null)
|
||||
return false;
|
||||
return fTelnetConnection.localEcho();
|
||||
}
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
@Override
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
if(fTelnetConnection!=null && (newWidth!=fWidth || newHeight!=fHeight)) {
|
||||
//avoid excessive communications due to change size requests by caching previous size
|
||||
fTelnetConnection.setTerminalSize(newWidth, newHeight);
|
||||
|
@ -98,7 +102,8 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
|||
public InputStream getInputStream() {
|
||||
return fInputStream;
|
||||
}
|
||||
public OutputStream getTerminalToRemoteStream() {
|
||||
@Override
|
||||
public OutputStream getTerminalToRemoteStream() {
|
||||
return fOutputStream;
|
||||
}
|
||||
private void setInputStream(InputStream inputStream) {
|
||||
|
@ -145,16 +150,20 @@ public class TelnetConnector extends TerminalConnectorImpl {
|
|||
public ITelnetSettings getTelnetSettings() {
|
||||
return fSettings;
|
||||
}
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new TelnetSettingsPage(fSettings);
|
||||
@Override
|
||||
public void setDefaultSettings() {
|
||||
fSettings.load(new NullSettingsStore());
|
||||
}
|
||||
public String getSettingsSummary() {
|
||||
@Override
|
||||
public String getSettingsSummary() {
|
||||
return fSettings.getSummary();
|
||||
}
|
||||
public void load(ISettingsStore store) {
|
||||
@Override
|
||||
public void load(ISettingsStore store) {
|
||||
fSettings.load(store);
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
@Override
|
||||
public void save(ISettingsStore store) {
|
||||
fSettings.save(store);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
|||
import org.eclipse.tm.terminal.connector.telnet.connector.NetworkPortMap;
|
||||
import org.eclipse.tm.terminal.connector.telnet.connector.TelnetConnector;
|
||||
import org.eclipse.tm.terminal.connector.telnet.connector.TelnetSettings;
|
||||
import org.eclipse.tm.terminal.connector.telnet.connector.TelnetSettingsPage;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
|
||||
import org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel;
|
||||
|
@ -31,7 +32,6 @@ import org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel
|
|||
/**
|
||||
* telnet wizard configuration panel implementation.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class TelnetWizardConfigurationPanel extends AbstractExtendedConfigurationPanel {
|
||||
|
||||
public TelnetSettings telnetSettings;
|
||||
|
@ -65,7 +65,7 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
|||
// MWE otherwise we don't get a valid default selection of the combo
|
||||
telnetSettings.setNetworkPort(NetworkPortMap.PROP_VALUETELNET);
|
||||
|
||||
telnetSettingsPage = conn.makeSettingsPage();
|
||||
telnetSettingsPage = new TelnetSettingsPage(telnetSettings);
|
||||
if (telnetSettingsPage instanceof AbstractSettingsPage) {
|
||||
((AbstractSettingsPage)telnetSettingsPage).setHasControlDecoration(true);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
|
|||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.makeSettingsPage();
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
|
|
@ -180,8 +180,9 @@ public class TerminalConnector implements ITerminalConnector {
|
|||
getConnectorImpl().load(store);
|
||||
}
|
||||
}
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return getConnectorImpl().makeSettingsPage();
|
||||
@Override
|
||||
public void setDefaultSettings() {
|
||||
getConnectorImpl().setDefaultSettings();
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
// no need to save the settings: it cannot have changed
|
||||
|
|
|
@ -132,18 +132,11 @@ public interface ITerminalConnector extends IAdaptable {
|
|||
* @param store
|
||||
*/
|
||||
void save(ISettingsStore store);
|
||||
|
||||
|
||||
/**
|
||||
* FIXME should not have UI related stuff in ITerminalConnector, since
|
||||
* connectors may be totally programmatic and UI-less. Better make the
|
||||
* connector adapt to an interface that controls the UI aspect.
|
||||
*
|
||||
* @return a new page that can be used in a dialog to setup this connection.
|
||||
* The dialog should persist its settings with the
|
||||
* {@link #load(ISettings)} and {@link #save(ISettings)}
|
||||
* methods.
|
||||
* Set or reset the settings store to the default values.
|
||||
*/
|
||||
ISettingsPage makeSettingsPage();
|
||||
void setDefaultSettings();
|
||||
|
||||
/**
|
||||
* @return A string that represents the settings of the connection. This representation
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2015 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.provisional.api;
|
||||
|
||||
/**
|
||||
* Uses an array of {@link ISettingsStore} to find a value.
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
|
||||
* of a work in progress. There is no guarantee that this API will work or that
|
||||
* it will remain the same. Please do not use this API without consulting with
|
||||
* the <a href="http://www.eclipse.org/tm/">Target Management</a> team.
|
||||
* </p>
|
||||
*/
|
||||
public class LayeredSettingsStore implements ISettingsStore {
|
||||
|
||||
private final ISettingsStore[] fStores;
|
||||
|
||||
/**
|
||||
* @param stores the stores used to search the values.
|
||||
* {@link #put(String, String)} will put the value in the
|
||||
* first store in the list.
|
||||
*/
|
||||
public LayeredSettingsStore(ISettingsStore[] stores) {
|
||||
fStores=stores;
|
||||
}
|
||||
/**
|
||||
* Convince constructor for two stores
|
||||
* @param s1 first store
|
||||
* @param s2 second store
|
||||
*/
|
||||
public LayeredSettingsStore(ISettingsStore s1, ISettingsStore s2) {
|
||||
this(new ISettingsStore[]{s1,s2});
|
||||
}
|
||||
public String get(String key) {
|
||||
for (int i = 0; i < fStores.length; i++) {
|
||||
String value=fStores[i].get(key);
|
||||
if(value!=null)
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String get(String key, String defaultValue) {
|
||||
String value=get(key);
|
||||
if ((value == null) || (value.equals(""))) //$NON-NLS-1$
|
||||
return defaultValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
public void put(String key, String value) {
|
||||
fStores[0].put(key,value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.provisional.api;
|
||||
|
||||
/**
|
||||
* A settings store implementation doing nothing.
|
||||
*/
|
||||
public class NullSettingsStore implements ISettingsStore {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#get(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String get(String key, String defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#put(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2015 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.provisional.api;
|
||||
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
|
||||
/**
|
||||
* A preference based settings store.
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
|
||||
* of a work in progress. There is no guarantee that this API will work or that
|
||||
* it will remain the same. Please do not use this API without consulting with
|
||||
* the <a href="http://www.eclipse.org/tm/">Target Management</a> team.
|
||||
* </p>
|
||||
*/
|
||||
public class PreferenceSettingStore implements ISettingsStore {
|
||||
private final String fPrefix;
|
||||
private final Preferences fPreferences;
|
||||
|
||||
/**
|
||||
* Creates a ISettingStore that uses the preferences as backend.
|
||||
*
|
||||
* @param preferences the backed.
|
||||
* @param prefix a string that is prepended to the key
|
||||
*/
|
||||
public PreferenceSettingStore(Preferences preferences, String prefix) {
|
||||
fPreferences=preferences;
|
||||
fPrefix=prefix;
|
||||
}
|
||||
public String get(String key) {
|
||||
return fPreferences.getString(makeKey(key));
|
||||
}
|
||||
public String get(String key, String defaultValue) {
|
||||
String value=get(key);
|
||||
if ((value == null) || (value.equals(""))) //$NON-NLS-1$
|
||||
return defaultValue;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public void put(String key, String value) {
|
||||
fPreferences.setValue(makeKey(key), value);
|
||||
}
|
||||
/**
|
||||
* @param key
|
||||
* @return the full path in the preferences
|
||||
*/
|
||||
private String makeKey(String key) {
|
||||
return fPrefix+key;
|
||||
}
|
||||
}
|
|
@ -105,17 +105,10 @@ public abstract class TerminalConnectorImpl {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a settings page for configuring this connector, or
|
||||
* <code>null</code> if it cannot be configured.
|
||||
*
|
||||
* The dialog should persist its settings with the
|
||||
* {@link #load(ISettings)} and {@link #save(ISettings)} methods.
|
||||
*
|
||||
* @return a new page that can be used in a dialog to setup this connection,
|
||||
* or <code>null</code>.
|
||||
* Set or reset the settings store to the default values.
|
||||
*/
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return null;
|
||||
public void setDefaultSettings() {
|
||||
// do nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,9 +116,8 @@ public abstract class TerminalConnectorImpl {
|
|||
* {@link #connect(ITerminalControl)}.
|
||||
*
|
||||
* Connectors that have nothing to configure do not need to implement this.
|
||||
* Those terminals that do have configuration (which they expose via
|
||||
* {@link #makeSettingsPage()} need to override this method to load
|
||||
* settings.
|
||||
* Those terminals that do have configuration need to override this method
|
||||
* to load settings.
|
||||
*
|
||||
* @param store a string based data store. Short keys like "foo" can be used
|
||||
* to store the state of the connection.
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.io.OutputStream;
|
|||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.terminal.remote.IRemoteSettings;
|
||||
|
@ -109,44 +110,16 @@ public class RemoteConnector extends TerminalConnectorImpl {
|
|||
return fOutputStream;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#initialize()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() throws Exception {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#load(org.eclipse.tm.internal.terminal.provisional
|
||||
* .api.ISettingsStore)
|
||||
*/
|
||||
@Override
|
||||
public void load(ISettingsStore store) {
|
||||
fSettings.load(store);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#makeSettingsPage()
|
||||
*/
|
||||
@Override
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new RemoteSettingsPage(fSettings);
|
||||
public void setDefaultSettings() {
|
||||
fSettings.load(new NullSettingsStore());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#save(org.eclipse.tm.internal.terminal.provisional
|
||||
* .api.ISettingsStore)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void save(ISettingsStore store) {
|
||||
fSettings.save(store);
|
||||
|
|
|
@ -39,8 +39,8 @@ public class RemoteSettings implements IRemoteSettings {
|
|||
* Load information into the RemoteSettings object.
|
||||
*/
|
||||
public void load(ISettingsStore store) {
|
||||
fRemoteServices = store.get(REMOTE_SERVICES);
|
||||
fConnectionName = store.get(CONNECTION_NAME);
|
||||
fRemoteServices = store.get(REMOTE_SERVICES, ""); //$NON-NLS-1$
|
||||
fConnectionName = store.get(CONNECTION_NAME, ""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -129,23 +129,6 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
|||
fLoadStore=store;
|
||||
}
|
||||
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new ISettingsPage(){
|
||||
public void createControl(Composite parent) {
|
||||
}
|
||||
public void loadSettings() {
|
||||
}
|
||||
public void saveSettings() {
|
||||
}
|
||||
public boolean validateSettings() {
|
||||
return false;
|
||||
}
|
||||
public void addListener(Listener listener) {
|
||||
}
|
||||
public void removeListener(Listener listener) {
|
||||
}};
|
||||
}
|
||||
|
||||
public void save(ISettingsStore store) {
|
||||
fSaveStore=store;
|
||||
}
|
||||
|
@ -264,10 +247,10 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
|||
assertSame(s,mock.fSaveStore);
|
||||
}
|
||||
|
||||
public void testMakeSettingsPage() {
|
||||
public void testSetDefaultSettings() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c = makeTerminalConnector(mock);
|
||||
assertNotNull(c.makeSettingsPage());
|
||||
c.setDefaultSettings();
|
||||
}
|
||||
|
||||
public void testSetTerminalSize() {
|
||||
|
|
|
@ -129,24 +129,6 @@ public class TerminalConnectorTest extends TestCase {
|
|||
fLoadStore=store;
|
||||
}
|
||||
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new ISettingsPage(){
|
||||
public void createControl(Composite parent) {
|
||||
}
|
||||
public void loadSettings() {
|
||||
}
|
||||
public void saveSettings() {
|
||||
}
|
||||
public boolean validateSettings() {
|
||||
return false;
|
||||
}
|
||||
public void addListener(Listener listener) {
|
||||
}
|
||||
public void removeListener(Listener listener) {
|
||||
}};
|
||||
|
||||
}
|
||||
|
||||
public void save(ISettingsStore store) {
|
||||
fSaveStore=store;
|
||||
}
|
||||
|
@ -243,10 +225,10 @@ public class TerminalConnectorTest extends TestCase {
|
|||
assertSame(s,mock.fSaveStore);
|
||||
}
|
||||
|
||||
public void testMakeSettingsPage() {
|
||||
public void testSetDefaultSettings() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName", false);
|
||||
assertNotNull(c.makeSettingsPage());
|
||||
c.setDefaultSettings();
|
||||
}
|
||||
|
||||
public void testSetTerminalSize() {
|
||||
|
|
|
@ -17,10 +17,10 @@ import java.io.FileNotFoundException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
|
||||
|
||||
|
@ -82,18 +82,15 @@ public class SpeedTestConnector extends TerminalConnectorImpl {
|
|||
return fSettings.getInputFile();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
//throw new RuntimeException("XXX problems\nSpeedTest\nXXX!");
|
||||
@Override
|
||||
public void setDefaultSettings() {
|
||||
fSettings.load(new NullSettingsStore());
|
||||
}
|
||||
|
||||
|
||||
public void load(ISettingsStore store) {
|
||||
fSettings.load(store);
|
||||
}
|
||||
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return new SpeedTestSettingsPage(fSettings);
|
||||
}
|
||||
|
||||
public void save(ISettingsStore store) {
|
||||
fSettings.save(store);
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ public class SpeedTestSettings {
|
|||
fInputFile = testFile;
|
||||
}
|
||||
public void load(ISettingsStore store) {
|
||||
fInputFile=store.get("inputFile");
|
||||
fBufferSize=store.get("bufferSize");
|
||||
fThrottle=store.get("throttle");
|
||||
fInputFile=store.get("inputFile", "");
|
||||
fBufferSize=store.get("bufferSize", "");
|
||||
fThrottle=store.get("throttle", "0");
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
store.put("inputFile", fInputFile);
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.speedtest;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
|
||||
|
||||
public class SpeedTestSettingsPage extends AbstractSettingsPage {
|
||||
final SpeedTestSettings fSettings;
|
||||
Text fInputFile;
|
||||
Text fBufferSize;
|
||||
private Text fThrottle;
|
||||
SpeedTestSettingsPage(SpeedTestSettings settings) {
|
||||
fSettings=settings;
|
||||
}
|
||||
public void createControl(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridLayout gridLayout = new GridLayout(2, false);
|
||||
|
||||
composite.setLayout(gridLayout);
|
||||
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
fInputFile=createTextField(composite, "Input File:");//$NON-NLS-1$
|
||||
fBufferSize=createTextField(composite, "Buffer Size:");//$NON-NLS-1$
|
||||
fThrottle=createTextField(composite, "Throttle:");//$NON-NLS-1$
|
||||
loadSettings();
|
||||
}
|
||||
private Text createTextField(Composite composite, String label) {
|
||||
new Label(composite, SWT.RIGHT).setText(label);
|
||||
Text text = new Text(composite, SWT.BORDER);
|
||||
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
return text;
|
||||
}
|
||||
|
||||
public void loadSettings() {
|
||||
setText(fInputFile, fSettings.getInputFile());
|
||||
setText(fBufferSize, fSettings.getBufferSizeString());
|
||||
setText(fThrottle, fSettings.getThrottleString());
|
||||
}
|
||||
private void setText(Text text, String value) {
|
||||
if(value==null)
|
||||
value="";
|
||||
text.setText(value);
|
||||
}
|
||||
|
||||
public void saveSettings() {
|
||||
fSettings.setInputFile(fInputFile.getText());
|
||||
fSettings.setBufferSizeString(fBufferSize.getText());
|
||||
fSettings.setThrottleString(fThrottle.getText());
|
||||
}
|
||||
|
||||
public boolean validateSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,6 +12,7 @@ package org.eclipse.tm.terminal.view.ui.streams;
|
|||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.NullSettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.ui.services.IDisposable;
|
||||
|
||||
|
@ -99,6 +100,11 @@ public class StreamsConnector extends AbstractStreamsConnector implements IDispo
|
|||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultSettings() {
|
||||
settings.load(new NullSettingsStore());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl#load(org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore)
|
||||
*/
|
||||
|
|
|
@ -103,7 +103,7 @@ public class StreamsLauncherDelegate extends AbstractLauncherDelegate {
|
|||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.makeSettingsPage();
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue