plugin_dlg.cpp
来自「ncbi源码」· C++ 代码 · 共 190 行
CPP
190 行
/* * =========================================================================== * PRODUCTION $Log: plugin_dlg.cpp,v $ * PRODUCTION Revision 1000.0 2004/06/01 21:17:18 gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.1 * PRODUCTION * =========================================================================== *//* $Id: plugin_dlg.cpp,v 1000.0 2004/06/01 21:17:18 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include <gui/core/plugin_dlg.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/core/plugin_registry.hpp>#include <gui/widgets/fl/status_bar.hpp>#include <gui/utils/message_box.hpp>#include "plugin_arg_form.hpp"BEGIN_NCBI_SCOPEUSING_SCOPE(objects);#include "plugin_dlg_.cpp"CPluginDlg::CPluginDlg(EDataCommand cmd) : m_DataCmd(cmd) , m_AlgoCmd(eAlgoCommand_no_command) , m_ViewCmd(eViewCommand_no_command){ m_Window.reset(x_CreateWindow()); // add the appropriate list of plugins CPluginRegistry::TPlugins plugins = CPluginRegistry::GetPlugins(CPluginCommandSet::e_Data); m_Handles.reserve(plugins.size()); NON_CONST_ITERATE (CPluginRegistry::TPlugins, iter, plugins) { // verify that we support the 'load' command CPluginHandle plugin = *iter; if ( !plugin.HasCommandSubtype(cmd) ) { continue; } string menu_item = plugin.GetMenuItem(); m_PluginList->add(menu_item.c_str()); m_Handles.push_back(plugin); } switch (cmd) { case eDataCommand_load: m_TitleBase = "Open Items in a New Document"; break; case eDataCommand_import: m_TitleBase = "Import Items Into the Current Document"; break; case eDataCommand_save: m_TitleBase = "Save the Current Document"; break; } m_Window->label(m_TitleBase.c_str()); m_StatusBar->SetMessage("Please select an option");}void CPluginDlg::x_OnOK(){ // first, process all of our formatters m_Form->Process(); // now, verify that our set of arguments is valid try { ITERATE (CPluginArgSet::Tdata, iter, m_Msg->GetRequest().GetCommand().GetArgs().Get()) { const CPluginArg& arg = **iter; if ( !CPluginUtils::IsValid(arg) && !(arg.IsSetOptional() && arg.GetOptional() && arg.IsEmpty()) ) { string msg("Field '"); msg += arg.GetDesc(); msg += "' does not contain a valid value"; throw runtime_error(msg); } } } catch (CException& e) { string msg("Error in form input:\n"); msg += e.GetMsg(); NcbiMessageBox(msg); return; } catch (std::exception& e) { string msg("Error in form input:\n"); msg += e.what(); NcbiMessageBox(msg); return; } CPluginUtils::CallPlugin(*m_Msg); CDialog::x_OnOK();}void CPluginDlg::x_OnPluginChanged(){ m_Form->Clear(); m_Msg.Reset(); m_TitleStr = m_TitleBase; m_Window->label(m_TitleStr.c_str()); m_StatusBar->SetMessage("Please select an option"); int idx = m_PluginList->value(); if (idx == 0) { return; } --idx; _ASSERT(idx < m_Handles.size()); CPluginHandle handle = m_Handles[idx]; if ( !handle ) { return; } m_TitleStr += " - " + handle.GetMenuItem(); m_Window->label(m_TitleStr.c_str()); m_StatusBar->SetMessage(handle.GetToolTip()); if (m_DataCmd != eDataCommand_no_command) { m_Msg.Reset(handle.CreateMessage(m_DataCmd)); } else if (m_AlgoCmd != eAlgoCommand_no_command) { m_Msg.Reset(handle.CreateMessage(m_AlgoCmd)); } else if (m_ViewCmd != eViewCommand_no_command) { m_Msg.Reset(handle.CreateMessage(m_ViewCmd)); } else { return; } if (m_Msg) { m_Form->SetArgs(m_Msg->SetRequest().SetCommand().SetArgs(), m_Objs); m_Form->redraw(); }}END_NCBI_SCOPE/* * =========================================================================== * $Log: plugin_dlg.cpp,v $ * Revision 1000.0 2004/06/01 21:17:18 gouriano * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.1 * * Revision 1.1 2004/06/01 18:04:44 dicuccio * Initial revision. Lots of changes: added gui_project ASN.1 project, added new * plugin arg form (separate widget), added plugin selector dialog * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?