Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-07-18 12:08:46 -0400
committerAlexander Kurtakov2018-07-18 12:08:46 -0400
commit987f29d0e8c9ef768ad4c357c2ff839ce547944e (patch)
treea8983265b9b8ba38f7e627dfd8c3e32476f3e794 /org.eclipse.jface.text/src
parent13f5f0b15fcbd21d97a3746b88323cd354645303 (diff)
downloadeclipse.platform.text-987f29d0e8c9ef768ad4c357c2ff839ce547944e.tar.gz
eclipse.platform.text-987f29d0e8c9ef768ad4c357c2ff839ce547944e.tar.xz
eclipse.platform.text-987f29d0e8c9ef768ad4c357c2ff839ce547944e.zip
DisposeListener to lambda.
And other lambda conversions as picked by the quick fix. Change-Id: I83d5318444387bf74ebea7e959d688588df6a53a Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.jface.text/src')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java46
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java120
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java17
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java24
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java36
6 files changed, 88 insertions, 166 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
index 1ea641fcd..3c44663dc 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.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
@@ -17,8 +17,6 @@ import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.VerifyKeyListener;
-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.VerifyEvent;
@@ -327,36 +325,30 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
} else {
if (fControlDecoration == null) {
fControlDecoration= new ControlDecoration(getControl(), (SWT.TOP | SWT.LEFT));
- getControl().addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fCueLabelProvider != null) {
- fCueLabelProvider.dispose();
- fCueLabelProvider= null;
- }
- if (fControlDecoration != null) {
- fControlDecoration.dispose();
- fControlDecoration= null;
- }
- if (fCachedDefaultCueImage != null) {
- fCachedDefaultCueImage.dispose();
- fCachedDefaultCueImage= null;
- }
+ getControl().addDisposeListener(e -> {
+ if (fCueLabelProvider != null) {
+ fCueLabelProvider.dispose();
+ fCueLabelProvider= null;
+ }
+ if (fControlDecoration != null) {
+ fControlDecoration.dispose();
+ fControlDecoration= null;
+ }
+ if (fCachedDefaultCueImage != null) {
+ fCachedDefaultCueImage.dispose();
+ fCachedDefaultCueImage= null;
}
});
fControlDecoration.setShowHover(true);
fControlDecoration.setShowOnlyOnFocus(true);
}
- ILabelProviderListener listener= new ILabelProviderListener() {
- @Override
- public void labelProviderChanged(LabelProviderChangedEvent event) {
- fControlDecoration.setDescriptionText(labelProvider.getText(getControl()));
- Image image= labelProvider.getImage(getControl());
- if (image == null)
- image= getDefaultCueImage();
- fControlDecoration.setImage(image);
- }
+ ILabelProviderListener listener= event -> {
+ fControlDecoration.setDescriptionText(labelProvider.getText(getControl()));
+ Image image= labelProvider.getImage(getControl());
+ if (image == null)
+ image= getDefaultCueImage();
+ fControlDecoration.setImage(image);
};
labelProvider.addListener(listener);
//initialize control decoration:
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
index 2355def61..fa49bf162 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
@@ -19,8 +19,6 @@ import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
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.SelectionEvent;
@@ -342,13 +340,8 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
});
fPopupCloser.install(fContentAssistant, fProposalTable);
-
- fProposalShell.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- unregister(); // but don't dispose the shell, since we're being called from its disposal event!
- }
- });
+ // but don't dispose the shell, since we're being called from its disposal event!
+ fProposalShell.addDisposeListener(e -> unregister());
fProposalTable.setHeaderVisible(false);
fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java
index 3df975523..da8180c7b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 IBM Corporation and others.
+ * Copyright (c) 2008, 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
@@ -11,15 +11,12 @@
package org.eclipse.jface.text;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
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.FontData;
@@ -33,7 +30,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.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
@@ -200,12 +196,7 @@ public abstract class AbstractInformationControl implements IInformationControl,
createStatusComposite(statusFieldText, toolBarManager, foreground, background);
- addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleDispose();
- }
- });
+ addDisposeListener(e -> handleDispose());
}
@@ -290,36 +281,33 @@ public abstract class AbstractInformationControl implements IInformationControl,
data.widthHint= size;
data.heightHint= size;
resizer.setLayoutData(data);
- resizer.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Point s= resizer.getSize();
- int x= s.x - 2;
- int y= s.y - 2;
- int min= Math.min(x, y);
- if (isWin) {
- // draw dots
- e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
- int end= min - 1;
- for (int i= 0; i <= 2; i++)
- for (int j= 0; j <= 2 - i; j++)
- e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2);
- end--;
- e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
- for (int i= 0; i <= 2; i++)
- for (int j= 0; j <= 2 - i; j++)
- e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2);
-
- } else {
- // draw diagonal lines
- e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
- for (int i= 1; i < min; i+= 4) {
- e.gc.drawLine(i, y, x, i);
- }
- e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
- for (int i= 2; i < min; i+= 4) {
- e.gc.drawLine(i, y, x, i);
- }
+ resizer.addPaintListener(e -> {
+ Point s= resizer.getSize();
+ int x= s.x - 2;
+ int y= s.y - 2;
+ int min= Math.min(x, y);
+ if (isWin) {
+ // draw dots
+ e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ int end= min - 1;
+ for (int i1= 0; i1 <= 2; i1++)
+ for (int j1= 0; j1 <= 2 - i1; j1++)
+ e.gc.fillRectangle(end - 4 * i1, end - 4 * j1, 2, 2);
+ end--;
+ e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ for (int i2= 0; i2 <= 2; i2++)
+ for (int j2= 0; j2 <= 2 - i2; j2++)
+ e.gc.fillRectangle(end - 4 * i2, end - 4 * j2, 2, 2);
+
+ } else {
+ // draw diagonal lines
+ e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ for (int i3= 1; i3 < min; i3+= 4) {
+ e.gc.drawLine(i3, y, x, i3);
+ }
+ e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ for (int i4= 2; i4 < min; i4+= 4) {
+ e.gc.drawLine(i4, y, x, i4);
}
}
});
@@ -339,18 +327,15 @@ public abstract class AbstractInformationControl implements IInformationControl,
Point mouseLoc= resizer.toDisplay(e.x, e.y);
final int mouseX= mouseLoc.x;
final int mouseY= mouseLoc.y;
- fResizeListener= new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e2) {
- Point mouseLoc2= resizer.toDisplay(e2.x, e2.y);
- int dx= mouseLoc2.x - mouseX;
- int dy= mouseLoc2.y - mouseY;
- if (isRTL) {
- setLocation(new Point(shellX + dx, shellY));
- setSize(shellWidth - dx, shellHeight + dy);
- } else {
- setSize(shellWidth + dx, shellHeight + dy);
- }
+ fResizeListener= e2 -> {
+ Point mouseLoc2= resizer.toDisplay(e2.x, e2.y);
+ int dx= mouseLoc2.x - mouseX;
+ int dy= mouseLoc2.y - mouseY;
+ if (isRTL) {
+ setLocation(new Point(shellX + dx, shellY));
+ setSize(shellWidth - dx, shellHeight + dy);
+ } else {
+ setSize(shellWidth + dx, shellHeight + dy);
}
};
resizer.addMouseMoveListener(fResizeListener);
@@ -396,14 +381,11 @@ public abstract class AbstractInformationControl implements IInformationControl,
Point mouseLoc= control.toDisplay(e.x, e.y);
final int mouseX= mouseLoc.x;
final int mouseY= mouseLoc.y;
- fMoveListener= new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e2) {
- Point mouseLoc2= control.toDisplay(e2.x, e2.y);
- int dx= mouseLoc2.x - mouseX;
- int dy= mouseLoc2.y - mouseY;
- fShell.setLocation(shellX + dx, shellY + dy);
- }
+ fMoveListener= e2 -> {
+ Point mouseLoc2= control.toDisplay(e2.x, e2.y);
+ int dx= mouseLoc2.x - mouseX;
+ int dy= mouseLoc2.y - mouseY;
+ fShell.setLocation(shellX + dx, shellY + dy);
};
control.addMouseMoveListener(fMoveListener);
}
@@ -687,16 +669,12 @@ public abstract class AbstractInformationControl implements IInformationControl,
@Override
public void addFocusListener(final FocusListener listener) {
if (fFocusListeners.isEmpty()) {
- fShellListener= new Listener() {
-
- @Override
- public void handleEvent(Event event) {
- for (FocusListener focusListener : fFocusListeners) {
- if (event.type == SWT.Activate) {
- focusListener.focusGained(new FocusEvent(event));
- } else {
- focusListener.focusLost(new FocusEvent(event));
- }
+ fShellListener= event -> {
+ for (FocusListener focusListener : fFocusListeners) {
+ if (event.type == SWT.Activate) {
+ focusListener.focusGained(new FocusEvent(event));
+ } else {
+ focusListener.focusLost(new FocusEvent(event));
}
}
};
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
index 9ac42ac02..1cd8b9889 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.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
@@ -14,7 +14,6 @@ package org.eclipse.jface.text;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
@@ -676,12 +675,7 @@ abstract public class AbstractInformationControlManager {
*/
private DisposeListener getSubjectControlDisposeListener() {
if (fSubjectControlDisposeListener == null) {
- fSubjectControlDisposeListener= new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleSubjectControlDisposed();
- }
- };
+ fSubjectControlDisposeListener= e -> handleSubjectControlDisposed();
}
return fSubjectControlDisposeListener;
}
@@ -829,12 +823,7 @@ abstract public class AbstractInformationControlManager {
if (fInformationControl == null) {
fInformationControl= creator.createInformationControl(fSubjectControl.getShell());
- fInformationControl.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- handleInformationControlDisposed();
- }
- });
+ fInformationControl.addDisposeListener(e -> handleInformationControlDisposed());
if (fInformationControlCloser != null)
fInformationControlCloser.setInformationControl(fInformationControl);
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 c032dfffd..ca4dfa39e 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
@@ -23,14 +23,10 @@ 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.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -629,21 +625,15 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
fCanvas.setForeground(fForeground);
- 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;
});
fMouseHandler= new MouseHandler();
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 369d1bcd5..f9b9e769e 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
@@ -22,13 +22,9 @@ 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.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
@@ -581,20 +577,14 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
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 event) {
- handleDispose();
- fTextViewer= null;
- }
+ fCanvas.addDisposeListener(event -> {
+ handleDispose();
+ fTextViewer= null;
});
fCanvas.addMouseListener(new MouseAdapter() {
@@ -604,19 +594,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
}
});
- fCanvas.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent event) {
- handleMouseMove(event);
- }
- });
+ fCanvas.addMouseMoveListener(event -> handleMouseMove(event));
- fCanvas.addMouseWheelListener(new MouseWheelListener() {
- @Override
- public void mouseScrolled(MouseEvent e) {
- handleMouseScrolled(e);
- }
- });
+ fCanvas.addMouseWheelListener(e -> handleMouseScrolled(e));
if (fTextViewer != null) {
fTextViewer.addTextListener(fInternalListener);

Back to the top