void PagePartSelectionTracker::SetPart(IWorkbenchPart::Pointer part, bool notify) { if (fPart.IsNotNull()) { // remove myself as a listener from the existing part ISelectionProvider::Pointer sp = fPart->GetSite()->GetSelectionProvider(); if (sp.IsNotNull()) { sp->RemoveSelectionChangedListener(selChangedListener.data()); if (sp.Cast<IPostSelectionProvider> ().IsNotNull()) { sp.Cast<IPostSelectionProvider> () ->RemovePostSelectionChangedListener( postSelectionListener.data()); } else { sp->RemoveSelectionChangedListener(postSelectionListener.data()); } } } fPart = part; ISelection::ConstPointer sel; if (part.IsNotNull()) { ISelectionProvider::Pointer sp = part->GetSite()->GetSelectionProvider(); if (sp.IsNotNull()) { sp->AddSelectionChangedListener(selChangedListener.data()); if (sp.Cast<IPostSelectionProvider> ().IsNotNull()) { sp.Cast<IPostSelectionProvider> () ->AddPostSelectionChangedListener( postSelectionListener.data()); } else { sp->AddSelectionChangedListener(postSelectionListener.data()); } if (notify) { // get the selection to send below sel = sp->GetSelection(); } } } if (notify) { this->FireSelection(part, sel); this->FirePostSelection(part, sel); } }
SelectionChangedEvent::SelectionChangedEvent( ISelectionProvider::Pointer source, ISelection::ConstPointer selection) { poco_assert(source.IsNotNull()); poco_assert(selection.IsNotNull()); this->source = source; this->selection = selection; }
ISelection::ConstPointer PagePartSelectionTracker::GetSelection() { IWorkbenchPart::Pointer part = this->GetPart(); if (part.IsNotNull()) { ISelectionProvider::Pointer sp = part->GetSite()->GetSelectionProvider(); if (sp.IsNotNull()) { return sp->GetSelection(); } } return ISelection::Pointer(nullptr); }