61 #include <wx/msgdlg.h>
62 #include <wx/filename.h>
87 LOG_POST(
Info <<
"Finished initializing Project Service");
101 LOG_POST(
Info <<
"Finished shutting down Project Service");
117 static const char*
kMRUTag =
"MRUProjectsWorkspaces";
129 vector<string> values;
136 CTime time(it->first);
140 values.push_back(s_time);
141 values.push_back(filename);
161 vector<string> values;
167 for(
size_t i = 0;
i + 1 < values.size() ; ) {
169 string s_time = values[
i++];
185 "Cannot create a new Workspace - a workspace already exists");
195 static unsigned int counter = 1;
196 string workspace_title;
199 if (!wxFileName::FileExists(
str +
wxT(
".gbw"))) {
200 workspace_title =
str.ToAscii();
207 m_Workspace->SetDescr().SetCreateDate(create_time);
208 m_Workspace->SetDescr().SetModifiedDate(create_time);
209 m_Workspace->SetWorkspace().SetInfo().SetTitle(workspace_title);
210 m_Workspace->SetWorkspace().SetInfo().SetCreateDate(create_time);
235 vector<TProjectId> projIds;
243 }
else if (doc->IsLoaded()) {
247 projIds.push_back(doc->GetId());
250 for (
auto id : projIds) {
262 static const string kErr(
"Error saving workspace");
264 static const string INVALID_WORKSPACE =
265 "Invalid workspace! The Workspace contains projects "
266 "with empty filenames.";
274 "Cannot save workspace - it does not exists.");
279 if (it->GetFilename().empty()) {
298 catch (std::exception& e) {
301 wxMessageBox(
ToWxString(err_msg),
wxT(
"Error saving workspace"),
324 for (
size_t i = 0;
i <
n; ++
i) {
339 LOG_POST(
Info <<
"CProjectService::x_LoadWorkspace(): loaded workspace: "
345 LOG_POST(
Error <<
"CProjectService::x_LoadWorkspace(): workspace: "
347 <<
": error reading: " << e.
GetMsg());
363 doc->Assign(*handle);
392 if (projectTreePanel)
408 const objects::CUser_object* params,
419 const objects::CUser_object* params,
456 int trace_limit = 10;
464 if( ix++ == trace_limit ){
469 const CObject* obj = it->object.GetPointer();
470 CScope* scope =
const_cast<CScope*
>(it->scope.GetPointer());
475 catch (
const exception&) {
476 arg_label =
"EXCEPTION";
484 ok = prj_view->InitView(
objects, params);
513 "Created view is not a Project View");
520 if (viewType.empty())
532 if (
objects.size() == 1 && &mainObject ==
objects.front().object.GetPointer()) {
551 if (
objects.size() == 1 && &mainObject ==
objects.front().object.GetPointer())
585 if (
objects.empty())
return view;
593 if (widgetFactory == 0) {
626 for(
size_t i = 0;
i < views.size();
i++ ) {
638 bool reset_hist_async)
689 vector<TProjectId>& ids)
699 CScope* scope = it->scope;
700 if (!scope)
continue;
716 if (projectTreePanel)
724 size_t id = doc.GetId();
746 if (it->GetObject() == &object) {
User-defined methods of the data storage class.
User-defined methods of the data storage class.
pair< CFormatGuess::EFormat, ESerialDataFormat > TSerialTypePair
static const TSerialTypePair sc_DataTypes[]
User-defined methods of the data storage class.
User-defined methods of the data storage class.
void UnloadProject(bool reset_hist_async=true)
CRegistryWriteView GetWriteView(const string §ion)
get a read-write view at a particular level.
static CGuiRegistry & GetInstance()
access the application-wide singleton
CRegistryReadView GetReadView(const string §ion) const
get a read-only view at a particular level.
CProjectServiceException.
void x_CreateDocuments(objects::CWorkspaceFolder &folder)
CRef< objects::CGBWorkspace > m_Workspace
the only Workspace
virtual void LoadSettings()
void x_UpdateWorkspaceLabel()
CIRef< IProjectView > ShowView(const string &viewName, FWindowFactory widgetFactory, TConstScopedObjects &objects, bool bFloat)
virtual void SetRegistryPath(const string &path)
string m_RegPath
path in the Registry to our settings
void CreateNewWorkspace()
virtual void InitService()
void GetObjProjects(TConstScopedObjects &objects, vector< TProjectId > &ids)
bool SaveWorkspace()
Save a workspace.
void RemoveAllProjectViews()
CIRef< IProjectView > AddProjectView(const string &view_name, SConstScopedObject &object, const objects::CUser_object *params, bool bFloat=false)
void RemoveProject(CGBDocument &doc)
virtual void SaveSettings() const
void ActivateProjectView(IProjectView *projectView)
CProjectTreePanel * GetProjectTreePanel()
CRef< objects::CGBWorkspace > x_LoadWorkspace(const wxString &filename)
virtual void SetServiceLocator(IServiceLocator *locator)
void ResetWorkspace()
release the current workspace and all its contents TODO - review
const TMRUPathList & GetProjectWorkspaceMRUList() const
get MRU Projects and Workspaces
IProjectView * FindView(const CObject &mainObject, const string &viewType)
void RemoveProjectView(IProjectView &view)
removes the view from View manager Service and disconnects it from the project
CRef< objects::CGBWorkspace > GetGBWorkspace()
TMRUPathList m_ProjectWorkspaceMRUList
filename for the workspace
void AddProject(CGBDocument &doc)
void AddToProjectWorkspaceMRUList(const wxString &path)
void OnViewAttached(IProjectView *view)
called by CDocument when IProjectView is attached/detached to it
void x_RemoveView(IViewManagerService &view_srv, IProjectView &view, bool reset_hist_async=true)
void FindViews(vector< CIRef< IProjectView > > &projectViews, const CObject &mainObject)
const objects::CProjectItem * GetProjectItem(const CObject &object, objects::CScope &scope)
void x_ReloadProjectTreeView()
IServiceLocator * m_ServiceLocator
virtual ~CProjectService()
virtual void ShutDownService()
CProjectTreePanel - a window that represents Project View.
void ProjectRemoved(size_t id)
void UpdateWorkspaceLabel()
void ProjectAdded(CGBDocument &doc)
CProjectTreeView - a system view that displays Project Tree.
virtual wxWindow * GetWindow()
returns a pointer to the wxWindow representing the client
CProjectViewBase - default implementation of IProjectView, the base class for CProjectView and CProje...
virtual void RefreshViewWindow()
class CRegistryReadView provides a nested hierarchical view at a particular key.
void GetStringVec(const string &key, vector< string > &val) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
Root class for all serialization exceptions.
Base class for all serializable objects.
static CIRef< IProjectView > CreateView(const string &viewName, FWindowFactory widgetFactory, IServiceLocator *serviceLocator, TConstScopedObjects &objects, ISimpleProjectViewCmdHandler *cmdHandler=0, bool bFloat=false)
const TTimeToTMap & GetMap() const
void Add(T elem, time_t time=0)
Template class for iteration on objects of class C (non-medifiable version)
Template class for iteration on objects of class C.
@ eViewAttached
general data update notification
CViewTypeDescriptor - holds description of a view type.
class IProjectView defines the abstract interface for views observing projects.
virtual TProjectId GetProjectId() const =0
virtual void SetAsyncDestroy(bool reset_hist_async)=0
Set async destruction mode.
virtual void DestroyView()=0
disconnects view from the project and associated data
virtual string GetLabel(ELabelType type) const =0
returns name of the plug-in created this view (view class name)
virtual void GetMainObject(TConstScopedObjects &objects) const =0
Adds the main data objects represented by the client to "objects".
IServiceLocator - an abstract mechanism for locating services.
IViewManagerService IViewManagerService manages views in Workbench.
IView - represents a standard visual part of Workbench UI.
IWClient - abstract Window Manager client.
virtual void SetFingerprint(const string &)
IWindowManagerService Window Manager Service provides access to Window Manager functionality.
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator end() const
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const string & GetMsg(void) const
Get message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
void Info(CExceptionArgs_Base &args)
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
virtual void AddToWorkbench(IView &view, bool bFloat=false)=0
adds view to Workbench and connects to the services the view must be already initialized
vector< CIRef< IView > > TViews
virtual void GetViews(TViews &views)=0
get all registered views
virtual void RemoveFromWorkbench(IView &view)=0
disconnects view from services and removes from the Workbench
virtual CIRef< IView > CreateViewInstance(const string &type_ui_name)=0
create a view instance of the specified type
virtual void ActivateClient(IWMClient &client)=0
makes client visible and focused
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
void NcbiErrorBox(const string &message, const string &title="Error")
specialized Message Box function for reporting critical errors
virtual const string & GetLabel() const
vector< SConstScopedObject > TConstScopedObjects
virtual bool Send(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Sends an event synchronously.
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
ESerialDataFormat
Data file format.
@ eSerial_AsnText
ASN.1 text.
@ eSerial_AsnBinary
ASN.1 binary.
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
CTime & ToLocalTime(void)
Convert the time into local time.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
time_t GetTimeT(void) const
Get time in time_t format.
static CTimeFormat GetPredefined(EPredefined fmt, TFlags flags=fDefault)
Get predefined format.
@ eCurrent
Use current time. See also CCurrentTime.
@ eISO8601_DateTimeSec
Y-M-DTh:m:s (eg 1997-07-16T19:20:30)
const string & GetName(void) const
Get name of this type.
TProjects & SetProjects(void)
Assign a value to Projects data member.
TFolders & SetFolders(void)
Assign a value to Folders data member.
list< CRef< CGBProjectHandle > > TProjects
list< CRef< CWorkspaceFolder > > TFolders
std::istream & in(std::istream &in_, double &x_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
void sAssertMainThread(const char *err_msg)
static const char * kMRUTag
static CNamedPipeClient * client
#define REPORT_USAGE(event, args)
Convenience macro to log usage statisitics.
static const char * type_name(CS_INT value)
wxString ToWxString(const string &s)
wxString FnToWxString(const string &s)
string FnToStdString(const wxString &s)