Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-04-18 09:08:59 +0000
committerAlexander Kurtakov2018-04-18 09:08:59 +0000
commit96346a0c7f8f82bdfdcb5085e3b4c919175be954 (patch)
tree69d4ae7da35d410f7fd0aae179a16fa124ee06de
parent3339e698dcf1f8f83c0d0b56fcbdb5081fee98d5 (diff)
downloadeclipse.platform.ua-96346a0c7f8f82bdfdcb5085e3b4c919175be954.tar.gz
eclipse.platform.ua-96346a0c7f8f82bdfdcb5085e3b4c919175be954.tar.xz
eclipse.platform.ua-96346a0c7f8f82bdfdcb5085e3b4c919175be954.zip
Bug 533739 - Direct use of IStructuredSelectionI20180420-2000I20180419-2000I20180418-2000
Instead of getSelection and cast blindly. Change-Id: I58f9725a4f89b40f2a9c4e0c797ee27a8565e7a5 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java9
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java6
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java9
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java6
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java13
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java4
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java12
-rw-r--r--org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java6
8 files changed, 29 insertions, 36 deletions
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java
index b85bcb4e0..a1a8cdc54 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarksPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 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
@@ -24,7 +24,6 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -124,7 +123,7 @@ public class BookmarksPart extends HyperlinkTreePart implements Observer {
@Override
public void run() {
- Object obj = ((IStructuredSelection)treeViewer.getSelection()).getFirstElement();
+ Object obj = treeViewer.getStructuredSelection().getFirstElement();
if (obj instanceof BookmarkManager.Bookmark) {
BookmarkManager.Bookmark b = (BookmarkManager.Bookmark)obj;
BaseHelpSystem.getBookmarkManager().removeBookmark(b);
@@ -145,12 +144,12 @@ public class BookmarksPart extends HyperlinkTreePart implements Observer {
@Override
public boolean fillContextMenu(IMenuManager manager) {
boolean value = super.fillContextMenu(manager);
- ISelection selection = treeViewer.getSelection();
+ IStructuredSelection selection = treeViewer.getStructuredSelection();
boolean canDeleteAll=false;
int count = BaseHelpSystem.getBookmarkManager().getBookmarks().length;
canDeleteAll = count>0;
- if (canDelete((IStructuredSelection) selection)) {
+ if (canDelete(selection)) {
if (value)
manager.add(new Separator());
manager.add(deleteAction);
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java
index e106422e1..1ef0c7360 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -12,7 +12,6 @@ package org.eclipse.help.ui.internal.views;
import org.eclipse.help.ui.internal.Messages;
import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
@@ -96,8 +95,7 @@ public class EngineTypeWizardPage extends WizardPage {
tableViewer.setLabelProvider(new EngineLabelProvider());
tableViewer.addSelectionChangedListener(event -> {
setPageComplete(!event.getSelection().isEmpty());
- selection = (EngineTypeDescriptor) ((IStructuredSelection) event.getSelection())
- .getFirstElement();
+ selection = (EngineTypeDescriptor) event.getStructuredSelection().getFirstElement();
});
tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
tableViewer.setInput(engineTypes);
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java
index afa5a7b24..94db6cfd8 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HyperlinkTreePart.java
@@ -137,8 +137,8 @@ public abstract class HyperlinkTreePart extends AbstractFormPart implements
treeViewer.setInput(this);
treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
treeViewer.addOpenListener(event -> doOpenSelection((IStructuredSelection) event.getSelection()));
- treeViewer.addSelectionChangedListener(
- event -> handleSelectionChanged((IStructuredSelection) event.getSelection()));
+ treeViewer
+ .addSelectionChangedListener(event -> handleSelectionChanged(event.getStructuredSelection()));
treeViewer.getTree().addMouseListener(new MouseAdapter() {
long lastTime;
@@ -213,7 +213,7 @@ public abstract class HyperlinkTreePart extends AbstractFormPart implements
}
Object obj = item.getData();
treeViewer.getTree().setCursor(handCursor);
- IStructuredSelection ssel = (IStructuredSelection) treeViewer.getSelection();
+ IStructuredSelection ssel = treeViewer.getStructuredSelection();
if (ssel.getFirstElement() == obj)
item.setForeground(e.display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
else
@@ -330,8 +330,7 @@ public abstract class HyperlinkTreePart extends AbstractFormPart implements
private void updateStatus(IHelpResource res, boolean defaultToSelection) {
if (defaultToSelection && res == null) {
- IStructuredSelection ssel = (IStructuredSelection) treeViewer
- .getSelection();
+ IStructuredSelection ssel = treeViewer.getStructuredSelection();
Object obj = ssel.getFirstElement();
if (obj instanceof IHelpResource)
res = (IHelpResource) obj;
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java
index ed3b7994b..983b8b10e 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -87,7 +87,7 @@ public class ScopePreferenceDialog extends PreferenceDialog {
protected TreeViewer createTreeViewer(Composite parent) {
TreeViewer viewer = super.createTreeViewer(parent);
viewer.addSelectionChangedListener(event -> {
- IStructuredSelection ssel = (IStructuredSelection) event.getSelection();
+ IStructuredSelection ssel = event.getStructuredSelection();
Object obj = ssel.getFirstElement();
treeSelectionChanged(obj);
});
@@ -138,7 +138,7 @@ public class ScopePreferenceDialog extends PreferenceDialog {
}
private void doDelete() {
- Object obj = ((IStructuredSelection)getTreeViewer().getSelection()).getFirstElement();
+ Object obj = getTreeViewer().getStructuredSelection().getFirstElement();
if (obj instanceof ScopePreferenceManager.EnginePreferenceNode) {
ScopePreferenceManager.EnginePreferenceNode node = (ScopePreferenceManager.EnginePreferenceNode)obj;
EngineDescriptor desc = node.getDescriptor();
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java
index b800081c2..13be27942 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 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
@@ -324,8 +324,7 @@ public class ScopeSetDialog extends TrayDialog {
setResult(manager.getDefaultScope());
} else {
// Build a list of selected children.
- IStructuredSelection selection = (IStructuredSelection) viewer
- .getSelection();
+ IStructuredSelection selection = viewer.getStructuredSelection();
setResult(selection.toList());
}
super.okPressed();
@@ -406,7 +405,7 @@ public class ScopeSetDialog extends TrayDialog {
private void doEdit() {
- IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
+ IStructuredSelection ssel = viewer.getStructuredSelection();
ScopeSet set = (ScopeSet)ssel.getFirstElement();
if (set==null) {
return;
@@ -428,7 +427,7 @@ public class ScopeSetDialog extends TrayDialog {
}
private void doRename() {
- IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
+ IStructuredSelection ssel = viewer.getStructuredSelection();
ScopeSet set = (ScopeSet)ssel.getFirstElement();
if (set!=null) {
RenameOperation rop = (RenameOperation)findOperation(set, RenameOperation.class);
@@ -462,7 +461,7 @@ public class ScopeSetDialog extends TrayDialog {
}
private void doRemove() {
- IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
+ IStructuredSelection ssel = viewer.getStructuredSelection();
ScopeSet set = (ScopeSet)ssel.getFirstElement();
if (set!=null) {
scheduleOperation(new RemoveOperation(set));
@@ -484,7 +483,7 @@ public class ScopeSetDialog extends TrayDialog {
}
private void updateButtons() {
- IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
+ IStructuredSelection ssel = viewer.getStructuredSelection();
editButton.setEnabled(ssel.isEmpty()==false);
ScopeSet set = (ScopeSet)ssel.getFirstElement();
boolean editableSet = set!=null && set.isEditable() && !set.isImplicit();
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java
index f8d8aea16..3b2271d9d 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -273,7 +273,7 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi
@Override
public void selectionChanged(SelectionChangedEvent event) {
- updateForSelection(event.getSelection());
+ updateForSelection(event.getStructuredSelection());
}
private void updateForSelection(ISelection selection) {
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java
index 99efb55ac..2d31846d3 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2017 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -25,7 +25,6 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
@@ -499,9 +498,8 @@ public class CheatSheetCategoryBasedSelectionDialog extends TrayDialog //extends
* selectionEvent, or <code>null</code> if the selectionEvent contains
* either 0 or 2+ selected objects.
*/
- protected Object getSingleSelection(ISelection selection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
- return ssel.size() == 1 ? ssel.getFirstElement() : null;
+ protected Object getSingleSelection(IStructuredSelection selection) {
+ return selection.size() == 1 ? selection.getFirstElement() : null;
}
/**
@@ -513,7 +511,7 @@ public class CheatSheetCategoryBasedSelectionDialog extends TrayDialog //extends
*/
@Override
public void selectionChanged(SelectionChangedEvent selectionEvent) {
- Object obj = getSingleSelection(selectionEvent.getSelection());
+ Object obj = getSingleSelection(selectionEvent.getStructuredSelection());
if (obj instanceof CheatSheetCollectionElement) {
currentSelection = null;
} else {
@@ -759,7 +757,7 @@ public class CheatSheetCategoryBasedSelectionDialog extends TrayDialog //extends
protected void storeSelectedCheatSheet() {
CheatSheetElement element = null;
- Object el = getSingleSelection(treeViewer.getSelection());
+ Object el = getSingleSelection(treeViewer.getStructuredSelection());
if (el == null)
return;
diff --git a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java
index 20dc4bbe6..177cb21ba 100644
--- a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java
+++ b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 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
@@ -226,7 +226,7 @@ public class CustomizationContentsArea {
@Override
public void dragStart(DragSourceEvent event) {
- IStructuredSelection ssel = (IStructuredSelection) viewer.getSelection();
+ IStructuredSelection ssel = viewer.getStructuredSelection();
if (ssel.size() > 0) {
event.doit = true;
} else {
@@ -236,7 +236,7 @@ public class CustomizationContentsArea {
@Override
public void dragSetData(DragSourceEvent event) {
- IStructuredSelection ssel = (IStructuredSelection) viewer.getSelection();
+ IStructuredSelection ssel = viewer.getStructuredSelection();
BaseData[] array = new BaseData[ssel.size()];
int i = 0;
for (Iterator<BaseData> iter = ssel.iterator(); iter.hasNext();) {

Back to the top