diff options
author | Alexander Kurtakov | 2018-04-18 12:33:32 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-04-18 12:33:32 +0000 |
commit | b771accd19e5806552c113be35e86e4f8bd9429b (patch) | |
tree | e8fe88ca4f7a7404457c36462380ae710ee64377 /examples | |
parent | 8130327f4416d4b951c1daaa60eceb0b793307b5 (diff) | |
download | eclipse.platform.team-b771accd19e5806552c113be35e86e4f8bd9429b.tar.gz eclipse.platform.team-b771accd19e5806552c113be35e86e4f8bd9429b.tar.xz eclipse.platform.team-b771accd19e5806552c113be35e86e4f8bd9429b.zip |
Bug 533755 - Direct use of IStructuredSelectionI20180420-2000I20180419-2000I20180418-2000
Instead of getSelection and cast.
Touched files have been converted to lambdas and useless @see comments
removed.
Change-Id: I249927f61cab0dfd2a1645b6aee3b0a1cc9760f1
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'examples')
2 files changed, 17 insertions, 33 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java index e2f55e7d4..5e1876125 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java @@ -16,12 +16,9 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; @@ -80,11 +77,7 @@ public class FileSystemHistoryPage extends HistoryPage { fileHistory.refresh(monitor); //Internal code used for convenience - you can use //your own here - Utils.asyncExec(new Runnable() { - public void run() { - tableViewer.setInput(fileHistory); - } - }, tableViewer); + Utils.asyncExec((Runnable) () -> tableViewer.setInput(fileHistory), tableViewer); } return status; @@ -143,18 +136,16 @@ public class FileSystemHistoryPage extends HistoryPage { openAction = new OpenFileSystemRevisionAction("Open"); //$NON-NLS-1$ tableViewer.getTable().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - openAction.selectionChanged((IStructuredSelection) tableViewer.getSelection()); + openAction.selectionChanged(tableViewer.getStructuredSelection()); } }); openAction.setPage(this); //Contribute actions to popup menu MenuManager menuMgr = new MenuManager(); Menu menu = menuMgr.createContextMenu(tableViewer.getTable()); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager menuMgr) { - menuMgr.add(new Separator(IWorkbenchActionConstants.GROUP_FILE)); - menuMgr.add(openAction); - } + menuMgr.addMenuListener(menuMgr1 -> { + menuMgr1.add(new Separator(IWorkbenchActionConstants.GROUP_FILE)); + menuMgr1.add(openAction); }); menuMgr.setRemoveAllWhenShown(true); tableViewer.getTable().setMenu(menu); diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java index 1ec6e3b52..863fcb8d0 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 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 @@ -19,7 +19,6 @@ import org.eclipse.core.resources.*; import org.eclipse.core.resources.mapping.*; import org.eclipse.core.runtime.*; import org.eclipse.jface.action.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.*; @@ -204,11 +203,7 @@ public class NonSyncModelMergePage extends Page { private void hookContextMenu(final TreeViewer viewer) { final MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(manager); - } - }); + menuMgr.addMenuListener(manager -> fillContextMenu(manager)); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); } @@ -230,18 +225,16 @@ public class NonSyncModelMergePage extends Page { Action markAsMerged = new Action("Mark as Merged") { public void run() { try { - final IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - IDiff[] diffs = getSelectedDiffs(selection, monitor); - if (!checkForModelOverlap(diffs, monitor)) { - return; - } - try { - context.markAsMerged(diffs, false, monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } + final IStructuredSelection selection = viewer.getStructuredSelection(); + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + IDiff[] diffs = getSelectedDiffs(selection, monitor); + if (!checkForModelOverlap(diffs, monitor)) { + return; + } + try { + context.markAsMerged(diffs, false, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { |