Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-07-18 11:39:57 -0400
committerAlexander Kurtakov2018-07-18 11:44:15 -0400
commite73a322d845e119eda68a22dbd59e2fce44acfe4 (patch)
tree6e08756d48c1d6eee415f378047a342d6da2ead7 /org.eclipse.jface.text/src
parentef3fedaa1552b42f3f0d8b2e64334e6cce484353 (diff)
downloadeclipse.platform.text-e73a322d845e119eda68a22dbd59e2fce44acfe4.tar.gz
eclipse.platform.text-e73a322d845e119eda68a22dbd59e2fce44acfe4.tar.xz
eclipse.platform.text-e73a322d845e119eda68a22dbd59e2fce44acfe4.zip
Lambda conversions.
Converting Runnable to lambda and whatever the quick fix picked in the file too. Change-Id: I0cbd8ef4a7cab89dced199b44a5be3b32b6f8195 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.jface.text/src')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java44
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java18
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java18
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java205
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerUndoManager.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java41
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java108
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java50
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java132
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java51
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/DefaultHyperlinkPresenter.java9
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java111
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java9
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java49
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java37
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java15
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java31
29 files changed, 442 insertions, 743 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java
index 921dc012c..e1a3e44f4 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 IBM Corporation 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
@@ -193,13 +193,8 @@ public class StickyHoverManager extends InformationControlReplacer implements IW
public void focusLost(FocusEvent e) {
if (DEBUG) System.out.println("StickyHoverManager.Closer.focusLost(): " + e); //$NON-NLS-1$
Display d= fSubjectControl.getDisplay();
- d.asyncExec(new Runnable() {
- // Without the asyncExec, mouse clicks to the workbench window are swallowed.
- @Override
- public void run() {
- hideInformationControl();
- }
- });
+ // Without the asyncExec, mouse clicks to the workbench window are swallowed.
+ d.asyncExec(() -> hideInformationControl());
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
index 0dd8a5900..c4f1fa8d0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -18,10 +18,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationListener;
-import org.eclipse.swt.browser.OpenWindowListener;
import org.eclipse.swt.browser.ProgressAdapter;
import org.eclipse.swt.browser.ProgressEvent;
-import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -226,13 +224,8 @@ public class BrowserInformationControl extends AbstractInformationControl implem
fCompleted= true;
}
});
-
- fBrowser.addOpenWindowListener(new OpenWindowListener() {
- @Override
- public void open(WindowEvent event) {
- event.required= true; // Cancel opening of new windows
- }
- });
+ // Cancel opening of new windows
+ fBrowser.addOpenWindowListener(event -> event.required= true);
// Replace browser's built-in context menu with none
fBrowser.setMenu(new Menu(getShell(), SWT.NONE));
@@ -344,12 +337,7 @@ public class BrowserInformationControl extends AbstractInformationControl implem
final Display display= shell.getDisplay();
// Make sure the display wakes from sleep after timeout:
- display.timerExec(100, new Runnable() {
- @Override
- public void run() {
- fCompleted= true;
- }
- });
+ display.timerExec(100, () -> fCompleted= true);
while (!fCompleted) {
// Drive the event loop to process the events required to load the browser widget's contents:
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java
index c04e83112..d1acb3205 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -49,12 +49,9 @@ public class HTMLPrinter {
final Display display= Display.getDefault();
if (display != null && !display.isDisposed()) {
try {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- cacheColors(display);
- installColorUpdater(display);
- }
+ display.asyncExec(() -> {
+ cacheColors(display);
+ installColorUpdater(display);
});
} catch (SWTError err) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=45294
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
index 48bb8b572..1caabdc10 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/AdditionalInfoController2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -159,12 +159,9 @@ class AdditionalInfoController2 extends AbstractInformationControlManager implem
}
if (fProposalTable != null && !fProposalTable.isDisposed()) {
- fProposalTable.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!fIsReset)
- showInformation();
- }
+ fProposalTable.getDisplay().asyncExec(() -> {
+ if (!fIsReset)
+ showInformation();
});
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index 6741ba96a..b1e9ea2f2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -45,7 +45,6 @@ import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
@@ -168,12 +167,9 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
if (control != null) {
Display d= control.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!hasFocus())
- hide();
- }
+ d.asyncExec(() -> {
+ if (!hasFocus())
+ hide();
});
}
}
@@ -308,14 +304,11 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
Display d= control.getDisplay();
if (d != null) {
try {
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- if (showStyle == SHOW_PROPOSALS)
- fProposalPopup.showProposals(true);
- else if (showStyle == SHOW_CONTEXT_INFO)
- fContextInfoPopup.showContextProposals(true);
- }
+ d.syncExec(() -> {
+ if (showStyle == SHOW_PROPOSALS)
+ fProposalPopup.showProposals(true);
+ else if (showStyle == SHOW_CONTEXT_INFO)
+ fContextInfoPopup.showContextProposals(true);
});
} catch (SWTError e) {
}
@@ -728,12 +721,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
* @return an <code>IInformationControlCreator</code> to be used to display context information
*/
private IInformationControlCreator getInformationControlCreator() {
- return new IInformationControlCreator() {
- @Override
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent, false);
- }
- };
+ return parent -> new DefaultInformationControl(parent, false);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
index 0632c2d8f..164e34f1b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -106,30 +106,27 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
*/
public String showContextProposals(final boolean autoActivated) {
final StyledText styledText= fViewer.getTextWidget();
- BusyIndicator.showWhile(styledText.getDisplay(), new Runnable() {
- @Override
- public void run() {
+ BusyIndicator.showWhile(styledText.getDisplay(), () -> {
- int position= fViewer.getSelectedRange().x;
+ int position= fViewer.getSelectedRange().x;
- IContextInformation[] contexts= computeContextInformation(position);
- int count = (contexts == null ? 0 : contexts.length);
- if (count == 1) {
+ IContextInformation[] contexts= computeContextInformation(position);
+ int count= (contexts == null ? 0 : contexts.length);
+ if (count == 1) {
- // Show context information directly
- internalShowContextInfo(contexts[0], position);
+ // Show context information directly
+ internalShowContextInfo(contexts[0], position);
- } else if (count > 0) {
- // Precise context must be selected
+ } else if (count > 0) {
+ // Precise context must be selected
- if (fLineDelimiter == null)
- fLineDelimiter= styledText.getLineDelimiter();
+ if (fLineDelimiter == null)
+ fLineDelimiter= styledText.getLineDelimiter();
- createContextSelector();
- setContexts(contexts);
- displayContextSelector();
- hideContextInfoPopup();
- }
+ createContextSelector();
+ setContexts(contexts);
+ displayContextSelector();
+ hideContextInfoPopup();
}
});
@@ -145,12 +142,9 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
*/
public void showContextInformation(final IContextInformation info, final int position) {
Control control= fViewer.getTextWidget();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- @Override
- public void run() {
- internalShowContextInfo(info, position);
- hideContextSelector();
- }
+ BusyIndicator.showWhile(control.getDisplay(), () -> {
+ internalShowContextInfo(info, position);
+ hideContextSelector();
});
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
index a8cb2bfb5..71971044b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -97,12 +97,9 @@ class PopupCloser2 extends ShellAdapter implements FocusListener, SelectionListe
public void focusLost(final FocusEvent e) {
fScrollbarClicked= false;
Display d= fTable.getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (Helper2.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
- fContentAssistant.popupFocusLost(e);
- }
+ d.asyncExec(() -> {
+ if (Helper2.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
+ fContentAssistant.popupFocusLost(e);
});
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
index 5321b8282..046e4d307 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2016 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 IBM Corporation 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
@@ -21,8 +21,6 @@ import java.util.Map.Entry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackListener;
@@ -740,12 +738,7 @@ public final class RevisionPainter {
fControl.addMouseMoveListener(fMouseHandler);
fControl.addListener(SWT.MouseUp, fMouseHandler);
fControl.addListener(SWT.MouseDown, fMouseHandler);
- fControl.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- }
- });
+ fControl.addDisposeListener(e -> handleDispose());
fRevisionSelectionProvider.install(fViewer);
}
@@ -1351,12 +1344,7 @@ public final class RevisionPainter {
if (isConnected() && !fControl.isDisposed()) {
Display d= fControl.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
+ d.asyncExec(() -> redraw());
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java
index 73c52f65d..7d0aac066 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/source/DiffPainter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2016 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 IBM Corporation 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
@@ -12,8 +12,6 @@ package org.eclipse.jface.internal.text.source;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.RGB;
@@ -196,12 +194,7 @@ public final class DiffPainter {
if (fControl == null)
return;
- fControl.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- }
- });
+ fControl.addDisposeListener(e -> handleDispose());
}
/**
@@ -381,12 +374,7 @@ public final class DiffPainter {
if (isConnected() && !fControl.isDisposed()) {
Display d= fControl.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
+ d.asyncExec(() -> redraw());
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
index 43adcc88e..0d924700f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -286,21 +286,11 @@ abstract public class AbstractHoverInformationControlManager extends AbstractInf
final IInputChangedListener inputChangeListener= new DelayedInputChangeListener(delayedICP, getInformationControlReplacer());
delayedICP.setDelayedInputChangeListener(inputChangeListener);
// cancel automatic input updating after a small timeout:
- control.getShell().getDisplay().timerExec(1000, new Runnable() {
- @Override
- public void run() {
- delayedICP.setDelayedInputChangeListener(null);
- }
- });
+ control.getShell().getDisplay().timerExec(1000, () -> delayedICP.setDelayedInputChangeListener(null));
}
// XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212392 :
- control.getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- replaceInformationControl(true);
- }
- });
+ control.getShell().getDisplay().asyncExec(() -> replaceInformationControl(true));
} else {
fWaitForMouseUp= true;
}
@@ -855,15 +845,12 @@ abstract public class AbstractHoverInformationControlManager extends AbstractInf
if (monitor.isCanceled() || display.isDisposed()) {
return Status.CANCEL_STATUS;
}
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- fReplacingDelayJob= null;
- if (monitor.isCanceled())
- return;
- if (! fWaitForMouseUp)
- replaceInformationControl(false);
- }
+ display.syncExec(() -> {
+ fReplacingDelayJob= null;
+ if (monitor.isCanceled())
+ return;
+ if (!fWaitForMouseUp)
+ replaceInformationControl(false);
});
return Status.OK_STATUS;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
index 07cd87ca0..9ed997b43 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -719,31 +719,28 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
case OperationHistoryEvent.ABOUT_TO_REDO:
// if this is one of our operations
if (event.getOperation().hasContext(fUndoContext)) {
- fTextViewer.getTextWidget().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
+ fTextViewer.getTextWidget().getDisplay().syncExec(() -> {
// if we are undoing/redoing a command we generated, then ignore
// the document changes associated with this undo or redo.
if (event.getOperation() instanceof TextCommand) {
if (fTextViewer instanceof TextViewer)
- ((TextViewer)fTextViewer).ignoreAutoEditStrategies(true);
+ ((TextViewer) fTextViewer).ignoreAutoEditStrategies(true);
listenToTextChanges(false);
// in the undo case only, make sure compounds are closed
if (type == OperationHistoryEvent.ABOUT_TO_UNDO) {
if (fFoldingIntoCompoundChange) {
endCompoundChange();
- }
}
+ }
} else {
// the undo or redo has our context, but it is not one of
// our commands. We will listen to the changes, but will
// reset the state that tracks the undo/redo history.
commit();
fLastAddedCommand= null;
- }
}
- });
+ });
fOperation= event.getOperation();
}
break;
@@ -751,15 +748,12 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
case OperationHistoryEvent.REDONE:
case OperationHistoryEvent.OPERATION_NOT_OK:
if (event.getOperation() == fOperation) {
- fTextViewer.getTextWidget().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
+ fTextViewer.getTextWidget().getDisplay().syncExec(() -> {
listenToTextChanges(true);
fOperation= null;
if (fTextViewer instanceof TextViewer)
- ((TextViewer)fTextViewer).ignoreAutoEditStrategies(false);
- }
- });
+ ((TextViewer) fTextViewer).ignoreAutoEditStrategies(false);
+ });
}
break;
}
@@ -1178,12 +1172,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
display= finalShell.getDisplay();
else
display= Display.getDefault();
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(finalShell, title, ex.getLocalizedMessage());
- }
- });
+ display.syncExec(() -> MessageDialog.openError(finalShell, title, ex.getLocalizedMessage()));
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
index 43f335098..20a63b96e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -337,12 +337,9 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
Control control= fTextViewer.getTextWidget();
if (control != null) {
- control.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fTextViewer != null)
- paint(IPainter.TEXT_CHANGE);
- }
+ control.getDisplay().asyncExec(() -> {
+ if (fTextViewer != null)
+ paint(IPainter.TEXT_CHANGE);
});
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index feb511c30..f96763145 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -39,8 +39,6 @@ import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseAdapter;
@@ -48,8 +46,6 @@ import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Color;
@@ -62,8 +58,6 @@ import org.eclipse.swt.printing.PrinterData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
@@ -1702,32 +1696,25 @@ public class TextViewer extends Viewer implements
fTextWidget= createTextWidget(parent, styles);
// Support scroll page upon MOD1+MouseWheel
- fTextWidget.addListener(SWT.MouseVerticalWheel, new Listener() {
-
- @Override
- public void handleEvent(Event event) {
- if (((event.stateMask & SWT.MOD1) == 0))
- return;
+ fTextWidget.addListener(SWT.MouseVerticalWheel, event -> {
+ if (((event.stateMask & SWT.MOD1) == 0))
+ return;
- int topIndex= fTextWidget.getTopIndex();
- int bottomIndex= JFaceTextUtil.getBottomIndex(fTextWidget);
+ int topIndex= fTextWidget.getTopIndex();
+ int bottomIndex= JFaceTextUtil.getBottomIndex(fTextWidget);
- if (event.count > 0)
- fTextWidget.setTopIndex(2 * topIndex - bottomIndex);
- else
- fTextWidget.setTopIndex(bottomIndex);
+ if (event.count > 0)
+ fTextWidget.setTopIndex(2 * topIndex - bottomIndex);
+ else
+ fTextWidget.setTopIndex(bottomIndex);
- updateViewportListeners(INTERNAL);
- }
+ updateViewportListeners(INTERNAL);
});
fTextWidget.addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
+ e -> {
fDisposedControl= getControl();
handleDispose();
- }
}
);
@@ -1738,12 +1725,9 @@ public class TextViewer extends Viewer implements
* Disable SWT Shift+TAB traversal in this viewer
* 1GIYQ9K: ITPUI:WINNT - StyledText swallows Shift+TAB
*/
- fTextWidget.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- if ((SWT.SHIFT == e.stateMask) && ('\t' == e.character))
- e.doit= !fTextWidget.getEditable();
- }
+ fTextWidget.addTraverseListener(e -> {
+ if ((SWT.SHIFT == e.stateMask) && ('\t' == e.character))
+ e.doit= !fTextWidget.getEditable();
});
// where does the first line start
@@ -3720,35 +3704,32 @@ public class TextViewer extends Viewer implements
boolean isFirst= e.time != fLastEventTime;
fLastEventTime= e.time;
if (isFirst) {
- wrapCompoundChange(new Runnable() {
- @Override
- public void run() {
- SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
- try {
- /* Use the selection instead of the event's coordinates. Is this dangerous? */
- ISelection selection= getSelection();
- int length= e.text.length();
- if (length == 0 && e.character == '\0') {
- // backspace in StyledText block selection mode...
- TextEdit edit= processor.backspace(selection);
- edit.apply(fDocument, TextEdit.UPDATE_REGIONS);
- ISelection empty= processor.makeEmpty(selection, true);
- setSelection(empty);
- } else {
- int lines= processor.getCoveredLines(selection);
- String delim= fDocument.getLegalLineDelimiters()[0];
- StringBuilder text= new StringBuilder(lines * length + (lines - 1) * delim.length());
+ wrapCompoundChange(() -> {
+ SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
+ try {
+ /* Use the selection instead of the event's coordinates. Is this dangerous? */
+ ISelection selection= getSelection();
+ int length= e.text.length();
+ if (length == 0 && e.character == '\0') {
+ // backspace in StyledText block selection mode...
+ TextEdit edit= processor.backspace(selection);
+ edit.apply(fDocument, TextEdit.UPDATE_REGIONS);
+ ISelection empty= processor.makeEmpty(selection, true);
+ setSelection(empty);
+ } else {
+ int lines= processor.getCoveredLines(selection);
+ String delim= fDocument.getLegalLineDelimiters()[0];
+ StringBuilder text= new StringBuilder(lines * length + (lines - 1) * delim.length());
+ text.append(e.text);
+ for (int i= 0; i < lines - 1; i++) {
+ text.append(delim);
text.append(e.text);
- for (int i= 0; i < lines - 1; i++) {
- text.append(delim);
- text.append(e.text);
- }
- processor.doReplace(selection, text.toString());
}
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$
+ processor.doReplace(selection, text.toString());
}
+ } catch (BadLocationException x) {
+ if (TRACE_ERRORS)
+ System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$
}
});
}
@@ -3838,12 +3819,7 @@ public class TextViewer extends Viewer implements
if (!fTextWidget.isTextSelected())
copyMarkedRegion(true);
else
- wrapCompoundChange(new Runnable() {
- @Override
- public void run() {
- fTextWidget.cut();
- }
- });
+ wrapCompoundChange(() -> fTextWidget.cut());
selection= fTextWidget.getSelectionRange();
fireSelectionChanged(selection.x, selection.y);
@@ -3909,15 +3885,12 @@ public class TextViewer extends Viewer implements
if (!fTextWidget.getBlockSelection()) {
fTextWidget.invokeAction(ST.DELETE_NEXT);
} else {
- wrapCompoundChange(new Runnable(){
- @Override
- public void run() {
- try {
- new SelectionProcessor(TextViewer.this).doDelete(getSelection());
- } catch (BadLocationException e) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.delete")); //$NON-NLS-1$
- }
+ wrapCompoundChange(() -> {
+ try {
+ new SelectionProcessor(TextViewer.this).doDelete(getSelection());
+ } catch (BadLocationException e) {
+ if (TRACE_ERRORS)
+ System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.delete")); //$NON-NLS-1$
}
});
}
@@ -3930,51 +3903,48 @@ public class TextViewer extends Viewer implements
if (!fTextWidget.getBlockSelection()) {
fTextWidget.paste();
} else {
- wrapCompoundChange(new Runnable(){
- @Override
- public void run() {
- SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
- Clipboard clipboard= new Clipboard(getDisplay());
- try {
- /*
- * Paste in block selection mode. If the pasted text is not a multi-line
- * text, pasting behaves like typing, i.e. the pasted text replaces
- * the selection on each line. If the pasted text is multi-line (e.g. from
- * copying a column selection), the selection is replaced, line-by-line, by
- * the corresponding contents of the pasted text. If the selection touches
- * more lines than the pasted text, the selection on the remaining lines
- * is deleted (assuming an empty text being pasted). If the pasted
- * text contains more lines than the selection, the selection is extended
- * to the succeeding lines, or more lines are added to accommodate the
- * paste operation.
- */
- ISelection selection= getSelection();
- TextTransfer plainTextTransfer = TextTransfer.getInstance();
- String contents= (String)clipboard.getContents(plainTextTransfer, DND.CLIPBOARD);
- String toInsert;
- if (TextUtilities.indexOf(fDocument.getLegalLineDelimiters(), contents, 0)[0] != -1) {
- // multi-line insertion
- toInsert= contents;
- } else {
- // single-line insertion
- int length= contents.length();
- int lines= processor.getCoveredLines(selection);
- String delim= fDocument.getLegalLineDelimiters()[0];
- StringBuilder text= new StringBuilder(lines * length + (lines - 1) * delim.length());
+ wrapCompoundChange(() -> {
+ SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
+ Clipboard clipboard= new Clipboard(getDisplay());
+ try {
+ /*
+ * Paste in block selection mode. If the pasted text is not a multi-line
+ * text, pasting behaves like typing, i.e. the pasted text replaces
+ * the selection on each line. If the pasted text is multi-line (e.g. from
+ * copying a column selection), the selection is replaced, line-by-line, by
+ * the corresponding contents of the pasted text. If the selection touches
+ * more lines than the pasted text, the selection on the remaining lines
+ * is deleted (assuming an empty text being pasted). If the pasted
+ * text contains more lines than the selection, the selection is extended
+ * to the succeeding lines, or more lines are added to accommodate the
+ * paste operation.
+ */
+ ISelection selection= getSelection();
+ TextTransfer plainTextTransfer= TextTransfer.getInstance();
+ String contents= (String) clipboard.getContents(plainTextTransfer, DND.CLIPBOARD);
+ String toInsert;
+ if (TextUtilities.indexOf(fDocument.getLegalLineDelimiters(), contents, 0)[0] != -1) {
+ // multi-line insertion
+ toInsert= contents;
+ } else {
+ // single-line insertion
+ int length= contents.length();
+ int lines= processor.getCoveredLines(selection);
+ String delim= fDocument.getLegalLineDelimiters()[0];
+ StringBuilder text= new StringBuilder(lines * length + (lines - 1) * delim.length());
+ text.append(contents);
+ for (int i= 0; i < lines - 1; i++) {
+ text.append(delim);
text.append(contents);
- for (int i= 0; i < lines - 1; i++) {
- text.append(delim);
- text.append(contents);
- }
- toInsert= text.toString();
}
- processor.doReplace(selection, toInsert);
- } catch (BadLocationException x) {
- if (TRACE_ERRORS)
- System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.paste")); //$NON-NLS-1$
- } finally {
- clipboard.dispose();
+ toInsert= text.toString();
}
+ processor.doReplace(selection, toInsert);
+ } catch (BadLocationException x) {
+ if (TRACE_ERRORS)
+ System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.paste")); //$NON-NLS-1$
+ } finally {
+ clipboard.dispose();
}
});
}
@@ -4069,12 +4039,7 @@ public class TextViewer extends Viewer implements
fTextWidget.setSelection(widgetMarkOffset, selection.x);
if (delete) {
- wrapCompoundChange(new Runnable() {
- @Override
- public void run() {
- fTextWidget.cut();
- }
- });
+ wrapCompoundChange(() -> fTextWidget.cut());
} else {
fTextWidget.copy();
fTextWidget.setSelection(selection.x); // restore old cursor position
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerUndoManager.java
index f71786e70..32ca36426 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerUndoManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerUndoManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 IBM Corporation 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
@@ -150,22 +150,16 @@ public class TextViewerUndoManager implements IUndoManager, IUndoManagerExtensio
if (extension != null)
extension.setRedraw(false);
}
- fTextViewer.getTextWidget().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- if (fTextViewer instanceof TextViewer)
- ((TextViewer)fTextViewer).ignoreAutoEditStrategies(true);
- }
- });
+ fTextViewer.getTextWidget().getDisplay().syncExec(() -> {
+ if (fTextViewer instanceof TextViewer)
+ ((TextViewer) fTextViewer).ignoreAutoEditStrategies(true);
+ });
} else if (((eventType & DocumentUndoEvent.UNDONE) != 0) || ((eventType & DocumentUndoEvent.REDONE) != 0)) {
- fTextViewer.getTextWidget().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- if (fTextViewer instanceof TextViewer)
- ((TextViewer)fTextViewer).ignoreAutoEditStrategies(false);
- }
- });
+ fTextViewer.getTextWidget().getDisplay().syncExec(() -> {
+ if (fTextViewer instanceof TextViewer)
+ ((TextViewer) fTextViewer).ignoreAutoEditStrategies(false);
+ });
if (event.isCompound()) {
ITextViewerExtension extension= null;
if (fTextViewer instanceof ITextViewerExtension)
@@ -300,12 +294,7 @@ public class TextViewerUndoManager implements IUndoManager, IUndoManagerExtensio
display= finalShell.getDisplay();
else
display= Display.getDefault();
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(finalShell, title, ex.getLocalizedMessage());
- }
- });
+ display.syncExec(() -> MessageDialog.openError(finalShell, title, ex.getLocalizedMessage()));
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
index 6016c81f6..2a9999e7e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -174,14 +174,11 @@ class AdditionalInfoController extends AbstractInformationControlManager {
public void run() {
final ICompletionProposal proposal= getCurrentProposal();
if (!fDisplay.isDisposed()) {
- fDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (Timer.this) {
- if (proposal == getCurrentProposal()) {
- Object info= proposal.getAdditionalProposalInfo();
- showInformation(proposal, info);
- }
+ fDisplay.asyncExec(() -> {
+ synchronized (Timer.this) {
+ if (proposal == getCurrentProposal()) {
+ Object info= proposal.getAdditionalProposalInfo();
+ showInformation(proposal, info);
}
}
});
@@ -256,15 +253,12 @@ class AdditionalInfoController extends AbstractInformationControlManager {
long current= System.currentTimeMillis();
schedule(IDLE, current);
- fThread= new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- loop();
- } catch (InterruptedException x) {
- }
- }
- }, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$
+ fThread= new Thread((Runnable) () -> {
+ try {
+ loop();
+ } catch (InterruptedException x) {
+ }
+ }, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$
fThread.start();
}
@@ -359,13 +353,10 @@ class AdditionalInfoController extends AbstractInformationControlManager {
private void triggerShowing() {
final Object info= fCurrentInfo;
if (!fDisplay.isDisposed()) {
- fDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (Timer.this) {
- if (info == fCurrentInfo) {
- showInformation(fCurrentProposal, info);
- }
+ fDisplay.asyncExec(() -> {
+ synchronized (Timer.this) {
+ if (info == fCurrentInfo) {
+ showInformation(fCurrentProposal, info);
}
}
});
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index 9951e6f29..1d4b8133c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -352,13 +352,13 @@ class CompletionProposalPopup implements IContentAssistListener {
int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
List<ICompletionProposal> proposals= null;
- try {
+ try {
if (offset > -1) {
DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
proposals= computeFilteredProposals(offset, event);
}
- } catch (BadLocationException x) {
- } finally {
+ } catch (BadLocationException x) {
+ } finally {
fDocumentEvents.clear();
}
fFilterOffset= offset;
@@ -480,27 +480,24 @@ class CompletionProposalPopup implements IContentAssistListener {
// when the user types fast.
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- @Override
- public void run() {
+ BusyIndicator.showWhile(control.getDisplay(), () -> {
- fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
- fFilterOffset= fInvocationOffset;
- fLastCompletionOffset= fFilterOffset;
- fComputedProposals= computeProposals(fInvocationOffset);
+ fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
+ fFilterOffset= fInvocationOffset;
+ fLastCompletionOffset= fFilterOffset;
+ fComputedProposals= computeProposals(fInvocationOffset);
- int count= (fComputedProposals == null ? 0 : fComputedProposals.size());
- if (count == 0 && hideWhenNoProposals(autoActivated))
- return;
+ int count= (fComputedProposals == null ? 0 : fComputedProposals.size());
+ if (count == 0 && hideWhenNoProposals(autoActivated))
+ return;
- if (count == 1 && !autoActivated && canAutoInsert(fComputedProposals.get(0))) {
- insertProposal(fComputedProposals.get(0), (char) 0, 0, fInvocationOffset);
- hide();
- } else {
- createProposalSelector();
- setProposals(fComputedProposals, false);
- displayProposals();
- }
+ if (count == 1 && !autoActivated && canAutoInsert(fComputedProposals.get(0))) {
+ insertProposal(fComputedProposals.get(0), (char) 0, 0, fInvocationOffset);
+ hide();
+ } else {
+ createProposalSelector();
+ setProposals(fComputedProposals, false);
+ displayProposals();
}
});
} else {
@@ -749,18 +746,18 @@ class CompletionProposalPopup implements IContentAssistListener {
public void focusGained(FocusEvent e) {
if (Helper.okToUse(control)) {
if (fTraverseListener == null) {
- fTraverseListener= new TraverseListener() {
- @Override
+ fTraverseListener= new TraverseListener() {
+ @Override
public void keyTraversed(TraverseEvent event) {
- if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
- IInformationControl iControl= fAdditionalInfoController.getCurrentInformationControl2();
- if (fAdditionalInfoController.getInternalAccessor().canReplace(iControl)) {
- fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
- event.doit= false;
- }
- }
- }
- };
+ if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
+ IInformationControl iControl= fAdditionalInfoController.getCurrentInformationControl2();
+ if (fAdditionalInfoController.getInternalAccessor().canReplace(iControl)) {
+ fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
+ event.doit= false;
+ }
+ }
+ }
+ };
fProposalTable.addTraverseListener(fTraverseListener);
}
}
@@ -1604,34 +1601,31 @@ class CompletionProposalPopup implements IContentAssistListener {
if (!Helper.okToUse(fProposalShell) && !control.isDisposed())
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- @Override
- public void run() {
+ BusyIndicator.showWhile(control.getDisplay(), () -> {
- fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
- fFilterOffset= fInvocationOffset;
- fLastCompletionOffset= fFilterOffset;
- fFilteredProposals= computeProposals(fInvocationOffset);
+ fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
+ fFilterOffset= fInvocationOffset;
+ fLastCompletionOffset= fFilterOffset;
+ fFilteredProposals= computeProposals(fInvocationOffset);
- int count= (fFilteredProposals == null ? 0 : fFilteredProposals.size());
- if (count == 0 && hideWhenNoProposals(false))
- return;
+ int count= (fFilteredProposals == null ? 0 : fFilteredProposals.size());
+ if (count == 0 && hideWhenNoProposals(false))
+ return;
- if (count == 1 && canAutoInsert(fFilteredProposals.get(0))) {
- insertProposal(fFilteredProposals.get(0), (char) 0, 0, fInvocationOffset);
- hide();
- } else {
- ensureDocumentListenerInstalled();
- if (count > 0 && completeCommonPrefix())
- hide();
- else {
- fComputedProposals= fFilteredProposals;
- createProposalSelector();
- setProposals(fComputedProposals, false);
- displayProposals();
- }
- }
+ if (count == 1 && canAutoInsert(fFilteredProposals.get(0))) {
+ insertProposal(fFilteredProposals.get(0), (char) 0, 0, fInvocationOffset);
+ hide();
+ } else {
+ ensureDocumentListenerInstalled();
+ if (count > 0 && completeCommonPrefix())
+ hide();
+ else {
+ fComputedProposals= fFilteredProposals;
+ createProposalSelector();
+ setProposals(fComputedProposals, false);
+ displayProposals();
}
+ }
});
}
return getErrorMessage();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index bd12c8e71..bf28a1439 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -40,7 +40,6 @@ import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Color;
@@ -211,12 +210,9 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
if (Helper.okToUse(control)) {
Display d= control.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!fProposalPopup.hasFocus() && (fContextInfoPopup == null || !fContextInfoPopup.hasFocus()))
- hide();
- }
+ d.asyncExec(() -> {
+ if (!fProposalPopup.hasFocus() && (fContextInfoPopup == null || !fContextInfoPopup.hasFocus()))
+ hide();
});
}
}
@@ -368,24 +364,21 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
return;
try {
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- if (isProposalPopupActive())
- return;
+ d.syncExec(() -> {
+ if (isProposalPopupActive())
+ return;
- if (control.isDisposed() || !control.isFocusControl())
- return;
+ if (control.isDisposed() || !control.isFocusControl())
+ return;
- if (showStyle == SHOW_PROPOSALS) {
- if (!prepareToShowCompletions(true))
- return;
- fProposalPopup.showProposals(true);
- fLastAutoActivation= System.currentTimeMillis();
- } else if (showStyle == SHOW_CONTEXT_INFO && fContextInfoPopup != null) {
- promoteKeyListener();
- fContextInfoPopup.showContextProposals(true);
- }
+ if (showStyle == SHOW_PROPOSALS) {
+ if (!prepareToShowCompletions(true))
+ return;
+ fProposalPopup.showProposals(true);
+ fLastAutoActivation= System.currentTimeMillis();
+ } else if (showStyle == SHOW_CONTEXT_INFO && fContextInfoPopup != null) {
+ promoteKeyListener();
+ fContextInfoPopup.showContextProposals(true);
}
});
} catch (SWTError e) {
@@ -1544,12 +1537,9 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) {
fContentAssistSubjectControlShell= fContentAssistSubjectControlAdapter.getControl().getShell();
- fCASCSTraverseListener= new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_ESCAPE && isProposalPopupActive())
- e.doit= false;
- }
+ fCASCSTraverseListener= e -> {
+ if (e.detail == SWT.TRAVERSE_ESCAPE && isProposalPopupActive())
+ e.doit= false;
};
fContentAssistSubjectControlShell.addTraverseListener(fCASCSTraverseListener);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
index 8315265a9..d52b55058 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -19,8 +19,6 @@ import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -180,62 +178,59 @@ class ContextInformationPopup implements IContentAssistListener {
*/
public String showContextProposals(final boolean autoActivated) {
final Control control= fContentAssistSubjectControlAdapter.getControl();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- @Override
- public void run() {
+ BusyIndicator.showWhile(control.getDisplay(), () -> {
- int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
+ int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
- IContextInformation[] contexts= computeContextInformation(offset);
- int count = (contexts == null ? 0 : contexts.length);
- if (count == 1) {
+ IContextInformation[] contexts= computeContextInformation(offset);
+ int count= (contexts == null ? 0 : contexts.length);
+ if (count == 1) {
- ContextFrame frame= createContextFrame(contexts[0], offset);
- if (isDuplicate(frame))
+ ContextFrame frame1= createContextFrame(contexts[0], offset);
+ if (isDuplicate(frame1))
+ validateContextInformation();
+ else
+ // Show context information directly
+ internalShowContextInfo(frame1);
+
+ } else if (count > 0) {
+
+ // if any of the proposed context matches any of the contexts on the stack,
+ // assume that one (so, if context info is invoked repeatedly, the current
+ // info is kept)
+ int index= 0;
+ for (int i= 0; i < contexts.length; i++) {
+ IContextInformation info= contexts[i];
+ ContextFrame frame2= createContextFrame(info, offset);
+
+ // check top of stack and stored context
+ if (isDuplicate(frame2)) {
validateContextInformation();
- else
- // Show context information directly
- internalShowContextInfo(frame);
-
- } else if (count > 0) {
-
- // if any of the proposed context matches any of the contexts on the stack,
- // assume that one (so, if context info is invoked repeatedly, the current
- // info is kept)
- int index= 0;
- for (int i= 0; i < contexts.length; i++) {
- IContextInformation info= contexts[i];
- ContextFrame frame= createContextFrame(info, offset);
-
- // check top of stack and stored context
- if (isDuplicate(frame)) {
- validateContextInformation();
- return;
- }
+ return;
+ }
- if (isLastFrame(frame)) {
- index= i;
- }
+ if (isLastFrame(frame2)) {
+ index= i;
+ }
- // also check all other contexts
- for (ContextFrame stackFrame : fContextFrameStack) {
- if (stackFrame.equals(frame)) {
- validateContextInformation();
- return;
- }
+ // also check all other contexts
+ for (ContextFrame stackFrame : fContextFrameStack) {
+ if (stackFrame.equals(frame2)) {
+ validateContextInformation();
+ return;
}
}
+ }
- // otherwise:
- // Precise context must be selected
+ // otherwise:
+ // Precise context must be selected
- if (fLineDelimiter == null)
- fLineDelimiter= fContentAssistSubjectControlAdapter.getLineDelimiter();
+ if (fLineDelimiter == null)
+ fLineDelimiter= fContentAssistSubjectControlAdapter.getLineDelimiter();
- createContextSelector();
- setContexts(contexts, index);
- displayContextSelector();
- }
+ createContextSelector();
+ setContexts(contexts, index);
+ displayContextSelector();
}
});
@@ -251,19 +246,16 @@ class ContextInformationPopup implements IContentAssistListener {
*/
public void showContextInformation(final IContextInformation info, final int offset) {
Control control= fContentAssistSubjectControlAdapter.getControl();
- BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
- @Override
- public void run() {
- if (info == null)
+ BusyIndicator.showWhile(control.getDisplay(), () -> {
+ if (info == null)
+ validateContextInformation();
+ else {
+ ContextFrame frame= createContextFrame(info, offset);
+ if (isDuplicate(frame))
validateContextInformation();
- else {
- ContextFrame frame= createContextFrame(info, offset);
- if (isDuplicate(frame))
- validateContextInformation();
- else
- internalShowContextInfo(frame);
- hideContextSelector();
- }
+ else
+ internalShowContextInfo(frame);
+ hideContextSelector();
}
});
}
@@ -542,25 +534,17 @@ class ContextInformationPopup implements IContentAssistListener {
final ITextViewerExtension textViewerExtension= (ITextViewerExtension)fViewer;
final StyledText textWidget= fViewer.getTextWidget();
- final VerifyKeyListener verifyListener= new VerifyKeyListener() {
- @Override
- public void verifyKey(VerifyEvent event) {
- if (isActive() && event.keyCode == 13 && event.character == '\r' && event.widget == textWidget) {
- event.doit= false;
- insertSelectedContext();
- hideContextSelector();
- }
+ final VerifyKeyListener verifyListener= event -> {
+ if (isActive() && event.keyCode == 13 && event.character == '\r' && event.widget == textWidget) {
+ event.doit= false;
+ insertSelectedContext();
+ hideContextSelector();
}
};
textViewerExtension.prependVerifyKeyListener(verifyListener);
- fContextSelectorShell.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- textViewerExtension.removeVerifyKeyListener(verifyListener);
- }
- });
+ fContextSelectorShell.addDisposeListener(e -> textViewerExtension.removeVerifyKeyListener(verifyListener));
}
fContextSelectorTable= new Table(fContextSelectorShell, SWT.H_SCROLL | SWT.V_SCROLL);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
index 5248c500f..0167a56f9 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -146,28 +146,22 @@ class PopupCloser extends ShellAdapter implements FocusListener, SelectionListen
public void focusLost(final FocusEvent e) {
fScrollbarClicked= false;
Display d= fTable.getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (Helper.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
- fContentAssistant.popupFocusLost(e);
- }
+ d.asyncExec(() -> {
+ if (Helper.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
+ fContentAssistant.popupFocusLost(e);
});
}
@Override
public void shellDeactivated(ShellEvent e) {
if (fContentAssistant != null && fDisplay != null) {
- fDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- /*
- * The asyncExec is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=235556 :
- * fContentAssistant.hasProposalPopupFocus() is still true during the shellDeactivated(..) event.
- */
- if (fContentAssistant != null && ! fContentAssistant.hasProposalPopupFocus())
- fContentAssistant.hide();
- }
+ fDisplay.asyncExec(() -> {
+ /*
+ * The asyncExec is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=235556 :
+ * fContentAssistant.hasProposalPopupFocus() is still true during the shellDeactivated(..) event.
+ */
+ if (fContentAssistant != null && !fContentAssistant.hasProposalPopupFocus())
+ fContentAssistant.hide();
});
}
}
@@ -221,21 +215,11 @@ class PopupCloser extends ShellAdapter implements FocusListener, SelectionListen
final IInputChangedListener inputChangeListener= new DelayedInputChangeListener(delayedICP, fAdditionalInfoController.getInternalAccessor().getInformationControlReplacer());
delayedICP.setDelayedInputChangeListener(inputChangeListener);
// cancel automatic input updating after a small timeout:
- control.getShell().getDisplay().timerExec(1000, new Runnable() {
- @Override
- public void run() {
- delayedICP.setDelayedInputChangeListener(null);
- }
- });
+ control.getShell().getDisplay().timerExec(1000, () -> delayedICP.setDelayedInputChangeListener(null));
}
// XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212392 :
- control.getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
- }
- });
+ control.getShell().getDisplay().asyncExec(() -> fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true));
}
}
}
@@ -251,12 +235,9 @@ class PopupCloser extends ShellAdapter implements FocusListener, SelectionListen
Control control= (Control) event.widget;
IInformationControlExtension5 iControl5= (IInformationControlExtension5) iControl;
if (iControl5.containsControl(control)) {
- control.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fContentAssistant != null && ! fContentAssistant.hasProposalPopupFocus())
- fContentAssistant.hide();
- }
+ control.getDisplay().asyncExec(() -> {
+ if (fContentAssistant != null && !fContentAssistant.hasProposalPopupFocus())
+ fContentAssistant.hide();
});
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/DefaultHyperlinkPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/DefaultHyperlinkPresenter.java
index 7d5bed653..d1cf3d07b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/DefaultHyperlinkPresenter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/DefaultHyperlinkPresenter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -297,12 +297,7 @@ public class DefaultHyperlinkPresenter implements IHyperlinkPresenter, IHyperlin
StyledText widget= fTextViewer.getTextWidget();
if (widget != null && !widget.isDisposed()) {
- widget.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- hideHyperlinks();
- }
- });
+ widget.getDisplay().asyncExec(() -> hideHyperlinks());
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
index 6d0cf9360..f8f5f43c6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -171,13 +171,10 @@ public class InformationPresenter extends AbstractInformationControlManager impl
@Override
public void focusLost(FocusEvent e) {
Display d= fSubjectControl.getDisplay();
- d.asyncExec(new Runnable() {
- // Without the asyncExec, mouse clicks to the workbench window are swallowed.
- @Override
- public void run() {
- if (fInformationControlToClose == null || !fInformationControlToClose.isFocusControl())
- hideInformationControl();
- }
+ // Without the asyncExec, mouse clicks to the workbench window are swallowed.
+ d.asyncExec(() -> {
+ if (fInformationControlToClose == null || !fInformationControlToClose.isFocusControl())
+ hideInformationControl();
});
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
index d34e191e2..09a2490d8 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -40,7 +40,6 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPartitioningException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.IDocument;
@@ -333,21 +332,18 @@ public class LinkedModeUI {
else
{
// Post in UI thread since the assistant popup will only get the focus after we lose it.
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fIsActive && viewer instanceof IEditingSupportRegistry) {
- IEditingSupport[] helpers= ((IEditingSupportRegistry) viewer).getRegisteredSupports();
- for (IEditingSupport helper : helpers) {
- if (helper.ownsFocusShell())
- return;
- }
+ display.asyncExec(() -> {
+ if (fIsActive && viewer instanceof IEditingSupportRegistry) {
+ IEditingSupport[] helpers= ((IEditingSupportRegistry) viewer).getRegisteredSupports();
+ for (IEditingSupport helper : helpers) {
+ if (helper.ownsFocusShell())
+ return;
}
+ }
- // else
- leave(ILinkedModeListener.EXIT_ALL);
+ // else
+ leave(ILinkedModeListener.EXIT_ALL);
- }
});
}
}
@@ -606,17 +602,14 @@ public class LinkedModeUI {
private boolean fHasOpenCompoundChange= false;
/** The position listener. */
private ILinkedModeUIFocusListener fPositionListener= new EmtpyFocusListener();
- private IAutoEditStrategy fAutoEditVetoer= new IAutoEditStrategy() {
-
- @Override
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- // invalidate the change to ensure that the change is performed on the document only.
- if (fModel.anyPositionContains(command.offset)) {
- command.doit= false;
- command.caretOffset= command.offset + command.length;
- }
+ private IAutoEditStrategy fAutoEditVetoer= (document, command) -> {
+ // invalidate the change to ensure that the change is performed on the document only.
+ if (fModel.anyPositionContains(command.offset)) {
+ command.doit= false;
+ command.caretOffset= command.offset + command.length;
}
+
};
@@ -970,24 +963,21 @@ public class LinkedModeUI {
return;
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=132263
- widget.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!widget.isDisposed())
- try {
+ widget.getDisplay().asyncExec(() -> {
+ if (!widget.isDisposed())
+ try {
widget.showSelection();
- } catch (IllegalArgumentException e) {
- /*
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66914
- * if the StyledText is in setRedraw(false) mode, its
- * selection may not be up2date and calling showSelection
- * will throw an IAE.
- * We don't have means to find out whether the selection is valid
- * or whether the widget is redrawing or not therefore we try
- * and ignore an IAE.
- */
- }
- }
+ } catch (IllegalArgumentException e) {
+ /*
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66914
+ * if the StyledText is in setRedraw(false) mode, its
+ * selection may not be up2date and calling showSelection
+ * will throw an IAE.
+ * We don't have means to find out whether the selection is valid
+ * or whether the widget is redrawing or not therefore we try
+ * and ignore an IAE.
+ */
+ }
});
}
@@ -1157,31 +1147,28 @@ public class LinkedModeUI {
fModel.stopForwarding(flags);
- Runnable runnable= new Runnable() {
- @Override
- public void run() {
- if (fExitPosition != null)
- fExitPosition.getDocument().removePosition(fExitPosition);
-
- for (IDocument doc : docs) {
- doc.removePositionUpdater(fPositionUpdater);
- boolean uninstallCat= false;
- String[] cats= doc.getPositionCategories();
- for (String cat : cats) {
- if (getCategory().equals(cat)) {
- uninstallCat= true;
- break;
- }
+ Runnable runnable= () -> {
+ if (fExitPosition != null)
+ fExitPosition.getDocument().removePosition(fExitPosition);
+
+ for (IDocument doc : docs) {
+ doc.removePositionUpdater(fPositionUpdater);
+ boolean uninstallCat= false;
+ String[] cats= doc.getPositionCategories();
+ for (String cat : cats) {
+ if (getCategory().equals(cat)) {
+ uninstallCat= true;
+ break;
}
- if (uninstallCat)
- try {
- doc.removePositionCategory(getCategory());
- } catch (BadPositionCategoryException e) {
- // ignore
- }
}
- fModel.exit(flags);
+ if (uninstallCat)
+ try {
+ doc.removePositionCategory(getCategory());
+ } catch (BadPositionCategoryException e) {
+ // ignore
+ }
}
+ fModel.exit(flags);
};
// remove positions (both exit positions AND linked positions in the
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
index dbe7d0912..c88ae3cd6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
@@ -1067,12 +1067,9 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
// changes any more. If the document gets modified between
// now and running the posted runnable, the position information
// is not accurate any longer.
- textWidgetDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fTextWidget != null && !fTextWidget.isDisposed())
- updatePainting(event);
- }
+ textWidgetDisplay.asyncExec(() -> {
+ if (fTextWidget != null && !fTextWidget.isDisposed())
+ updatePainting(event);
});
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
index 8c6808893..e8ce28d7c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -26,14 +26,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseWheelListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
@@ -264,21 +258,15 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
fCanvas= createCanvas(parentControl);
- fCanvas.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
+ fCanvas.addPaintListener(event -> {
+ if (fCachedTextViewer != null)
+ doubleBufferPaint(event.gc);
});
- fCanvas.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
+ fCanvas.addDisposeListener(e -> {
+ handleDispose();
+ fCachedTextViewer= null;
+ fCachedTextWidget= null;
});
fMouseListener= new MouseListener() {
@@ -323,19 +311,9 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
};
fCanvas.addMouseListener(fMouseListener);
- fCanvas.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- handleMouseMove(e);
- }
- });
+ fCanvas.addMouseMoveListener(e -> handleMouseMove(e));
- fCanvas.addMouseWheelListener(new MouseWheelListener() {
- @Override
- public void mouseScrolled(MouseEvent e) {
- handleMouseScrolled(e);
- }
- });
+ fCanvas.addMouseWheelListener(e -> handleMouseScrolled(e));
if (fCachedTextViewer != null) {
VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
@@ -845,12 +823,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
if (fCanvas != null && !fCanvas.isDisposed()) {
Display d= fCanvas.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
+ d.asyncExec(() -> redraw());
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
index 0946f5d99..e9d4dbdcd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -12,13 +12,9 @@ package org.eclipse.jface.text.source;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
@@ -189,21 +185,15 @@ public final class ChangeRulerColumn implements IChangeRulerColumn, IRevisionRul
fCanvas= new Canvas(parentControl, SWT.NONE);
fCanvas.setBackground(getBackground());
- fCanvas.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent event) {
- if (fCachedTextViewer != null)
- doubleBufferPaint(event.gc);
- }
+ fCanvas.addPaintListener(event -> {
+ if (fCachedTextViewer != null)
+ doubleBufferPaint(event.gc);
});
- fCanvas.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fCachedTextViewer= null;
- fCachedTextWidget= null;
- }
+ fCanvas.addDisposeListener(e -> {
+ handleDispose();
+ fCachedTextViewer= null;
+ fCachedTextWidget= null;
});
fCanvas.addMouseListener(fMouseHandler);
@@ -429,12 +419,7 @@ public final class ChangeRulerColumn implements IChangeRulerColumn, IRevisionRul
if (fCanvas != null && !fCanvas.isDisposed()) {
Display d= fCanvas.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
+ d.asyncExec(() -> redraw());
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
index eea192133..c8b02c8df 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -21,7 +21,6 @@ import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.GestureListener;
@@ -39,7 +38,6 @@ import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
@@ -142,25 +140,19 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public CompositeRulerCanvas(Composite parent, int style) {
super(parent, style);
- fMenuDetectListener= new Listener() {
- @Override
- public void handleEvent(Event event) {
- if (event.type == SWT.MenuDetect) {
- Menu menu= getMenu();
- if (menu != null) {
- menu.setLocation(event.x, event.y);
- menu.setVisible(true);
- }
+ fMenuDetectListener= event -> {
+ if (event.type == SWT.MenuDetect) {
+ Menu menu= getMenu();
+ if (menu != null) {
+ menu.setLocation(event.x, event.y);
+ menu.setVisible(true);
}
}
};
- super.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fCachedListeners != null) {
- fCachedListeners.clear();
- fCachedListeners= null;
- }
+ super.addDisposeListener(e -> {
+ if (fCachedListeners != null) {
+ fCachedListeners.clear();
+ fCachedListeners= null;
}
});
}
@@ -640,12 +632,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
if (fComposite != null && !fComposite.isDisposed()) {
Display d= fComposite.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- immediateUpdate();
- }
- });
+ d.asyncExec(() -> immediateUpdate());
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
index 092e24688..c032dfffd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -413,14 +413,11 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
* Redraw runnable
* @since 3.0
*/
- private Runnable fRunnable= new Runnable() {
- @Override
- public void run() {
- synchronized (fRunnableLock) {
- fIsRunnablePosted= false;
- }
- redraw();
+ private Runnable fRunnable= () -> {
+ synchronized (fRunnableLock) {
+ fIsRunnablePosted= false;
}
+ redraw();
};
/* @since 3.2 */
private MouseHandler fMouseHandler;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
index 5cccb5d81..369d1bcd5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -475,15 +475,12 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* Redraw runnable
* @since 3.3
*/
- private Runnable fRunnable= new Runnable() {
- @Override
- public void run() {
- synchronized (fRunnableLock) {
- fIsRunnablePosted= false;
- }
- redraw();
- updateHeader();
+ private Runnable fRunnable= () -> {
+ synchronized (fRunnableLock) {
+ fIsRunnablePosted= false;
}
+ redraw();
+ updateHeader();
};
/**
* Tells whether temporary annotations are drawn with
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
index 958b71c1a..c72cb1650 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -15,12 +15,8 @@ import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -150,20 +146,14 @@ public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtens
fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
- fCanvas.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent event) {
- if (fTextViewer != null)
- doubleBufferPaint(event.gc);
- }
+ fCanvas.addPaintListener(event -> {
+ if (fTextViewer != null)
+ doubleBufferPaint(event.gc);
});
- fCanvas.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- fTextViewer= null;
- }
+ fCanvas.addDisposeListener(e -> {
+ handleDispose();
+ fTextViewer= null;
});
fCanvas.addMouseListener(new MouseListener() {
@@ -457,12 +447,7 @@ public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtens
if (fCanvas != null && !fCanvas.isDisposed()) {
Display d= fCanvas.getDisplay();
if (d != null) {
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
+ d.asyncExec(() -> redraw());
}
}
}

Back to the top