1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +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,39 +5961,45 @@ 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())
{ {
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){
IStructuredSelection fakeSelection = null; if (activePart != ourPart){
// create events in order to update the property sheet ourPart.setFocus(); // without part focus, there are no post selection change listeners
if (selection instanceof IStructuredSelection){ }
fakeSelection = new StructuredSelection(new Object());
} // create events in order to update the property sheet
IStructuredSelection fakeSelection = new StructuredSelection(new Object());
if (fakeSelection != null){
SelectionChangedEvent dummyEvent = new SelectionChangedEvent(this, fakeSelection); if (fakeSelection != null){
// first change the selection, then change it back (otherwise the property sheet ignores the event) SelectionChangedEvent dummyEvent = new SelectionChangedEvent(this, fakeSelection);
fireSelectionChanged(dummyEvent); // first change the selection, then change it back (otherwise the property sheet ignores the event)
firePostSelectionChanged(dummyEvent); fireSelectionChanged(dummyEvent);
} firePostSelectionChanged(dummyEvent);
SelectionChangedEvent event = new SelectionChangedEvent(this, selection); }
SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
// fire the event
fireSelectionChanged(event); // fire the event
firePostSelectionChanged(event); fireSelectionChanged(event);
firePostSelectionChanged(event);
if (ourPart != activePart){
activePart.setFocus(); if (ourPart != activePart){
activePart.setFocus();
}
} }
} }