00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef SESSIONEXPLORER_H 00011 #define SESSIONEXPLORER_H 00012 00013 #include "DockWindow.h" 00014 #include "ModelServices.h" 00015 #include "Service.h" 00016 #include "EnumWrapper.h" 00017 00018 #include <vector> 00019 00020 class SessionItem; 00021 00022 /** 00023 * \ingroup ServiceModule 00024 * A window that displays all items in the current session. 00025 * 00026 * The session explorer window contains a tab widget that contains tree views 00027 * displaying all session items in the current session. The available views 00028 * in the window are defined by the SessionExplorer::ItemViewType enum. 00029 * 00030 * The tree view contained on each tab shows the relationship of session items 00031 * to other session items. The contents of each tree view are updated 00032 * automatically. 00033 * 00034 * This subclass of Subject will notify upon the following conditions: 00035 * - The user changes the active tab in the window, or the setItemViewType() 00036 * method is called. 00037 * - The context menu for the selected session item(s) is about to be 00038 * displayed. 00039 * - Everything else documented in DockWindow. 00040 * 00041 * @see DockWindow, SessionItem 00042 */ 00043 class SessionExplorer : public DockWindow 00044 { 00045 public: 00046 /** 00047 * Defines the various tree views displaying different types of session 00048 * items in the session explorer. 00049 * 00050 * The session explorer window contains tabs that each display a tree view 00051 * of session items. This enum defines the available views and which 00052 * session items are displayed. To change the active view, call 00053 * setItemViewType(). The user changes the active view by clicking on a 00054 * new tab in the session explorer window. 00055 */ 00056 enum ItemViewTypeEnum 00057 { 00058 WINDOW_ITEMS, /**< Displays toolbars, dock windows, and workspace 00059 windows and their contents. */ 00060 ANIMATION_ITEMS, /**< Displays all animation controllers and their 00061 animations. */ 00062 ELEMENT_ITEMS, /**< Displays data elements and their children. */ 00063 PLUGIN_ITEMS /**< Displays all modules, plug-ins, and currently 00064 running plug-in instances. */ 00065 }; 00066 00067 /** 00068 * @EnumWrapper SessionExplorer::ItemViewTypeEnum. 00069 */ 00070 typedef EnumWrapper<ItemViewTypeEnum> ItemViewType; 00071 00072 /** 00073 * Emitted with boost::any<SessionExplorer::ItemViewType> when the current 00074 * tree view tab changes in the session explorer window. 00075 * 00076 * @see setItemViewType() 00077 */ 00078 SIGNAL_METHOD(SessionExplorer, ItemViewTypeChanged) 00079 00080 /** 00081 * Emitted with boost::any<ContextMenu*> when the user right-clicks on a 00082 * session item in the window to invoke a context menu. 00083 * 00084 * This signal provides a means by which an object can be notified when a 00085 * context menu is invoked by the user clicking on an item in the session 00086 * explorer. To receive notification for when a context menu is invoked 00087 * when the user clicks on any session item, attach to the 00088 * DesktopServices::signalAboutToShowContextMenu() signal instead. 00089 * 00090 * This signal is emitted after the 00091 * DesktopServices::signalAboutToShowContextMenu() signal is emitted and 00092 * after the signalAboutToShowContextMenu() signal is emitted, but before 00093 * the context menu is shown to give attached objects a chance to add or 00094 * modify the context menu of the selected session item(s) that will be 00095 * displayed to the user. 00096 * 00097 * Objects that attach to the 00098 * DesktopServices::signalAboutToShowContextMenu() signal may also need to 00099 * attach to this signal if they are interested in the selected item(s) in 00100 * the session explorer. 00101 * 00102 * The ContextMenu pointer value is guaranteed to be non-\c NULL. 00103 * 00104 * @see \ref callingsequence "Context menu calling sequence" 00105 */ 00106 SIGNAL_METHOD(SessionExplorer, AboutToShowSessionItemContextMenu) 00107 00108 /** 00109 * Sets the current tree view tab in the session explorer window. 00110 * 00111 * @param itemView 00112 * The tree view type to display. 00113 * 00114 * @notify This method will notify signalItemViewTypeChanged() with 00115 * boost::any<SessionExplorer::ItemViewType> if the current tab 00116 * changes. 00117 */ 00118 virtual void setItemViewType(ItemViewType itemView) = 0; 00119 00120 /** 00121 * Returns the current tree view tab in the session explorer window. 00122 * 00123 * @return The tree view type on the currently displayed tab. 00124 */ 00125 virtual ItemViewType getItemViewType() const = 0; 00126 00127 /** 00128 * Sets the selected session items on the current view tab. 00129 * 00130 * @param selectedItems 00131 * The session items to select. If the vector is empty, all 00132 * session items in the current view are unselected. 00133 */ 00134 virtual void setSelectedSessionItems(const std::vector<SessionItem*>& selectedItems) = 0; 00135 00136 /** 00137 * Returns the selected session items on the current view tab. 00138 * 00139 * This is a convenience method that calls getItemViewType() and then 00140 * getSelectedSessionItems(ItemViewType). 00141 * 00142 * @return The selected session items on the current view. If the 00143 * returned vector is empty, no session items are selected. 00144 * 00145 * @see getCurrentSessionItem() 00146 */ 00147 virtual std::vector<SessionItem*> getSelectedSessionItems() const = 0; 00148 00149 /** 00150 * Returns the selected session items of a specified type on the current 00151 * view tab. 00152 * 00153 * This is a convenience method that gets all selected session items on the 00154 * current view and filters the returned items based on the specified type. 00155 * 00156 * @return The selected session items of the specified type on the current 00157 * view. If the returned vector is empty, no session items of the 00158 * specified type are selected. The pointers in the returned 00159 * vector are guaranteed to be non-\b NULL. 00160 * 00161 * @see getCurrentSessionItem() 00162 */ 00163 template<typename T> 00164 std::vector<T*> getSelectedSessionItems() const 00165 { 00166 std::vector<T*> selectedItems; 00167 00168 std::vector<SessionItem*> items = getSelectedSessionItems(); 00169 for (std::vector<SessionItem*>::iterator iter = items.begin(); iter != items.end(); ++iter) 00170 { 00171 T* pItem = model_cast<T*>(*iter); 00172 if (pItem != NULL) 00173 { 00174 selectedItems.push_back(pItem); 00175 } 00176 } 00177 00178 return selectedItems; 00179 } 00180 00181 /** 00182 * Returns the current session item on the current view tab. 00183 * 00184 * This is a convenience method that calls getItemViewType() and then 00185 * getCurrentSessionItem(ItemViewType). 00186 * 00187 * @return The current session item on the current view. \b NULL is 00188 * returned if no session item is current in the tree view. 00189 * 00190 * @see getSelectedSessionItems() 00191 */ 00192 virtual SessionItem* getCurrentSessionItem() const = 0; 00193 00194 /** 00195 * Sets the selected session items on a given view tab. 00196 * 00197 * @param itemView 00198 * The view in which to select the session items. 00199 * @param selectedItems 00200 * The session items to select. If the vector is empty, all 00201 * session items in the given view are unselected. 00202 */ 00203 virtual void setSelectedSessionItems(ItemViewType itemView, const std::vector<SessionItem*>& selectedItems) = 0; 00204 00205 /** 00206 * Returns the selected session items on a given view tab. 00207 * 00208 * This method returns the currently selected session items on the given 00209 * view tab, which may be different than the current session item. 00210 * 00211 * @param itemView 00212 * The view in which to get the selected session items. 00213 * 00214 * @return The selected session items. If the returned vector is empty, 00215 * no session items are selected on the given view tab. 00216 * 00217 * @see getCurrentSessionItem(ItemViewType) 00218 */ 00219 virtual std::vector<SessionItem*> getSelectedSessionItems(ItemViewType itemView) const = 0; 00220 00221 /** 00222 * Returns the current session item on a given view tab. 00223 * 00224 * This method returns the current session item on the given view tab, 00225 * which may be different than the selected session items. The current 00226 * item is identified in the tree view by a focus rectangle. 00227 * 00228 * @param itemView 00229 * The view in which to get the current session item. 00230 * 00231 * @return The current session item on the given view. \b NULL is 00232 * returned if no session item is current in the tree view. 00233 * 00234 * @see getSelectedSessionItems(ItemViewType) 00235 */ 00236 virtual SessionItem* getCurrentSessionItem(ItemViewType itemView) const = 0; 00237 00238 /** 00239 * Expands a given session item on the current view tab. 00240 * 00241 * This method expands the node in the tree view for the given session item 00242 * to display its children. This method does nothing if the session item 00243 * is not displayed in the current tree view or if the session item has no 00244 * child items. 00245 * 00246 * @param pItem 00247 * The session item to expand in the view. 00248 * 00249 * @see collapseSessionItem() 00250 */ 00251 virtual void expandSessionItem(SessionItem* pItem) = 0; 00252 00253 /** 00254 * Collapes a given session item on the current view tab. 00255 * 00256 * This method collapses the node in the tree view for the given session 00257 * item to hide its children. This method does nothing if the session item 00258 * is not displayed in the current tree view or if the session item has no 00259 * child items. 00260 * 00261 * @param pItem 00262 * The session item to collapse in the view. 00263 * 00264 * @see expandSessionItem() 00265 */ 00266 virtual void collapseSessionItem(SessionItem* pItem) = 0; 00267 00268 /** 00269 * Queries whether a given session item is expanded on the current view 00270 * tab. 00271 * 00272 * This method collapses the node in the tree view for the given session 00273 * item to hide its children. This method does nothing if the session item 00274 * is not displayed in the current tree view or if the session item has no 00275 * child items. 00276 * 00277 * @param pItem 00278 * The session item in the view to query for its expanded state. 00279 * 00280 * @return Returns \b true if the given session item is expanded in the 00281 * current view and its children are displayed; otherwise returns 00282 * \b false. 00283 * 00284 * @see expandSessionItem(), collapseSessionItem() 00285 */ 00286 virtual bool isSessionItemExpanded(SessionItem* pItem) const = 0; 00287 00288 /** 00289 * @copydoc SessionItem::getContextMenuActions() 00290 * 00291 * @default The default implementation returns the context menu actions 00292 * listed \ref sessionexplorer "here". If the user has clicked on 00293 * a session item in the current tree view, the actions returned 00294 * by this method are not displayed, but rather the actions for 00295 * the selected session item(s) are displayed instead. These 00296 * default actions can be removed or additional actions can be 00297 * added by attaching to the signalAboutToShowContextMenu() 00298 * signal. To override the default actions of the selected 00299 * session item(s) attach to the 00300 * signalAboutToShowSessionItemContextMenu() signal instead. 00301 */ 00302 virtual std::list<ContextMenuAction> getContextMenuActions() const = 0; 00303 00304 protected: 00305 /** 00306 * The session explorer cannot be destroyed directly. It is destroyed 00307 * automatically on application shutdown. 00308 */ 00309 virtual ~SessionExplorer() {} 00310 }; 00311 00312 #endif