mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 22:55:26 +02:00
bug 200541: [terminal][api] TerminalConnectorProxy class should be removed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=200541 The attached patch contains the following changes: - ITerminalConnectorInfo is gone - ITerminalConnector is now the client interface - the implmentation is in org.eclipse.tm.internal.terminal.connector.TerminalConnector (was TerminalConnectorExtension.TerminalConnectorProxy) - TerminalConnector is adaptable and can be adapted to the TerminalConnectorImpl - the terminalConnector extension now requires extensions to implement TerminalConnectorImpl (was ITerminalConnector before) - a test added for TerminalConnector
This commit is contained in:
parent
bb8d4a18c5
commit
c91dfb4717
24 changed files with 690 additions and 308 deletions
|
@ -30,12 +30,12 @@ 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.ITerminalConnector;
|
||||
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.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
public class SerialConnector implements ITerminalConnector {
|
||||
public class SerialConnector extends TerminalConnectorImpl {
|
||||
private OutputStream fOutputStream;
|
||||
private InputStream fInputStream;
|
||||
private ITerminalControl fControl;
|
||||
|
|
|
@ -16,15 +16,15 @@ 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.ITerminalConnector;
|
||||
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.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
import com.jcraft.jsch.ChannelShell;
|
||||
import com.jcraft.jsch.JSch;
|
||||
|
||||
public class SshConnector implements ITerminalConnector {
|
||||
public class SshConnector extends TerminalConnectorImpl {
|
||||
private OutputStream fOutputStream;
|
||||
private InputStream fInputStream;
|
||||
private ITerminalControl fControl;
|
||||
|
|
|
@ -23,12 +23,12 @@ 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.ITerminalConnector;
|
||||
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.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
public class TelnetConnector implements ITerminalConnector {
|
||||
public class TelnetConnector extends TerminalConnectorImpl {
|
||||
private OutputStream fOutputStream;
|
||||
private InputStream fInputStream;
|
||||
private Socket fSocket;
|
||||
|
|
|
@ -8,7 +8,8 @@ Bundle-Localization: plugin
|
|||
Require-Bundle: org.junit,
|
||||
org.eclipse.tm.terminal,
|
||||
org.eclipse.swt,
|
||||
org.eclipse.jface
|
||||
org.eclipse.jface,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||
Export-Package: org.eclipse.tm.internal.terminal.emulator;x-internal:=true,
|
||||
org.eclipse.tm.internal.terminal.model;x-internal:=true,
|
||||
|
|
|
@ -0,0 +1,255 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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.connector;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.tm.internal.terminal.connector.TerminalConnector.Factory;
|
||||
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.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
public class TerminalConnectorTest extends TestCase {
|
||||
public class SettingsMock implements ISettingsStore {
|
||||
|
||||
public String get(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String get(String key, String defaultValue) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(String key, String value) {
|
||||
}
|
||||
|
||||
}
|
||||
public static class TerminalControlMock implements ITerminalControl {
|
||||
|
||||
public void displayTextInTerminal(String text) {
|
||||
}
|
||||
|
||||
public OutputStream getRemoteToTerminalOutputStream() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Shell getShell() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TerminalState getState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
}
|
||||
|
||||
public void setState(TerminalState state) {
|
||||
}
|
||||
|
||||
public void setTerminalTitle(String title) {
|
||||
}
|
||||
|
||||
}
|
||||
static class ConnectorMock extends TerminalConnectorImpl {
|
||||
|
||||
public boolean fEcho;
|
||||
public int fWidth;
|
||||
public int fHeight;
|
||||
public ITerminalControl fControl;
|
||||
public ISettingsStore fSaveStore;
|
||||
public ISettingsStore fLoadStore;
|
||||
public boolean fDisconnect;
|
||||
|
||||
public boolean isLocalEcho() {
|
||||
return fEcho;
|
||||
}
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
fWidth=newWidth;
|
||||
fHeight=newHeight;
|
||||
}
|
||||
public void connect(ITerminalControl control) {
|
||||
fControl=control;
|
||||
}
|
||||
public void disconnect() {
|
||||
fDisconnect=true;
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSettingsSummary() {
|
||||
return "Summary";
|
||||
}
|
||||
|
||||
public void load(ISettingsStore store) {
|
||||
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 save(ISettingsStore store) {
|
||||
fSaveStore=store;
|
||||
}
|
||||
}
|
||||
static class SimpleFactory implements Factory {
|
||||
final TerminalConnectorImpl fConnector;
|
||||
public SimpleFactory(TerminalConnectorImpl connector) {
|
||||
fConnector = connector;
|
||||
}
|
||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return fConnector;
|
||||
}
|
||||
}
|
||||
public void testGetInitializationErrorMessage() {
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
|
||||
c.connect(new TerminalControlMock());
|
||||
assertNull(c.getInitializationErrorMessage());
|
||||
|
||||
c=new TerminalConnector(new SimpleFactory(new ConnectorMock(){
|
||||
public void initialize() throws Exception {
|
||||
throw new Exception("FAILED");
|
||||
}}),"xID","xName");
|
||||
c.connect(new TerminalControlMock());
|
||||
assertEquals("FAILED",c.getInitializationErrorMessage());
|
||||
|
||||
}
|
||||
|
||||
public void testGetIdAndName() {
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
|
||||
assertEquals("xID", c.getId());
|
||||
assertEquals("xName", c.getName());
|
||||
}
|
||||
|
||||
public void testIsInitialized() {
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
|
||||
assertFalse(c.isInitialized());
|
||||
c.getId();
|
||||
assertFalse(c.isInitialized());
|
||||
c.getName();
|
||||
assertFalse(c.isInitialized());
|
||||
c.getSettingsSummary();
|
||||
assertFalse(c.isInitialized());
|
||||
c.setTerminalSize(10,10);
|
||||
assertFalse(c.isInitialized());
|
||||
c.load(null);
|
||||
assertFalse(c.isInitialized());
|
||||
c.save(null);
|
||||
assertFalse(c.isInitialized());
|
||||
c.getAdapter(ConnectorMock.class);
|
||||
assertFalse(c.isInitialized());
|
||||
}
|
||||
|
||||
public void testConnect() {
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
|
||||
assertFalse(c.isInitialized());
|
||||
c.connect(new TerminalControlMock());
|
||||
assertTrue(c.isInitialized());
|
||||
|
||||
}
|
||||
|
||||
public void testDisconnect() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
TerminalControlMock control=new TerminalControlMock();
|
||||
c.connect(control);
|
||||
c.disconnect();
|
||||
assertTrue(mock.fDisconnect);
|
||||
}
|
||||
|
||||
public void testGetTerminalToRemoteStream() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
TerminalControlMock control=new TerminalControlMock();
|
||||
c.connect(control);
|
||||
assertSame(mock.fControl,control);
|
||||
}
|
||||
|
||||
public void testGetSettingsSummary() {
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
|
||||
assertEquals("Not Initialized", c.getSettingsSummary());
|
||||
c.connect(new TerminalControlMock());
|
||||
assertEquals("Summary", c.getSettingsSummary());
|
||||
}
|
||||
|
||||
public void testIsLocalEcho() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
assertFalse(c.isLocalEcho());
|
||||
mock.fEcho=true;
|
||||
assertTrue(c.isLocalEcho());
|
||||
}
|
||||
|
||||
public void testLoad() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
ISettingsStore s=new SettingsMock();
|
||||
c.load(s);
|
||||
// the load is called after the connect...
|
||||
assertNull(mock.fLoadStore);
|
||||
c.connect(new TerminalControlMock());
|
||||
assertSame(s,mock.fLoadStore);
|
||||
}
|
||||
|
||||
public void testSave() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
ISettingsStore s=new SettingsMock();
|
||||
c.save(s);
|
||||
assertNull(mock.fSaveStore);
|
||||
c.connect(new TerminalControlMock());
|
||||
c.save(s);
|
||||
assertSame(s,mock.fSaveStore);
|
||||
}
|
||||
|
||||
public void testMakeSettingsPage() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
assertNotNull(c.makeSettingsPage());
|
||||
}
|
||||
|
||||
public void testSetTerminalSize() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
c.setTerminalSize(100, 200);
|
||||
|
||||
}
|
||||
|
||||
public void testGetAdapter() {
|
||||
ConnectorMock mock=new ConnectorMock();
|
||||
TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
|
||||
assertNull(c.getAdapter(ConnectorMock.class));
|
||||
// the load is called after the connect...
|
||||
c.connect(new TerminalControlMock());
|
||||
|
||||
assertSame(mock, c.getAdapter(ConnectorMock.class));
|
||||
}
|
||||
|
||||
}
|
|
@ -18,12 +18,12 @@ 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.ITerminalConnector;
|
||||
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.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
public class SpeedTestConnector implements ITerminalConnector {
|
||||
public class SpeedTestConnector extends TerminalConnectorImpl {
|
||||
final SpeedTestSettings fSettings=new SpeedTestSettings();
|
||||
InputStream fInputStream;
|
||||
OutputStream fOutputStream;
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.io.OutputStream;
|
|||
|
||||
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
|
||||
import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.terminal.model.ITerminalTextData;
|
||||
|
||||
|
@ -89,7 +89,7 @@ final class VT100DataSource implements IDataSource {
|
|||
return TerminalState.CONNECTED;
|
||||
}
|
||||
|
||||
public ITerminalConnectorInfo getTerminalConnectorInfo() {
|
||||
public ITerminalConnector getTerminalConnector() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@ import org.eclipse.swt.widgets.Label;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
|
||||
class TerminalSettingsDlg extends Dialog {
|
||||
private Combo fCtlConnTypeCombo;
|
||||
private Text fTerminalTitleText;
|
||||
private final ITerminalConnectorInfo[] fConnectors;
|
||||
private final ITerminalConnector[] fConnectors;
|
||||
private final ISettingsPage[] fPages;
|
||||
/**
|
||||
* Maps the fConnectors index to the fPages index
|
||||
|
@ -58,7 +58,7 @@ class TerminalSettingsDlg extends Dialog {
|
|||
private IDialogSettings fDialogSettings;
|
||||
private String fTerminalTitle;
|
||||
|
||||
public TerminalSettingsDlg(Shell shell, ITerminalConnectorInfo[] connectors, ITerminalConnectorInfo connector) {
|
||||
public TerminalSettingsDlg(Shell shell, ITerminalConnector[] connectors, ITerminalConnector connector) {
|
||||
super(shell);
|
||||
fConnectors=getValidConnectors(connectors);
|
||||
fPages=new ISettingsPage[fConnectors.length];
|
||||
|
@ -73,21 +73,21 @@ class TerminalSettingsDlg extends Dialog {
|
|||
* @param connectors
|
||||
* @return connectors excluding connectors with errors
|
||||
*/
|
||||
private ITerminalConnectorInfo[] getValidConnectors(ITerminalConnectorInfo[] connectors) {
|
||||
private ITerminalConnector[] getValidConnectors(ITerminalConnector[] connectors) {
|
||||
List list=new ArrayList(Arrays.asList(connectors));
|
||||
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
|
||||
ITerminalConnectorInfo info = (ITerminalConnectorInfo) iterator.next();
|
||||
ITerminalConnector info = (ITerminalConnector) iterator.next();
|
||||
if(info.isInitialized() && info.getInitializationErrorMessage()!=null)
|
||||
iterator.remove();
|
||||
}
|
||||
connectors=(ITerminalConnectorInfo[]) list.toArray(new ITerminalConnectorInfo[list.size()]);
|
||||
connectors=(ITerminalConnector[]) list.toArray(new ITerminalConnector[list.size()]);
|
||||
return connectors;
|
||||
}
|
||||
ISettingsPage getPage(int i) {
|
||||
if(fPages[i]==null) {
|
||||
if(fConnectors[i].getInitializationErrorMessage()!=null) {
|
||||
// create a error message
|
||||
final ITerminalConnectorInfo conn=fConnectors[i];
|
||||
final ITerminalConnector conn=fConnectors[i];
|
||||
fPages[i]=new ISettingsPage(){
|
||||
public void createControl(Composite parent) {
|
||||
Label l=new Label(parent,SWT.WRAP);
|
||||
|
@ -105,7 +105,7 @@ class TerminalSettingsDlg extends Dialog {
|
|||
public boolean validateSettings() {return false;}
|
||||
};
|
||||
} else {
|
||||
fPages[i]=fConnectors[i].getConnector().makeSettingsPage();
|
||||
fPages[i]=fConnectors[i].makeSettingsPage();
|
||||
}
|
||||
// TODO: what happens if an error occurs while
|
||||
// the control is partly created?
|
||||
|
@ -245,7 +245,7 @@ class TerminalSettingsDlg extends Dialog {
|
|||
}
|
||||
});
|
||||
}
|
||||
public ITerminalConnectorInfo getConnector() {
|
||||
public ITerminalConnector getConnector() {
|
||||
if(fSelectedConnector>=0)
|
||||
return fConnectors[fSelectedConnector];
|
||||
return null;
|
||||
|
|
|
@ -56,7 +56,7 @@ import org.eclipse.tm.internal.terminal.control.ITerminalListener;
|
|||
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
|
||||
import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
@ -211,7 +211,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
//if (isConnected())
|
||||
if (fCtlTerminal.getState()!=TerminalState.CLOSED)
|
||||
return;
|
||||
if(fCtlTerminal.getTerminalConnectorInfo()==null)
|
||||
if(fCtlTerminal.getTerminalConnector()==null)
|
||||
setConnector(showSettingsDialog());
|
||||
fCtlTerminal.connectTerminal();
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
}
|
||||
|
||||
public void onTerminalSettings() {
|
||||
ITerminalConnectorInfo c=showSettingsDialog();
|
||||
ITerminalConnector c=showSettingsDialog();
|
||||
if(c!=null) {
|
||||
setConnector(c);
|
||||
|
||||
|
@ -254,11 +254,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
}
|
||||
}
|
||||
|
||||
private ITerminalConnectorInfo showSettingsDialog() {
|
||||
private ITerminalConnector showSettingsDialog() {
|
||||
// When the settings dialog is opened, load the Terminal settings from the
|
||||
// persistent settings.
|
||||
|
||||
TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnectorInfo());
|
||||
TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector());
|
||||
dlgTerminalSettings.setTerminalTitle(getPartName());
|
||||
Logger.log("opening Settings dialog."); //$NON-NLS-1$
|
||||
|
||||
|
@ -276,7 +276,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
return dlgTerminalSettings.getConnector();
|
||||
}
|
||||
|
||||
private void setConnector(ITerminalConnectorInfo connector) {
|
||||
private void setConnector(ITerminalConnector connector) {
|
||||
fCtlTerminal.setConnector(connector);
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
// display in the view's content description line. This is used by class
|
||||
// TerminalText when it processes an ANSI OSC escape sequence that commands
|
||||
// the terminal to display text in its title bar.
|
||||
} else if(fCtlTerminal.getTerminalConnectorInfo()==null){
|
||||
} else if(fCtlTerminal.getTerminalConnector()==null){
|
||||
strTitle=ViewMessages.NO_CONNECTION_SELECTED;
|
||||
} else {
|
||||
// When parameter 'data' is null, we construct a descriptive string to
|
||||
|
@ -307,7 +307,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
//In order to make the logic of assembling, and the separators, better adapt to foreign languages
|
||||
if(summary.length()>0)
|
||||
summary=summary+" - "; //$NON-NLS-1$
|
||||
String name=fCtlTerminal.getTerminalConnectorInfo().getName();
|
||||
String name=fCtlTerminal.getTerminalConnector().getName();
|
||||
if(name.length()>0) {
|
||||
name+=": "; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
// TODO: use another mechanism than "?" for the magic non initialized state
|
||||
// see TerminalConnectorProxy.getSettingsSummary
|
||||
String summary="?"; //$NON-NLS-1$
|
||||
if(fCtlTerminal.getTerminalConnectorInfo()!=null)
|
||||
if(fCtlTerminal.getTerminalConnector()!=null)
|
||||
summary=fCtlTerminal.getSettingsSummary();
|
||||
if("?".equals(summary)) { //$NON-NLS-1$
|
||||
summary=fStore.get(STORE_SETTING_SUMMARY, ""); //$NON-NLS-1$
|
||||
|
@ -451,11 +451,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
* This method creates the top-level control for the Terminal view.
|
||||
*/
|
||||
protected void setupControls(Composite wndParent) {
|
||||
ITerminalConnectorInfo[] connectors=TerminalConnectorExtension.getTerminalConnectors();
|
||||
ITerminalConnector[] connectors = makeConnectors();
|
||||
fCtlTerminal = TerminalViewControlFactory.makeControl(this, wndParent, connectors);
|
||||
String connectionType=fStore.get(STORE_CONNECTION_TYPE);
|
||||
for (int i = 0; i < connectors.length; i++) {
|
||||
connectors[i].getConnector().load(getStore(connectors[i]));
|
||||
connectors[i].load(getStore(connectors[i]));
|
||||
if(connectors[i].getId().equals(connectionType))
|
||||
fCtlTerminal.setConnector(connectors[i]);
|
||||
}
|
||||
|
@ -469,10 +469,18 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
setPartName(title);
|
||||
}
|
||||
|
||||
private void saveSettings(ITerminalConnectorInfo connector) {
|
||||
ITerminalConnectorInfo[] connectors=fCtlTerminal.getConnectors();
|
||||
/**
|
||||
* @return a list of connectors this view can use
|
||||
*/
|
||||
protected ITerminalConnector[] makeConnectors() {
|
||||
ITerminalConnector[] connectors=TerminalConnectorExtension.makeTerminalConnectors();
|
||||
return connectors;
|
||||
}
|
||||
|
||||
private void saveSettings(ITerminalConnector connector) {
|
||||
ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
|
||||
for (int i = 0; i < connectors.length; i++) {
|
||||
connectors[i].getConnector().save(getStore(connectors[i]));
|
||||
connectors[i].save(getStore(connectors[i]));
|
||||
}
|
||||
if(connector!=null) {
|
||||
fStore.put(STORE_CONNECTION_TYPE,connector.getId());
|
||||
|
@ -493,7 +501,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
fStore.put(STORE_TITLE,getPartName());
|
||||
fStore.saveState(memento);
|
||||
}
|
||||
private ISettingsStore getStore(ITerminalConnectorInfo connector) {
|
||||
private ISettingsStore getStore(ITerminalConnector connector) {
|
||||
return new SettingStorePrefixDecorator(fStore,connector.getId()+"."); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,16 @@ Bundle-ActivationPolicy: lazy
|
|||
Eclipse-LazyStart: true
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||
Bundle-ClassPath: .
|
||||
Export-Package: org.eclipse.tm.internal.terminal.control;x-friends:="org.eclipse.tm.terminal.view",
|
||||
Export-Package: org.eclipse.tm.internal.terminal.connector;x-friends:="org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.internal.terminal.control;x-friends:="org.eclipse.tm.terminal.view",
|
||||
org.eclipse.tm.internal.terminal.control.impl;x-friends:="org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.internal.terminal.emulator;x-friends:="org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.internal.terminal.model;x-friends:="org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.internal.terminal.provisional.api;x-friends:="org.eclipse.tm.terminal.serial,org.eclipse.tm.terminal.ssh,org.eclipse.tm.terminal.telnet,org.eclipse.tm.terminal.view,org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.internal.terminal.provisional.api;
|
||||
x-friends:="org.eclipse.tm.terminal.serial,
|
||||
org.eclipse.tm.terminal.ssh,
|
||||
org.eclipse.tm.terminal.telnet,
|
||||
org.eclipse.tm.terminal.view,
|
||||
org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.internal.terminal.textcanvas;x-friends:="org.eclipse.tm.terminal.test",
|
||||
org.eclipse.tm.terminal.model
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.tm.terminal" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.tm.terminal" id="terminalConnector" name="TerminalConnector"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
|
@ -34,9 +34,9 @@
|
|||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
|
@ -49,9 +49,9 @@
|
|||
<documentation>
|
||||
A class implementing ITerminalConnector
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector"/>
|
||||
</appInfo>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorImpl:"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string" use="required">
|
||||
|
@ -66,9 +66,9 @@
|
|||
<documentation>
|
||||
The name of the connection (used in the UI)
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
|
@ -78,11 +78,10 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
|
|
|
@ -0,0 +1,190 @@
|
|||
package org.eclipse.tm.internal.terminal.connector;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages;
|
||||
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.ITerminalConnector;
|
||||
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.TerminalConnectorImpl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
/**
|
||||
* A placeholder for the ITerminalConnector. It gets initialized when
|
||||
* the real connector is needed.
|
||||
* The following methods can be called without initializing
|
||||
* the contributed class: {@link #getId()}, {@link #getName()},
|
||||
* {@link #getSettingsSummary()},{@link #load(ISettingsStore)},
|
||||
* {@link #setTerminalSize(int, int)}, {@link #save(ISettingsStore)},
|
||||
* {@link #getAdapter(Class)}
|
||||
*
|
||||
*/
|
||||
public class TerminalConnector implements ITerminalConnector {
|
||||
/**
|
||||
* Creates an instance of TerminalConnectorImpl. This is
|
||||
* used to lazily load classed defined in extensions.
|
||||
*/
|
||||
public interface Factory {
|
||||
/**
|
||||
* @return an Connector
|
||||
* @throws Exception
|
||||
*/
|
||||
TerminalConnectorImpl makeConnector() throws Exception;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final TerminalConnector.Factory fTerminalConnectorFactory;
|
||||
/**
|
||||
* The (display) name of the TerminalConnector
|
||||
*/
|
||||
private final String fName;
|
||||
/**
|
||||
* The unique id the connector
|
||||
*/
|
||||
private final String fId;
|
||||
/**
|
||||
* The connector
|
||||
*/
|
||||
private TerminalConnectorImpl fConnector;
|
||||
/**
|
||||
* If the initialization of the class specified in the extension fails,
|
||||
* this variable contains the error
|
||||
*/
|
||||
private Exception fException;
|
||||
/**
|
||||
* The store might be set before the real connector is initialized.
|
||||
* This keeps the value until the connector is created.
|
||||
*/
|
||||
private ISettingsStore fStore;
|
||||
/**
|
||||
* @param terminalConnectorFactory
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
public TerminalConnector(TerminalConnector.Factory terminalConnectorFactory, String id, String name) {
|
||||
fTerminalConnectorFactory = terminalConnectorFactory;
|
||||
fId = id;
|
||||
fName = name;
|
||||
}
|
||||
public String getInitializationErrorMessage() {
|
||||
getConnectorImpl();
|
||||
if(fException!=null)
|
||||
return fException.getLocalizedMessage();
|
||||
return null;
|
||||
}
|
||||
public String getId() {
|
||||
return fId;
|
||||
}
|
||||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
private TerminalConnectorImpl getConnectorImpl() {
|
||||
if(!isInitialized()) {
|
||||
try {
|
||||
fConnector=fTerminalConnectorFactory.makeConnector();
|
||||
fConnector.initialize();
|
||||
} catch (Exception e) {
|
||||
fException=e;
|
||||
fConnector=new TerminalConnectorImpl(){
|
||||
public void connect(ITerminalControl control) {
|
||||
control.setState(TerminalState.CLOSED);
|
||||
control.setMsg(getInitializationErrorMessage());
|
||||
}
|
||||
public void disconnect() {
|
||||
}
|
||||
public OutputStream getOutputStream() {
|
||||
return null;
|
||||
}
|
||||
public String getSettingsSummary() {
|
||||
return null;
|
||||
}
|
||||
public void load(ISettingsStore store) {
|
||||
}
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return null;
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
}};
|
||||
// that's the place where we log the exception
|
||||
Logger.logException(e);
|
||||
}
|
||||
if(fConnector!=null && fStore!=null)
|
||||
fConnector.load(fStore);
|
||||
}
|
||||
return fConnector;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return fConnector!=null || fException!=null;
|
||||
}
|
||||
public void connect(ITerminalControl control) {
|
||||
getConnectorImpl().connect(control);
|
||||
}
|
||||
public void disconnect() {
|
||||
getConnectorImpl().disconnect();
|
||||
}
|
||||
public OutputStream getTerminalToRemoteStream() {
|
||||
return getConnectorImpl().getOutputStream();
|
||||
}
|
||||
public String getSettingsSummary() {
|
||||
if(fConnector!=null)
|
||||
return getConnectorImpl().getSettingsSummary();
|
||||
else
|
||||
return TerminalMessages.NotInitialized;
|
||||
}
|
||||
public boolean isLocalEcho() {
|
||||
return getConnectorImpl().isLocalEcho();
|
||||
}
|
||||
public void load(ISettingsStore store) {
|
||||
if(fConnector==null) {
|
||||
fStore=store;
|
||||
} else {
|
||||
getConnectorImpl().load(store);
|
||||
}
|
||||
}
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return getConnectorImpl().makeSettingsPage();
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
// no need to save the settings: it cannot have changed
|
||||
// because we are not initialized....
|
||||
if(fConnector!=null)
|
||||
getConnectorImpl().save(store);
|
||||
}
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
// we assume that setTerminalSize is called also after
|
||||
// the terminal has been initialized. Else we would have to cache
|
||||
// the values....
|
||||
if(fConnector!=null) {
|
||||
fConnector.setTerminalSize(newWidth, newHeight);
|
||||
}
|
||||
}
|
||||
public Object getAdapter(Class adapter) {
|
||||
TerminalConnectorImpl connector=null;
|
||||
if(isInitialized())
|
||||
connector=getConnectorImpl();
|
||||
// if we cannot create the connector then we cannot adapt...
|
||||
if(connector!=null) {
|
||||
// maybe the connector is adaptable
|
||||
if(connector instanceof IAdaptable) {
|
||||
Object result =((IAdaptable)connector).getAdapter(adapter);
|
||||
// Not sure if the next block is needed....
|
||||
if(result==null)
|
||||
//defer to the platform
|
||||
result= Platform.getAdapterManager().getAdapter(connector, adapter);
|
||||
if(result!=null)
|
||||
return result;
|
||||
}
|
||||
// maybe the real adapter is what we need....
|
||||
if(adapter.isInstance(connector))
|
||||
return connector;
|
||||
}
|
||||
// maybe we have to be adapted....
|
||||
return Platform.getAdapterManager().getAdapter(this, adapter);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ package org.eclipse.tm.internal.terminal.control;
|
|||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
/**
|
||||
|
@ -38,10 +38,10 @@ public interface ITerminalViewControl {
|
|||
void disconnectTerminal();
|
||||
void disposeTerminal();
|
||||
String getSettingsSummary();
|
||||
ITerminalConnectorInfo[] getConnectors();
|
||||
ITerminalConnector[] getConnectors();
|
||||
void setFocus();
|
||||
ITerminalConnectorInfo getTerminalConnectorInfo();
|
||||
void setConnector(ITerminalConnectorInfo connector);
|
||||
ITerminalConnector getTerminalConnector();
|
||||
void setConnector(ITerminalConnector connector);
|
||||
void connectTerminal();
|
||||
/**
|
||||
* @param write a single character to terminal
|
||||
|
|
|
@ -13,10 +13,10 @@ package org.eclipse.tm.internal.terminal.control;
|
|||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
|
||||
public class TerminalViewControlFactory {
|
||||
public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnectorInfo[] connectors) {
|
||||
public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) {
|
||||
return new VT100TerminalControl(target, wndParent, connectors);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ package org.eclipse.tm.internal.terminal.control.impl;
|
|||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ public interface ITerminalControlForText {
|
|||
void setState(TerminalState state);
|
||||
void setTerminalTitle(String title);
|
||||
|
||||
ITerminalConnectorInfo getTerminalConnectorInfo();
|
||||
ITerminalConnector getTerminalConnector();
|
||||
|
||||
void disconnectTerminal();
|
||||
|
||||
|
|
|
@ -22,4 +22,5 @@ public class TerminalMessages extends NLS {
|
|||
public static String SocketError;
|
||||
public static String IOError;
|
||||
public static String CannotConnectTo;
|
||||
public static String NotInitialized;
|
||||
}
|
||||
|
|
|
@ -17,4 +17,5 @@
|
|||
TerminalError = Terminal Error
|
||||
SocketError = Socket Error
|
||||
IOError = IO Error
|
||||
CannotConnectTo = Cannot initialize {0}:\n{1}
|
||||
CannotConnectTo = Cannot initialize {0}:\n{1}
|
||||
NotInitialized = Not Initialized
|
||||
|
|
|
@ -1046,8 +1046,8 @@ public class VT100Emulator implements ControlListener {
|
|||
}
|
||||
|
||||
private ITerminalConnector getConnector() {
|
||||
if(terminal.getTerminalConnectorInfo()!=null)
|
||||
return terminal.getTerminalConnectorInfo().getConnector();
|
||||
if(terminal.getTerminalConnector()!=null)
|
||||
return terminal.getTerminalConnector();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
|
|||
import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages;
|
||||
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
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.TerminalState;
|
||||
|
@ -103,8 +102,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
private final ITerminalListener fTerminalListener;
|
||||
private String fMsg = ""; //$NON-NLS-1$
|
||||
private FocusListener fFocusListener;
|
||||
private ITerminalConnectorInfo fConnectorInfo;
|
||||
private final ITerminalConnectorInfo[] fConnectors;
|
||||
private ITerminalConnector fConnector;
|
||||
private final ITerminalConnector[] fConnectors;
|
||||
PipedInputStream fInputStream;
|
||||
|
||||
private ICommandInputField fCommandInputField;
|
||||
|
@ -118,7 +117,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
*/
|
||||
volatile private Job fJob;
|
||||
|
||||
public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnectorInfo[] connectors) {
|
||||
public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) {
|
||||
fConnectors=connectors;
|
||||
fTerminalListener=target;
|
||||
fTerminalModel=TerminalTextDataFactory.makeTerminalTextData();
|
||||
|
@ -129,7 +128,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
setupTerminal(wndParent);
|
||||
}
|
||||
|
||||
public ITerminalConnectorInfo[] getConnectors() {
|
||||
public ITerminalConnector[] getConnectors() {
|
||||
return fConnectors;
|
||||
}
|
||||
|
||||
|
@ -266,11 +265,11 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
if(getTerminalConnector()==null)
|
||||
return;
|
||||
fTerminalText.resetState();
|
||||
if(fConnectorInfo.getInitializationErrorMessage()!=null) {
|
||||
if(fConnector.getInitializationErrorMessage()!=null) {
|
||||
showErrorMessage(NLS.bind(
|
||||
TerminalMessages.CannotConnectTo,
|
||||
fConnectorInfo.getName(),
|
||||
fConnectorInfo.getInitializationErrorMessage()));
|
||||
fConnector.getName(),
|
||||
fConnector.getInitializationErrorMessage()));
|
||||
// we cannot connect because the connector was not initialized
|
||||
return;
|
||||
}
|
||||
|
@ -280,10 +279,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
waitForConnect();
|
||||
}
|
||||
|
||||
private ITerminalConnector getTerminalConnector() {
|
||||
if(fConnectorInfo==null)
|
||||
return null;
|
||||
return fConnectorInfo.getConnector();
|
||||
public ITerminalConnector getTerminalConnector() {
|
||||
return fConnector;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#disconnectTerminal()
|
||||
|
@ -605,7 +602,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
|
||||
public OutputStream getOutputStream() {
|
||||
if(getTerminalConnector()!=null)
|
||||
return getTerminalConnector().getOutputStream();
|
||||
return getTerminalConnector().getTerminalToRemoteStream();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -633,13 +630,6 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
public VT100Emulator getTerminalText() {
|
||||
return fTerminalText;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public ITerminalConnectorInfo getTerminalConnectorInfo() {
|
||||
return fConnectorInfo;
|
||||
}
|
||||
|
||||
protected class TerminalFocusListener implements FocusListener {
|
||||
private IContextActivation contextActivation = null;
|
||||
|
||||
|
@ -844,9 +834,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
// locally, send a LF after sending a CR.
|
||||
// ISSUE: Is this absolutely required?
|
||||
|
||||
if (character == '\r' && getTerminalConnectorInfo() != null
|
||||
if (character == '\r' && getTerminalConnector() != null
|
||||
&& isConnected()
|
||||
&& getTerminalConnectorInfo().getConnector().isLocalEcho()) {
|
||||
&& getTerminalConnector().isLocalEcho()) {
|
||||
sendChar('\n', false);
|
||||
}
|
||||
|
||||
|
@ -865,8 +855,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
//
|
||||
// o The character is the DELETE character.
|
||||
|
||||
if (getTerminalConnectorInfo() == null
|
||||
|| getTerminalConnectorInfo().getConnector().isLocalEcho() == false || altKeyPressed
|
||||
if (getTerminalConnector() == null
|
||||
|| getTerminalConnector().isLocalEcho() == false || altKeyPressed
|
||||
|| (character >= '\u0001' && character < '\t')
|
||||
|| (character > '\t' && character < '\r')
|
||||
|| (character > '\r' && character <= '\u001f')
|
||||
|
@ -912,8 +902,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void setConnector(ITerminalConnectorInfo connector) {
|
||||
fConnectorInfo=connector;
|
||||
public void setConnector(ITerminalConnector connector) {
|
||||
fConnector=connector;
|
||||
|
||||
}
|
||||
public ICommandInputField getCommandInputField() {
|
||||
|
|
|
@ -13,11 +13,16 @@ package org.eclipse.tm.internal.terminal.provisional.api;
|
|||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
|
||||
/**
|
||||
* Manage a single connection. Implementations of this class are contributed
|
||||
* via <code>org.eclipse.tm.terminal.terminalConnector</code> extension point.
|
||||
*
|
||||
* This class is a handle to a {@link ITerminalConnector connector} that comes from an
|
||||
* extension. It maintains {@link TerminalConnectorImpl} to the connector to allow lazy initialization of the
|
||||
* real {@link ITerminalConnector connector} that comes from an extension.
|
||||
|
||||
* @author Michael Scharf
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
|
@ -26,14 +31,31 @@ import java.io.OutputStream;
|
|||
* consulting with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team.
|
||||
* </p>
|
||||
*/
|
||||
public interface ITerminalConnector {
|
||||
public interface ITerminalConnector extends IAdaptable {
|
||||
/**
|
||||
* Initializes the Connector. Some connector depend on external libraries that
|
||||
* might not be installed.
|
||||
* @throws Exception The exception should have a useful
|
||||
* {@link Exception#getLocalizedMessage()} that explains the problem to the user.
|
||||
* @return an ID of this connector. The id from the plugin.xml.
|
||||
*/
|
||||
void initialize() throws Exception;
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return <code>null</code> the name (as specified in the plugin.xml)
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return true if the {@link TerminalConnectorImpl} has been initialized.
|
||||
* If there was an initialization error, {@link #getInitializationErrorMessage()}
|
||||
* returns the error message.
|
||||
*/
|
||||
boolean isInitialized();
|
||||
|
||||
/**
|
||||
* This method initializes the connector if it is not initialized!
|
||||
* If the connector was initialized successfully, <code>null</code> is
|
||||
* returned. Otherwise an error message describing the problem is returned.
|
||||
* @return <code>null</code> or a localized error message.
|
||||
*/
|
||||
String getInitializationErrorMessage();
|
||||
|
||||
/**
|
||||
* Connect using the current state of the settings.
|
||||
|
@ -60,9 +82,11 @@ public interface ITerminalConnector {
|
|||
void setTerminalSize(int newWidth, int newHeight);
|
||||
|
||||
/**
|
||||
* @return a stream with data coming from the remote site.
|
||||
* @return the terminal to remote stream (bytes written to this stream will
|
||||
* be sent to the remote site). For the stream in the other direction (remote to
|
||||
* terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()}
|
||||
*/
|
||||
OutputStream getOutputStream();
|
||||
OutputStream getTerminalToRemoteStream();
|
||||
|
||||
/**
|
||||
* Load the state of this connection. Is typically called before
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 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;
|
||||
|
||||
/**
|
||||
* This class is a handle to a {@link ITerminalConnector connector} that comes from an
|
||||
* extension. It maintains a proxy to the connector to allow lazy initialization of the
|
||||
* real {@link ITerminalConnector connector} that comes from an extension.
|
||||
*
|
||||
* <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/dsdp/tm/">Target Management</a> team.
|
||||
* </p>
|
||||
*/
|
||||
public interface ITerminalConnectorInfo {
|
||||
/**
|
||||
* @return an ID of this connector. The id from the plugin.xml.
|
||||
* <p>Note: return <code>null</code> because the framework takes
|
||||
* care to get the value from the plugin.xml
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return <code>null</code> the name (as specified in the plugin.xml)
|
||||
* <p>Note: return <code>null</code> because the framework takes
|
||||
* care to get the value from the plugin.xml
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return true if the ITerminalConnector has been initialized.
|
||||
* If there was an initialization error, {@link #getInitializationErrorMessage()}
|
||||
* returns the error message.
|
||||
*/
|
||||
boolean isInitialized();
|
||||
|
||||
/**
|
||||
* This method initializes the connector if it is not initialized!
|
||||
* If the connector was initialized successfully, <code>null</code> is
|
||||
* returned. Otherwise an error message describing the problem is returned.
|
||||
* @return <code>null</code> or a localized error message.
|
||||
*/
|
||||
String getInitializationErrorMessage();
|
||||
|
||||
/**
|
||||
* Returns a proxy to the connector that is lazily initialized.
|
||||
* The following methods can be called without initializing
|
||||
* the contributed class:
|
||||
* {@link ITerminalConnector#getSettingsSummary()}, {@link ITerminalConnector#load(ISettingsStore)},
|
||||
* {@link ITerminalConnector#save(ISettingsStore)}, {@link ITerminalConnector#setTerminalSize(int, int)}
|
||||
* @return a proxy of the real connector. Some calls initialize the the connection.
|
||||
*/
|
||||
ITerminalConnector getConnector();
|
||||
}
|
|
@ -56,7 +56,8 @@ public interface ITerminalControl {
|
|||
/**
|
||||
* @return a stream used to write to the terminal. Any bytes written to this
|
||||
* stream appear in the terminal or are interpreted by the emulator as
|
||||
* control sequences.
|
||||
* control sequences. The stream in the opposite direction, terminal
|
||||
* to remote is in {@link ITerminalConnector#getTerminalToRemoteStream()}.
|
||||
*/
|
||||
OutputStream getRemoteToTerminalOutputStream();
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.provisional.api;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.RegistryFactory;
|
||||
import org.eclipse.tm.internal.terminal.connector.TerminalConnector;
|
||||
|
||||
/**
|
||||
* A factory to get {@link ITerminalConnector} instances.
|
||||
|
@ -31,162 +31,47 @@ import org.eclipse.core.runtime.RegistryFactory;
|
|||
* </p>
|
||||
*/
|
||||
public class TerminalConnectorExtension {
|
||||
static private class TerminalConnectorInfo implements ITerminalConnectorInfo {
|
||||
TerminalConnectorProxy fProxy;
|
||||
TerminalConnectorInfo(TerminalConnectorProxy proxy) {
|
||||
fProxy=proxy;
|
||||
}
|
||||
public ITerminalConnector getConnector() {
|
||||
return fProxy;
|
||||
}
|
||||
public String getId() {
|
||||
return fProxy.getId();
|
||||
}
|
||||
public String getName() {
|
||||
return fProxy.getName();
|
||||
}
|
||||
public String getInitializationErrorMessage() {
|
||||
return fProxy.getLocalizedErrorMessage();
|
||||
}
|
||||
public boolean isInitialized() {
|
||||
return fProxy.isInitialized();
|
||||
static private ITerminalConnector makeConnector(final IConfigurationElement config) {
|
||||
String id = config.getAttribute("id"); //$NON-NLS-1$
|
||||
if(id==null || id.length()==0)
|
||||
id=config.getAttribute("class"); //$NON-NLS-1$
|
||||
String name= config.getAttribute("name"); //$NON-NLS-1$
|
||||
if(name==null || name.length()==0) {
|
||||
name=id;
|
||||
}
|
||||
TerminalConnector.Factory factory=new TerminalConnector.Factory(){
|
||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
||||
return (TerminalConnectorImpl)config.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
}};
|
||||
return new TerminalConnector(factory,id,name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id of the terminal connector in the
|
||||
* <code>org.eclipse.tm.terminal.terminalConnector</code> extension point
|
||||
* @return a new ITerminalConnector with id or <code>null</code> if there is no
|
||||
* extension with that id.
|
||||
*/
|
||||
public static ITerminalConnector makeTerminalConnector(String id) {
|
||||
IConfigurationElement[] config=RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.terminalConnector"); //$NON-NLS-1$
|
||||
for (int i = 0; i < config.length; i++) {
|
||||
if(id.equals(config[i].getAttribute("id"))) { //$NON-NLS-1$
|
||||
return makeConnector(config[i]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* A placeholder for the ITerminalConnector. It gets initialized when
|
||||
* the real connector is needed.
|
||||
* The following methods can be called without initializing
|
||||
* the contributed class: {@link #getId()}, {@link #getName()},
|
||||
* {@link #getSettingsSummary()},{@link #load(ISettingsStore)},
|
||||
* {@link #setTerminalSize(int, int)}, {@link #save(ISettingsStore)}
|
||||
*
|
||||
* @return a new list of {@link ITerminalConnector} instances defined in
|
||||
* the <code>org.eclipse.tm.terminal.terminalConnector</code> extension point
|
||||
*/
|
||||
static private class TerminalConnectorProxy implements ITerminalConnector {
|
||||
/**
|
||||
* The connector
|
||||
*/
|
||||
private ITerminalConnector fConnector;
|
||||
/**
|
||||
* The plugin contribution, needed for lazy initialization
|
||||
* of {@link #fConnector}
|
||||
*/
|
||||
private final IConfigurationElement fConfig;
|
||||
/**
|
||||
* If the initialization of the class specified in the extension fails,
|
||||
* this variable contains the error
|
||||
*/
|
||||
private Exception fException;
|
||||
/**
|
||||
* The store might be set before the real connector is initialized.
|
||||
* This keeps the value until the connector is created.
|
||||
*/
|
||||
private ISettingsStore fStore;
|
||||
|
||||
TerminalConnectorProxy(IConfigurationElement config) {
|
||||
fConfig=config;
|
||||
}
|
||||
public String getLocalizedErrorMessage() {
|
||||
getConnector();
|
||||
if(fException!=null)
|
||||
return fException.getLocalizedMessage();
|
||||
return null;
|
||||
}
|
||||
public String getId() {
|
||||
String id = fConfig.getAttribute("id"); //$NON-NLS-1$
|
||||
if(id==null || id.length()==0)
|
||||
id=fConfig.getAttribute("class"); //$NON-NLS-1$
|
||||
return id;
|
||||
}
|
||||
public String getName() {
|
||||
String name= fConfig.getAttribute("name"); //$NON-NLS-1$
|
||||
if(name==null || name.length()==0) {
|
||||
name=getId();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
private ITerminalConnector getConnector() {
|
||||
if(!isInitialized()) {
|
||||
try {
|
||||
fConnector=createConnector(fConfig);
|
||||
fConnector.initialize();
|
||||
} catch (Exception e) {
|
||||
fConnector=null;
|
||||
fException=e;
|
||||
// that's the place where we log the exception
|
||||
Logger.logException(e);
|
||||
}
|
||||
if(fConnector!=null && fStore!=null)
|
||||
fConnector.load(fStore);
|
||||
}
|
||||
return fConnector;
|
||||
}
|
||||
private boolean isInitialized() {
|
||||
return fConnector!=null || fException!=null;
|
||||
}
|
||||
public void connect(ITerminalControl control) {
|
||||
getConnector().connect(control);
|
||||
}
|
||||
public void disconnect() {
|
||||
getConnector().disconnect();
|
||||
}
|
||||
public OutputStream getOutputStream() {
|
||||
return getConnector().getOutputStream();
|
||||
}
|
||||
public String getSettingsSummary() {
|
||||
if(fConnector!=null)
|
||||
return getConnector().getSettingsSummary();
|
||||
else
|
||||
// TODO: see TerminalView.getSettingsSummary
|
||||
return "?"; //$NON-NLS-1$
|
||||
}
|
||||
public boolean isLocalEcho() {
|
||||
return getConnector().isLocalEcho();
|
||||
}
|
||||
public void load(ISettingsStore store) {
|
||||
if(fConnector==null) {
|
||||
fStore=store;
|
||||
} else {
|
||||
getConnector().load(store);
|
||||
}
|
||||
}
|
||||
public ISettingsPage makeSettingsPage() {
|
||||
return getConnector().makeSettingsPage();
|
||||
}
|
||||
public void save(ISettingsStore store) {
|
||||
// no need to save the settings: it cannot have changed
|
||||
// because we are not initialized....
|
||||
if(fConnector!=null)
|
||||
getConnector().save(store);
|
||||
}
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
// we assume that setTerminalSize is called also after
|
||||
// the terminal has been initialized. Else we would have to cache
|
||||
// the values....
|
||||
if(fConnector!=null) {
|
||||
fConnector.setTerminalSize(newWidth, newHeight);
|
||||
}
|
||||
}
|
||||
public void initialize() throws Exception {
|
||||
throw new IllegalStateException("Connector already initialized!"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return null or a new connector created from the extension
|
||||
*/
|
||||
static private ITerminalConnector createConnector(IConfigurationElement config) throws Exception {
|
||||
return (ITerminalConnector)config.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* @return a new list of ITerminalConnectorInfo.
|
||||
*/
|
||||
public static ITerminalConnectorInfo[] getTerminalConnectors() {
|
||||
public static ITerminalConnector[] makeTerminalConnectors() {
|
||||
IConfigurationElement[] config=RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.terminalConnector"); //$NON-NLS-1$
|
||||
List result=new ArrayList();
|
||||
for (int i = 0; i < config.length; i++) {
|
||||
result.add(new TerminalConnectorInfo(new TerminalConnectorProxy(config[i])));
|
||||
result.add(makeConnector(config[i]));
|
||||
}
|
||||
return (ITerminalConnectorInfo[]) result.toArray(new ITerminalConnectorInfo[result.size()]);
|
||||
return (ITerminalConnector[]) result.toArray(new ITerminalConnector[result.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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 java.io.OutputStream;
|
||||
|
||||
public abstract class TerminalConnectorImpl {
|
||||
/**
|
||||
* Called once after the constructor
|
||||
* @throws Exception
|
||||
*/
|
||||
public void initialize() throws Exception {
|
||||
}
|
||||
/**
|
||||
* Connect using the current state of the settings.
|
||||
* @param control Used to inform the UI about state changes and messages from the connection.
|
||||
*/
|
||||
abstract public void connect(ITerminalControl control);
|
||||
|
||||
/**
|
||||
* Disconnect if connected. Else do nothing.
|
||||
* Has to set the state of the {@link ITerminalControl}
|
||||
*/
|
||||
abstract public void disconnect();
|
||||
|
||||
/**
|
||||
* @return the terminal to remote stream (bytes written to this stream will
|
||||
* be sent to the remote site). For the stream in the other direction (remote to
|
||||
* terminal see {@link ITerminalControl#getRemoteToTerminalOutputStream()}
|
||||
*/
|
||||
abstract public OutputStream getOutputStream();
|
||||
|
||||
/**
|
||||
* @return A string that represents the settings of the connection. This representation
|
||||
* may be shown in the status line of the terminal view.
|
||||
*/
|
||||
abstract public String getSettingsSummary();
|
||||
|
||||
/**
|
||||
* @return true if a local echo is needed.
|
||||
* TODO:Michael Scharf: this should be handed within the connection....
|
||||
*/
|
||||
public boolean isLocalEcho() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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(ISettingsStore)}
|
||||
* and {@link #save(ISettingsStore)} methods.
|
||||
*
|
||||
*/
|
||||
abstract public ISettingsPage makeSettingsPage();
|
||||
|
||||
/**
|
||||
* Load the state of this connection. Is typically called before
|
||||
* {@link #connect(ITerminalControl)}.
|
||||
*
|
||||
* @param store a string based data store. Short keys like "foo" can be used to
|
||||
* store the state of the connection.
|
||||
*/
|
||||
abstract public void load(ISettingsStore store);
|
||||
/**
|
||||
* When the view or dialog containing the terminal is closed,
|
||||
* the state of the connection is saved into the settings store <code>store</code>
|
||||
* @param store
|
||||
*/
|
||||
abstract public void save(ISettingsStore store);
|
||||
|
||||
/**
|
||||
* Notify the remote site that the size of the terminal has changed.
|
||||
* @param newWidth
|
||||
* @param newHeight
|
||||
*/
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue