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
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>
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java39
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java41
-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
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java58
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java55
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java15
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java82
-rwxr-xr-xorg.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java48
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java93
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java25
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java48
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java23
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java318
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java72
47 files changed, 802 insertions, 1346 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
index fee3349c4..08e73380c 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 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
@@ -13,6 +13,7 @@ package org.eclipse.core.filebuffers.manipulation;
import java.util.ArrayList;
import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -105,25 +106,23 @@ public class GenericFileBufferOperationRunner {
fThrowable= null;
synchronized (fCompletionLock) {
- executeInContext(new Runnable() {
- @Override
- public void run() {
- synchronized(fCompletionLock) {
- try {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable throwable) {
- fThrowable= throwable;
- }
- @Override
- public void run() throws Exception {
- performOperation(synchronizedFileBuffers, operation, subMonitor.split(50));
- }
- });
- } finally {
- fIsCompleted= true;
- fCompletionLock.notifyAll();
- }
+ executeInContext(() -> {
+ synchronized (fCompletionLock) {
+ try {
+ SafeRunner.run(new ISafeRunnable() {
+ @Override
+ public void handleException(Throwable throwable) {
+ fThrowable= throwable;
+ }
+
+ @Override
+ public void run() throws Exception {
+ performOperation(synchronizedFileBuffers, operation, subMonitor.split(50));
+ }
+ });
+ } finally {
+ fIsCompleted= true;
+ fCompletionLock.notifyAll();
}
}
});
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
index 6455181de..07bfa673c 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.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
@@ -874,28 +874,25 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
if (widget != null) {
Display display= widget.getDisplay();
if (display != null) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- try {
- while (true) {
- AnnotationModelEvent ame= null;
- synchronized (fLock) {
- if (fPendingRequests.size() == 0)
- return;
- ame= fPendingRequests.remove(0);
- }
- catchupWithProjectionAnnotationModel(ame);
+ display.asyncExec(() -> {
+ try {
+ while (true) {
+ AnnotationModelEvent ame= null;
+ synchronized (fLock) {
+ if (fPendingRequests.size() == 0)
+ return;
+ ame= fPendingRequests.remove(0);
}
- } catch (BadLocationException x) {
- try {
- catchupWithProjectionAnnotationModel(null);
- } catch (BadLocationException x1) {
- throw new IllegalArgumentException();
- } finally {
- synchronized (fLock) {
- fPendingRequests.clear();
- }
+ catchupWithProjectionAnnotationModel(ame);
+ }
+ } catch (BadLocationException x) {
+ try {
+ catchupWithProjectionAnnotationModel(null);
+ } catch (BadLocationException x1) {
+ throw new IllegalArgumentException();
+ } finally {
+ synchronized (fLock) {
+ fPendingRequests.clear();
}
}
}
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());
}
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
index 44af5ee43..3bb953e40 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
@@ -36,7 +36,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
@@ -298,12 +297,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
fBatchedUpdates = new HashSet<>();
fBatchedClearAll= false;
- fListener = new ISearchResultListener() {
- @Override
- public void searchResultChanged(SearchResultEvent e) {
- handleSearchResultChanged(e);
- }
- };
+ fListener = e -> handleSearchResultChanged(e);
fFilterActions= null;
fElementLimit= null;
}
@@ -540,13 +534,10 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
fMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
fMenu.setRemoveAllWhenShown(true);
fMenu.setParent(getSite().getActionBars().getMenuManager());
- fMenu.addMenuListener(new IMenuListener() {
- @Override
- public void menuAboutToShow(IMenuManager mgr) {
- SearchView.createContextMenuGroups(mgr);
- fillContextMenu(mgr);
- fViewPart.fillContextMenu(mgr);
- }
+ fMenu.addMenuListener(mgr -> {
+ SearchView.createContextMenuGroups(mgr);
+ fillContextMenu(mgr);
+ fViewPart.fillContextMenu(mgr);
});
fPagebook = new PageBook(parent, SWT.NULL);
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -597,20 +588,15 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
@Override
public void queryStarting(final ISearchQuery query) {
- final Runnable runnable1 = new Runnable() {
- @Override
- public void run() {
- updateBusyLabel();
- AbstractTextSearchResult result = getInput();
-
- if (result == null || !result.getQuery().equals(query)) {
- return;
- }
- turnOffDecoration();
- scheduleUIUpdate();
- }
-
+ final Runnable runnable1 = () -> {
+ updateBusyLabel();
+ AbstractTextSearchResult result = getInput();
+ if (result == null || !result.getQuery().equals(query)) {
+ return;
+ }
+ turnOffDecoration();
+ scheduleUIUpdate();
};
asyncExec(runnable1);
}
@@ -763,12 +749,9 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
};
- fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- fCurrentMatchIndex = -1;
- fRemoveSelectedMatches.setEnabled(canRemoveMatchesWith(event.getSelection()));
- }
+ fViewer.addSelectionChangedListener(event -> {
+ fCurrentMatchIndex = -1;
+ fRemoveSelectedMatches.setEnabled(canRemoveMatchesWith(event.getSelection()));
});
fViewer.addSelectionChangedListener(fViewerAdapter);
@@ -1288,12 +1271,9 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
if (currentDisplay == null || !currentDisplay.equals(control.getDisplay()))
// meaning we're not executing on the display thread of the
// control
- control.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!control.isDisposed())
- runnable.run();
- }
+ control.getDisplay().asyncExec(() -> {
+ if (!control.isDisposed())
+ runnable.run();
});
else
runnable.run();
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
index 146c202d5..4fa93c9ce 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.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
@@ -28,7 +28,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -75,32 +74,25 @@ public class DefaultEncodingSupport implements IEncodingSupport {
IEclipsePreferences prefs= InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
- fPreferenceChangeListener= new IPreferenceChangeListener() {
- @Override
- public void preferenceChange(PreferenceChangeEvent event) {
- if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) {
- Runnable runnable= new Runnable() {
- @Override
- public void run() {
- setEncoding(null, false); // null means: use default
- }
- };
- if (Display.getCurrent() != null)
- runnable.run();
- else {
- // Post runnable into UI thread
- Shell shell;
- if (fTextEditor != null)
- shell= fTextEditor.getSite().getShell();
- else
- shell= getActiveWorkbenchShell();
- Display display;
- if (shell != null)
- display= shell.getDisplay();
- else
- display= Display.getDefault();
- display.asyncExec(runnable);
- }
+ fPreferenceChangeListener= event -> {
+ if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) {
+ // null means: use default
+ Runnable runnable= () -> setEncoding(null, false);
+ if (Display.getCurrent() != null)
+ runnable.run();
+ else {
+ // Post runnable into UI thread
+ Shell shell;
+ if (fTextEditor != null)
+ shell= fTextEditor.getSite().getShell();
+ else
+ shell= getActiveWorkbenchShell();
+ Display display;
+ if (shell != null)
+ display= shell.getDisplay();
+ else
+ display= Display.getDefault();
+ display.asyncExec(runnable);
}
}
};
@@ -143,12 +135,7 @@ public class DefaultEncodingSupport implements IEncodingSupport {
if (apply) {
provider.setEncoding(input, encoding);
Runnable encodingSetter=
- new Runnable() {
- @Override
- public void run() {
- fTextEditor.doRevertToSaved();
- }
- };
+ () -> fTextEditor.doRevertToSaved();
Display display= fTextEditor.getSite().getShell().getDisplay();
if (display != null && !display.isDisposed())
BusyIndicator.showWhile(display, encodingSetter);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java
index 172ebd936..84d216d65 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.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
@@ -312,14 +312,11 @@ public class LastSaveReferenceProvider implements IQuickDiffReferenceProvider, I
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=66686 and
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56871
- Runnable runnable= new Runnable() {
- @Override
- public void run() {
- synchronized (fLock) {
- if (fDocumentProvider == provider)
- // addElementStateListener adds at most once - no problem to call repeatedly
- provider.addElementStateListener(LastSaveReferenceProvider.this);
- }
+ Runnable runnable= () -> {
+ synchronized (fLock) {
+ if (fDocumentProvider == provider)
+ // addElementStateListener adds at most once - no problem to call repeatedly
+ provider.addElementStateListener(LastSaveReferenceProvider.this);
}
};
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
index 70601ed12..def0032d7 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
@@ -42,10 +42,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
@@ -297,12 +295,7 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
fIsNextPreviousTargetCheckBox.setLayoutData(gd);
- fAnnotationTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- handleAnnotationListSelection();
- }
- });
+ fAnnotationTypeViewer.addSelectionChangedListener(event -> handleAnnotationListSelection());
fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
@Override
@@ -390,34 +383,30 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
}
});
- fDecorationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- String[] decoration= (String[]) fDecorationViewer.getStructuredSelection().getFirstElement();
- ListItem item= getSelectedItem();
+ fDecorationViewer.addSelectionChangedListener(event -> {
+ String[] decoration= (String[]) fDecorationViewer.getStructuredSelection().getFirstElement();
+ ListItem item= getSelectedItem();
- if (fShowInTextCheckBox.getSelection()) {
- if (HIGHLIGHT.equals(decoration)) {
- fStore.setValue(item.highlightKey, true);
- if (item.textKey != null) {
- fStore.setValue(item.textKey, false);
- if (item.textStyleKey != null)
- fStore.setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
- }
- } else {
- if (item.highlightKey != null)
- fStore.setValue(item.highlightKey, false);
- if (item.textKey != null) {
- fStore.setValue(item.textKey, true);
- if (item.textStyleKey != null)
- fStore.setValue(item.textStyleKey, decoration[1]);
- }
+ if (fShowInTextCheckBox.getSelection()) {
+ if (HIGHLIGHT.equals(decoration)) {
+ fStore.setValue(item.highlightKey, true);
+ if (item.textKey != null) {
+ fStore.setValue(item.textKey, false);
+ if (item.textStyleKey != null)
+ fStore.setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
+ }
+ } else {
+ if (item.highlightKey != null)
+ fStore.setValue(item.highlightKey, false);
+ if (item.textKey != null) {
+ fStore.setValue(item.textKey, true);
+ if (item.textStyleKey != null)
+ fStore.setValue(item.textStyleKey, decoration[1]);
}
}
-
- fAnnotationTypeViewer.refresh(item);
}
+
+ fAnnotationTypeViewer.refresh(item);
});
composite.layout();
@@ -450,12 +439,9 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
final ListItem element= fListModel[i];
if (data.equals(element.label)) {
final Control control= fAnnotationTypeViewer.getControl();
- control.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- control.setFocus();
- fAnnotationTypeViewer.setSelection(new StructuredSelection(element), true);
- }
+ control.getDisplay().asyncExec(() -> {
+ control.setFocus();
+ fAnnotationTypeViewer.setSelection(new StructuredSelection(element), true);
});
return;
}
@@ -515,12 +501,9 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
public void initialize() {
fAnnotationTypeViewer.setInput(fListModel);
- fAnnotationTypeViewer.getControl().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fAnnotationTypeViewer != null && !fAnnotationTypeViewer.getControl().isDisposed()) {
- fAnnotationTypeViewer.setSelection(new StructuredSelection(fListModel[0]));
- }
+ fAnnotationTypeViewer.getControl().getDisplay().asyncExec(() -> {
+ if (fAnnotationTypeViewer != null && !fAnnotationTypeViewer.getControl().isDisposed()) {
+ fAnnotationTypeViewer.setSelection(new StructuredSelection(fListModel[0]));
}
});
@@ -544,15 +527,12 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
}
}
- Comparator<ListItem> comparator= new Comparator<ListItem>() {
- @Override
- public int compare(ListItem o1, ListItem o2) {
- String label1= o1.label;
- String label2= o2.label;
+ Comparator<ListItem> comparator= (o1, o2) -> {
+ String label1= o1.label;
+ String label2= o2.label;
- return Collator.getInstance().compare(label1, label2);
+ return Collator.getInstance().compare(label1, label2);
- }
};
Collections.sort(listModelItems, comparator);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
index 01f65231d..5d62ef6b6 100755
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
@@ -42,10 +42,8 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
@@ -295,12 +293,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
createDependency(fShowInTextCheckBox, new Control[] {label, foregroundColorButton});
- fAnnotationTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- handleAnnotationListSelection();
- }
- });
+ fAnnotationTypeViewer.addSelectionChangedListener(event -> handleAnnotationListSelection());
fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
@Override
@@ -342,23 +335,19 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
}
});
- fDecorationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ fDecorationViewer.addSelectionChangedListener(event -> {
+ String[] decoration= (String[]) fDecorationViewer.getStructuredSelection().getFirstElement();
+ ListItem item= getSelectedItem();
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- String[] decoration= (String[]) fDecorationViewer.getStructuredSelection().getFirstElement();
- ListItem item= getSelectedItem();
-
- if (fShowInTextCheckBox.getSelection()) {
- if (HIGHLIGHT.equals(decoration)) {
- getPreferenceStore().setValue(item.highlightKey, true);
- getPreferenceStore().setValue(item.textKey, false);
- getPreferenceStore().setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
- } else {
- getPreferenceStore().setValue(item.highlightKey, false);
- getPreferenceStore().setValue(item.textKey, true);
- getPreferenceStore().setValue(item.textStyleKey, decoration[1]);
- }
+ if (fShowInTextCheckBox.getSelection()) {
+ if (HIGHLIGHT.equals(decoration)) {
+ getPreferenceStore().setValue(item.highlightKey, true);
+ getPreferenceStore().setValue(item.textKey, false);
+ getPreferenceStore().setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
+ } else {
+ getPreferenceStore().setValue(item.highlightKey, false);
+ getPreferenceStore().setValue(item.textKey, true);
+ getPreferenceStore().setValue(item.textStyleKey, decoration[1]);
}
}
});
@@ -444,13 +433,10 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
initializeFields();
fAnnotationTypeViewer.setInput(fListModel);
- fAnnotationTypeViewer.getControl().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fAnnotationTypeViewer != null && !fAnnotationTypeViewer.getControl().isDisposed()) {
- fAnnotationTypeViewer.setSelection(new StructuredSelection(fListModel[0]));
- initializeFields();
- }
+ fAnnotationTypeViewer.getControl().getDisplay().asyncExec(() -> {
+ if (fAnnotationTypeViewer != null && !fAnnotationTypeViewer.getControl().isDisposed()) {
+ fAnnotationTypeViewer.setSelection(new StructuredSelection(fListModel[0]));
+ initializeFields();
}
});
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
index 4da7156e7..523435010 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.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
@@ -401,12 +401,7 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
String label= fQuickDiffProviderListModel[i][1];
fQuickDiffProviderCombo.add(label);
}
- fQuickDiffProviderCombo.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- updateProviderList();
- }
- });
+ fQuickDiffProviderCombo.getDisplay().asyncExec(() -> updateProviderList());
initializeFields();
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
index eaf450a35..32bf4a64f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
@@ -167,16 +167,13 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
public void checkStateChanged(final CheckStateChangedEvent event) {
//Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), new Runnable() {
- @Override
- public void run() {
- if (event.getCheckable().equals(treeViewer))
- treeItemChecked(event.getElement(), event.getChecked());
- else
- listItemChecked(event.getElement(), event.getChecked(), true);
+ BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), () -> {
+ if (event.getCheckable().equals(treeViewer))
+ treeItemChecked(event.getElement(), event.getChecked());
+ else
+ listItemChecked(event.getElement(), event.getChecked(), true);
- notifyCheckStateChangeListeners(event);
- }
+ notifyCheckStateChangeListeners(event);
});
}
@@ -292,37 +289,34 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* @param element the element to be expanded
*/
private void expandTreeElement(final Object element) {
- BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), new Runnable() {
- @Override
- public void run() {
-
- // First see if the children need to be given their checked
- // state at all. If they've
- // already been realized then this won't be necessary
- if (expandedTreeNodes.contains(element))
- checkNewTreeElements(treeContentProvider.getChildren(element));
- else {
-
- expandedTreeNodes.add(element);
- if (whiteCheckedTreeItems.contains(element)) {
- //If this is the first expansion and this is a white
- // checked node then check the children
- Object[] children= treeContentProvider.getChildren(element);
- for (int i= 0; i < children.length; ++i) {
- if (!whiteCheckedTreeItems.contains(children[i])) {
- Object child= children[i];
- setWhiteChecked(child, true);
- treeViewer.setChecked(child, true);
- checkedStateStore.put(child, new ArrayList<>());
- }
+ BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), () -> {
+
+ // First see if the children need to be given their checked
+ // state at all. If they've
+ // already been realized then this won't be necessary
+ if (expandedTreeNodes.contains(element))
+ checkNewTreeElements(treeContentProvider.getChildren(element));
+ else {
+
+ expandedTreeNodes.add(element);
+ if (whiteCheckedTreeItems.contains(element)) {
+ //If this is the first expansion and this is a white
+ // checked node then check the children
+ Object[] children= treeContentProvider.getChildren(element);
+ for (int i= 0; i < children.length; ++i) {
+ if (!whiteCheckedTreeItems.contains(children[i])) {
+ Object child= children[i];
+ setWhiteChecked(child, true);
+ treeViewer.setChecked(child, true);
+ checkedStateStore.put(child, new ArrayList<>());
}
-
- //Now be sure to select the list of items too
- setListForWhiteSelection(element);
}
- }
+ //Now be sure to select the list of items too
+ setListForWhiteSelection(element);
+ }
}
+
});
}
@@ -589,12 +583,9 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
if (!(expandedTreeNodes.contains(treeElement)) && whiteCheckedTreeItems.contains(treeElement)) {
//Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), new Runnable() {
- @Override
- public void run() {
- setListForWhiteSelection(treeElement);
- listViewer.setAllChecked(true);
- }
+ BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), () -> {
+ setListForWhiteSelection(treeElement);
+ listViewer.setAllChecked(true);
});
} else {
@@ -680,23 +671,17 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
return;
//Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), new Runnable() {
- @Override
- public void run() {
- setTreeChecked(root, selection);
- listViewer.setAllChecked(selection);
- }
+ BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), () -> {
+ setTreeChecked(root, selection);
+ listViewer.setAllChecked(selection);
});
}
public void refresh() {
//Potentially long operation - show a busy cursor
- BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), new Runnable() {
- @Override
- public void run() {
- treeViewer.refresh();
- populateListViewer(currentTreeSelection);
- }
+ BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), () -> {
+ treeViewer.refresh();
+ populateListViewer(currentTreeSelection);
});
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
index 7a3db4da6..2afde75bf 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.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
@@ -41,8 +41,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.ui.dialogs.TypeFilteringDialog;
@@ -112,12 +110,7 @@ class SelectResourcesDialog extends Dialog {
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fResourceGroup= new SelectResourcesBlock(composite, ResourcesPlugin.getWorkspace().getRoot(), getResourceProvider(IResource.FOLDER | IResource.PROJECT), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), getResourceProvider(IResource.FILE), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), SWT.NONE, useHeightHint(parent));
- fResourceGroup.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- updateSelectionCount();
- }
- });
+ fResourceGroup.addCheckStateListener(event -> updateSelectionCount());
fCountIndication= new Label(composite, SWT.LEFT);
fCountIndication.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -245,22 +238,12 @@ class SelectResourcesDialog extends Dialog {
private void filterSelection() {
- final IFilter filter= new IFilter() {
- @Override
- public boolean accept(IResource resource) {
- return hasAcceptedFileType(resource);
- }
- };
+ final IFilter filter= resource -> hasAcceptedFileType(resource);
List<Object> list= fResourceGroup.getAllWhiteCheckedItems();
final IResource[] resources= list.toArray(new IResource[list.size()]);
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- setSelection(resources, filter);
- }
- };
+ Runnable runnable= () -> setSelection(resources, filter);
BusyIndicator.showWhile(getShell().getDisplay(), runnable);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
index fabb85214..e1accfb99 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.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
@@ -48,12 +48,7 @@ class SharedTextColors implements ISharedTextColors {
if (colorTable == null) {
colorTable= new HashMap<>(10);
fDisplayTable.put(display, colorTable);
- display.disposeExec(new Runnable() {
- @Override
- public void run() {
- dispose(display);
- }
- });
+ display.disposeExec(() -> dispose(display));
}
Color color= colorTable.get(rgb);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index 987373fcc..3553573c5 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -19,8 +19,6 @@ import java.util.Map;
import java.util.Set;
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.events.SelectionListener;
@@ -620,18 +618,14 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
textControl.setToolTipText(preference.getDescription());
if (domain != null) {
- textControl.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- String value= textControl.getText();
- IStatus status= domain.validate(value);
- if (!status.matches(IStatus.ERROR)) {
- fDialogOverlayStore.setValue(preference.getKey(), value);
- setErrorMessage(null);
- }
- else {
- setErrorMessage(NLSUtility.format(TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogInvalidInput, value));
- }
+ textControl.addModifyListener(e -> {
+ String value= textControl.getText();
+ IStatus status= domain.validate(value);
+ if (!status.matches(IStatus.ERROR)) {
+ fDialogOverlayStore.setValue(preference.getKey(), value);
+ setErrorMessage(null);
+ } else {
+ setErrorMessage(NLSUtility.format(TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogInvalidInput, value));
}
});
}
@@ -1044,13 +1038,10 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
for (int i= 0; i < fAppearanceColorListModel.length; i++)
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
- fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
- fAppearanceColorList.select(0);
- handleAppearanceColorListSelection();
- }
+ fAppearanceColorList.getDisplay().asyncExec(() -> {
+ if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
+ fAppearanceColorList.select(0);
+ handleAppearanceColorListSelection();
}
});
}
@@ -1301,15 +1292,12 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
textControl.setToolTipText(preference.getDescription());
if (domain != null) {
- textControl.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- String value= textControl.getText();
- IStatus status= domain.validate(value);
- if (!status.matches(IStatus.ERROR))
- fOverlayStore.setValue(preference.getKey(), value);
- updateStatus(domain);
- }
+ textControl.addModifyListener(e -> {
+ String value= textControl.getText();
+ IStatus status= domain.validate(value);
+ if (!status.matches(IStatus.ERROR))
+ fOverlayStore.setValue(preference.getKey(), value);
+ updateStatus(domain);
});
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
index 5fcf71bdd..68e6bfedd 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 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
@@ -95,18 +95,15 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation implements IQuickFi
protected static Map<ImageDescriptor, Image> getImageRegistry(Display display) {
if (fgImageRegistry == null) {
fgImageRegistry= new HashMap<>();
- display.disposeExec(new Runnable() {
- @Override
- public void run() {
- if (fgImageRegistry != null) {
- Map<ImageDescriptor, Image> map= fgImageRegistry;
- fgImageRegistry= null;
- Iterator<Image> e= map.values().iterator();
- while (e.hasNext()) {
- Image image= e.next();
- if (!image.isDisposed())
- image.dispose();
- }
+ display.disposeExec(() -> {
+ if (fgImageRegistry != null) {
+ Map<ImageDescriptor, Image> map= fgImageRegistry;
+ fgImageRegistry= null;
+ Iterator<Image> e= map.values().iterator();
+ while (e.hasNext()) {
+ Image image= e.next();
+ if (!image.isDisposed())
+ image.dispose();
}
}
});
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index 1a01cdbd6..e04180eb6 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -67,7 +67,6 @@ 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.Menu;
import org.eclipse.swt.widgets.Shell;
@@ -114,7 +113,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.IShellProvider;
import org.eclipse.jface.text.AbstractInformationControlManager;
import org.eclipse.jface.text.BadLocationException;
@@ -402,30 +400,27 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void elementStateValidationChanged(final Object element, final boolean isStateValidated) {
if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- @Override
- public void run() {
- enableSanityChecking(true);
- if (isStateValidated) {
- if (fValidator != null) {
- ISourceViewer viewer= fSourceViewer;
- if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.removeVerifyListener(fValidator);
- fValidator= null;
- }
+ Runnable r = () -> {
+ enableSanityChecking(true);
+ if (isStateValidated) {
+ if (fValidator != null) {
+ ISourceViewer viewer1 = fSourceViewer;
+ if (viewer1 != null) {
+ StyledText textWidget1 = viewer1.getTextWidget();
+ if (textWidget1 != null && !textWidget1.isDisposed())
+ textWidget1.removeVerifyListener(fValidator);
+ fValidator = null;
}
- enableStateValidation(false);
- } else if (!isStateValidated && fValidator == null) {
- ISourceViewer viewer= fSourceViewer;
- if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- fValidator= new Validator();
- enableStateValidation(true);
- textWidget.addVerifyListener(fValidator);
- }
+ }
+ enableStateValidation(false);
+ } else if (!isStateValidated && fValidator == null) {
+ ISourceViewer viewer2 = fSourceViewer;
+ if (viewer2 != null) {
+ StyledText textWidget2 = viewer2.getTextWidget();
+ if (textWidget2 != null && !textWidget2.isDisposed()) {
+ fValidator = new Validator();
+ enableStateValidation(true);
+ textWidget2.addVerifyListener(fValidator);
}
}
}
@@ -438,12 +433,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void elementDirtyStateChanged(Object element, boolean isDirty) {
if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- @Override
- public void run() {
- enableSanityChecking(true);
- firePropertyChange(PROP_DIRTY);
- }
+ Runnable r = () -> {
+ enableSanityChecking(true);
+ firePropertyChange(PROP_DIRTY);
};
execute(r, false);
}
@@ -452,13 +444,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void elementContentAboutToBeReplaced(Object element) {
if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- @Override
- public void run() {
- enableSanityChecking(true);
- rememberSelection();
- resetHighlightRange();
- }
+ Runnable r = () -> {
+ enableSanityChecking(true);
+ rememberSelection();
+ resetHighlightRange();
};
execute(r, false);
}
@@ -467,14 +456,11 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void elementContentReplaced(Object element) {
if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- @Override
- public void run() {
- enableSanityChecking(true);
- firePropertyChange(PROP_DIRTY);
- restoreSelection();
- handleElementContentReplaced();
- }
+ Runnable r = () -> {
+ enableSanityChecking(true);
+ firePropertyChange(PROP_DIRTY);
+ restoreSelection();
+ handleElementContentReplaced();
};
execute(r, false);
}
@@ -483,12 +469,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void elementDeleted(Object deletedElement) {
if (deletedElement != null && deletedElement.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- @Override
- public void run() {
- enableSanityChecking(true);
- close(false);
- }
+ Runnable r = () -> {
+ enableSanityChecking(true);
+ close(false);
};
execute(r, false);
}
@@ -548,14 +531,11 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
if (wasDirty && changed != null) {
- Runnable r2= new Runnable() {
- @Override
- public void run() {
- validateState(getEditorInput());
- d.getDocument(getEditorInput()).set(previousContent);
- updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
- restoreSelection();
- }
+ Runnable r2 = () -> {
+ validateState(getEditorInput());
+ d.getDocument(getEditorInput()).set(previousContent);
+ updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
+ restoreSelection();
};
execute(r2, doValidationAsync);
} else
@@ -607,67 +587,70 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
class TextListener implements ITextListener, ITextInputListener {
+ /**
+ * Should the last edit position be updated?
+ *
+ * @since 3.0
+ */
+ private boolean fUpdateLastEditPosition = false;
+
+ /**
+ * The editor's last edit position
+ *
+ * @since 3.0
+ */
+ private Position fLocalLastEditPosition;
+
/** The posted updater code. */
- private Runnable fRunnable= new Runnable() {
- @Override
- public void run() {
- fIsRunnablePosted= false;
-
- if (fSourceViewer != null) {
- updateContentDependentActions();
-
- // remember the last edit position
- if (isDirty() && fUpdateLastEditPosition) {
- fUpdateLastEditPosition= false;
- ISelection sel= getSelectionProvider().getSelection();
- IEditorInput input= getEditorInput();
- IDocument document= getDocumentProvider().getDocument(input);
-
- if (fLocalLastEditPosition != null) {
- if (document != null) {
- document.removePosition(fLocalLastEditPosition);
- }
- fLocalLastEditPosition= null;
+ private Runnable fRunnable = () -> {
+ fIsRunnablePosted = false;
+
+ if (fSourceViewer != null) {
+ updateContentDependentActions();
+
+ // remember the last edit position
+ if (isDirty() && fUpdateLastEditPosition) {
+ fUpdateLastEditPosition = false;
+ ISelection sel = getSelectionProvider().getSelection();
+ IEditorInput input = getEditorInput();
+ IDocument document = getDocumentProvider().getDocument(input);
+
+ if (fLocalLastEditPosition != null) {
+ if (document != null) {
+ document.removePosition(fLocalLastEditPosition);
}
+ fLocalLastEditPosition = null;
+ }
- if (sel instanceof ITextSelection && !sel.isEmpty()) {
- ITextSelection s= (ITextSelection) sel;
- fLocalLastEditPosition= new Position(s.getOffset(), s.getLength());
- if (document != null) {
- try {
- document.addPosition(fLocalLastEditPosition);
- } catch (BadLocationException ex) {
- fLocalLastEditPosition = null;
- }
+ if (sel instanceof ITextSelection && !sel.isEmpty()) {
+ ITextSelection s = (ITextSelection) sel;
+ fLocalLastEditPosition = new Position(s.getOffset(), s.getLength());
+ if (document != null) {
+ try {
+ document.addPosition(fLocalLastEditPosition);
+ } catch (BadLocationException ex) {
+ fLocalLastEditPosition = null;
}
}
-
- IEditorSite editorSite= getEditorSite();
- if (editorSite instanceof MultiPageEditorSite)
- editorSite= ((MultiPageEditorSite)editorSite).getMultiPageEditor().getEditorSite();
- TextEditorPlugin.getDefault().setLastEditPosition(new EditPosition(input, editorSite.getId(), fLocalLastEditPosition));
}
+
+ IEditorSite editorSite = getEditorSite();
+ if (editorSite instanceof MultiPageEditorSite)
+ editorSite = ((MultiPageEditorSite) editorSite).getMultiPageEditor().getEditorSite();
+ TextEditorPlugin.getDefault()
+ .setLastEditPosition(new EditPosition(input, editorSite.getId(), fLocalLastEditPosition));
}
}
};
/** Display used for posting the updater code. */
private Display fDisplay;
- /**
- * The editor's last edit position
- * @since 3.0
- */
- private Position fLocalLastEditPosition;
+
/**
* Has the runnable been posted?
* @since 3.0
*/
private boolean fIsRunnablePosted= false;
- /**
- * Should the last edit position be updated?
- * @since 3.0
- */
- private boolean fUpdateLastEditPosition= false;
@Override
public void textChanged(TextEvent event) {
@@ -983,12 +966,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11731
* Will be removed when SWT has solved the problem.
*/
- window.getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- handleActivation();
- }
- });
+ window.getShell().getDisplay().asyncExec(() -> handleActivation());
}
}
@@ -2956,17 +2934,14 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 3.4
*/
protected IMenuListener createContextMenuListener() {
- return new IMenuListener() {
- @Override
- public void menuAboutToShow(IMenuManager menu) {
- String id= menu.getId();
- if (getRulerContextMenuId().equals(id)) {
- setFocus();
- rulerContextMenuAboutToShow(menu);
- } else if (getEditorContextMenuId().equals(id)) {
- setFocus();
- editorContextMenuAboutToShow(menu);
- }
+ return menu -> {
+ String id = menu.getId();
+ if (getRulerContextMenuId().equals(id)) {
+ setFocus();
+ rulerContextMenuAboutToShow(menu);
+ } else if (getEditorContextMenuId().equals(id)) {
+ setFocus();
+ editorContextMenuAboutToShow(menu);
}
};
}
@@ -3024,12 +2999,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (1 != e.button)
return;
- Runnable runnable= new Runnable() {
- @Override
- public void run() {
- if (!fDoubleClicked)
- triggerAction(ITextEditorActionConstants.RULER_CLICK, e);
- }
+ Runnable runnable = () -> {
+ if (!fDoubleClicked)
+ triggerAction(ITextEditorActionConstants.RULER_CLICK, e);
};
if (delay <= 0)
runnable.run();
@@ -3070,14 +3042,11 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (fSelectionChangedListener == null) {
fSelectionChangedListener= new ISelectionChangedListener() {
- private Runnable fRunnable= new Runnable() {
- @Override
- public void run() {
- // check whether editor has not been disposed yet
- if (fSourceViewer != null && fSourceViewer.getDocument() != null) {
- handleCursorPositionChanged();
- updateSelectionDependentActions();
- }
+ private Runnable fRunnable = () -> {
+ // check whether editor has not been disposed yet
+ if (fSourceViewer != null && fSourceViewer.getDocument() != null) {
+ handleCursorPositionChanged();
+ updateSelectionDependentActions();
}
};
@@ -3152,25 +3121,22 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected final void internalInit(IWorkbenchWindow window, final IEditorSite site, final IEditorInput input) throws PartInitException {
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
+ IRunnableWithProgress runnable = monitor -> {
+ try {
- if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) getDocumentProvider();
- extension.setProgressMonitor(monitor);
- }
+ if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
+ IDocumentProviderExtension2 extension1 = (IDocumentProviderExtension2) getDocumentProvider();
+ extension1.setProgressMonitor(monitor);
+ }
- doSetInput(input);
+ doSetInput(input);
- } catch (CoreException x) {
- throw new InvocationTargetException(x);
- } finally {
- if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) getDocumentProvider();
- extension.setProgressMonitor(null);
- }
+ } catch (CoreException x) {
+ throw new InvocationTargetException(x);
+ } finally {
+ if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
+ IDocumentProviderExtension2 extension2 = (IDocumentProviderExtension2) getDocumentProvider();
+ extension2.setProgressMonitor(null);
}
}
};
@@ -3396,12 +3362,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
styledText.addKeyListener(getCursorListener());
// Disable orientation switching until we fully support it.
- styledText.addListener(SWT.OrientationChange, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.doit= false;
- }
- });
+ styledText.addListener(SWT.OrientationChange, event -> event.doit = false);
if (getHelpContextId() != null)
PlatformUI.getWorkbench().getHelpSystem().setHelp(styledText, getHelpContextId());
@@ -4293,12 +4254,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
enableSanityChecking(false);
Display display= getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (fSourceViewer != null)
- getSite().getPage().closeEditor(AbstractTextEditor.this, save);
- }
+ display.asyncExec(() -> {
+ if (fSourceViewer != null)
+ getSite().getPage().closeEditor(AbstractTextEditor.this, save);
});
}
@@ -4984,12 +4942,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
try {
final IEditorInput input= getEditorInput();
- BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
- @Override
- public void run() {
- validateState(input);
- }
- });
+ BusyIndicator.showWhile(getSite().getShell().getDisplay(), () -> validateState(input));
sanityCheckState(input);
return !isEditorInputReadOnly() && !fTextInputListener.inputChanged;
@@ -5937,22 +5890,14 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_WRAP);
setAction(ITextEditorActionConstants.WORD_WRAP, action);
- blockAction.addPropertyChangeListener(new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (IAction.CHECKED == event.getProperty() &&
- Boolean.TRUE.equals(event.getNewValue())) {
- wrapAction.setChecked(false);
- }
+ blockAction.addPropertyChangeListener(event -> {
+ if (IAction.CHECKED == event.getProperty() && Boolean.TRUE.equals(event.getNewValue())) {
+ wrapAction.setChecked(false);
}
});
- wrapAction.addPropertyChangeListener(new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (IAction.CHECKED == event.getProperty() &&
- Boolean.TRUE.equals(event.getNewValue())) {
- blockAction.setChecked(false);
- }
+ wrapAction.addPropertyChangeListener(event -> {
+ if (IAction.CHECKED == event.getProperty() && Boolean.TRUE.equals(event.getNewValue())) {
+ blockAction.setChecked(false);
}
});
}
@@ -5963,12 +5908,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
setAction(ITextEditorActionConstants.OPEN_HYPERLINK, action);
PropertyDialogAction openProperties= new PropertyDialogAction(
- new IShellProvider() {
- @Override
- public Shell getShell() {
- return getSite().getShell();
- }
- },
+ () -> getSite().getShell(),
new ISelectionProvider() {
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java
index 92ed2b77d..88014aa77 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.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
@@ -78,12 +78,8 @@ public final class ContentAssistAction extends TextEditorAction {
if (shell != null && !shell.isDisposed())
display= shell.getDisplay();
- BusyIndicator.showWhile(display, new Runnable() {
- @Override
- public void run() {
- fOperationTarget.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- }
- });
+ BusyIndicator.showWhile(display,
+ () -> fOperationTarget.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS));
}
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java
index 5ebfdb452..1dd68022e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.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
@@ -81,12 +81,7 @@ public class ShiftAction extends TextEditorAction implements IReadOnlyDependent
if (shell != null && !shell.isDisposed())
display= shell.getDisplay();
- BusyIndicator.showWhile(display, new Runnable() {
- @Override
- public void run() {
- fOperationTarget.doOperation(fOperationCode);
- }
- });
+ BusyIndicator.showWhile(display, () -> fOperationTarget.doOperation(fOperationCode));
}
@Override
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java
index 5addf9df0..ae5705a9e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.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
@@ -124,12 +124,7 @@ public final class TextOperationAction extends TextEditorAction {
if (shell != null && !shell.isDisposed())
display= shell.getDisplay();
- BusyIndicator.showWhile(display, new Runnable() {
- @Override
- public void run() {
- fOperationTarget.doOperation(fOperationCode);
- }
- });
+ BusyIndicator.showWhile(display, () -> fOperationTarget.doOperation(fOperationCode));
}
/**
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
index 336652ab4..944711d5c 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
@@ -53,7 +53,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
@@ -63,11 +62,8 @@ import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.layout.TreeColumnLayout;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -501,17 +497,7 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
int sashSize= fPreferenceStore.getInt(SASH_SIZE_PREF_ID);
fControl.setWeights(new int[] { sashSize, 100 - sashSize });
- fTemplateChangeListener= new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- refresh();
- }
- });
- }
- };
+ fTemplateChangeListener = event -> getShell().getDisplay().asyncExec(() -> refresh());
getTemplatePreferenceStore().addPropertyChangeListener(fTemplateChangeListener);
updateContextTypes(getEditorContextTypeIds());
}
@@ -906,12 +892,7 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
String pattern= ((String)clipboard.getContents(TextTransfer.getInstance()));
if (pattern != null) {
final Template template= new Template(createTemplateName(), TemplatesMessages.TemplatesPage_paste_description, getContextTypeId(), pattern.replaceAll("\\$", "\\$\\$"), true); //$NON-NLS-1$//$NON-NLS-2$
- getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- addTemplate(template);
- }
- });
+ getShell().getDisplay().asyncExec(() -> addTemplate(template));
return;
}
TemplatePersistenceData[] templates= (TemplatePersistenceData[])clipboard.getContents(TemplatesTransfer.getInstance());
@@ -1071,22 +1052,16 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
fTreeViewer.setComparator(new TemplateViewerComparator());
fTreeViewer.setInput(getTemplatePreferenceStore());
- fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent e) {
- updateSelectedItems();
- TemplatePersistenceData[] selectedTemplates= getSelectedTemplates();
- if (selectedTemplates.length > 0)
- insertTemplate(selectedTemplates[0].getTemplate());
- }
+ fTreeViewer.addDoubleClickListener(e -> {
+ updateSelectedItems();
+ TemplatePersistenceData[] selectedTemplates = getSelectedTemplates();
+ if (selectedTemplates.length > 0)
+ insertTemplate(selectedTemplates[0].getTemplate());
});
- fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent e) {
- updateSelectedItems();
- updateButtons();
- }
+ fTreeViewer.addSelectionChangedListener(e -> {
+ updateSelectedItems();
+ updateButtons();
});
fTreeViewer.expandAll();
}
@@ -1126,12 +1101,7 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
private void hookContextMenu() {
MenuManager menuMgr= new MenuManager(POPUP_MENU_ID);
menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- @Override
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- }
- });
+ menuMgr.addMenuListener(manager -> fillContextMenu(manager));
fContextMenu= menuMgr.createContextMenu(fTreeViewer.getControl());
fTreeViewer.getControl().setMenu(fContextMenu);
getSite().registerContextMenu(POPUP_MENU_ID, menuMgr, fTreeViewer);
@@ -1482,25 +1452,17 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
final Template template= new Template(createTemplateName(),
TemplatesMessages.TemplatesPage_paste_description, contextId, text,
true);
- getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- addTemplate(template);
- }
- });
+ getShell().getDisplay().asyncExec(() -> addTemplate(template));
return;
}
if (templateTransfer.isSupportedType(event.currentDataType)) {
final TemplatePersistenceData[] templates= (TemplatePersistenceData[]) event.data;
final int dropType= event.detail;
- getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (dropType == DND.DROP_COPY)
- copyTemplates(templates, contextId);
- else
- moveTemplates(templates, contextId);
- }
+ getShell().getDisplay().asyncExec(() -> {
+ if (dropType == DND.DROP_COPY)
+ copyTemplates(templates, contextId);
+ else
+ moveTemplates(templates, contextId);
});
}
}

Back to the top