blob: a173827a5c050b2166eb8daa5b325e687e2515e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*******************************************************************************
* Copyright (c) 2011, 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.tcf.te.tcf.terminals.ui.connector;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tcf.te.tcf.terminals.core.interfaces.launcher.ITerminalsLauncher;
import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore;
import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType;
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.TerminalConnectorExtension;
/**
* Terminals terminal connector type implementation.
*/
@SuppressWarnings("restriction")
public class TerminalsConnectorType extends AbstractConnectorType {
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(java.util.Map)
*/
@Override
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
Assert.isNotNull(properties);
// Check for the terminal connector id
String connectorId = (String)properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
if (connectorId == null) connectorId = "org.eclipse.tcf.te.tcf.terminals.ui.TerminalsConnector"; //$NON-NLS-1$
// Extract the streams properties
OutputStream stdin = (OutputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDIN);
InputStream stdout = (InputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT);
InputStream stderr = (InputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDERR);
Object value = properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
boolean localEcho = value instanceof Boolean ? ((Boolean)value).booleanValue() : false;
String lineSeparator = (String)properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
ITerminalsLauncher launcher = (ITerminalsLauncher)properties.get(ITerminalsConnectorConstants.PROP_DATA);
// Construct the terminal settings store
ISettingsStore store = new SettingsStore();
// Construct the terminals settings
TerminalsSettings terminalsSettings = new TerminalsSettings();
terminalsSettings.setStdinStream(stdin);
terminalsSettings.setStdoutStream(stdout);
terminalsSettings.setStderrStream(stderr);
terminalsSettings.setLocalEcho(localEcho);
terminalsSettings.setLineSeparator(lineSeparator);
terminalsSettings.setTerminalsLauncher(launcher);
// And save the settings to the store
terminalsSettings.save(store);
// Construct the terminal connector instance
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
if (connector != null) {
// Apply default settings
connector.makeSettingsPage();
// And load the real settings
connector.load(store);
}
return connector;
}
}
|