Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ILineSeparatorConstants.java34
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.processes.core/src/org/eclipse/tm/te/tcf/processes/core/launcher/ProcessLauncher.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/internal/dialogs/LaunchObjectDialog.java135
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.properties16
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnector.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnectorType.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessSettings.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/AbstractStreamsConnector.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/InputStreamMonitor.java133
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsConnector.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsSettings.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/types/StreamsConnectorType.java20
16 files changed, 426 insertions, 81 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ILineSeparatorConstants.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ILineSeparatorConstants.java
new file mode 100644
index 000000000..7ff707278
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ILineSeparatorConstants.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.te.runtime.services.interfaces.constants;
+
+/**
+ * Line separator constants.
+ * <p>
+ * Copied from <code>org.eclipse.tm.internal.terminal.local.ILocalTerminalSettings</code>.
+ */
+public interface ILineSeparatorConstants {
+
+ /**
+ * The line separator setting CR (carriage return only; for example, used by Mac OS 9).
+ */
+ public final static String LINE_SEPARATOR_CR = "\\r"; //$NON-NLS-1$
+
+ /**
+ * The line separator setting CRLF (carriage return and line feed; for example, used by
+ * Windows).
+ */
+ public final static String LINE_SEPARATOR_CRLF = "\\r\\n"; //$NON-NLS-1$
+
+ /**
+ * The line separator setting LF (line feed only; used by all UNIX-based systems).
+ */
+ public final static String LINE_SEPARATOR_LF = "\\n"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java
index f6c823697..25419c94a 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java
@@ -56,6 +56,12 @@ public interface ITerminalsConnectorConstants {
*/
public static final String PROP_LOCAL_ECHO = "localEcho"; //$NON-NLS-1$
+ /**
+ * Property: The line separator used by the terminal input.
+ * <p>Typical for process and streams terminals.
+ */
+ public static final String PROP_LINE_SEPARATOR = "lineSeparator"; //$NON-NLS-1$
+
// ***** IP based terminals connector properties *****
/**
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.core/src/org/eclipse/tm/te/tcf/processes/core/launcher/ProcessLauncher.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.core/src/org/eclipse/tm/te/tcf/processes/core/launcher/ProcessLauncher.java
index a9fbdec86..ee57beb1e 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.core/src/org/eclipse/tm/te/tcf/processes/core/launcher/ProcessLauncher.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.core/src/org/eclipse/tm/te/tcf/processes/core/launcher/ProcessLauncher.java
@@ -516,8 +516,9 @@ public class ProcessLauncher extends PlatformObject implements IProcessLauncher
// Create and store the streams the terminal will see as stderr
props.setProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDERR, connectRemoteInputStream(getStreamsListener(), new String[] { IProcesses.PROP_STDERR_ID }));
- // Local echo is OFF
- props.setProperty(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, false);
+ // Copy the terminal properties
+ props.setProperty(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_LOCAL_ECHO));
+ props.setProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, properties.getStringProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR));
// The custom data object is the process launcher itself
props.setProperty(ITerminalsConnectorConstants.PROP_DATA, this);
@@ -543,7 +544,7 @@ public class ProcessLauncher extends PlatformObject implements IProcessLauncher
// Create the receiver instance. If the file already exist, we
// overwrite the file content.
ProcessStreamsDataReceiver receiver = new ProcessStreamsDataReceiver(new BufferedWriter(new FileWriter(filename)),
- new String[] { IProcesses.PROP_STDOUT_ID, IProcesses.PROP_STDERR_ID });
+ new String[] { IProcesses.PROP_STDOUT_ID, IProcesses.PROP_STDERR_ID });
// Register the receiver to the streams listener
if (getStreamsListener() instanceof ProcessStreamsListener) {
((ProcessStreamsListener)getStreamsListener()).registerDataReceiver(receiver);
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/META-INF/MANIFEST.MF
index 05f96b62e..ced5e6f39 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/META-INF/MANIFEST.MF
@@ -11,6 +11,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tm.tcf.core;bundle-version="0.5.0",
org.eclipse.tm.te.runtime;bundle-version="1.0.0",
org.eclipse.tm.te.runtime.statushandler;bundle-version="1.0.0",
+ org.eclipse.tm.te.runtime.services;bundle-version="1.0.0",
org.eclipse.tm.te.core;bundle-version="1.0.0",
org.eclipse.tm.te.ui.forms;bundle-version="1.0.0",
org.eclipse.tm.te.ui;bundle-version="1.0.0",
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/internal/dialogs/LaunchObjectDialog.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/internal/dialogs/LaunchObjectDialog.java
index 35a035279..6df98a046 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/internal/dialogs/LaunchObjectDialog.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/internal/dialogs/LaunchObjectDialog.java
@@ -28,10 +28,13 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tm.te.core.utils.text.StringUtil;
+import org.eclipse.tm.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
+import org.eclipse.tm.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tm.te.tcf.filesystem.controls.FSTreeContentProvider;
import org.eclipse.tm.te.tcf.filesystem.dialogs.FSOpenFileDialog;
import org.eclipse.tm.te.tcf.filesystem.model.FSTreeNode;
@@ -39,6 +42,7 @@ import org.eclipse.tm.te.tcf.processes.core.interfaces.launcher.IProcessLauncher
import org.eclipse.tm.te.tcf.processes.ui.internal.help.IContextHelpIds;
import org.eclipse.tm.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tm.te.ui.jface.dialogs.CustomTrayDialog;
+import org.eclipse.tm.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.forms.editor.FormPage;
@@ -49,9 +53,13 @@ public class LaunchObjectDialog extends CustomTrayDialog {
private Text imagePath;
private Button imagePathBrowse;
private Text arguments;
+ /* default */ Button lineSeparatorDefault;
+ /* default */ Button lineSeparatorLF;
+ /* default */ Button lineSeparatorCRLF;
+ /* default */ Button lineSeparatorCR;
private Map<String, Object> launchAttributes = null;
- /* default */final IEditorPart part;
+ /* default */ final IEditorPart part;
/**
* Constructor.
@@ -94,14 +102,16 @@ public class LaunchObjectDialog extends CustomTrayDialog {
Composite panel = new Composite(composite, SWT.NONE);
panel.setLayout(new GridLayout(3, false));
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// Add the controls
Label label = new Label(panel, SWT.NONE);
- label.setText(Messages.LaunchObjectSelectionControl_editfield_label);
+ label.setText(Messages.LaunchObjectDialog_image_label);
imagePath = new Text(panel, SWT.SINGLE | SWT.BORDER);
- imagePath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(imagePath, 40);
+ imagePath.setLayoutData(layoutData);
imagePath.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -132,10 +142,10 @@ public class LaunchObjectDialog extends CustomTrayDialog {
});
label = new Label(panel, SWT.NONE);
- label.setText(Messages.LaunchObjectArgumentsControl_editfield_label);
+ label.setText(Messages.LaunchObjectDialog_arguments_label);
arguments = new Text(panel, SWT.SINGLE | SWT.BORDER);
- GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
layoutData.horizontalSpan = 2;
arguments.setLayoutData(layoutData);
arguments.addModifyListener(new ModifyListener() {
@@ -145,6 +155,76 @@ public class LaunchObjectDialog extends CustomTrayDialog {
}
});
+ Group group = new Group(composite, SWT.NONE);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ group.setLayoutData(layoutData);
+ group.setText(Messages.LaunchObjectDialog_group_label);
+ group.setLayout(new GridLayout());
+
+ label = new Label(group, SWT.NONE);
+ label.setText(Messages.LaunchObjectDialog_lineseparator_label);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ label.setLayoutData(layoutData);
+
+ Composite panel2 = new Composite(group, SWT.NONE);
+ GridLayout layout = new GridLayout(4, false);
+ layout.marginLeft = 15; layout.marginHeight = 2;
+ panel2.setLayout(layout);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ panel2.setLayoutData(layoutData);
+
+ lineSeparatorDefault = new Button(panel2, SWT.RADIO);
+ lineSeparatorDefault.setText(Messages.LaunchObjectDialog_lineseparator_default);
+ lineSeparatorDefault.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (lineSeparatorDefault.getSelection()) {
+ SWTControlUtil.setSelection(lineSeparatorLF, false);
+ SWTControlUtil.setSelection(lineSeparatorCRLF, false);
+ SWTControlUtil.setSelection(lineSeparatorCR, false);
+ }
+ }
+ });
+
+ lineSeparatorLF = new Button(panel2, SWT.RADIO);
+ lineSeparatorLF.setText(Messages.LaunchObjectDialog_lineseparator_lf);
+ lineSeparatorLF.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (lineSeparatorDefault.getSelection()) {
+ SWTControlUtil.setSelection(lineSeparatorDefault, false);
+ SWTControlUtil.setSelection(lineSeparatorCRLF, false);
+ SWTControlUtil.setSelection(lineSeparatorCR, false);
+ }
+ }
+ });
+
+ lineSeparatorCRLF = new Button(panel2, SWT.RADIO);
+ lineSeparatorCRLF.setText(Messages.LaunchObjectDialog_lineseparator_crlf);
+ lineSeparatorCRLF.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (lineSeparatorDefault.getSelection()) {
+ SWTControlUtil.setSelection(lineSeparatorDefault, false);
+ SWTControlUtil.setSelection(lineSeparatorLF, false);
+ SWTControlUtil.setSelection(lineSeparatorCR, false);
+ }
+ }
+ });
+
+ lineSeparatorCR = new Button(panel2, SWT.RADIO);
+ lineSeparatorCR.setText(Messages.LaunchObjectDialog_lineseparator_cr);
+ lineSeparatorCR.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (lineSeparatorDefault.getSelection()) {
+ SWTControlUtil.setSelection(lineSeparatorDefault, false);
+ SWTControlUtil.setSelection(lineSeparatorLF, false);
+ SWTControlUtil.setSelection(lineSeparatorCRLF, false);
+ }
+ }
+ });
+
// Setup the control content
setupContent();
@@ -169,7 +249,7 @@ public class LaunchObjectDialog extends CustomTrayDialog {
* {@link #createDialogArea(Composite)}.
*/
protected void configureTitles() {
- setDialogTitle(Messages.LaunchObjectSelectionControl_title);
+ setDialogTitle(Messages.LaunchObjectDialog_title);
}
/**
@@ -226,6 +306,21 @@ public class LaunchObjectDialog extends CustomTrayDialog {
String argumentsString = arguments.getText();
String[] args = argumentsString != null && !"".equals(argumentsString.trim()) ? StringUtil.tokenize(argumentsString, 0, true) : null; //$NON-NLS-1$
launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args);
+
+ // Local Echo is OFF.
+ launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE);
+
+ String lineSeparator = null;
+ if (SWTControlUtil.getSelection(lineSeparatorLF)) {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_LF;
+ }
+ else if (SWTControlUtil.getSelection(lineSeparatorCRLF)) {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CRLF;
+ }
+ else if (SWTControlUtil.getSelection(lineSeparatorCR)) {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CR;
+ }
+ launchAttributes.put(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, lineSeparator);
}
/**
@@ -253,6 +348,18 @@ public class LaunchObjectDialog extends CustomTrayDialog {
if (settings != null) {
settings.put(IProcessLauncher.PROP_PROCESS_PATH, imagePath.getText());
settings.put(IProcessLauncher.PROP_PROCESS_ARGS, arguments.getText());
+
+ String lineSeparator = null;
+ if (SWTControlUtil.getSelection(lineSeparatorLF)) {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_LF;
+ }
+ else if (SWTControlUtil.getSelection(lineSeparatorCRLF)) {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CRLF;
+ }
+ else if (SWTControlUtil.getSelection(lineSeparatorCR)) {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CR;
+ }
+ settings.put(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, lineSeparator);
}
}
@@ -266,6 +373,20 @@ public class LaunchObjectDialog extends CustomTrayDialog {
if (path != null) imagePath.setText(path);
String args = settings.get(IProcessLauncher.PROP_PROCESS_ARGS);
if (args != null) arguments.setText(args);
+
+ String lineSeparator = settings.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
+ if (lineSeparator == null) {
+ SWTControlUtil.setSelection(lineSeparatorDefault, true);
+ }
+ else if (ILineSeparatorConstants.LINE_SEPARATOR_LF.equals(lineSeparator)) {
+ SWTControlUtil.setSelection(lineSeparatorLF, true);
+ }
+ else if (ILineSeparatorConstants.LINE_SEPARATOR_CRLF.equals(lineSeparator)) {
+ SWTControlUtil.setSelection(lineSeparatorCRLF, true);
+ }
+ else if (ILineSeparatorConstants.LINE_SEPARATOR_CR.equals(lineSeparator)) {
+ SWTControlUtil.setSelection(lineSeparatorCR, true);
+ }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.java
index d94327fbd..596bcd5f2 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.java
@@ -39,14 +39,15 @@ public class Messages extends NLS {
public static String ProcessSelectionDialog_title;
- public static String LaunchObjectSelectionControl_editfield_label;
- public static String LaunchObjectSelectionControl_info_missingValue;
- public static String LaunchObjectSelectionControl_error_invalidName;
-
- public static String LaunchObjectArgumentsControl_editfield_label;
-
- public static String LaunchObjectSelectionControl_title;
- public static String LaunchObjectSelectionControl_defaultMessage;
+ public static String LaunchObjectDialog_title;
+ public static String LaunchObjectDialog_image_label;
+ public static String LaunchObjectDialog_arguments_label;
+ public static String LaunchObjectDialog_group_label;
+ public static String LaunchObjectDialog_lineseparator_label;
+ public static String LaunchObjectDialog_lineseparator_default;
+ public static String LaunchObjectDialog_lineseparator_lf;
+ public static String LaunchObjectDialog_lineseparator_crlf;
+ public static String LaunchObjectDialog_lineseparator_cr;
public static String LaunchProcessesCommandHandler_error_title;
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.properties
index 38960cbb0..0560729ee 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.processes.ui/src/org/eclipse/tm/te/tcf/processes/ui/nls/Messages.properties
@@ -13,12 +13,16 @@ ProcessesTreeControl_column_user_label=User
ProcessSelectionDialog_title=Select Process to Attach
-LaunchObjectSelectionControl_editfield_label=Process Image:
-LaunchObjectSelectionControl_info_missingValue=Please select the process image to launch.
-LaunchObjectSelectionControl_error_invalidName=The specified process image path is invalid. Please select or enter a valid path to the process image.
+LaunchObjectDialog_title=Launch Process
+LaunchObjectDialog_image_label=Process Image:
+LaunchObjectDialog_arguments_label=Process Arguments:
+LaunchObjectDialog_group_label=Process Line Separator Settings
+LaunchObjectDialog_lineseparator_label=Please specify the line separator used by the launched process.
+LaunchObjectDialog_lineseparator_default=Default
+LaunchObjectDialog_lineseparator_lf=LF
+LaunchObjectDialog_lineseparator_crlf=CRLF
+LaunchObjectDialog_lineseparator_cr=CR
-LaunchObjectArgumentsControl_editfield_label=Process Arguments:
-
-LaunchObjectSelectionControl_title=Launch Process
+AbstractChannelCommandHandler_statusDialog_title=Error
LaunchProcessesCommandHandler_error_title=Process Launch Failed
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnector.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnector.java
index da3ec649a..4f4eb5b6c 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnector.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnector.java
@@ -39,6 +39,7 @@ 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.TerminalState;
+import org.eclipse.tm.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
import org.eclipse.tm.te.ui.terminals.process.activator.UIPlugin;
import org.eclipse.tm.te.ui.terminals.process.nls.Messages;
import org.eclipse.tm.te.ui.terminals.streams.AbstractStreamsConnector;
@@ -155,8 +156,22 @@ public class ProcessConnector extends AbstractStreamsConnector {
}
}
+ String lineSeparator = settings.getLineSeparator();
+ if (lineSeparator == null) {
+ lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
+ if ("\r".equals(lineSeparator)) { //$NON-NLS-1$
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CR;
+ }
+ else if ("\n".equals(lineSeparator)) { //$NON-NLS-1$
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_LF;
+ }
+ else {
+ lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CRLF;
+ }
+ }
+
// connect the streams
- connectStreams(control, process.getOutputStream(), process.getInputStream(), (pty == null ? process.getErrorStream() : null));
+ connectStreams(control, process.getOutputStream(), process.getInputStream(), (pty == null ? process.getErrorStream() : null), settings.isLocalEcho(), lineSeparator);
// Set the terminal control state to CONNECTED
control.setState(TerminalState.CONNECTED);
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnectorType.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnectorType.java
index 1fa3bbea1..0a8a64322 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnectorType.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessConnectorType.java
@@ -34,37 +34,18 @@ public class ProcessConnectorType extends AbstractConnectorType {
// Check for the terminal connector id
String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
+ if (connectorId == null) connectorId = "org.eclipse.tm.te.ui.terminals.ProcessConnector"; //$NON-NLS-1$
// Extract the process properties
- String path = properties.getStringProperty(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
+ String image = properties.getStringProperty(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
String arguments = properties.getStringProperty(ITerminalsConnectorConstants.PROP_PROCESS_ARGS);
Process process = (Process)properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_OBJ);
PTY pty = (PTY)properties.getProperty(ITerminalsConnectorConstants.PROP_PTY_OBJ);
boolean localEcho = properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
+ String lineSeparator = properties.getStringProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
- return createProcessConnector(connectorId, path, arguments, process, pty, localEcho);
- }
-
- /**
- * Creates a terminal connector object based on the given process image
- * and the corresponding process object.
- *
- * @param connectorTypeId Optional ID of the specific process connector implementation to use.
- * If <code>null</code>, the default process connector will be used.
- * @param image The process image path. Must not be <code>null</code>.
- * @param arguments The process arguments or <code>null</code>.
- * @param process The process. Must not be <code>null</code>.
- * @param pty The pseudo terminal or <code>null</code>.
- * @param localEcho <code>True</code> if the terminal widget local echo shall be enabled, <code>false</code> otherwise.
- *
- * @return The terminal connector object instance or <code>null</code>.
- */
- public ITerminalConnector createProcessConnector(String connectorTypeId, final String image, final String arguments, final Process process, PTY pty, boolean localEcho) {
Assert.isTrue(image != null || process != null);
- // Normalize the process connector id
- if (connectorTypeId == null) connectorTypeId = "org.eclipse.tm.te.ui.terminals.ProcessConnector"; //$NON-NLS-1$
-
// Construct the terminal settings store
ISettingsStore store = new SettingsStore();
@@ -75,11 +56,12 @@ public class ProcessConnectorType extends AbstractConnectorType {
processSettings.setProcess(process);
processSettings.setPTY(pty);
processSettings.setLocalEcho(localEcho);
+ processSettings.setLineSeparator(lineSeparator);
// And save the settings to the store
processSettings.save(store);
// Construct the terminal connector instance
- ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorTypeId);
+ ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
if (connector != null) {
// Apply default settings
connector.makeSettingsPage();
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessSettings.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessSettings.java
index 5976fdfed..58e25812d 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessSettings.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals.process/src/org/eclipse/tm/te/ui/terminals/process/ProcessSettings.java
@@ -30,6 +30,8 @@ public class ProcessSettings {
// Flag to control the local echo (defaults to true if
// the PTY is not supported on the current host platform)
private boolean localEcho = !PTY.isSupported();
+ // The line separator setting
+ private String lineSeparator = null;
/**
* Sets the process image.
@@ -129,6 +131,24 @@ public class ProcessSettings {
}
/**
+ * Sets the process line separator.
+ *
+ * @param separator The process line separator <code>null</code>.
+ */
+ public void setLineSeparator(String separator) {
+ this.lineSeparator = separator;
+ }
+
+ /**
+ * Returns the process line separator.
+ *
+ * @return The process line separator or <code>null</code>.
+ */
+ public String getLineSeparator() {
+ return lineSeparator;
+ }
+
+ /**
* Loads the process settings from the given settings store.
*
* @param store The settings store. Must not be <code>null</code>.
@@ -138,6 +158,7 @@ public class ProcessSettings {
image = store.get("Path", null);//$NON-NLS-1$
arguments = store.get("Arguments", null); //$NON-NLS-1$
localEcho = Boolean.parseBoolean(store.get("LocalEcho", Boolean.FALSE.toString())); //$NON-NLS-1$
+ lineSeparator = store.get("LineSeparator", null); //$NON-NLS-1$
if (store instanceof IPropertiesContainer) {
process = (Process)((IPropertiesContainer)store).getProperty("Process"); //$NON-NLS-1$
pty = (PTY)((IPropertiesContainer)store).getProperty("PTY"); //$NON-NLS-1$
@@ -154,6 +175,7 @@ public class ProcessSettings {
store.put("Path", image);//$NON-NLS-1$
store.put("Arguments", arguments); //$NON-NLS-1$
store.put("LocalEcho", Boolean.toString(localEcho)); //$NON-NLS-1$
+ store.put("LineSeparator", lineSeparator); //$NON-NLS-1$
if (store instanceof IPropertiesContainer) {
((IPropertiesContainer)store).setProperty("Process", process); //$NON-NLS-1$
((IPropertiesContainer)store).setProperty("PTY", pty); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/AbstractStreamsConnector.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/AbstractStreamsConnector.java
index c51a8d474..5f4025d67 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/AbstractStreamsConnector.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/AbstractStreamsConnector.java
@@ -37,13 +37,15 @@ public abstract class AbstractStreamsConnector extends TerminalConnectorImpl {
* @param stdin The stdin stream or <code>null</code>.
* @param stdout The stdout stream or <code>null</code>.
* @param stderr The stderr stream or <code>null</code>.
+ * @param localEcho Local echo on or off.
+ * @param lineSeparator The line separator used by the stream.
*/
- protected void connectStreams(ITerminalControl terminalControl, OutputStream stdin, InputStream stdout, InputStream stderr) {
+ protected void connectStreams(ITerminalControl terminalControl, OutputStream stdin, InputStream stdout, InputStream stderr, boolean localEcho, String lineSeparator) {
Assert.isNotNull(terminalControl);
// Create the input stream monitor
if (stdin != null) {
- stdInMonitor = createStdInMonitor(terminalControl, stdin);
+ stdInMonitor = createStdInMonitor(terminalControl, stdin, localEcho, lineSeparator);
// Register the connector if it implements IDisposable and stdout/stderr are not monitored
if (stdout == null && stderr == null && this instanceof IDisposable) stdInMonitor.addDisposable((IDisposable)this);
// Start the monitoring
@@ -52,7 +54,7 @@ public abstract class AbstractStreamsConnector extends TerminalConnectorImpl {
// Create the output stream monitor
if (stdout != null) {
- stdOutMonitor = createStdOutMonitor(terminalControl, stdout);
+ stdOutMonitor = createStdOutMonitor(terminalControl, stdout, lineSeparator);
// Register the connector if it implements IDisposable
if (this instanceof IDisposable) stdOutMonitor.addDisposable((IDisposable)this);
// Start the monitoring
@@ -61,7 +63,7 @@ public abstract class AbstractStreamsConnector extends TerminalConnectorImpl {
// Create the error stream monitor
if (stderr != null) {
- stdErrMonitor = createStdErrMonitor(terminalControl, stderr);
+ stdErrMonitor = createStdErrMonitor(terminalControl, stderr, lineSeparator);
// Register the connector if it implements IDisposable and stdout is not monitored
if (stdout == null && this instanceof IDisposable) stdErrMonitor.addDisposable((IDisposable)this);
// Start the monitoring
@@ -75,10 +77,13 @@ public abstract class AbstractStreamsConnector extends TerminalConnectorImpl {
*
* @param terminalControl The terminal control. Must not be <code>null</code>.
* @param stdin The stdin stream or <code>null</code>.
+ * @param localEcho Local echo on or off.
+ * @param lineSeparator The line separator used by the stream.
+ *
* @return input stream monitor
*/
- protected InputStreamMonitor createStdInMonitor(ITerminalControl terminalControl, OutputStream stdin) {
- return new InputStreamMonitor(terminalControl, stdin);
+ protected InputStreamMonitor createStdInMonitor(ITerminalControl terminalControl, OutputStream stdin, boolean localEcho, String lineSeparator) {
+ return new InputStreamMonitor(terminalControl, stdin, localEcho, lineSeparator);
}
/**
@@ -87,10 +92,12 @@ public abstract class AbstractStreamsConnector extends TerminalConnectorImpl {
*
* @param terminalControl The terminal control. Must not be <code>null</code>.
* @param stdout The stdout stream or <code>null</code>.
+ * @param lineSeparator The line separator used by the stream.
+ *
* @return output stream monitor
*/
- protected OutputStreamMonitor createStdOutMonitor(ITerminalControl terminalControl, InputStream stdout) {
- return new OutputStreamMonitor(terminalControl, stdout);
+ protected OutputStreamMonitor createStdOutMonitor(ITerminalControl terminalControl, InputStream stdout, String lineSeparator) {
+ return new OutputStreamMonitor(terminalControl, stdout, lineSeparator);
}
/**
@@ -99,10 +106,12 @@ public abstract class AbstractStreamsConnector extends TerminalConnectorImpl {
*
* @param terminalControl The terminal control. Must not be <code>null</code>.
* @param stderr The stderr stream or <code>null</code>.
+ * @param lineSeparator The line separator used by the stream.
+ *
* @return output stream monitor
*/
- protected OutputStreamMonitor createStdErrMonitor(ITerminalControl terminalControl, InputStream stderr) {
- return new OutputStreamMonitor(terminalControl, stderr);
+ protected OutputStreamMonitor createStdErrMonitor(ITerminalControl terminalControl, InputStream stderr, String lineSeparator) {
+ return new OutputStreamMonitor(terminalControl, stderr, lineSeparator);
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/InputStreamMonitor.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/InputStreamMonitor.java
index e50b6413d..19d7aa877 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/InputStreamMonitor.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/InputStreamMonitor.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
+import org.eclipse.tm.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
import org.eclipse.tm.te.ui.terminals.activator.UIPlugin;
import org.eclipse.tm.te.ui.terminals.nls.Messages;
import org.eclipse.ui.services.IDisposable;
@@ -53,19 +54,70 @@ public class InputStreamMonitor extends OutputStream implements IDisposable {
// Queue to buffer the data to write to the output stream
private final Queue<byte[]> queue = new LinkedList<byte[]>();
+ // ***** Line separator replacement logic *****
+ // ***** Adapted from org.eclipse.tm.internal.terminal.local.LocalTerminalOutputStream *****
+
+ private final static int TERMINAL_SENDS_CR = 0;
+ private final static int TERMINAL_SENDS_CRLF = 1;
+ private final static int PROGRAM_EXPECTS_LF = 0;
+ private final static int PROGRAM_EXPECTS_CRLF = 1;
+ private final static int PROGRAM_EXPECTS_CR = 2;
+ private final static int NO_CHANGE = 0;
+ private final static int CHANGE_CR_TO_LF = 1;
+ private final static int INSERT_LF_AFTER_CR = 2;
+ private final static int REMOVE_CR = 3;
+ private final static int REMOVE_LF = 4;
+
+ // CRLF conversion table:
+ //
+ // Expected line separator --> | LF | CRLF | CR |
+ // ------------------------------------+-----------------+--------------------+----------------+
+ // Local echo off - control sends CR | change CR to LF | insert LF after CR | no change |
+ // ------------------------------------+-----------------+--------------------+----------------+
+ // Local echo on - control sends CRLF | remove CR | no change | remove LF |
+ //
+ private final static int[][] CRLF_REPLACEMENT = {
+
+ {CHANGE_CR_TO_LF, INSERT_LF_AFTER_CR, NO_CHANGE},
+ {REMOVE_CR, NO_CHANGE, REMOVE_LF}
+ };
+
+ private int replacement;
+
/**
* Constructor.
*
* @param terminalControl The parent terminal control. Must not be <code>null</code>.
* @param stream The stream. Must not be <code>null</code>.
+ * @param localEcho Local echo on or off.
+ * @param lineSeparator The line separator used by the stream.
*/
- public InputStreamMonitor(ITerminalControl terminalControl, OutputStream stream) {
+ public InputStreamMonitor(ITerminalControl terminalControl, OutputStream stream, boolean localEcho, String lineSeparator) {
super();
Assert.isNotNull(terminalControl);
this.terminalControl = terminalControl;
Assert.isNotNull(stream);
this.stream = stream;
+
+ // Determine the line separator replacement setting
+ int terminalSends = localEcho ? TERMINAL_SENDS_CRLF : TERMINAL_SENDS_CR;
+ if (lineSeparator == null) {
+ replacement = NO_CHANGE;
+ } else {
+ int programExpects;
+ if (lineSeparator.equals(ILineSeparatorConstants.LINE_SEPARATOR_LF)) {
+ programExpects = PROGRAM_EXPECTS_LF;
+ }
+ else if (lineSeparator.equals(ILineSeparatorConstants.LINE_SEPARATOR_CR)) {
+ programExpects = PROGRAM_EXPECTS_CR;
+ }
+ else {
+ programExpects = PROGRAM_EXPECTS_CRLF;
+ }
+ replacement = CRLF_REPLACEMENT[terminalSends][programExpects];
+ }
+
}
/**
@@ -205,11 +257,88 @@ public class InputStreamMonitor extends OutputStream implements IDisposable {
}
}
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
@Override
public void write(byte[] b, int off, int len) throws IOException {
+ // Write the whole block to the queue to avoid synchronization
+ // to happen for every byte. To do so, we have to avoid calling
+ // the super method. Therefore we have to do the same checking
+ // here as the base class does.
+
+ // Null check. See the implementation in OutputStream.
+ if (b == null) throw new NullPointerException();
+
+ // Boundary check. See the implementation in OutputStream.
+ if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) {
+ throw new IndexOutOfBoundsException();
+ }
+ else if (len == 0) {
+ return;
+ }
+
// Make sure that the written block is not interlaced with other input.
synchronized(queue) {
- super.write(b, off, len);
+ // Preprocess the block to be written
+ byte[] processedBytes = onWriteContentToStream(b, off, len);
+ // If the returned array is not the original one, adjust offset and length
+ if (processedBytes != b) {
+ off = 0; len = processedBytes.length;
+ }
+
+ // Get the content from the byte buffer specified by offset and length
+ byte[] bytes = new byte[len];
+ int j = 0;
+ for (int i = 0 ; i < len ; i++) {
+ bytes[j++] = b[off + i];
+ }
+
+ queue.add(bytes);
+ queue.notifyAll();
}
}
+
+ /**
+ * Allow for processing of data from byte stream from the terminal before
+ * it is written to the output stream. If the returned byte array is different
+ * than the one that was passed in with the bytes argument, then the
+ * length value will be adapted.
+ *
+ * @param bytes The byte stream. Must not be <code>null</code>.
+ * @param off The offset.
+ * @param len the length.
+ *
+ * @return The processed byte stream.
+ *
+ */
+ protected byte[] onWriteContentToStream(byte[] bytes, int off, int len) {
+ Assert.isNotNull(bytes);
+
+ if (replacement != NO_CHANGE && len > 0) {
+ String text = new String(bytes, off, len);
+ //
+ // TODO: check whether this is correct! new String(byte[], int, int) always uses the default
+ // encoding!
+
+ if (replacement == CHANGE_CR_TO_LF) {
+ text = text.replace('\r', '\n');
+ }
+ else if (replacement == INSERT_LF_AFTER_CR) {
+ text = text.replaceAll(ILineSeparatorConstants.LINE_SEPARATOR_CR, "\r\n"); //$NON-NLS-1$
+ }
+ else if (replacement == REMOVE_CR) {
+ text = text.replaceAll(ILineSeparatorConstants.LINE_SEPARATOR_CR, ""); //$NON-NLS-1$
+ }
+ else if (replacement == REMOVE_LF) {
+ text = text.replaceAll(ILineSeparatorConstants.LINE_SEPARATOR_LF, ""); //$NON-NLS-1$
+ }
+
+ if (text.length() > 0) {
+ bytes = text.getBytes();
+ }
+ }
+
+ return bytes;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java
index 29170ce85..ff135dd70 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
+import org.eclipse.tm.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
import org.eclipse.tm.te.ui.terminals.activator.UIPlugin;
import org.eclipse.tm.te.ui.terminals.nls.Messages;
import org.eclipse.ui.services.IDisposable;
@@ -42,6 +43,9 @@ public class OutputStreamMonitor implements IDisposable {
// Reference to the monitored (input) stream
private final InputStream stream;
+ // The line separator used by the monitored (input) stream
+ private final String lineSeparator;
+
// Reference to the thread reading the stream
private Thread thread;
@@ -57,14 +61,17 @@ public class OutputStreamMonitor implements IDisposable {
*
* @param terminalControl The parent terminal control. Must not be <code>null</code>.
* @param stream The stream. Must not be <code>null</code>.
+ * @param lineSeparator The line separator used by the stream.
*/
- public OutputStreamMonitor(ITerminalControl terminalControl, InputStream stream) {
+ public OutputStreamMonitor(ITerminalControl terminalControl, InputStream stream, String lineSeparator) {
super();
Assert.isNotNull(terminalControl);
this.terminalControl = terminalControl;
Assert.isNotNull(stream);
this.stream = new BufferedInputStream(stream, BUFFER_SIZE);
+
+ this.lineSeparator = lineSeparator;
}
/**
@@ -207,8 +214,6 @@ public class OutputStreamMonitor implements IDisposable {
* array is different than the one that was passed in with the byteBuffer
* argument, then the bytesRead value will be ignored and the full
* returned array will be written out.
- * <p>
- * The default implementation is returning the byte stream unmodified.
*
* @param byteBuffer The byte stream. Must not be <code>null</code>.
* @param bytesRead The number of bytes that were read into the read buffer.
@@ -217,6 +222,13 @@ public class OutputStreamMonitor implements IDisposable {
*/
protected byte[] onContentReadFromStream(byte[] byteBuffer, int bytesRead) {
Assert.isNotNull(byteBuffer);
+
+ if (lineSeparator != null && !ILineSeparatorConstants.LINE_SEPARATOR_CRLF.equals(lineSeparator)) {
+ String text = new String(byteBuffer, 0, bytesRead);
+ text = text.replaceAll(lineSeparator, "\r\n"); //$NON-NLS-1$
+ byteBuffer = text.getBytes();
+ }
+
return byteBuffer;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsConnector.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsConnector.java
index 0bc89e64c..119a3f911 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsConnector.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsConnector.java
@@ -51,7 +51,7 @@ public class StreamsConnector extends AbstractStreamsConnector implements IDispo
super.connect(control);
// connect the streams
- connectStreams(control, settings.getStdinStream(), settings.getStdoutStream(), settings.getStderrStream());
+ connectStreams(control, settings.getStdinStream(), settings.getStdoutStream(), settings.getStderrStream(), settings.isLocalEcho(), settings.getLineSeparator());
// Set the terminal control state to CONNECTED
control.setState(TerminalState.CONNECTED);
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsSettings.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsSettings.java
index a3ef45196..66118342c 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsSettings.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/StreamsSettings.java
@@ -29,6 +29,8 @@ public class StreamsSettings {
private InputStream stderr;
// Flag to control the local echo
private boolean localEcho = true;
+ // The line separator setting
+ private String lineSeparator = null;
/**
* Sets the stdin stream instance.
@@ -104,6 +106,24 @@ public class StreamsSettings {
}
/**
+ * Sets the stream line separator.
+ *
+ * @param separator The stream line separator <code>null</code>.
+ */
+ public void setLineSeparator(String separator) {
+ this.lineSeparator = separator;
+ }
+
+ /**
+ * Returns the stream line separator.
+ *
+ * @return The stream line separator or <code>null</code>.
+ */
+ public String getLineSeparator() {
+ return lineSeparator;
+ }
+
+ /**
* Loads the streams settings from the given settings store.
*
* @param store The settings store. Must not be <code>null</code>.
@@ -111,6 +131,7 @@ public class StreamsSettings {
public void load(ISettingsStore store) {
Assert.isNotNull(store);
localEcho = Boolean.parseBoolean(store.get("LocalEcho", Boolean.FALSE.toString())); //$NON-NLS-1$
+ lineSeparator = store.get("LineSeparator", null); //$NON-NLS-1$
if (store instanceof IPropertiesContainer) {
stdin = (OutputStream)((IPropertiesContainer)store).getProperty("stdin"); //$NON-NLS-1$
stdout = (InputStream)((IPropertiesContainer)store).getProperty("stdout"); //$NON-NLS-1$
@@ -126,6 +147,7 @@ public class StreamsSettings {
public void save(ISettingsStore store) {
Assert.isNotNull(store);
store.put("LocalEcho", Boolean.toString(localEcho)); //$NON-NLS-1$
+ store.put("LineSeparator", lineSeparator); //$NON-NLS-1$
if (store instanceof IPropertiesContainer) {
((IPropertiesContainer)store).setProperty("stdin", stdin); //$NON-NLS-1$
((IPropertiesContainer)store).setProperty("stdout", stdout); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/types/StreamsConnectorType.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/types/StreamsConnectorType.java
index f8d98d540..5fbf1af74 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/types/StreamsConnectorType.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/types/StreamsConnectorType.java
@@ -36,39 +36,25 @@ public class StreamsConnectorType extends AbstractConnectorType {
// Check for the terminal connector id
String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
+ if (connectorId == null) connectorId = "org.eclipse.tm.te.ui.terminals.StreamsConnector"; //$NON-NLS-1$
// Extract the streams properties
OutputStream stdin = (OutputStream)properties.getProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDIN);
InputStream stdout = (InputStream)properties.getProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT);
InputStream stderr = (InputStream)properties.getProperty(ITerminalsConnectorConstants.PROP_STREAMS_STDERR);
boolean localEcho = properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
+ String lineSeparator = properties.getStringProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
- return createStreamsConnector(connectorId, stdin, stdout, stderr, localEcho);
- }
-
- /**
- * Creates a terminal connector object based on the given stream objects.
- *
- * @param connectorId The terminal connector id or <code>null</code>.
- * @param stdin The stdin stream or <code>null</code>.
- * @param stdout The stdout stream or <code>null</code>.
- * @param stderr The stderr stream or <code>null</code>.
- * @param localEcho <code>True</code> if the terminal widget local echo shall be enabled, <code>false</code> otherwise.
- *
- * @return The terminal connector object instance or <code>null</code>.
- */
- protected ITerminalConnector createStreamsConnector(String connectorId, OutputStream stdin, InputStream stdout, InputStream stderr, boolean localEcho) {
// Construct the terminal settings store
ISettingsStore store = new SettingsStore();
- if (connectorId == null) connectorId = "org.eclipse.tm.te.ui.terminals.StreamsConnector"; //$NON-NLS-1$
-
// Construct the streams settings
StreamsSettings streamsSettings = new StreamsSettings();
streamsSettings.setStdinStream(stdin);
streamsSettings.setStdoutStream(stdout);
streamsSettings.setStderrStream(stderr);
streamsSettings.setLocalEcho(localEcho);
+ streamsSettings.setLineSeparator(lineSeparator);
// And save the settings to the store
streamsSettings.save(store);

Back to the top