mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Lambda conversion in terminal code.
Change-Id: I30c23a89b3e78306d3e05fa65f5d2d8dd9e23540 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
da67b8d706
commit
cc8211514f
19 changed files with 157 additions and 306 deletions
|
@ -68,12 +68,7 @@ public class ProcessMonitor {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create a new runnable which is constantly reading from the stream
|
// Create a new runnable which is constantly reading from the stream
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = () -> monitorProcess();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
monitorProcess();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the monitor thread
|
// Create the monitor thread
|
||||||
thread = new Thread(runnable, "Terminal Process Monitor Thread"); //$NON-NLS-1$
|
thread = new Thread(runnable, "Terminal Process Monitor Thread"); //$NON-NLS-1$
|
||||||
|
|
|
@ -28,8 +28,6 @@ import java.util.List;
|
||||||
import org.eclipse.jface.dialogs.IMessageProvider;
|
import org.eclipse.jface.dialogs.IMessageProvider;
|
||||||
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
|
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -195,12 +193,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
fHostText = new Text(composite, SWT.BORDER);
|
fHostText = new Text(composite, SWT.BORDER);
|
||||||
fHostText.setLayoutData(gridData);
|
fHostText.setLayoutData(gridData);
|
||||||
fHostText.addModifyListener(new ModifyListener() {
|
fHostText.addModifyListener(e -> fireListeners(fHostText));
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
fireListeners(fHostText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
createControlDecoration(fHostText);
|
createControlDecoration(fHostText);
|
||||||
|
|
||||||
// Add label
|
// Add label
|
||||||
|
@ -211,12 +204,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
fNetworkPortCombo = new Combo(composite, SWT.DROP_DOWN);
|
fNetworkPortCombo = new Combo(composite, SWT.DROP_DOWN);
|
||||||
fNetworkPortCombo.setLayoutData(gridData);
|
fNetworkPortCombo.setLayoutData(gridData);
|
||||||
fNetworkPortCombo.addModifyListener(new ModifyListener() {
|
fNetworkPortCombo.addModifyListener(e -> fireListeners(fNetworkPortCombo));
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
fireListeners(fNetworkPortCombo);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fNetworkPortCombo.addSelectionListener(new SelectionAdapter() {
|
fNetworkPortCombo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
@ -232,12 +220,7 @@ public class TelnetSettingsPage extends AbstractSettingsPage {
|
||||||
new Label(composite, SWT.RIGHT).setText(TelnetMessages.TIMEOUT + ":"); //$NON-NLS-1$
|
new Label(composite, SWT.RIGHT).setText(TelnetMessages.TIMEOUT + ":"); //$NON-NLS-1$
|
||||||
fTimeout = new Text(composite, SWT.BORDER);
|
fTimeout = new Text(composite, SWT.BORDER);
|
||||||
fTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
fTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
fTimeout.addModifyListener(new ModifyListener() {
|
fTimeout.addModifyListener(e -> fireListeners(fTimeout));
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
fireListeners(fTimeout);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
createControlDecoration(fTimeout);
|
createControlDecoration(fTimeout);
|
||||||
|
|
||||||
new Label(composite, SWT.RIGHT).setText(TelnetMessages.END_OF_LINE + ":"); //$NON-NLS-1$
|
new Label(composite, SWT.RIGHT).setText(TelnetMessages.END_OF_LINE + ":"); //$NON-NLS-1$
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
|
import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||||
import org.eclipse.tm.terminal.connector.telnet.connector.NetworkPortMap;
|
import org.eclipse.tm.terminal.connector.telnet.connector.NetworkPortMap;
|
||||||
|
@ -72,13 +71,9 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio
|
||||||
telnetSettingsPage.createControl(panel);
|
telnetSettingsPage.createControl(panel);
|
||||||
|
|
||||||
// Add the listener to the settings page
|
// Add the listener to the settings page
|
||||||
telnetSettingsPage.addListener(new ISettingsPage.Listener() {
|
telnetSettingsPage.addListener(control -> {
|
||||||
|
if (getContainer() != null)
|
||||||
@Override
|
getContainer().validate();
|
||||||
public void onSettingsPageChanged(Control control) {
|
|
||||||
if (getContainer() != null)
|
|
||||||
getContainer().validate();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the encoding selection combo
|
// Create the encoding selection combo
|
||||||
|
|
|
@ -35,8 +35,6 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.Sash;
|
import org.eclipse.swt.widgets.Sash;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
|
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
|
||||||
|
@ -235,27 +233,25 @@ public class CommandInputFieldWithHistory implements ICommandInputField {
|
||||||
final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
gd_sash.heightHint = 5;
|
gd_sash.heightHint = 5;
|
||||||
fSash.setLayoutData(gd_sash);
|
fSash.setLayoutData(gd_sash);
|
||||||
fSash.addListener(SWT.Selection, new Listener() {
|
fSash.addListener(SWT.Selection, e -> {
|
||||||
public void handleEvent(Event e) {
|
if (e.detail == SWT.DRAG) {
|
||||||
if (e.detail == SWT.DRAG) {
|
// don't redraw during drag, it causes paint errors - bug 220971
|
||||||
// don't redraw during drag, it causes paint errors - bug 220971
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
// no idea why this is needed
|
|
||||||
GridData gdata = (GridData) fInputField.getLayoutData();
|
|
||||||
Rectangle sashRect = fSash.getBounds();
|
|
||||||
Rectangle containerRect = parent.getClientArea();
|
|
||||||
|
|
||||||
int h = fInputField.getLineHeight();
|
|
||||||
// make sure the input filed height is a multiple of the line height
|
|
||||||
gdata.heightHint = Math.max(((containerRect.height - e.y - sashRect.height) / h) * h, h);
|
|
||||||
// do not show less then one line
|
|
||||||
e.y = Math.min(e.y, containerRect.height - h);
|
|
||||||
fInputField.setLayoutData(gdata);
|
|
||||||
parent.layout();
|
|
||||||
// else the content assist icon will be replicated
|
|
||||||
parent.redraw();
|
|
||||||
}
|
}
|
||||||
|
// no idea why this is needed
|
||||||
|
GridData gdata = (GridData) fInputField.getLayoutData();
|
||||||
|
Rectangle sashRect = fSash.getBounds();
|
||||||
|
Rectangle containerRect = parent.getClientArea();
|
||||||
|
|
||||||
|
int h = fInputField.getLineHeight();
|
||||||
|
// make sure the input filed height is a multiple of the line height
|
||||||
|
gdata.heightHint = Math.max(((containerRect.height - e.y - sashRect.height) / h) * h, h);
|
||||||
|
// do not show less then one line
|
||||||
|
e.y = Math.min(e.y, containerRect.height - h);
|
||||||
|
fInputField.setLayoutData(gdata);
|
||||||
|
parent.layout();
|
||||||
|
// else the content assist icon will be replicated
|
||||||
|
parent.redraw();
|
||||||
});
|
});
|
||||||
fPanel = new Composite(parent, SWT.NONE);
|
fPanel = new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
|
|
|
@ -67,7 +67,6 @@ import org.eclipse.jface.bindings.keys.KeyStroke;
|
||||||
import org.eclipse.jface.bindings.keys.SWTKeySupport;
|
import org.eclipse.jface.bindings.keys.SWTKeySupport;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.dnd.Clipboard;
|
import org.eclipse.swt.dnd.Clipboard;
|
||||||
|
@ -165,21 +164,15 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
/**
|
/**
|
||||||
* Listens to changes in the preferences
|
* Listens to changes in the preferences
|
||||||
*/
|
*/
|
||||||
private final IPropertyChangeListener fPreferenceListener = new IPropertyChangeListener() {
|
private final IPropertyChangeListener fPreferenceListener = event -> {
|
||||||
@Override
|
if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES)
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
|| event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) {
|
||||||
if (event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES)
|
updatePreferences();
|
||||||
|| event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) {
|
|
||||||
updatePreferences();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() {
|
private final IPropertyChangeListener fFontListener = event -> {
|
||||||
@Override
|
if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) {
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
onTerminalFontChanged();
|
||||||
if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) {
|
|
||||||
onTerminalFontChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -731,12 +724,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
new TextLineRenderer(fCtlText, fPollingTextCanvasModel));
|
new TextLineRenderer(fCtlText, fPollingTextCanvasModel));
|
||||||
|
|
||||||
fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
fCtlText.addResizeHandler(new TextCanvas.ResizeListener() {
|
fCtlText.addResizeHandler((lines, columns) -> fTerminalText.setDimensions(lines, columns));
|
||||||
@Override
|
|
||||||
public void sizeChanged(int lines, int columns) {
|
|
||||||
fTerminalText.setDimensions(lines, columns);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fCtlText.addMouseListener(new MouseAdapter() {
|
fCtlText.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseUp(MouseEvent e) {
|
public void mouseUp(MouseEvent e) {
|
||||||
|
@ -1233,17 +1221,14 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
fState = state;
|
fState = state;
|
||||||
fTerminalListener.setState(state);
|
fTerminalListener.setState(state);
|
||||||
// enable the (blinking) cursor if the terminal is connected
|
// enable the (blinking) cursor if the terminal is connected
|
||||||
runAsyncInDisplayThread(new Runnable() {
|
runAsyncInDisplayThread(() -> {
|
||||||
@Override
|
if (fCtlText != null && !fCtlText.isDisposed()) {
|
||||||
public void run() {
|
if (isConnected()) {
|
||||||
if (fCtlText != null && !fCtlText.isDisposed()) {
|
fCtlText.setCursorEnabled(true);
|
||||||
if (isConnected()) {
|
} else {
|
||||||
fCtlText.setCursorEnabled(true);
|
fCtlText.setCursorEnabled(false);
|
||||||
} else {
|
// Stop capturing all key events
|
||||||
fCtlText.setCursorEnabled(false);
|
fFocusListener.captureKeyEvents(false);
|
||||||
// Stop capturing all key events
|
|
||||||
fFocusListener.captureKeyEvents(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,11 +49,7 @@ public class TerminalConnectorExtension {
|
||||||
}
|
}
|
||||||
String hidden = config.getAttribute("hidden"); //$NON-NLS-1$
|
String hidden = config.getAttribute("hidden"); //$NON-NLS-1$
|
||||||
boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false;
|
boolean isHidden = hidden != null ? new Boolean(hidden).booleanValue() : false;
|
||||||
TerminalConnector.Factory factory = new TerminalConnector.Factory() {
|
TerminalConnector.Factory factory = () -> (TerminalConnectorImpl) config.createExecutableExtension("class");
|
||||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
|
||||||
return (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return new TerminalConnector(factory, id, name, isHidden);
|
return new TerminalConnector(factory, id, name, isHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@ import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,16 +30,14 @@ abstract public class GridCanvas extends VirtualCanvas {
|
||||||
|
|
||||||
public GridCanvas(Composite parent, int style) {
|
public GridCanvas(Composite parent, int style) {
|
||||||
super(parent, style);
|
super(parent, style);
|
||||||
addListener(SWT.MouseWheel, new Listener() {
|
addListener(SWT.MouseWheel, event -> {
|
||||||
public void handleEvent(Event event) {
|
if (getVerticalBar().isVisible()) {
|
||||||
if (getVerticalBar().isVisible()) {
|
int delta = -fCellHeight;
|
||||||
int delta = -fCellHeight;
|
if (event.count < 0)
|
||||||
if (event.count < 0)
|
delta = -delta;
|
||||||
delta = -delta;
|
scrollYDelta(delta);
|
||||||
scrollYDelta(delta);
|
|
||||||
}
|
|
||||||
event.doit = false;
|
|
||||||
}
|
}
|
||||||
|
event.doit = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.swt.events.FocusEvent;
|
||||||
import org.eclipse.swt.events.FocusListener;
|
import org.eclipse.swt.events.FocusListener;
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
import org.eclipse.swt.events.MouseListener;
|
import org.eclipse.swt.events.MouseListener;
|
||||||
import org.eclipse.swt.events.MouseMoveListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
@ -185,13 +184,10 @@ public class TextCanvas extends GridCanvas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addMouseMoveListener(new MouseMoveListener() {
|
addMouseMoveListener(e -> {
|
||||||
|
if (fDraggingStart != null) {
|
||||||
public void mouseMove(MouseEvent e) {
|
updateHasSelection(e);
|
||||||
if (fDraggingStart != null) {
|
setSelection(screenPointToCell(e.x, e.y));
|
||||||
updateHasSelection(e);
|
|
||||||
setSelection(screenPointToCell(e.x, e.y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
serVerticalBarVisible(true);
|
serVerticalBarVisible(true);
|
||||||
|
|
|
@ -19,8 +19,6 @@ import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
import org.eclipse.swt.widgets.Canvas;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
||||||
|
|
||||||
|
@ -42,30 +40,13 @@ public abstract class VirtualCanvas extends Canvas {
|
||||||
public VirtualCanvas(Composite parent, int style) {
|
public VirtualCanvas(Composite parent, int style) {
|
||||||
super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
|
super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
|
||||||
fClientArea = getClientArea();
|
fClientArea = getClientArea();
|
||||||
addListener(SWT.Paint, new Listener() {
|
addListener(SWT.Paint, event -> paint(event.gc));
|
||||||
public void handleEvent(Event event) {
|
addListener(SWT.Resize, event -> {
|
||||||
paint(event.gc);
|
fClientArea = getClientArea();
|
||||||
}
|
onResize();
|
||||||
});
|
|
||||||
addListener(SWT.Resize, new Listener() {
|
|
||||||
public void handleEvent(Event event) {
|
|
||||||
fClientArea = getClientArea();
|
|
||||||
onResize();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getVerticalBar().addListener(SWT.Selection, new Listener() {
|
|
||||||
public void handleEvent(Event e) {
|
|
||||||
scrollY((ScrollBar) e.widget);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
getHorizontalBar().addListener(SWT.Selection, new Listener() {
|
|
||||||
public void handleEvent(Event e) {
|
|
||||||
scrollX((ScrollBar) e.widget);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
getVerticalBar().addListener(SWT.Selection, e -> scrollY((ScrollBar) e.widget));
|
||||||
|
getHorizontalBar().addListener(SWT.Selection, e -> scrollX((ScrollBar) e.widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onResize() {
|
protected void onResize() {
|
||||||
|
|
|
@ -170,12 +170,7 @@ public class TerminalConnectorFactoryTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TerminalConnector makeTerminalConnector(final TerminalConnectorImpl mock) {
|
protected TerminalConnector makeTerminalConnector(final TerminalConnectorImpl mock) {
|
||||||
TerminalConnector c = new TerminalConnector(new TerminalConnector.Factory() {
|
TerminalConnector c = new TerminalConnector(() -> mock, "xID", "xName", false);
|
||||||
@Override
|
|
||||||
public TerminalConnectorImpl makeConnector() throws Exception {
|
|
||||||
return mock;
|
|
||||||
}
|
|
||||||
}, "xID", "xName", false);
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,12 +183,7 @@ public class UIPlugin extends AbstractUIPlugin {
|
||||||
if (window != null && windowListener != null)
|
if (window != null && windowListener != null)
|
||||||
windowListener.windowOpened(window);
|
windowListener.windowOpened(window);
|
||||||
} else {
|
} else {
|
||||||
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> activateContexts());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
activateContexts();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,7 @@ package org.eclipse.tm.terminal.view.ui.controls;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.graphics.Font;
|
import org.eclipse.swt.graphics.Font;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -116,23 +113,15 @@ public class NoteCompositeHelper {
|
||||||
noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
|
noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
|
||||||
noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
|
noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
|
||||||
|
|
||||||
final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
|
final IPropertyChangeListener fontListener = event -> {
|
||||||
@Override
|
// Note: This is actually wrong but the same as in platforms
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
// PreferencePage
|
||||||
// Note: This is actually wrong but the same as in platforms
|
if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
|
||||||
// PreferencePage
|
noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
|
||||||
if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
|
|
||||||
noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
JFaceResources.getFontRegistry().addListener(fontListener);
|
JFaceResources.getFontRegistry().addListener(fontListener);
|
||||||
noteLabel.addDisposeListener(new DisposeListener() {
|
noteLabel.addDisposeListener(event -> JFaceResources.getFontRegistry().removeListener(fontListener));
|
||||||
@Override
|
|
||||||
public void widgetDisposed(DisposeEvent event) {
|
|
||||||
JFaceResources.getFontRegistry().removeListener(fontListener);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Label messageLabel = new Label(messageComposite, SWT.WRAP);
|
Label messageLabel = new Label(messageComposite, SWT.WRAP);
|
||||||
messageLabel.setText(message);
|
messageLabel.setText(message);
|
||||||
|
|
|
@ -23,8 +23,6 @@ import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
import org.eclipse.jface.dialogs.TrayDialog;
|
import org.eclipse.jface.dialogs.TrayDialog;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.ScrolledComposite;
|
import org.eclipse.swt.custom.ScrolledComposite;
|
||||||
import org.eclipse.swt.events.ModifyEvent;
|
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -142,12 +140,7 @@ public class ExternalExecutablesDialog extends TrayDialog {
|
||||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
||||||
name.setLayoutData(layoutData);
|
name.setLayoutData(layoutData);
|
||||||
name.addModifyListener(new ModifyListener() {
|
name.addModifyListener(e -> validate());
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
label = new Label(panel, SWT.HORIZONTAL);
|
label = new Label(panel, SWT.HORIZONTAL);
|
||||||
label.setText(Messages.ExternalExecutablesDialog_field_path);
|
label.setText(Messages.ExternalExecutablesDialog_field_path);
|
||||||
|
@ -166,12 +159,7 @@ public class ExternalExecutablesDialog extends TrayDialog {
|
||||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
||||||
path.setLayoutData(layoutData);
|
path.setLayoutData(layoutData);
|
||||||
path.addModifyListener(new ModifyListener() {
|
path.addModifyListener(e -> validate());
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button button = new Button(panel2, SWT.PUSH);
|
Button button = new Button(panel2, SWT.PUSH);
|
||||||
button.setText(Messages.ExternalExecutablesDialog_button_browse);
|
button.setText(Messages.ExternalExecutablesDialog_button_browse);
|
||||||
|
@ -228,12 +216,7 @@ public class ExternalExecutablesDialog extends TrayDialog {
|
||||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
||||||
args.setLayoutData(layoutData);
|
args.setLayoutData(layoutData);
|
||||||
args.addModifyListener(new ModifyListener() {
|
args.addModifyListener(e -> validate());
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
label = new Label(panel, SWT.HORIZONTAL);
|
label = new Label(panel, SWT.HORIZONTAL);
|
||||||
label.setText(Messages.ExternalExecutablesDialog_field_icon);
|
label.setText(Messages.ExternalExecutablesDialog_field_icon);
|
||||||
|
@ -252,12 +235,7 @@ public class ExternalExecutablesDialog extends TrayDialog {
|
||||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
layoutData.widthHint = convertWidthInCharsToPixels(30);
|
||||||
icon.setLayoutData(layoutData);
|
icon.setLayoutData(layoutData);
|
||||||
icon.addModifyListener(new ModifyListener() {
|
icon.addModifyListener(e -> validate());
|
||||||
@Override
|
|
||||||
public void modifyText(ModifyEvent e) {
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
button = new Button(panel2, SWT.PUSH);
|
button = new Button(panel2, SWT.PUSH);
|
||||||
button.setText(Messages.ExternalExecutablesDialog_button_browse);
|
button.setText(Messages.ExternalExecutablesDialog_button_browse);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Set;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
import org.eclipse.jface.dialogs.IInputValidator;
|
|
||||||
import org.eclipse.jface.dialogs.InputDialog;
|
import org.eclipse.jface.dialogs.InputDialog;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
@ -462,24 +461,21 @@ public abstract class AbstractExtendedConfigurationPanel extends AbstractConfigu
|
||||||
if (Messages.AbstractConfigurationPanel_encoding_custom.equals(encodingCombo.getText())) {
|
if (Messages.AbstractConfigurationPanel_encoding_custom.equals(encodingCombo.getText())) {
|
||||||
InputDialog dialog = new InputDialog(parent.getShell(),
|
InputDialog dialog = new InputDialog(parent.getShell(),
|
||||||
Messages.AbstractConfigurationPanel_encoding_custom_title,
|
Messages.AbstractConfigurationPanel_encoding_custom_title,
|
||||||
Messages.AbstractConfigurationPanel_encoding_custom_message, null, new IInputValidator() {
|
Messages.AbstractConfigurationPanel_encoding_custom_message, null, newText -> {
|
||||||
@Override
|
boolean valid = false;
|
||||||
public String isValid(String newText) {
|
try {
|
||||||
boolean valid = false;
|
if (newText != null && !"".equals(newText)) { //$NON-NLS-1$
|
||||||
try {
|
valid = Charset.isSupported(newText);
|
||||||
if (newText != null && !"".equals(newText)) { //$NON-NLS-1$
|
|
||||||
valid = Charset.isSupported(newText);
|
|
||||||
}
|
|
||||||
} catch (IllegalCharsetNameException e) {
|
|
||||||
/* ignored on purpose */ }
|
|
||||||
|
|
||||||
if (!valid) {
|
|
||||||
return newText != null && !"".equals(newText) //$NON-NLS-1$
|
|
||||||
? Messages.AbstractConfigurationPanel_encoding_custom_error
|
|
||||||
: ""; //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
return null;
|
} catch (IllegalCharsetNameException e1) {
|
||||||
|
/* ignored on purpose */ }
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
return newText != null && !"".equals(newText) //$NON-NLS-1$
|
||||||
|
? Messages.AbstractConfigurationPanel_encoding_custom_error
|
||||||
|
: ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
if (dialog.open() == Window.OK) {
|
if (dialog.open() == Window.OK) {
|
||||||
String encoding = dialog.getValue();
|
String encoding = dialog.getValue();
|
||||||
|
|
|
@ -185,12 +185,7 @@ public class TerminalService implements ITerminalService {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Display display = PlatformUI.getWorkbench().getDisplay();
|
Display display = PlatformUI.getWorkbench().getDisplay();
|
||||||
display.asyncExec(new Runnable() {
|
display.asyncExec(() -> runnable.run(finId, finSecondaryId, finTitle, connector, finData, done));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
runnable.run(finId, finSecondaryId, finTitle, connector, finData, done);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// if display is disposed, silently ignore.
|
// if display is disposed, silently ignore.
|
||||||
}
|
}
|
||||||
|
@ -273,12 +268,7 @@ public class TerminalService implements ITerminalService {
|
||||||
// After that schedule opening the requested console
|
// After that schedule opening the requested console
|
||||||
try {
|
try {
|
||||||
Display display = PlatformUI.getWorkbench().getDisplay();
|
Display display = PlatformUI.getWorkbench().getDisplay();
|
||||||
display.asyncExec(new Runnable() {
|
display.asyncExec(() -> doRun(id, secondaryId, title, connector, data, done));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
doRun(id, secondaryId, title, connector, data, done);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// if display is disposed, silently ignore.
|
// if display is disposed, silently ignore.
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,12 +198,7 @@ public class InputStreamMonitor extends OutputStream implements IDisposable {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create a new runnable which is constantly reading from the stream
|
// Create a new runnable which is constantly reading from the stream
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = () -> writeStream();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
writeStream();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the writer thread
|
// Create the writer thread
|
||||||
thread = new Thread(runnable, "Terminal Input Stream Monitor Thread"); //$NON-NLS-1$
|
thread = new Thread(runnable, "Terminal Input Stream Monitor Thread"); //$NON-NLS-1$
|
||||||
|
|
|
@ -132,12 +132,8 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
|
||||||
// Fire a selection changed event with the terminal controls selection
|
// Fire a selection changed event with the terminal controls selection
|
||||||
try {
|
try {
|
||||||
Display display = PlatformUI.getWorkbench().getDisplay();
|
Display display = PlatformUI.getWorkbench().getDisplay();
|
||||||
display.asyncExec(new Runnable() {
|
display.asyncExec(
|
||||||
@Override
|
() -> fireSelectionChanged(new StructuredSelection(getTerminal().getSelection())));
|
||||||
public void run() {
|
|
||||||
fireSelectionChanged(new StructuredSelection(getTerminal().getSelection()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// if display is disposed, silently ignore.
|
// if display is disposed, silently ignore.
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,27 +83,24 @@ public class TabTerminalListener implements ITerminalListener2 {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Run asynchronously in the display thread
|
// Run asynchronously in the display thread
|
||||||
item.getDisplay().asyncExec(new Runnable() {
|
item.getDisplay().asyncExec(() -> {
|
||||||
@Override
|
// Update the tab item title
|
||||||
public void run() {
|
String newTitle = getTerminalConsoleTabTitle(state);
|
||||||
// Update the tab item title
|
if (newTitle != null)
|
||||||
String newTitle = getTerminalConsoleTabTitle(state);
|
item.setText(newTitle);
|
||||||
if (newTitle != null)
|
|
||||||
item.setText(newTitle);
|
|
||||||
|
|
||||||
// Turn off the command field (if necessary)
|
// Turn off the command field (if necessary)
|
||||||
TabCommandFieldHandler handler = tabFolderManager.getTabCommandFieldHandler(item);
|
TabCommandFieldHandler handler = tabFolderManager.getTabCommandFieldHandler(item);
|
||||||
if (TerminalState.CLOSED.equals(state) && handler != null && handler.hasCommandInputField()) {
|
if (TerminalState.CLOSED.equals(state) && handler != null && handler.hasCommandInputField()) {
|
||||||
handler.setCommandInputField(false);
|
handler.setCommandInputField(false);
|
||||||
// Trigger a selection changed event to update the action enablements
|
// Trigger a selection changed event to update the action enablements
|
||||||
// and the status line
|
// and the status line
|
||||||
ISelectionProvider provider = tabFolderManager.getParentView().getViewSite().getSelectionProvider();
|
ISelectionProvider provider = tabFolderManager.getParentView().getViewSite().getSelectionProvider();
|
||||||
Assert.isNotNull(provider);
|
Assert.isNotNull(provider);
|
||||||
provider.setSelection(provider.getSelection());
|
provider.setSelection(provider.getSelection());
|
||||||
} else {
|
} else {
|
||||||
// Update the status line
|
// Update the status line
|
||||||
tabFolderManager.updateStatusLine();
|
tabFolderManager.updateStatusLine();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,70 +50,67 @@ public class OldTerminalsViewHandler extends ViewPart {
|
||||||
IViewSite site = getViewSite();
|
IViewSite site = getViewSite();
|
||||||
final IWorkbenchPage page = site.getPage();
|
final IWorkbenchPage page = site.getPage();
|
||||||
|
|
||||||
site.getShell().getDisplay().asyncExec(new Runnable() {
|
site.getShell().getDisplay().asyncExec(() -> {
|
||||||
@Override
|
if (fReplaced)
|
||||||
public void run() {
|
return;
|
||||||
if (fReplaced)
|
if (!page.isPageZoomed() || page.getActivePart() instanceof TerminalsView) {
|
||||||
return;
|
fReplaced = true;
|
||||||
if (!page.isPageZoomed() || page.getActivePart() instanceof TerminalsView) {
|
// Show the new view
|
||||||
fReplaced = true;
|
try {
|
||||||
// Show the new view
|
page.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_CREATE);
|
||||||
try {
|
} catch (PartInitException e) {
|
||||||
page.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_CREATE);
|
/* ignored on purpose */ }
|
||||||
} catch (PartInitException e) {
|
|
||||||
/* ignored on purpose */ }
|
|
||||||
|
|
||||||
// Hide ourself in the current perspective
|
// Hide ourself in the current perspective
|
||||||
page.hideView(OldTerminalsViewHandler.this);
|
page.hideView(OldTerminalsViewHandler.this);
|
||||||
} else if (fPartlistener == null) {
|
} else if (fPartlistener == null) {
|
||||||
final IWorkbenchPart maximizedPart = page.getActivePart();
|
final IWorkbenchPart maximizedPart = page.getActivePart();
|
||||||
page.addPartListener(fPartlistener = new IPartListener2() {
|
page.addPartListener(fPartlistener = new IPartListener2() {
|
||||||
@Override
|
@Override
|
||||||
public void partVisible(IWorkbenchPartReference partRef) {
|
public void partVisible(IWorkbenchPartReference partRef) {
|
||||||
if (partRef.getPart(false) == OldTerminalsViewHandler.this) {
|
if (partRef.getPart(false) == OldTerminalsViewHandler.this) {
|
||||||
page.removePartListener(this);
|
page.removePartListener(this);
|
||||||
fPartlistener = null;
|
fPartlistener = null;
|
||||||
replaceWithTerminalsView();
|
replaceWithTerminalsView();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partOpened(IWorkbenchPartReference partRef) {
|
public void partOpened(IWorkbenchPartReference partRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partInputChanged(IWorkbenchPartReference partRef) {
|
public void partInputChanged(IWorkbenchPartReference partRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partHidden(IWorkbenchPartReference partRef) {
|
public void partHidden(IWorkbenchPartReference partRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partDeactivated(IWorkbenchPartReference partRef) {
|
public void partDeactivated(IWorkbenchPartReference partRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partClosed(IWorkbenchPartReference partRef) {
|
public void partClosed(IWorkbenchPartReference partRef) {
|
||||||
if (partRef.getPart(false) == OldTerminalsViewHandler.this) {
|
if (partRef.getPart(false) == OldTerminalsViewHandler.this) {
|
||||||
page.removePartListener(this);
|
page.removePartListener(this);
|
||||||
fPartlistener = null;
|
fPartlistener = null;
|
||||||
} else if (partRef.getPart(false) == maximizedPart) {
|
} else if (partRef.getPart(false) == maximizedPart) {
|
||||||
page.removePartListener(this);
|
page.removePartListener(this);
|
||||||
fPartlistener = null;
|
fPartlistener = null;
|
||||||
replaceWithTerminalsView();
|
replaceWithTerminalsView();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partBroughtToTop(IWorkbenchPartReference partRef) {
|
public void partBroughtToTop(IWorkbenchPartReference partRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void partActivated(IWorkbenchPartReference partRef) {
|
public void partActivated(IWorkbenchPartReference partRef) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue