Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2006-11-06 16:54:48 +0000
committerAnton Leherbauer2006-11-06 16:54:48 +0000
commit181d4104c18dd40afbd6e5c8f4f38fcf5b21fd22 (patch)
tree45110794df57c52fc3d29ff31edf472371d5ae29
parent7087da743bf56bd58b3b87234b123fcb123dd962 (diff)
downloadorg.eclipse.cdt-181d4104c18dd40afbd6e5c8f4f38fcf5b21fd22.tar.gz
org.eclipse.cdt-181d4104c18dd40afbd6e5c8f4f38fcf5b21fd22.tar.xz
org.eclipse.cdt-181d4104c18dd40afbd6e5c8f4f38fcf5b21fd22.zip
Patch by Sascha Radike for Bug 163377 - [CView] CView does not reveal new resources
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java2
2 files changed, 25 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
index 85404744ff..9fd06c6f94 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
@@ -38,8 +38,26 @@ import org.eclipse.ui.texteditor.ITextEditor;
public class SelectionConverter {
protected static final ICElement[] EMPTY_RESULT= new ICElement[0];
-
- public static IStructuredSelection convertSelectionToCElements(ISelection s) {
+
+ /**
+ * Converts objects of a structured selection to c elements if possible.
+ * This is a convenience method, fully equivalent to
+ * <code>convertSelectionToCElements(s, false)</code>.
+ * @param s The structured selection
+ * @return The converted selection
+ */
+ public static IStructuredSelection convertSelectionToCElements(ISelection s) {
+ return convertSelectionToCElements(s, false);
+ }
+
+ /**
+ * Converts objects of a structured selection to c elements if possible.
+ * @param s The structured selection
+ * @param keepNonCElements Whether to keep objects in selection if they cannot be converted
+ * @return The converted selection
+ */
+ public static IStructuredSelection convertSelectionToCElements(ISelection s,
+ boolean keepNonCElements) {
List converted = new ArrayList();
if (s instanceof StructuredSelection) {
Object[] elements = ((StructuredSelection) s).toArray();
@@ -51,8 +69,10 @@ public class SelectionConverter {
ICElement c = (ICElement) ((IAdaptable) e).getAdapter(ICElement.class);
if (c != null) {
converted.add(c);
- }
- }
+ } else if (keepNonCElements)
+ converted.add(e);
+ } else if (keepNonCElements)
+ converted.add(e);
}
}
return new StructuredSelection(converted.toArray());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
index a1b91ec491..58ffecb47c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
@@ -203,7 +203,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
* @see ISetSelectionTarget#selectReveal()
*/
public void selectReveal(ISelection selection) {
- IStructuredSelection ssel = SelectionConverter.convertSelectionToCElements(selection);
+ IStructuredSelection ssel = SelectionConverter.convertSelectionToCElements(selection, true);
if (!ssel.isEmpty()) {
getViewer().setSelection(ssel, true);
}

Back to the top