NCBI C++ ToolKit
ui_tool_manager.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_FRAMEWORK___UI_TOOL_MANAGER__HPP
2 #define GUI_FRAMEWORK___UI_TOOL_MANAGER__HPP
3 
4 /* $Id: ui_tool_manager.hpp 38477 2017-05-15 21:10:59Z evgeniev $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 
37 #include <gui/gui_export.h>
38 
39 #include <gui/objutils/objects.hpp>
40 
41 #include <gui/utils/ui_object.hpp>
42 
43 class wxPanel;
44 class wxWindow;
45 
46 
48 
49 class IAppTask;
50 class IServiceLocator;
51 class IWizardPage;
52 class IExecuteUnit;
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 // The purpose of IUIToolManager is to manage UI associated with a tool
56 // (algorithm, loader, exporter) in a specialized wizard-like dialog (or other
57 // similar UI component).
58 // The dialog serves as a host for the Tool Manager and provides basic support
59 // for creating wizard-like user interfaces. It is assumed that Tool Manager
60 // works as a state machine with states corresponding to different steps in the
61 // process of gathering user input. For every step a UI panel can be displayed
62 // in the dialog, the tool manager is responsible for providing the panel.
63 // Pressing “Back”, Forward” and “Finish” buttons leads to a transition from one
64 // state to another. When transition is peformed the data entered by the user is
65 // extracted from the current panel and validated; the destinaton state may
66 // depend on the user input.
67 // In the end the Tool Manager produces an IAppTask object representing the
68 // algorithm, this object shall contain all necessary input arguments gathered
69 // in the process. The task object then can be executed using Application Task Manager.
70 
71 // Classes implementing IUIToolManager shall be CIRef-compatible. The easiest
72 // way to achieve this is to derive your implementation from CObject.
73 
75 {
76 public:
77  // enumerates possible transitions, corresponding to "Back" and "Next" buttons
78  enum EAction {
79  eBack = 0,
81  eSkip
82  };
83 
84  /// Returns the object describing this tool (UI meta data).
85  virtual const IUIObject& GetDescriptor() const = 0;
86 
87  /// Sets / unsets Service Locator. Tool Manager can use the locator
88  /// to obtain the services necessary services.
89  virtual void SetServiceLocator(IServiceLocator* srv_locator) = 0;
90 
91  virtual void SetParentWindow(wxWindow* parent) = 0;
92 
93  /// Initializes the Manager before using it in UI. This function shall reset
94  /// Internal state of the tool.
95  virtual void InitUI() = 0;
96 
97  /// CleanUI() is called after the host finished using the manager. This function
98  /// shall free resources associated with the session and reset internal state.
99  virtual void CleanUI() = 0;
100 
101  /// Return the panel corresponding to the current state of Tool Manager.
102  virtual wxPanel* GetCurrentPanel() = 0;
103 
104  /// Return the panel that occupies max size on display, to calculate dialog window size
105  virtual wxPanel* GetMaxPanel() { return 0; }
106 
107  /// True if Tool Manager has reached its final state, i.e. the last page
108  /// (panel) in the sequence is displayed and "Finish" button is shown. The
109  /// framework calls this function to decide whether “Finish” or “Next”
110  /// button needs to be shown.
111  virtual bool IsFinalState() = 0;
112 
113  /// Manager goes into "Complete" state when "Finish" button is pressed and
114  /// all input data is gatherred and validated. Typically this is the last
115  /// state after Final state. This state does not have an associated UI panel.
116  /// When manager reaches the “Completed” state the framework hides the dialog
117  /// and calls GetTask() function.
118  virtual bool IsCompletedState() = 0;
119 
120  /// Indicates whether given transition is possible in the current state.
121  virtual bool CanDo(EAction action) = 0;
122 
123  /// Performs transition if possible and returns true, otherwise the function
124  /// shall warn the user about the problem preventing the transition
125  /// (such as insufficient or invalid input) and return false.
126  /// Typically this function would take user input from the current panel,
127  /// validate the input and go to the next state creating new UI panel if needed.
128  virtual bool DoTransition(EAction action) = 0;
129 
130  /// If a transition fails, it may make sense to switch to a different tool manger
131  /// When a tool manager identifies a more appropriate manager for a task, it
132  /// returns it here, otherwise NULL
134 
135  /// Once parameters are gathered and validated this function is called
136  /// to produce the final Task object that will be executed to do the actual
137  /// computational work.
138  virtual IAppTask* GetTask() = 0;
139 
140  virtual IExecuteUnit* GetExecuteUnit() { return nullptr; }
141 
142  /// Returns first options page (if any) of the tool to be shown in wizard dialog
143  virtual IWizardPage* GetFirstPage() { return 0; }
144  /// Returns page for tool options (long wizard path via "Options" button)
145  virtual IWizardPage* GetOptionsPage() { return 0; }
146  /// Sets a wizard page which should show before the first page of the tool
147  virtual void SetPrevPage(IWizardPage*) {}
148  /// Sets a wizard page which should show after the last page of the tool
149  virtual void SetNextPage(IWizardPage*) {}
150 
151  /// Restores the default options for the current panel
152  virtual void RestoreDefaults() {}
153 
154  virtual void ResetState() {}
155 
156  virtual bool UsesSingleOMScope() { return true; }
157 
158  virtual ~IUIToolManager() {};
159 };
160 
161 
162 ///////////////////////////////////////////////////////////////////////////////
163 /// IUIAlgoToolManager is a IUIToolManager that represents an algorithmic tool.
164 ///
165 /// TODO - consider placing this interface in a separate file
167 {
168 public:
169  /// returns the name for the ToolCategory to which the tool belongs.
170  /// Tools are shown in in UI groupped by Categories.
171  virtual string GetCategory() = 0;
172 
173  /// sets input objects that can be used as arguments for the tool.
174  /// the manager can save the pointer, it will remain valid until
175  /// CleanUI() is called.
176  virtual string SetInputObjects(const vector<TConstScopedObjects>& input) = 0;
177  //virtual bool IsMultiScopeInputAccepted() const { return false; }
178 
179  virtual bool CanQuickLaunch() const = 0;
180  virtual IAppTask* QuickLaunch() = 0;
181 };
182 
183 
184 ///////////////////////////////////////////////////////////////////////////////
185 /// This Extension Point allows external components to add new algorithmic
186 /// tools.
187 /// The Extensions shall implement IUIAlgoToolManager interface.
188 
189 /// Extension Point ID for Tool Managers implementing IUIAlgoToolManager interface
190 #define EXT_POINT__UI_ALGO_TOOL_MANAGER "ui_algo_tool_manager"
191 
192 
194 
195 
196 #endif // GUI_FRAMEWORK___UI_TOOL_MANAGER__HPP
197 
IAppTask.
Definition: app_task.hpp:83
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IUIAlgoToolManager is a IUIToolManager that represents an algorithmic tool.
virtual IAppTask * QuickLaunch()=0
virtual string SetInputObjects(const vector< TConstScopedObjects > &input)=0
sets input objects that can be used as arguments for the tool.
virtual string GetCategory()=0
returns the name for the ToolCategory to which the tool belongs.
virtual bool CanQuickLaunch() const =0
IUIObject - object that provides basic properties often required in a UI object.
Definition: ui_object.hpp:63
virtual bool UsesSingleOMScope()
virtual void SetServiceLocator(IServiceLocator *srv_locator)=0
Sets / unsets Service Locator.
virtual void ResetState()
virtual bool CanDo(EAction action)=0
Indicates whether given transition is possible in the current state.
virtual bool DoTransition(EAction action)=0
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
virtual bool IsFinalState()=0
True if Tool Manager has reached its final state, i.e.
virtual void RestoreDefaults()
Restores the default options for the current panel.
virtual const IUIObject & GetDescriptor() const =0
Returns the object describing this tool (UI meta data).
virtual wxPanel * GetCurrentPanel()=0
Return the panel corresponding to the current state of Tool Manager.
virtual IWizardPage * GetOptionsPage()
Returns page for tool options (long wizard path via "Options" button)
virtual IWizardPage * GetFirstPage()
Returns first options page (if any) of the tool to be shown in wizard dialog.
virtual IUIToolManager * GetAlternateToolManager()
If a transition fails, it may make sense to switch to a different tool manger When a tool manager ide...
virtual IExecuteUnit * GetExecuteUnit()
virtual void CleanUI()=0
CleanUI() is called after the host finished using the manager.
virtual ~IUIToolManager()
virtual wxPanel * GetMaxPanel()
Return the panel that occupies max size on display, to calculate dialog window size.
virtual bool IsCompletedState()=0
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
virtual void SetParentWindow(wxWindow *parent)=0
virtual IAppTask * GetTask()=0
Once parameters are gathered and validated this function is called to produce the final Task object t...
virtual void SetNextPage(IWizardPage *)
Sets a wizard page which should show after the last page of the tool.
virtual void SetPrevPage(IWizardPage *)
Sets a wizard page which should show before the first page of the tool.
virtual void InitUI()=0
Initializes the Manager before using it in UI.
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUICORE_EXPORT
Definition: gui_export.h:508
@ eSkip
Unicode to be skipped in translation. Usually it is combined mark.
Definition: unicode.hpp:52
Defines to provide correct exporting from DLLs in Windows.
static int input()
Modified on Fri Sep 20 14:57:05 2024 by modify_doxy.py rev. 669887