コード例 #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
Object::Pointer ResetPerspectiveHandler::Execute(const SmartPointer<const ExecutionEvent>& event)
{

  IWorkbenchWindow::Pointer activeWorkbenchWindow = HandlerUtil::GetActiveWorkbenchWindow(event);
  if (activeWorkbenchWindow.IsNotNull())
  {
    WorkbenchPage::Pointer page = activeWorkbenchWindow->GetActivePage().Cast<WorkbenchPage>();
    if (page.IsNotNull())
    {
      IPerspectiveDescriptor::Pointer descriptor = page->GetPerspective();
      if (descriptor.IsNotNull())
      {
        bool offerRevertToBase = false;
        if (PerspectiveDescriptor::Pointer desc = descriptor.Cast<PerspectiveDescriptor>())
        {
          offerRevertToBase = desc->IsPredefined() && desc->HasCustomDefinition();
        }

        if (offerRevertToBase)
        {
          QString message = QString("Do you want to reset the current %1 perspective to its saved state?").arg(
                              descriptor->GetLabel());
//          bool toggleState = false;
//          MessageDialogWithToggle dialog = MessageDialogWithToggle.open(
//                                             MessageDialog.QUESTION, activeWorkbenchWindow.getShell(),
//                                             WorkbenchMessages.RevertPerspective_title, message,
//                                             WorkbenchMessages.RevertPerspective_option,
//                                             toggleState, null, null, SWT.SHEET);
//          if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
//            if (dialog.getToggleState()) {
//              PerspectiveRegistry* reg = PlatformUI::GetWorkbench()->GetPerspectiveRegistry();
//              reg->RevertPerspective(descriptor);
//            }
//            page->ResetPerspective();
//          }
          qDebug() << "****** " << message;
        }
        else
        {
          QString message = QString("Do you want to reset the current %1 perspective to its defaults?").arg(
                                    descriptor->GetLabel());
          if (QMessageBox::question(activeWorkbenchWindow->GetShell()->GetControl(), "Reset Perspective",
                                    message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ==
              QMessageBox::Yes)
          {
            page->ResetPerspective();
          }
        }
      }
    }
  }

  return Object::Pointer();
}
コード例 #3
0
ファイル: berryHelpEditor.cpp プロジェクト: Cymatium/MITK
void HelpEditor::PerspectiveDeactivated(const SmartPointer<IWorkbenchPage>& /*page*/,
                                        const IPerspectiveDescriptor::Pointer& perspective)
{
  if (perspective->GetId() == HelpPerspective::ID)
  {
    m_OpenHelpMode->setVisible(true);
    m_CloseHelpMode->setVisible(false);
  }
}
コード例 #4
0
 void PerspectiveActivated(IWorkbenchPage::Pointer /*page*/,
         IPerspectiveDescriptor::Pointer perspective)
 {
   QAction* action = switcher->perspIdToActionMap[QString::fromStdString(perspective->GetId())];
   if (action) action->setChecked(true);
 }
コード例 #5
0
 void PerspectiveActivated(const IWorkbenchPage::Pointer& /*page*/,
                           const IPerspectiveDescriptor::Pointer& perspective) override
 {
   QAction* action = switcher->perspIdToActionMap[perspective->GetId()];
   if (action) action->setChecked(true);
 }