From 35c5e71ccf539088ef71f988e6b555b7cf52c583 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 28 Jun 2011 14:48:27 +0000 Subject: [PATCH] [342095] Properties in Properties view remain "Pending..." in some cases -account for non-structured selection and dialog scenario --- .../rse/internal/ui/view/SystemView.java | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index ae778ed2824..8cec37334e6 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -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(); + } } }