1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 22:35: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) {
ISelection selection = getSelection();
if (selection == null) return;
if (selection == null || !(selection instanceof IStructuredSelection)) return;
// only fire this event if the view actually has focus
if (force || getControl().isFocusControl())
{
{
Object object = ((IStructuredSelection)selection).getFirstElement();
if (object != null){
IWorkbenchPart ourPart = getWorkbenchPart();
IWorkbenchPart activePart = getWorkbenchWindow().getActivePage().getActivePart();
if (activePart != ourPart){
ourPart.setFocus(); // without part focus, there are no post selection change listeners
IWorkbenchPart activePart = null;
IWorkbenchWindow win = getWorkbenchWindow(); // from dialog it's possible to not have an active part
if (win != null){
IWorkbenchPage page = win.getActivePage();
if (page != null){
activePart = page.getActivePart();
}
}
IStructuredSelection fakeSelection = null;
// create events in order to update the property sheet
if (selection instanceof IStructuredSelection){
fakeSelection = new StructuredSelection(new Object());
}
if (fakeSelection != null){
SelectionChangedEvent dummyEvent = new SelectionChangedEvent(this, fakeSelection);
// first change the selection, then change it back (otherwise the property sheet ignores the event)
fireSelectionChanged(dummyEvent);
firePostSelectionChanged(dummyEvent);
}
SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
// fire the event
fireSelectionChanged(event);
firePostSelectionChanged(event);
if (ourPart != activePart){
activePart.setFocus();
if (activePart != null){
if (activePart != ourPart){
ourPart.setFocus(); // without part focus, there are no post selection change listeners
}
// create events in order to update the property sheet
IStructuredSelection fakeSelection = new StructuredSelection(new Object());
if (fakeSelection != null){
SelectionChangedEvent dummyEvent = new SelectionChangedEvent(this, fakeSelection);
// first change the selection, then change it back (otherwise the property sheet ignores the event)
fireSelectionChanged(dummyEvent);
firePostSelectionChanged(dummyEvent);
}
SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
// fire the event
fireSelectionChanged(event);
firePostSelectionChanged(event);
if (ourPart != activePart){
activePart.setFocus();
}
}
}