mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch by Sascha Radike for Bug 163377 - [CView] CView does not reveal new resources
This commit is contained in:
parent
a63a250e0b
commit
c2ad331a4e
2 changed files with 24 additions and 4 deletions
|
@ -67,7 +67,25 @@ public class SelectionConverter {
|
||||||
return StructuredSelection.EMPTY;
|
return StructuredSelection.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
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();
|
List converted = new ArrayList();
|
||||||
if (s instanceof StructuredSelection) {
|
if (s instanceof StructuredSelection) {
|
||||||
Object[] elements = ((StructuredSelection) s).toArray();
|
Object[] elements = ((StructuredSelection) s).toArray();
|
||||||
|
@ -79,8 +97,10 @@ public class SelectionConverter {
|
||||||
ICElement c = (ICElement) ((IAdaptable) e).getAdapter(ICElement.class);
|
ICElement c = (ICElement) ((IAdaptable) e).getAdapter(ICElement.class);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
converted.add(c);
|
converted.add(c);
|
||||||
}
|
} else if (keepNonCElements)
|
||||||
}
|
converted.add(e);
|
||||||
|
} else if (keepNonCElements)
|
||||||
|
converted.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new StructuredSelection(converted.toArray());
|
return new StructuredSelection(converted.toArray());
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
|
||||||
* @see ISetSelectionTarget#selectReveal(ISelection)
|
* @see ISetSelectionTarget#selectReveal(ISelection)
|
||||||
*/
|
*/
|
||||||
public void selectReveal(ISelection selection) {
|
public void selectReveal(ISelection selection) {
|
||||||
IStructuredSelection ssel = SelectionConverter.convertSelectionToCElements(selection);
|
IStructuredSelection ssel = SelectionConverter.convertSelectionToCElements(selection, true);
|
||||||
if (!ssel.isEmpty()) {
|
if (!ssel.isEmpty()) {
|
||||||
getViewer().setSelection(ssel, true);
|
getViewer().setSelection(ssel, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue