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