Ejemplo n.º 1
0
void PartList::PartOpened(WorkbenchPartReference::Pointer ref)
{
  poco_assert(ref.IsNotNull());

  IWorkbenchPart::Pointer actualPart = ref->GetPart(false);
  // We're firing the event that says "the part was just created"... so
  // there better be a part there.
  poco_assert(actualPart.IsNotNull());
  // Must be called after the part is inserted into the part list
  //poco_assert(this->Contains(ref));
  // The active part must be opened before it is activated, so we should
  // never get an open event for a part that is already active.
  // (This either indicates that a redundant
  // open event was fired or that a closed part was somehow activated)
  poco_assert(activePartReference.Lock() != ref);
  // The active editor must be opened before it is activated, so we should
  // never get an open event for an editor that is already active.
  // (This either indicates that a redundant
  // open event was fired or that a closed editor was somehow activated)
  poco_assert((void*)activeEditorReference.Lock().GetPointer() != (void*)ref.GetPointer());

  SaveablesList* modelManager = dynamic_cast<SaveablesList*>(
        actualPart->GetSite()->GetService<ISaveablesLifecycleListener>());
  modelManager->PostOpen(actualPart);

  // Fire the "part opened" event
  this->FirePartOpened(ref);
}
ISelectionProvider::Pointer PagePartSelectionTracker::GetSelectionProvider()
{
    IWorkbenchPart::Pointer part = this->GetPart();
    if (part.IsNotNull())
    {
        return part->GetSite()->GetSelectionProvider();
    }
    return ISelectionProvider::Pointer(nullptr);
}
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);
    }
}
Ejemplo n.º 4
0
IIntroPart::Pointer WorkbenchIntroManager::ShowIntro(SmartPointer<
    IWorkbenchWindow> preferredWindow, bool standby)
{
  if (!preferredWindow)
  {
    preferredWindow = this->workbench->GetActiveWorkbenchWindow();
  }

  if (!preferredWindow)
  {
    return IIntroPart::Pointer(nullptr);
  }

  IWorkbenchPart::Pointer part = GetIntroAdapterPart();
  if (!part)
  {
    CreateIntro(preferredWindow);
  }
  else
  {
    try
    {
      IWorkbenchPage::Pointer page = part->GetSite()->GetPage();
      IWorkbenchWindow::Pointer window = page->GetWorkbenchWindow();
      if (window != preferredWindow)
      {
        window->GetShell()->SetActive();
      }

      if (IntroIsView())
      {
        page->ShowView(IntroConstants::INTRO_VIEW_ID);
      }
      else
      {
        IEditorInput::Pointer input(new NullEditorInput());
        page->OpenEditor(input, IntroConstants::INTRO_EDITOR_ID);
      }
    } catch (PartInitException& e)
    {
      //TODO IStatus
//      WorkbenchPlugin::Log("Could not open intro", new Status(IStatus.ERROR,
//          WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open intro",
//          e)); //$NON-NLS-1$ //$NON-NLS-2$
      WorkbenchPlugin::Log("Could not open intro", e);
    }
  }
  SetIntroStandby(introPart, standby);
  return introPart;
}
Ejemplo n.º 5
0
bool WorkbenchIntroManager::IsIntroInWindow(
    SmartPointer<IWorkbenchWindow> testWindow) const
{
  IWorkbenchPart::Pointer part = GetIntroAdapterPart();
  if (!part)
  {
    return false;
  }

  IWorkbenchWindow::Pointer window = part->GetSite()->GetWorkbenchWindow();
  if (window == testWindow)
  {
    return true;
  }
  return false;
}
Ejemplo n.º 6
0
bool WorkbenchIntroManager::CloseIntro(IIntroPart::Pointer part)
{
  if (!introPart || introPart != part)
  {
    return false;
  }

  IWorkbenchPart::Pointer introView = GetIntroAdapterPart();
  if (introView)
  {
    //assumption is that there is only ever one intro per workbench
    //if we ever support one per window then this will need revisiting
    IWorkbenchPage::Pointer page = introView->GetSite()->GetPage();
    if (IntroIsView())
    {
      IViewReference::Pointer reference = page->FindViewReference(
          IntroConstants::INTRO_VIEW_ID);
      page->HideView(introView.Cast<IViewPart>());
      if (!reference || reference->GetPart(false) == 0)
      {
        introPart = nullptr;
        return true;
      }
      return false;
    }
    else
    {
      QList<IEditorReference::Pointer> references(page->FindEditors(IEditorInput::Pointer(nullptr), IntroConstants::INTRO_EDITOR_ID, IWorkbenchPage::MATCH_ID));
      Q_ASSERT(references.size() < 2);
      if (references.empty())
        return false;

      if (page->CloseEditors(references, false))
      {
        introPart = nullptr;
        return true;
      }
      return false;
    }
  }

  // if there is no part then null our reference
  introPart = nullptr;

  return true;
}
 void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection)
 {
   // check, if selection comes from datamanager
   if (part)
   {
     QString partname(part->GetPartName().c_str());
     if(partname.compare("Data Manager")==0)
     {
       // apply selection
       DoSelectionChanged(selection);
     }
   }
 }
 void SelectionChanged(const IWorkbenchPart::Pointer& part, const ISelection::ConstPointer& selection) override
 {
   // check, if selection comes from datamanager
   if (part)
   {
     QString partname = part->GetPartName();
     if(partname.compare("Data Manager")==0)
     {
       // apply selection
       DoSelectionChanged(selection);
     }
   }
 }
