1
//////////////////////////////////////////////////////////////////////////////
2
//////////////////////////////////////////////////////////////////////////////
4
// copyright : (C) 2008 by Eran Ifrah
5
// file name : imanager.h
7
// -------------------------------------------------------------------------
10
// / __ \ | | | | (_) |
11
// | / \/ ___ __| | ___| | _| |_ ___
12
// | | / _ \ / _ |/ _ \ | | | __/ _ )
13
// | \__/\ (_) | (_| | __/ |___| | || __/
14
// \____/\___/ \__,_|\___\_____/_|\__\___|
18
// This program is free software; you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation; either version 2 of the License, or
21
// (at your option) any later version.
23
//////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////////////////////////////////////////////////
30
#include "iconfigtool.h"
31
#include "ikeyboard.h"
32
#include "wx/treectrl.h"
33
#include "custom_notebook.h"
34
#include "optionsconfig.h"
35
#include "queuecommand.h"
39
class EnvironmentConfig;
44
class BuildSettingsConfig;
47
//--------------------------
49
//--------------------------
54
wxFileName m_fileName; //< FileName where available (FileView & File Explorer trees)
55
wxString m_text; //< Tree item text (all)
56
int m_itemType; //< For FileView items (FileView only)
59
//---------------------------
60
// List of availabla trees
61
//---------------------------
67
//------------------------------------------------------------------
68
// Defines the interface of the manager
69
//------------------------------------------------------------------
75
* @brief every plugin holds an instance of this class.
76
* You should use this class to interact with CodeLite
82
virtual ~IManager() {}
84
//return the current editor
86
* @brief return the active editor
87
* @return pointer to the current editor, or NULL incase the active editor is not of type LEditor or no active editor open
89
virtual IEditor *GetActiveEditor() = 0;
91
* @brief open file and make it the active editor
92
* @param fileName the file to open - use absolute path
93
* @param projectName project to associate this file - can be wxEmptyString
94
* @param lineno if lineno is not wxNOT_FOUD, the caret will placed on this line number
95
* @return true if file opened
97
virtual bool OpenFile(const wxString &fileName, const wxString &projectName = wxEmptyString, int lineno = wxNOT_FOUND) = 0;
100
* @brief Open file using browsing record
101
* @param rec browsing record
102
* @return true on success false otherwise
104
virtual bool OpenFile(const BrowseRecord &rec) = 0;
107
* @brief return a pointer to the configuration tool
110
virtual IConfigTool *GetConfigTool() = 0;
113
* @brief return TreeItemInfo for the selected tree item
114
* @param type the tree we are interested in
118
virtual TreeItemInfo GetSelectedTreeItemInfo(TreeType type) = 0;
120
* @brief returns a pointer to wxTreeCtrl by type
121
* @param type the type of tree
124
virtual wxTreeCtrl *GetTree(TreeType type) = 0;
126
* @brief return a pointer to the workspace pane notebook (the one with the 'workspace' title)
127
* @return pointer to Notebook
130
virtual Notebook *GetWorkspacePaneNotebook() = 0;
132
* @brief return a pointer to the output pane notebook (the one with the 'output' title)
133
* @return pointer to Notebook
136
virtual Notebook *GetOutputPaneNotebook() = 0;
138
* @brief return the startup directory of CodeLite which is also the base directory for searching installation files
139
* @return a full path to the startup directory
141
virtual wxString GetStartupDirectory() const = 0;
144
* @brief return the installation directory of codelite
145
* @return a full path to codelite installation
147
virtual wxString GetInstallDirectory() const = 0;
150
* @brief add project to the workspace
151
* @param path full path to the project to add
153
virtual void AddProject(const wxString & path) = 0;
156
* @brief return true of a workspace is already open
158
virtual bool IsWorkspaceOpen() const = 0;
161
* @brief return an instance to the tags manager - which allows access to CodeLite CodeCompletion API
162
* @return a pointer to the tags manager
165
virtual TagsManager *GetTagsManager() = 0;
167
* @brief return a pointer to the workspace manager
170
virtual Workspace *GetWorkspace() = 0;
173
* @brief add files to a virtual folder in the project
174
* @param item a tree item which represents the tree item of the virtual folder
175
* @param paths an array of files to add
176
* @return true on sucesss, false otherwise
178
virtual bool AddFilesToVirtualFolder(wxTreeItemId &item, wxArrayString &paths) = 0;
181
* @brief add files to a virtual folder in the project
182
* @param vdFullPath virtual directory full path in the form of <project>:vd1:vd2:...:vdN
183
* @param paths an array of files to add
184
* @return true on sucesss, false otherwise
186
virtual bool AddFilesToVirtualFolder(const wxString &vdFullPath, wxArrayString &paths) = 0;
189
* @brief create virtual folder to parentPath
190
* @param parentPath parent virtual directory full path in the form of <project>:vd1:vd2:...:vdN which must exist
191
* @param vdName child VD name
192
* @return true on success, false otherwise
194
virtual bool CreateVirtualDirectory(const wxString& parentPath, const wxString& vdName) = 0;
197
* @brief return the size of the icons used by CodeLite
200
virtual int GetToolbarIconSize() = 0;
203
* @brief return true if toobars are allowed for plugins. This is useful for the Mac port of
204
* codelite. On Mac, only single toolbar is allowed in the application (otherwise, the application
205
* does not feet into the environment)
206
* @return true if plugin can create a toolbar, false otherwise
208
virtual bool AllowToolbar() = 0;
211
* @brief return a pointer to the docking manager (wxAUI)
213
virtual wxAuiManager* GetDockingManager() = 0;
215
* @brief return a pointer to the environment manager
216
* @sa EnvironmentConfig
218
virtual EnvironmentConfig *GetEnv() = 0;
220
* @brief return a pointer to the job queue manager
221
* @return job queue manager
223
virtual JobQueue *GetJobQueue() = 0;
226
* @brief return the project execution command as set in the project's settings
227
* @param projectName the project
228
* @param wd starting dirctory
229
* @return the execution command or wxEmptyString if the project does not exist
231
virtual wxString GetProjectExecutionCommand(const wxString &projectName, wxString &wd) = 0;
234
* @brief return the application
236
virtual wxApp *GetTheApp() = 0;
239
* @brief reload the current workspace, this function does not do anything if a workspace is not opened
241
virtual void ReloadWorkspace() = 0;
244
* @brief search for loaded plugin by its name, if the plugin is loaded returns its pointer
245
* @param pluginName plugin to search
246
* @return pointer to the plugin or NULL if it is not loaded
248
virtual IPlugin *GetPlugin(const wxString &pluginName) = 0;
251
* @brief output window for receiving async cmd events
253
virtual wxEvtHandler *GetOutputWindow() = 0;
256
* @brief save all modified files
258
virtual bool SaveAll() = 0;
261
* @brief return the keyboard manager
263
virtual IKeyboard *GetKeyboardManager() = 0;
266
* @brief return the editor's settings object
268
virtual OptionsConfigPtr GetEditorSettings() = 0;
271
* @brief search for pattern in active editor and select name if found
273
virtual void FindAndSelect(const wxString& pattern, const wxString& name) = 0;
276
* @brief return tag at caret in active editor (if ambiguous, user will get a selection dialog)
277
* @param scoped whether to do scope-aware lookup
278
* @param impl whether to return declaration (false) or definition (true)
279
* @return the found tag or NULL
281
virtual TagEntryPtr GetTagAtCaret(bool scoped, bool impl) = 0;
284
* @brief show a (short) message in the status bar
286
virtual void SetStatusMessage(const wxString &msg, int col, int id) = 0;
289
* @brief start processing commands from the queue
291
virtual void ProcessCommandQueue() = 0;
294
* @brief place a command on the internal queue of codelite to be processed. Each command is executed on
295
* a separated process. The queue will not start processing, until a call to ProcessCommandQueue() is issued
296
* @param cmd command to process
298
virtual void PushQueueCommand(const QueueCommand &cmd) = 0;
301
* @brief stop the current process execution and clear all commands from the queue
303
virtual void StopAndClearQueue() = 0;
306
* @brief return the project name of a file
307
* @param fullPathFileName file to search
308
* @return project name or wxEmptyString if the search failed
310
virtual wxString GetProjectNameByFile( const wxString &fullPathFileName ) = 0;
313
* @brief accessor to singleton object in the application
315
virtual BuildManager *GetBuildManager() = 0;
318
* @brief accessor to singleton object in the application
320
virtual BuildSettingsConfig *GetBuildSettingsConfigManager() = 0;
323
* @brief return the singleton object of the navigation manager
325
virtual NavMgr *GetNavigationMgr() = 0;
327
void SetStatusMessage(const wxString &msg, int id)
328
{ SetStatusMessage(msg, 0, id); }
331
* @brief close the named page in the mainbook
333
virtual bool ClosePage(const wxString &text) = 0;
336
* @brief return named window in mainbook
338
virtual wxWindow *FindPage(const wxString &text) = 0;
341
* @brief add a page to the mainbook
343
virtual bool AddPage(wxWindow *win, const wxString &text, const wxBitmap &bmp = wxNullBitmap, bool selected = false) = 0;
346
* @brief select a window in mainbook
348
virtual bool SelectPage(wxWindow *win) = 0;
352
class PluginStatusMessage
358
PluginStatusMessage(IManager *mgr, const wxString &msg, int col, int id)
362
{ mgr->SetStatusMessage(msg, col, id); }
363
PluginStatusMessage(IManager *mgr, const wxString &msg, int id)
367
{ mgr->SetStatusMessage(msg, 0, id); }
368
~PluginStatusMessage()
369
{ m_mgr->SetStatusMessage(wxEmptyString, m_col, m_id); }
373
class PluginBusyMessage : public PluginStatusMessage, public wxBusyCursor
376
PluginBusyMessage(IManager *mgr, const wxString &msg, int col, int id)
377
: PluginStatusMessage(mgr, msg, col, id)
379
PluginBusyMessage(IManager *mgr, const wxString &msg, int id)
380
: PluginStatusMessage(mgr, msg, id)