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); }
void PerspectivesPreferencePage::MakeDefaultPerspective() { PerspectiveDescriptor::Pointer desc = GetSelectedPerspective(); if (desc.IsNotNull() && !perspToDelete.contains(desc)) { int row = perspectives.indexOf(desc); defaultPerspectiveId = desc->GetId(); UpdatePerspectivesTable(); ui->perspectivesListWidget->item(row)->setSelected(true); } UpdateButtons(); }