Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-07-18 11:39:57 -0400
committerAlexander Kurtakov2018-07-18 11:44:15 -0400
commite73a322d845e119eda68a22dbd59e2fce44acfe4 (patch)
tree6e08756d48c1d6eee415f378047a342d6da2ead7 /org.eclipse.ui.workbench.texteditor
parentef3fedaa1552b42f3f0d8b2e64334e6cce484353 (diff)
downloadeclipse.platform.text-e73a322d845e119eda68a22dbd59e2fce44acfe4.tar.gz
eclipse.platform.text-e73a322d845e119eda68a22dbd59e2fce44acfe4.tar.xz
eclipse.platform.text-e73a322d845e119eda68a22dbd59e2fce44acfe4.zip
Lambda conversions.
Converting Runnable to lambda and whatever the quick fix picked in the file too. Change-Id: I0cbd8ef4a7cab89dced199b44a5be3b32b6f8195 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-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
5 files changed, 153 insertions, 265 deletions
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