Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/rpm
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-05-19 07:07:13 +0000
committerAlexander Kurtakov2017-05-19 08:42:08 +0000
commitbcaae52874672d24ee39738e02b1236711673f8d (patch)
tree2e5d331300072bc87244fbe55ea7221afd6e7be6 /rpm
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
Diffstat (limited to 'rpm')
-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
3 files changed, 31 insertions, 39 deletions
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;
+ }
}

Back to the top