Ejemplo n.º 9
0
void PartList::PartClosed(WorkbenchPartReference::Pointer ref)
{
  poco_assert(ref.IsNotNull());

  IWorkbenchPart::Pointer actualPart = ref->GetPart(false);
  // Called before the part is disposed, so the part should still be
  // there.
  poco_assert(actualPart.IsNotNull());
  // Must be called before the part is actually removed from the part list
  // poco_assert(this->Contains(ref));
  // Not allowed to close the active part. The part must be deactivated
  // before it may be closed.
  poco_assert(activePartReference.Lock() != ref);
  // Not allowed to close the active editor. The editor must be
  // deactivated before it may be closed.
  if (ref.Cast<IEditorReference>())
  {
    poco_assert(activeEditorReference.Lock() != ref.Cast<IEditorReference>());
  }

  this->FirePartClosed(ref);
}
Ejemplo n.º 10
0
QString PagePartSelectionTracker::GetPartId(IWorkbenchPart::Pointer part)
{
    QString id = part->GetSite()->GetId();
    if (part.Cast<IViewPart> ().IsNotNull())
    {
        QString secondaryId =
            part.Cast<IViewPart> ()->GetViewSite() ->GetSecondaryId();
        if (secondaryId != "")
        {
            id = id + ':' + secondaryId;
        }
    }
    return id;
}
void AbstractSelectionService::SetActivePart(IWorkbenchPart::Pointer newPart)
{
  // Optimize.
  if (newPart == activePart)
  {
    return;
  }

  ISelectionProvider::Pointer selectionProvider;

  if (newPart.IsNotNull())
  {
    selectionProvider = newPart->GetSite()->GetSelectionProvider();

    if (selectionProvider.IsNull())
    {
      newPart = nullptr;
    }
  }

  if (newPart == activePart)
  {
    return;
  }

  if (activePart.IsNotNull())
  {
    if (activeProvider.IsNotNull())
    {
      activeProvider->RemoveSelectionChangedListener(selListener.data());
      if (activeProvider.Cast<IPostSelectionProvider>().IsNotNull())
      {
        activeProvider.Cast<IPostSelectionProvider>()
        ->RemovePostSelectionChangedListener(postSelListener.data());
      }
      else
      {
        activeProvider
        ->RemoveSelectionChangedListener(postSelListener.data());
      }
      activeProvider = nullptr;
    }
    activePart = nullptr;
  }

  activePart = newPart;

  if (newPart.IsNotNull())
  {
    activeProvider = selectionProvider;
    // Fire an event if there's an active provider
    activeProvider->AddSelectionChangedListener(selListener.data());
    ISelection::ConstPointer sel = activeProvider->GetSelection();
    this->FireSelection(newPart, sel);
    if (activeProvider.Cast<IPostSelectionProvider>().IsNotNull())
    {
      activeProvider.Cast<IPostSelectionProvider>()
      ->AddPostSelectionChangedListener(postSelListener.data());
    }
    else
    {
      activeProvider->AddSelectionChangedListener(postSelListener.data());
    }
    this->FirePostSelection(newPart, sel);
  }
  else
  {
    this->FireSelection(IWorkbenchPart::Pointer(nullptr), ISelection::ConstPointer(nullptr));
    this->FirePostSelection(IWorkbenchPart::Pointer(nullptr), ISelection::ConstPointer(nullptr));
  }
}