use of org.eclipse.tm.terminal.view.core.interfaces.ITerminalService in project linuxtools by eclipse.
the class RemoveContainerLogCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
List<IDockerContainer> selectedContainers = CommandUtils.getSelectedContainers(activePart);
if (activePart instanceof DockerContainersView) {
connection = ((DockerContainersView) activePart).getConnection();
}
if (selectedContainers.size() != 1 || connection == null)
return null;
container = selectedContainers.get(0);
IDockerContainerInfo info = connection.getContainerInfo(container.id());
if (info.config().tty()) {
Map<String, Object> properties = new HashMap<>();
properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, "org.eclipse.tm.terminal.connector.streams.launcher.streams");
properties.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.streams.StreamsConnector");
properties.put(ITerminalsConnectorConstants.PROP_TITLE, info.name());
ITerminalService service = TerminalServiceFactory.getService();
service.closeConsole(properties, null);
return null;
}
final RunConsole rc = RunConsole.findConsole(container);
if (rc != null) {
RunConsole.removeConsole(rc);
}
return null;
}
use of org.eclipse.tm.terminal.view.core.interfaces.ITerminalService in project linuxtools by eclipse.
the class DockerConnection method openTerminal.
private void openTerminal(LogStream pty_stream, String name, DockerConsoleOutputStream out) throws DockerException {
try {
OutputStream tout = noBlockingOutputStream(HttpHijackWorkaround.getOutputStream(pty_stream, getUri()));
InputStream tin = HttpHijackWorkaround.getInputStream(pty_stream);
TerminalOutputMonitorListener monitor = new TerminalOutputMonitorListener(out);
// org.eclipse.tm.terminal.connector.ssh.controls.SshWizardConfigurationPanel
Map<String, Object> properties = new HashMap<>();
properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, // $NON-NLS-1$
"org.eclipse.tm.terminal.connector.streams.launcher.streams");
properties.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, // $NON-NLS-1$
"org.eclipse.tm.terminal.connector.streams.StreamsConnector");
properties.put(ITerminalsConnectorConstants.PROP_TITLE, name);
properties.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, false);
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, true);
properties.put(ITerminalsConnectorConstants.PROP_STREAMS_STDIN, tout);
properties.put(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT, tin);
properties.put(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS, new ITerminalServiceOutputStreamMonitorListener[] { monitor });
properties.put(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS, new ITerminalServiceOutputStreamMonitorListener[] { monitor });
properties.put(ITerminalsConnectorConstants.PROP_DATA, pty_stream);
/*
* The JVM will call finalize() on 'pty_stream' (LogStream)
* since we hold no references to it (although we do hold
* references to one of its heavily nested fields. The
* LogStream overrides finalize() to close the stream being
* used so we must preserve a reference to it.
*/
// $NON-NLS-1$
properties.put("PREVENT_JVM_GC_FINALIZE", pty_stream);
// save properties to remove terminal later
if (out != null) {
out.setTerminalProperties(properties);
}
ITerminalService service = TerminalServiceFactory.getService();
service.openConsole(properties, null);
} catch (Exception e) {
throw new DockerException(e.getMessage(), e.getCause());
}
}
Aggregations