1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

[342095] Properties in Properties view remain "Pending..." in some cases

-account for non-structured selection and dialog scenario
This commit is contained in:
David McKnight 2011-06-28 14:48:27 +00:00
parent 9cf86ee217
commit 35c5e71ccf

View file

@ -5961,7 +5961,7 @@ public class SystemView extends SafeTreeViewer
*/ */
private void updatePropertySheet(boolean force) { private void updatePropertySheet(boolean force) {
ISelection selection = getSelection(); ISelection selection = getSelection();
if (selection == null) return; if (selection == null || !(selection instanceof IStructuredSelection)) return;
// only fire this event if the view actually has focus // only fire this event if the view actually has focus
if (force || getControl().isFocusControl()) if (force || getControl().isFocusControl())
@ -5969,31 +5969,37 @@ public class SystemView extends SafeTreeViewer
Object object = ((IStructuredSelection)selection).getFirstElement(); Object object = ((IStructuredSelection)selection).getFirstElement();
if (object != null){ if (object != null){
IWorkbenchPart ourPart = getWorkbenchPart(); IWorkbenchPart ourPart = getWorkbenchPart();
IWorkbenchPart activePart = getWorkbenchWindow().getActivePage().getActivePart(); IWorkbenchPart activePart = null;
if (activePart != ourPart){ IWorkbenchWindow win = getWorkbenchWindow(); // from dialog it's possible to not have an active part
ourPart.setFocus(); // without part focus, there are no post selection change listeners if (win != null){
IWorkbenchPage page = win.getActivePage();
if (page != null){
activePart = page.getActivePart();
}
} }
if (activePart != null){
if (activePart != ourPart){
ourPart.setFocus(); // without part focus, there are no post selection change listeners
}
IStructuredSelection fakeSelection = null; // create events in order to update the property sheet
// create events in order to update the property sheet IStructuredSelection fakeSelection = new StructuredSelection(new Object());
if (selection instanceof IStructuredSelection){
fakeSelection = new StructuredSelection(new Object());
}
if (fakeSelection != null){ if (fakeSelection != null){
SelectionChangedEvent dummyEvent = new SelectionChangedEvent(this, fakeSelection); SelectionChangedEvent dummyEvent = new SelectionChangedEvent(this, fakeSelection);
// first change the selection, then change it back (otherwise the property sheet ignores the event) // first change the selection, then change it back (otherwise the property sheet ignores the event)
fireSelectionChanged(dummyEvent); fireSelectionChanged(dummyEvent);
firePostSelectionChanged(dummyEvent); firePostSelectionChanged(dummyEvent);
} }
SelectionChangedEvent event = new SelectionChangedEvent(this, selection); SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
// fire the event // fire the event
fireSelectionChanged(event); fireSelectionChanged(event);
firePostSelectionChanged(event); firePostSelectionChanged(event);
if (ourPart != activePart){ if (ourPart != activePart){
activePart.setFocus(); activePart.setFocus();
}
} }
} }