Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-05-19 07:07:13 +0000
committerAlexander Kurtakov2017-05-19 08:42:08 +0000
commitbcaae52874672d24ee39738e02b1236711673f8d (patch)
tree2e5d331300072bc87244fbe55ea7221afd6e7be6
parent8723f076b325d0dc7b0d9b71c02f04e2a5e551ff (diff)
downloadorg.eclipse.linuxtools-bcaae52874672d24ee39738e02b1236711673f8d.tar.gz
org.eclipse.linuxtools-bcaae52874672d24ee39738e02b1236711673f8d.tar.xz
org.eclipse.linuxtools-bcaae52874672d24ee39738e02b1236711673f8d.zip
Make use IStructuredSelection directly.
Request the structured selection directly instead of getting the selection and checking whether it's instance of IStructuredSelection or just blindly cast. Change-Id: Id1b3b7a2e0398b83fa5a736fcbc484f81c14183a Signed-off-by: Alexander Kurtakov <akurtako@redhat.com> Reviewed-on: https://git.eclipse.org/r/97513 Tested-by: Hudson CI
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java5
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java6
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerTreeGroup.java5
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java59
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java21
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java10
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java7
-rwxr-xr-xprofiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java22
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.rpmlint/src/org/eclipse/linuxtools/internal/rpm/rpmlint/actions/ToggleRpmlintNatureAction.java23
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java5
-rw-r--r--rpm/org.eclipse.linuxtools.rpmstubby/src/org/eclipse/linuxtools/internal/rpmstubby/popup/actions/StubifyHandler.java42
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/TreeExpandCollapseAction.java5
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/DefinitionHandler.java19
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/BaseVMCommandHandler.java7
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/CommandUtils.java48
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/PackageVMCommandHandler.java7
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java10
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java10
18 files changed, 138 insertions, 173 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java
index 444edfe9ea..24e372b46b 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -211,8 +211,7 @@ public class ChangeLogContainerSelectionGroup extends Composite {
treeViewer.setComparator(new ViewerComparator());
treeViewer.setUseHashlookup(true);
treeViewer.addSelectionChangedListener(event -> {
- IStructuredSelection selection = (IStructuredSelection) event
- .getSelection();
+ IStructuredSelection selection = event.getStructuredSelection();
containerSelectionChanged((IContainer) selection
.getFirstElement()); // allow null
});
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java
index e418780057..c9ef14724a 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Phil Muldoon <pkmuldoon@picobot.org>.
+ * Copyright (c) 2006, 2017 Phil Muldoon <pkmuldoon@picobot.org>.
* 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
@@ -27,10 +27,6 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * @author pmuldoon (Phil Muldoon)
- */
public class InsertChangeLogKeyHandler extends ChangeLogAction implements
IHandler, IWorkbenchWindowActionDelegate {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerTreeGroup.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerTreeGroup.java
index dde4dd5e09..b8576eac11 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerTreeGroup.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/ContainerTreeGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -208,8 +208,7 @@ public class ContainerTreeGroup extends EventManager implements
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event
- .getSelection();
+ IStructuredSelection selection = event.getStructuredSelection();
Object selectedElement = selection.getFirstElement();
currentTreeSelection = selectedElement;
notifySelectionChangeListeners(event);
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java
index a59a8c877c..d1e0f3a8cd 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2016 Red Hat Inc. and others.
+ * Copyright (c) 2014, 2017 Red Hat Inc. 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
@@ -22,7 +22,6 @@ import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
@@ -128,20 +127,20 @@ public class CommandUtils {
private static <T> List<T> getSelectedElements(
final IWorkbenchPart activePart, final Class<T> targetClass) {
if (activePart instanceof DockerContainersView) {
- final ISelection selection = ((DockerContainersView) activePart)
- .getSelection();
+ final IStructuredSelection selection = ((DockerContainersView) activePart)
+ .getStructuredSelection();
return castSelectionTo(selection, targetClass);
} else if (activePart instanceof DockerImagesView) {
- final ISelection selection = ((DockerImagesView) activePart)
- .getSelection();
+ final IStructuredSelection selection = ((DockerImagesView) activePart)
+ .getStructuredSelection();
return castSelectionTo(selection, targetClass);
} else if (activePart instanceof DockerExplorerView) {
- final ISelection selection = ((DockerExplorerView) activePart)
- .getCommonViewer().getSelection();
+ final IStructuredSelection selection = ((DockerExplorerView) activePart)
+ .getCommonViewer().getStructuredSelection();
return castSelectionTo(selection, targetClass);
} else if (activePart instanceof DockerImageHierarchyView) {
- final ISelection selection = ((DockerImageHierarchyView) activePart)
- .getCommonViewer().getSelection();
+ final IStructuredSelection selection = ((DockerImageHierarchyView) activePart)
+ .getCommonViewer().getStructuredSelection();
return adaptSelectionTo(selection, targetClass);
}
return Collections.emptyList();
@@ -220,17 +219,13 @@ public class CommandUtils {
* {@code targetClass}.
*/
@SuppressWarnings("unchecked")
- private static <T> List<T> castSelectionTo(final ISelection selection,
- final Class<T> targetClass) {
- if (selection instanceof IStructuredSelection) {
- final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- return (List<T>) structuredSelection.toList().stream()
- .filter(selectedElement -> targetClass
- .isAssignableFrom(selectedElement.getClass()))
- .map(selectedElement -> (T) selectedElement)
- .collect(Collectors.toList());
- }
- return Collections.emptyList();
+ private static <T> List<T> castSelectionTo(
+ final IStructuredSelection selection, final Class<T> targetClass) {
+ return (List<T>) selection.toList().stream()
+ .filter(selectedElement -> targetClass
+ .isAssignableFrom(selectedElement.getClass()))
+ .map(selectedElement -> (T) selectedElement)
+ .collect(Collectors.toList());
}
/**
@@ -246,19 +241,15 @@ public class CommandUtils {
* {@code targetClass}.
*/
@SuppressWarnings("unchecked")
- private static <T> List<T> adaptSelectionTo(final ISelection selection,
- final Class<T> targetClass) {
- if (selection instanceof IStructuredSelection) {
- final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- return (List<T>) structuredSelection.toList().stream()
- .filter(selectedElement -> selectedElement instanceof IAdaptable
- && ((IAdaptable) selectedElement)
- .getAdapter(targetClass) != null)
- .map(selectedElement -> ((IAdaptable) selectedElement)
- .getAdapter(targetClass))
- .collect(Collectors.toList());
- }
- return Collections.emptyList();
+ private static <T> List<T> adaptSelectionTo(
+ final IStructuredSelection selection, final Class<T> targetClass) {
+ return (List<T>) selection.toList().stream()
+ .filter(selectedElement -> selectedElement instanceof IAdaptable
+ && ((IAdaptable) selectedElement)
+ .getAdapter(targetClass) != null)
+ .map(selectedElement -> ((IAdaptable) selectedElement)
+ .getAdapter(targetClass))
+ .collect(Collectors.toList());
}
/**
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java
index 32279214ba..9c2ce79dcd 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersView.java
@@ -397,10 +397,8 @@ public class DockerContainersView extends ViewPart implements
IAction ret = new Action(label, img) {
@Override
public void run() {
- ISelection sel = getSelection();
- if (sel instanceof StructuredSelection) {
- CommandUtils.execute(id, (StructuredSelection) sel);
- }
+ IStructuredSelection sel = getStructuredSelection();
+ CommandUtils.execute(id, sel);
}
};
ret.setEnabled(false);
@@ -472,11 +470,8 @@ public class DockerContainersView extends ViewPart implements
private ISelectionChangedListener onContainerSelection() {
return event -> {
- ISelection s = event.getSelection();
- if (s instanceof StructuredSelection) {
- StructuredSelection ss = (StructuredSelection) s;
- updateToolBarItemEnablement(ss);
- }
+ IStructuredSelection s = event.getStructuredSelection();
+ updateToolBarItemEnablement(s);
};
}
@@ -595,11 +590,11 @@ public class DockerContainersView extends ViewPart implements
/**
* @return the current selection
*/
- public ISelection getSelection() {
- if(this.viewer != null) {
- return this.viewer.getSelection();
+ public IStructuredSelection getStructuredSelection() {
+ if (this.viewer != null) {
+ return this.viewer.getStructuredSelection();
}
- return null;
+ return StructuredSelection.EMPTY;
}
/**
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java
index 886229bd8a..1ce92f3fea 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesView.java
@@ -32,7 +32,9 @@ import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
@@ -467,11 +469,11 @@ public class DockerImagesView extends ViewPart implements IDockerImageListener,
/**
* @return the current selection
*/
- public ISelection getSelection() {
- if(this.viewer != null) {
- return this.viewer.getSelection();
+ public IStructuredSelection getStructuredSelection() {
+ if (this.viewer != null) {
+ return this.viewer.getStructuredSelection();
}
- return null;
+ return StructuredSelection.EMPTY;
}
/**
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java
index f712fc8838..45e67b4297 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * (C) Copyright 2010 IBM Corp. 2010
+ * (C) Copyright 2010, 2017 IBM Corp. 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,7 +17,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.linuxtools.internal.perf.PerfPlugin;
@@ -39,8 +38,8 @@ public class PerfDoubleClickAction extends Action {
}
@Override
public void run() {
- ISelection selection = viewer.getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
+ IStructuredSelection selection = viewer.getStructuredSelection();
+ Object obj = selection.getFirstElement();
try {
if (obj instanceof PMLineRef) {
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java
index 22be3bca9a..33545484b5 100755
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012, 2017 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 org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
@@ -149,17 +148,14 @@ public class FileSystemSelectionArea {
* @return FileSystemElement or <code>null</code> if nothing
* is selected.
*/
- public FileSystemElement getSelectedFileSystem() {
- ISelection selection = fileSystems.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structured = (IStructuredSelection) selection;
- if (structured.size() == 1) {
- return ((FileSystemElement) structured.getFirstElement());
- }
- }
- return null;
- }
+ public FileSystemElement getSelectedFileSystem() {
+ IStructuredSelection selection = fileSystems.getStructuredSelection();
+
+ if (selection.size() == 1) {
+ return ((FileSystemElement) selection.getFirstElement());
+ }
+ return null;
+ }
/**
* Set the filesystem selection combo box to the specified scheme.
diff --git a/rpm/org.eclipse.linuxtools.rpm.rpmlint/src/org/eclipse/linuxtools/internal/rpm/rpmlint/actions/ToggleRpmlintNatureAction.java b/rpm/org.eclipse.linuxtools.rpm.rpmlint/src/org/eclipse/linuxtools/internal/rpm/rpmlint/actions/ToggleRpmlintNatureAction.java
index f54a5086a9..4ff9cd3327 100644
--- a/rpm/org.eclipse.linuxtools.rpm.rpmlint/src/org/eclipse/linuxtools/internal/rpm/rpmlint/actions/ToggleRpmlintNatureAction.java
+++ b/rpm/org.eclipse.linuxtools.rpm.rpmlint/src/org/eclipse/linuxtools/internal/rpm/rpmlint/actions/ToggleRpmlintNatureAction.java
@@ -23,7 +23,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.linuxtools.internal.rpm.rpmlint.Activator;
import org.eclipse.linuxtools.internal.rpm.rpmlint.builder.RpmlintNature;
@@ -41,18 +40,16 @@ public class ToggleRpmlintNatureAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- for (Object element : ((IStructuredSelection) selection).toList()) {
- IProject project = null;
- if (element instanceof IProject) {
- project = (IProject) element;
- } else if (element instanceof IAdaptable) {
- project = ((IAdaptable) element).getAdapter(IProject.class);
- }
- if (project != null) {
- toggleNature(project);
- }
+ IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event);
+ for (Object element : selection.toList()) {
+ IProject project = null;
+ if (element instanceof IProject) {
+ project = (IProject) element;
+ } else if (element instanceof IAdaptable) {
+ project = ((IAdaptable) element).getAdapter(IProject.class);
+ }
+ if (project != null) {
+ toggleNature(project);
}
}
return null;
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java
index 62c615970c..a5112c62e6 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java
@@ -11,7 +11,6 @@
package org.eclipse.linuxtools.internal.rpm.ui.editor.outline;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
@@ -84,11 +83,11 @@ public class SpecfileContentOutlinePage extends ContentOutlinePage {
// find out which item in tree viewer we have selected, and set
// highlight range accordingly
- ISelection selection = event.getSelection();
+ IStructuredSelection selection = event.getStructuredSelection();
if (selection.isEmpty()) {
editor.resetHighlightRange();
} else {
- SpecfileElement element = (SpecfileElement) ((IStructuredSelection) selection).getFirstElement();
+ SpecfileElement element = (SpecfileElement) selection.getFirstElement();
int start = element.getLineStartPosition();
try {
diff --git a/rpm/org.eclipse.linuxtools.rpmstubby/src/org/eclipse/linuxtools/internal/rpmstubby/popup/actions/StubifyHandler.java b/rpm/org.eclipse.linuxtools.rpmstubby/src/org/eclipse/linuxtools/internal/rpmstubby/popup/actions/StubifyHandler.java
index 45ac25826b..bf74f0b988 100644
--- a/rpm/org.eclipse.linuxtools.rpmstubby/src/org/eclipse/linuxtools/internal/rpmstubby/popup/actions/StubifyHandler.java
+++ b/rpm/org.eclipse.linuxtools.rpmstubby/src/org/eclipse/linuxtools/internal/rpmstubby/popup/actions/StubifyHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Red Hat, Inc.
+ * Copyright (c) 2011, 2017 Red Hat, Inc.
* 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,7 +15,6 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.linuxtools.rpmstubby.Generator;
import org.eclipse.linuxtools.rpmstubby.InputType;
@@ -27,28 +26,25 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public abstract class StubifyHandler extends AbstractHandler {
- protected abstract InputType getInputType();
+ protected abstract InputType getInputType();
- @Override
- public Object execute(ExecutionEvent event) {
+ @Override
+ public Object execute(ExecutionEvent event) {
- IFile featureFile = null;
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- for (Object element : ((IStructuredSelection) selection).toList()) {
- if (element instanceof IFile) {
- featureFile = (IFile) element;
- } else if (element instanceof IAdaptable) {
- featureFile = ((IAdaptable) element)
- .getAdapter(IFile.class);
- }
- if (featureFile != null) {
- Generator generator = new Generator(getInputType());
- generator.generate(featureFile);
- }
- }
- }
- return null;
- }
+ IFile featureFile = null;
+ IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event);
+ for (Object element : selection.toList()) {
+ if (element instanceof IFile) {
+ featureFile = (IFile) element;
+ } else if (element instanceof IAdaptable) {
+ featureFile = ((IAdaptable) element).getAdapter(IFile.class);
+ }
+ if (featureFile != null) {
+ Generator generator = new Generator(getInputType());
+ generator.generate(featureFile);
+ }
+ }
+ return null;
+ }
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/TreeExpandCollapseAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/TreeExpandCollapseAction.java
index a6711d8475..5385504116 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/TreeExpandCollapseAction.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/TreeExpandCollapseAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation.
+ * Copyright (c) 2006, 2017 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
@@ -70,8 +70,7 @@ public class TreeExpandCollapseAction extends Action implements
*/
@Override
public void run() {
- ISelection incoming = viewer.getViewer().getSelection();
- IStructuredSelection selection = (IStructuredSelection)incoming;
+ IStructuredSelection selection = viewer.getViewer().getStructuredSelection();
Object o = selection.getFirstElement();
if(o == null) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/DefinitionHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/DefinitionHandler.java
index 45c450f62f..d0b782bb16 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/DefinitionHandler.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/DefinitionHandler.java
@@ -17,8 +17,7 @@ import java.util.regex.Pattern;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.CommentRemover;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.OpenFileHandler;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
@@ -51,15 +50,13 @@ public class DefinitionHandler extends AbstractHandler {
return null;
}
- private TreeDefinitionNode getSelection(ExecutionEvent event) {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof StructuredSelection) {
- Object[] selections = ((StructuredSelection) selection).toArray();
- return (selections.length == 1 && selections[0] instanceof TreeDefinitionNode)
- ? (TreeDefinitionNode) selections[0] : null;
- }
- return null;
- }
+ private TreeDefinitionNode getSelection(ExecutionEvent event) {
+ IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event);
+ Object[] selections = selection.toArray();
+ return (selections.length == 1 && selections[0] instanceof TreeDefinitionNode)
+ ? (TreeDefinitionNode) selections[0]
+ : null;
+ }
private int findDefinitionLine(ISearchableNode data, STPEditor editor) {
int locationIndex;
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/BaseVMCommandHandler.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/BaseVMCommandHandler.java
index d1d3845ef5..c8363e5371 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/BaseVMCommandHandler.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/BaseVMCommandHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2015 Red Hat.
+ * Copyright (c) 2014, 2017 Red Hat.
* 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
@@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.linuxtools.vagrant.core.IVagrantVM;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -29,7 +29,8 @@ public abstract class BaseVMCommandHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) {
- final ISelection selection = HandlerUtil.getCurrentSelection(event);
+ final IStructuredSelection selection = HandlerUtil
+ .getCurrentStructuredSelection(event);
final List<IVagrantVM> selectedContainers = CommandUtils
.getSelectedContainers(selection);
final Job job = new Job(getJobName(selectedContainers)) {
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/CommandUtils.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/CommandUtils.java
index 51e5910b87..cde69c1dc4 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/CommandUtils.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/CommandUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Red Hat.
+ * Copyright (c) 2015, 2017 Red Hat.
* 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
@@ -61,7 +61,8 @@ public class CommandUtils {
*/
public static List<IVagrantVM> getSelectedContainers(final IWorkbenchPart activePart) {
if (activePart instanceof VagrantVMView) {
- final ISelection selection = ((VagrantVMView) activePart).getSelection();
+ final IStructuredSelection selection = ((VagrantVMView) activePart)
+ .getStructuredSelection();
return getSelectedContainers(selection);
}
return Collections.emptyList();
@@ -75,20 +76,18 @@ public class CommandUtils {
* given {@link ISelection}, or {@link Collections#emptyList()} if
* none was selected.
*/
- public static List<IVagrantVM> getSelectedContainers(final ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- final List<IVagrantVM> selectedContainers = new ArrayList<>();
- final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();) {
- final Object selectedElement = iterator.next();
- if (selectedElement instanceof IVagrantVM) {
- selectedContainers.add((IVagrantVM) selectedElement);
- }
+ public static List<IVagrantVM> getSelectedContainers(
+ final IStructuredSelection selection) {
+ final List<IVagrantVM> selectedContainers = new ArrayList<>();
+ for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
+ final Object selectedElement = iterator.next();
+ if (selectedElement instanceof IVagrantVM) {
+ selectedContainers.add((IVagrantVM) selectedElement);
}
- return Collections.unmodifiableList(selectedContainers);
}
- return Collections.emptyList();
+ return Collections.unmodifiableList(selectedContainers);
}
+
/**
* @param activePart
* the active {@link IWorkbenchPart}
@@ -99,8 +98,8 @@ public class CommandUtils {
public static List<IVagrantBox> getSelectedImages(
final IWorkbenchPart activePart) {
if (activePart instanceof VagrantBoxView) {
- final ISelection selection = ((VagrantBoxView) activePart)
- .getSelection();
+ final IStructuredSelection selection = ((VagrantBoxView) activePart)
+ .getStructuredSelection();
return getSelectedImages(selection);
}
return Collections.emptyList();
@@ -115,20 +114,15 @@ public class CommandUtils {
* none was selected.
*/
public static List<IVagrantBox> getSelectedImages(
- final ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- final List<IVagrantBox> selectedImages = new ArrayList<>();
- final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- for (Iterator<?> iterator = structuredSelection.iterator(); iterator
- .hasNext();) {
- final Object selectedElement = iterator.next();
- if (selectedElement instanceof IVagrantBox) {
- selectedImages.add((IVagrantBox) selectedElement);
- }
+ final IStructuredSelection selection) {
+ final List<IVagrantBox> selectedImages = new ArrayList<>();
+ for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
+ final Object selectedElement = iterator.next();
+ if (selectedElement instanceof IVagrantBox) {
+ selectedImages.add((IVagrantBox) selectedElement);
}
- return Collections.unmodifiableList(selectedImages);
}
- return Collections.emptyList();
+ return Collections.unmodifiableList(selectedImages);
}
/**
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/PackageVMCommandHandler.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/PackageVMCommandHandler.java
index 3f4863e5b2..ebcbf65226 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/PackageVMCommandHandler.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/PackageVMCommandHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Red Hat.
+ * Copyright (c) 2015, 2017 Red Hat.
* 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
@@ -24,7 +24,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.linuxtools.internal.vagrant.ui.wizards.PackageVMWizard;
import org.eclipse.linuxtools.vagrant.core.IVagrantConnection;
import org.eclipse.linuxtools.vagrant.core.IVagrantVM;
@@ -38,7 +38,8 @@ public class PackageVMCommandHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) {
- final ISelection selection = HandlerUtil.getCurrentSelection(event);
+ final IStructuredSelection selection = HandlerUtil
+ .getCurrentStructuredSelection(event);
List<IVagrantVM> vms = CommandUtils.getSelectedContainers(selection);
IVagrantVM vm = vms.iterator().next();
PackageVMWizard wizard = new PackageVMWizard();
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java
index d8e498b02f..5a32f8c1ca 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantBoxView.java
@@ -20,6 +20,8 @@ import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
@@ -255,11 +257,11 @@ public class VagrantBoxView extends ViewPart implements IVagrantBoxListener {
/**
* @return the current selection
*/
- public ISelection getSelection() {
- if(this.viewer != null) {
- return this.viewer.getSelection();
+ public IStructuredSelection getStructuredSelection() {
+ if (this.viewer != null) {
+ return this.viewer.getStructuredSelection();
}
- return null;
+ return StructuredSelection.EMPTY;
}
/**
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java
index 44845ae59e..7a19d27b7f 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/views/VagrantVMView.java
@@ -20,6 +20,8 @@ import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
@@ -265,11 +267,11 @@ public class VagrantVMView extends ViewPart implements IVagrantVMListener {
/**
* @return the current selection
*/
- public ISelection getSelection() {
- if(this.viewer != null) {
- return this.viewer.getSelection();
+ public IStructuredSelection getStructuredSelection() {
+ if (this.viewer != null) {
+ return this.viewer.getStructuredSelection();
}
- return null;
+ return StructuredSelection.EMPTY;
}
/**

Back to the top