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();
}
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;
}
Esempio n. 3
0
IWorkbenchWindow::Pointer UITestCase::OpenTestWindow(
    const std::string& perspectiveId)
{
  try
  {
    IWorkbenchWindow::Pointer window = fWorkbench->OpenWorkbenchWindow(
        perspectiveId, GetPageInput());
    WaitOnShell(window->GetShell());
    return window;
  } catch (WorkbenchException& e)
  {
    failmsg(e.displayText());
    return IWorkbenchWindow::Pointer(0);
  }
}
QtPerspectiveSwitcher::QtPerspectiveSwitcher(IWorkbenchWindow::Pointer window)
: window(window)
{
  QWidget* parent = static_cast<QWidget*>(window->GetShell()->GetControl());
  this->setParent(parent);

  this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

  QActionGroup* perspGroup = new QActionGroup(this);

  IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry();

  std::vector<IPerspectiveDescriptor::Pointer> perspectives(perspRegistry->GetPerspectives());
  for (std::vector<IPerspectiveDescriptor::Pointer>::iterator perspIt =
      perspectives.begin(); perspIt != perspectives.end(); ++perspIt)
  {
    QAction* perspAction = new QtOpenPerspectiveAction(window, *perspIt, perspGroup);
    perspIdToActionMap[QString::fromStdString((*perspIt)->GetId())] = perspAction;
  }
  this->addActions(perspGroup->actions());

  perspListener = new QtPerspectiveSwitcherListener(this);
  window->AddPerspectiveListener(perspListener);
}