コード例 #1
0
void SavePerspectiveHandler::SaveNonSingleton(const IWorkbenchPage::Pointer& page,
                                              const PerspectiveDescriptor::Pointer& oldDesc) {
  // Get reg.
  PerspectiveRegistry* reg = static_cast<PerspectiveRegistry*>(
                               berry::WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry());
  assert(reg != nullptr);

  // Get persp name.
  SavePerspectiveDialog dlg(*reg, page->GetWorkbenchWindow()->GetShell()->GetControl());
  // Look up the descriptor by id again to ensure it is still valid.
  IPerspectiveDescriptor::Pointer description = reg->FindPerspectiveWithId(oldDesc->GetId());
  dlg.SetInitialSelection(description);
  if (dlg.exec() != QDialog::Accepted)
  {
    return;
  }

  // Create descriptor.
  IPerspectiveDescriptor::Pointer newDesc = dlg.GetPersp();
  if (newDesc.IsNull())
  {
    QString name = dlg.GetPerspName();
    newDesc = reg->CreatePerspective(name, description);
    if (newDesc.IsNull())
    {
      QMessageBox::critical(&dlg,
                            "Cannot Save Perspective",
                            "Invalid Perspective Descriptor");
      return;
    }
  }

  // Save state.
  page->SavePerspectiveAs(newDesc);
}
コード例 #2
0
PagePartSelectionTracker::~PagePartSelectionTracker()
{
    IWorkbenchPage::Pointer page = GetPage();
    page->GetWorkbenchWindow()->RemovePerspectiveListener(perspListener.data());
    page->RemovePartListener(partListener.data());
    this->SetPart(IWorkbenchPart::Pointer(nullptr), false);
    this->SetPage(nullptr);
}
コード例 #3
0
void SavePerspectiveHandler::SaveSingleton(const IWorkbenchPage::Pointer& page)
{
  QMessageBox::StandardButton btn =
      QMessageBox::question(page->GetWorkbenchWindow()->GetShell()->GetControl(),
                            "Overwrite perspective",
                            "The current perspective can only be opened once and cannot be saved using a new name. "
                            "Do you want to overwrite?",
                            QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
  if (btn == QMessageBox::Ok)
  {
    page->SavePerspective();
  }
}
コード例 #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;
}