void PartOpened(const IWorkbenchPartReference::Pointer& partRef) override
 {
     if (tracker->GetPartId(partRef->GetPart(false))
             == tracker->AbstractPartSelectionTracker::GetPartId())
     {
         tracker->SetPart(partRef->GetPart(false), true);
     }
 }
Пример #2
0
void WWinPartService::PageActivated(SmartPointer<IWorkbenchPage> newPage)
{
  // Optimize.
  if (newPage == activePage)
  {
    return;
  }

  // Fire events in the following order:

  // 1. For each open part in the new page, open it and then (if applicable) make it visible
  // 2. Deactivate old active part
  // 3. Activate the new active part
  // 4. For each open part in the old page, make it invisible then close it

  // Hook listener on the new page.
  if (newPage)
  {
    std::vector<IWorkbenchPartReference::Pointer> refs(newPage.Cast<
        WorkbenchPage> ()->GetOpenParts());

    for (std::size_t i = 0; i < refs.size(); i++)
    {
      IWorkbenchPartReference::Pointer reference = refs[i];

      partService.FirePartOpened(reference);

      IWorkbenchPart::Pointer part = reference->GetPart(false);
      if (part && newPage->IsPartVisible(part))
      {
        partService.FirePartVisible(reference);
      }
    }

    partService.SetActivePart(newPage->GetActivePartReference());
    selectionService.SetActivePart(newPage->GetActivePart());
  }
  else
  {
    partService.SetActivePart(IWorkbenchPartReference::Pointer(0));
    selectionService.SetActivePart(IWorkbenchPart::Pointer(0));
  }

  // Unhook listener from the old page.
  Reset();

  // Update active page.
  activePage = newPage.GetPointer();

  if (newPage)
  {
    newPage->AddPartListener(partListener);
  }

}
Пример #3
0
void WorkbenchPagePartList::FireActiveEditorChanged(
    IWorkbenchPartReference::Pointer ref)
{
  if (ref.IsNotNull())
  {
    this->FirePartBroughtToTop(ref);
  }
}
Пример #4
0
void WorkbenchPagePartList::FireActivePartChanged(
    IWorkbenchPartReference::Pointer /*oldRef*/,
    IWorkbenchPartReference::Pointer newRef)
{
  partService.SetActivePart(newRef);

  IWorkbenchPart::Pointer realPart = newRef == 0 ? IWorkbenchPart::Pointer(0) : newRef->GetPart(false);
  selectionService->SetActivePart(realPart);
}
Пример #5
0
void PartService::SetActivePart(IWorkbenchPartReference::Pointer ref)
{
  IWorkbenchPartReference::Pointer oldRef = activePart.Lock();

  // Filter out redundant activation events
  if (oldRef == ref)
  {
    return;
  }

  if (oldRef.IsNotNull())
  {
    this->FirePartDeactivated(oldRef);
  }

  activePart = ref;

  if (ref.IsNotNull())
  {
    this->FirePartActivated(ref);
  }
}
    void PerspectiveChanged(const IWorkbenchPage::Pointer&,
                            const IPerspectiveDescriptor::Pointer&,
                            const IWorkbenchPartReference::Pointer& partRef,
                            const QString& changeId) override
    {
        if (!partRef)
            return;
        IWorkbenchPart::Pointer part = partRef->GetPart(false);
        if (!part)
            return;

        if (IWorkbenchPage::CHANGE_VIEW_SHOW == changeId)
        {
            if (tracker->GetPart()) // quick check first, plus avoids double setting
                return;
            if (tracker->GetPartId(part) == tracker->AbstractPartSelectionTracker::GetPartId())
                tracker->SetPart(part, true);
        }
    }