mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 303808: Remove dependency on o.e.tm.view.*
The streams connector provided by TM was located in the o.e.tm.view.* plugins which bring in the terminals view. This patch implements our own streams connector so that we don't have this extra dependency. Change-Id: If2a8bdfbdd87eb9ec5c42180a372634e322ba1c1
This commit is contained in:
parent
1b7f91a406
commit
10381a74e4
5 changed files with 161 additions and 36 deletions
|
@ -350,8 +350,6 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U
|
||||||
<plugin id="org.eclipse.team.ui"/>
|
<plugin id="org.eclipse.team.ui"/>
|
||||||
<plugin id="org.eclipse.text"/>
|
<plugin id="org.eclipse.text"/>
|
||||||
<plugin id="org.eclipse.tm.terminal.control"/>
|
<plugin id="org.eclipse.tm.terminal.control"/>
|
||||||
<plugin id="org.eclipse.tm.terminal.view.core"/>
|
|
||||||
<plugin id="org.eclipse.tm.terminal.view.ui"/>
|
|
||||||
<plugin id="org.eclipse.tools.templates.core"/>
|
<plugin id="org.eclipse.tools.templates.core"/>
|
||||||
<plugin id="org.eclipse.tools.templates.ui"/>
|
<plugin id="org.eclipse.tools.templates.ui"/>
|
||||||
<plugin id="org.eclipse.ui"/>
|
<plugin id="org.eclipse.ui"/>
|
||||||
|
|
|
@ -26,9 +26,7 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.cdt.launch;bundle-version="6.1.0",
|
org.eclipse.cdt.launch;bundle-version="6.1.0",
|
||||||
org.eclipse.debug.core,
|
org.eclipse.debug.core,
|
||||||
org.eclipse.core.resources,
|
org.eclipse.core.resources,
|
||||||
org.eclipse.tm.terminal.control;bundle-version="4.0.0",
|
org.eclipse.tm.terminal.control;bundle-version="4.0.0"
|
||||||
org.eclipse.tm.terminal.view.core;bundle-version="4.0.0",
|
|
||||||
org.eclipse.tm.terminal.view.ui;bundle-version="4.1.0"
|
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui;x-friends:="org.eclipse.cdt.docker.launcher",
|
Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui;x-friends:="org.eclipse.cdt.docker.launcher",
|
||||||
|
|
|
@ -9,8 +9,6 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.debuggerconsole.DebuggerConsoleView;
|
import org.eclipse.cdt.debug.internal.ui.views.debuggerconsole.DebuggerConsoleView;
|
||||||
|
@ -45,10 +43,6 @@ import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
|
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.ITerminalControl;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
import org.eclipse.tm.terminal.view.core.interfaces.ITerminalServiceOutputStreamMonitorListener;
|
|
||||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
|
||||||
import org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate;
|
|
||||||
import org.eclipse.tm.terminal.view.ui.launcher.LauncherDelegateManager;
|
|
||||||
import org.eclipse.ui.part.Page;
|
import org.eclipse.ui.part.Page;
|
||||||
|
|
||||||
public class GdbFullCliConsolePage extends Page implements IDebugContextListener {
|
public class GdbFullCliConsolePage extends Page implements IDebugContextListener {
|
||||||
|
@ -210,13 +204,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void attachTerminal(Process process) {
|
protected void attachTerminal(Process process) {
|
||||||
ILauncherDelegate delegate =
|
fTerminalControl.setConnector(new GdbTerminalConnector(process));
|
||||||
LauncherDelegateManager.getInstance().getLauncherDelegate("org.eclipse.tm.terminal.connector.streams.launcher.streams", false); //$NON-NLS-1$
|
|
||||||
if (delegate != null) {
|
|
||||||
Map<String, Object> properties = createNewSettings(process);
|
|
||||||
|
|
||||||
ITerminalConnector connector = delegate.createTerminalConnector(properties);
|
|
||||||
fTerminalControl.setConnector(connector);
|
|
||||||
if (fTerminalControl instanceof ITerminalControl) {
|
if (fTerminalControl instanceof ITerminalControl) {
|
||||||
((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false);
|
((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false);
|
||||||
((ITerminalControl)fTerminalControl).setVT100LineWrapping(true);
|
((ITerminalControl)fTerminalControl).setVT100LineWrapping(true);
|
||||||
|
@ -234,22 +222,6 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected Map<String, Object> createNewSettings(Process process) {
|
|
||||||
|
|
||||||
// Create the terminal connector
|
|
||||||
Map<String, Object> properties = new HashMap<String, Object>();
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE);
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_STREAMS_STDIN, process.getOutputStream());
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT, process.getInputStream());
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_STREAMS_STDERR, process.getErrorStream());
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS,
|
|
||||||
new ITerminalServiceOutputStreamMonitorListener[0]);
|
|
||||||
properties.put(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS,
|
|
||||||
new ITerminalServiceOutputStreamMonitorListener[0]);
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the launch to which the current selection belongs.
|
* Returns the launch to which the current selection belongs.
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 Ericsson 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
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
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.TerminalState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that connects the GDB process I/O with the terminal.
|
||||||
|
*/
|
||||||
|
public class GdbTerminalConnector extends PlatformObject implements ITerminalConnector {
|
||||||
|
|
||||||
|
private ITerminalControl fControl;
|
||||||
|
private final Process fProcess;
|
||||||
|
|
||||||
|
public GdbTerminalConnector(Process process) {
|
||||||
|
if (process == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid Process"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
fProcess = process;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnect() {
|
||||||
|
// Set the terminal control state to CLOSED.
|
||||||
|
if (fControl != null) {
|
||||||
|
fControl.setState(TerminalState.CLOSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutputStream getTerminalToRemoteStream() {
|
||||||
|
// When the user writes to the terminal, it should be sent
|
||||||
|
// directly to GDB
|
||||||
|
return fProcess.getOutputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connect(ITerminalControl control) {
|
||||||
|
if (control == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid ITerminalControl"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
fControl = control;
|
||||||
|
|
||||||
|
// connect the streams
|
||||||
|
new OutputReadJob(fProcess.getInputStream()).schedule();
|
||||||
|
new OutputReadJob(fProcess.getErrorStream()).schedule();
|
||||||
|
|
||||||
|
// Set the terminal control state to CONNECTED
|
||||||
|
fControl.setState(TerminalState.CONNECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
// No need for an id, as we're are just used locally
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
// No name
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHidden() {
|
||||||
|
// in case we do leak into the TM world, we shouldn't be visible
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInitialized() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInitializationErrorMessage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLocalEcho() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefaultSettings() {
|
||||||
|
// we don't do settings
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSettingsSummary() {
|
||||||
|
// we don't do settings
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(ISettingsStore arg0) {
|
||||||
|
// we don't do settings
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(ISettingsStore arg0) {
|
||||||
|
// we don't do settings
|
||||||
|
}
|
||||||
|
|
||||||
|
private class OutputReadJob extends Job {
|
||||||
|
{
|
||||||
|
setSystem(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream fInputStream;
|
||||||
|
|
||||||
|
OutputReadJob(InputStream inputStream) {
|
||||||
|
super("GDB CLI output Job"); //$NON-NLS-1$
|
||||||
|
fInputStream = inputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
try {
|
||||||
|
byte[] b = new byte[1024];
|
||||||
|
int read = 0;
|
||||||
|
do {
|
||||||
|
read = fInputStream.read(b);
|
||||||
|
if (read > 0) {
|
||||||
|
fControl.getRemoteToTerminalOutputStream().write(b, 0, read);
|
||||||
|
}
|
||||||
|
} while (read >= 0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<?pde version="3.8"?><target name="cdt" sequenceNumber="15">
|
<?pde version="3.8"?><target name="cdt" sequenceNumber="16">
|
||||||
<locations>
|
<locations>
|
||||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||||
<unit id="org.apache.commons.compress" version="0.0.0"/>
|
<unit id="org.apache.commons.compress" version="0.0.0"/>
|
||||||
|
@ -60,7 +60,6 @@
|
||||||
</location>
|
</location>
|
||||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||||
<unit id="org.eclipse.tm.terminal.control" version="0.0.0"/>
|
<unit id="org.eclipse.tm.terminal.control" version="0.0.0"/>
|
||||||
<unit id="org.eclipse.tm.terminal.view.ui" version="0.0.0"/>
|
|
||||||
<repository location="http://download.eclipse.org/tm/terminal/builds/development/nightly/"/>
|
<repository location="http://download.eclipse.org/tm/terminal/builds/development/nightly/"/>
|
||||||
</location>
|
</location>
|
||||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||||
|
|
Loading…
Add table
Reference in a new issue