From: asl Date: Fri, 20 Nov 2009 14:58:28 +0000 (+0000) Subject: persistence implementation X-Git-Tag: PHASE_17_Part1_V1~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a79c954feb701b50b0ec0e5d63e03da644510540;p=modules%2Fkernel.git persistence implementation --- diff --git a/src/Makefile.am b/src/Makefile.am index ba83ba54b..6cf47e778 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,9 +47,9 @@ SUBDIR_CORBA = \ Launcher \ LifeCycleCORBA \ LifeCycleCORBA_SWIG \ + TOOLSDS \ Notebook \ SALOMEDSClient \ - TOOLSDS \ SALOMEDSImpl \ SALOMEDS \ ModuleGenerator \ diff --git a/src/Notebook/Makefile.am b/src/Notebook/Makefile.am index 36b4a145b..5db33dd75 100644 --- a/src/Notebook/Makefile.am +++ b/src/Notebook/Makefile.am @@ -34,6 +34,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS = \ SALOME_Parameter.hxx \ SALOME_Notebook.hxx \ + SALOME_NotebookDriver.hxx \ SALOME_Eval.hxx \ SALOME_EvalExpr.hxx \ SALOME_EvalParser.hxx \ @@ -55,11 +56,12 @@ COMMON_CPPFLAGS = \ -I$(srcdir)/../SALOMELocalTrace \ -I$(srcdir)/../Basics \ -I$(srcdir)/../Utils \ + -I$(srcdir)/../TOOLSDS \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ # This local variable defines the list of dependant libraries common to all target in this package. -COMMON_LIBS = +COMMON_LIBS = ../TOOLSDS/libTOOLSDS.la #LDFLAGS+= -lSalomeGenericObj -lSalomeLifeCycleCORBA @@ -73,6 +75,7 @@ lib_LTLIBRARIES = libSalomeNotebook.la libSalomeNotebook_la_SOURCES = \ SALOME_Parameter.cxx \ SALOME_Notebook.cxx \ + SALOME_NotebookDriver.cxx \ SALOME_EvalExpr.cxx \ SALOME_EvalParser.cxx \ SALOME_EvalSet.cxx \ diff --git a/src/Notebook/SALOME_Notebook.cxx b/src/Notebook/SALOME_Notebook.cxx index ddd36aa80..592eee847 100644 --- a/src/Notebook/SALOME_Notebook.cxx +++ b/src/Notebook/SALOME_Notebook.cxx @@ -27,7 +27,8 @@ #include #include -SALOME_Notebook::SALOME_Notebook( SALOMEDS::Study_ptr theStudy ) +SALOME_Notebook::SALOME_Notebook( PortableServer::POA_ptr thePOA, SALOMEDS::Study_ptr theStudy ) +: SALOME::GenericObj_i( thePOA ) { myStudy = SALOMEDS::Study::_duplicate( theStudy ); } @@ -50,7 +51,7 @@ void SALOME_Notebook::ClearDependencies( SALOME::ParameterizedObject_ptr theObj void SALOME_Notebook::SetToUpdate( SALOME::ParameterizedObject_ptr theObj ) { - printf( "SetToUpdate: %s\n", GetKey( theObj ).c_str() ); + //printf( "SetToUpdate: %s\n", GetKey( theObj ).c_str() ); SALOME::Parameter_ptr aParam = SALOME::Parameter::_narrow( theObj ); if( !CORBA::is_nil( aParam ) ) @@ -93,20 +94,22 @@ void SALOME_Notebook::SetToUpdate( SALOME::ParameterizedObject_ptr theObj ) *uit = tmp; } + /* uit = myToUpdate.begin(); ulast = myToUpdate.end(); for( ; uit!=ulast; uit++ ) printf( "To update: %s\n", (*uit).key().c_str() ); + */ } void SALOME_Notebook::Update() { - printf( "Update\n" ); + //printf( "Update\n" ); std::list< KeyHelper > aPostponedUpdate; std::list::const_iterator it = myToUpdate.begin(), last = myToUpdate.end(); for( ; it!=last; it++ ) { std::string aKey = (*it).key(); - printf( "key = %s\n", aKey.c_str() ); + //printf( "key = %s\n", aKey.c_str() ); SALOME::ParameterizedObject_ptr anObj = FindObject( aKey ); if( CORBA::is_nil( anObj ) ) aPostponedUpdate.push_back( *it ); @@ -139,6 +142,11 @@ void SALOME_Notebook::Remove( const char* theParamName ) myParams.erase( theParamName ); } +SALOME::StringList* SALOME_Notebook::Params() +{ + return 0; +} + SALOME::Parameter_ptr SALOME_Notebook::Param( const char* theParamName ) { //printf( "Param, name = %s\n", theParamName ); @@ -159,6 +167,9 @@ SALOME_Parameter* SALOME_Notebook::ParamPtr( const char* theParamName ) const bool SALOME_Notebook::AddParam( SALOME_Parameter* theParam ) { std::string anEntry = theParam->GetEntry(); + if( !CheckParamName( anEntry ) ) + return false; + //printf( "Add param: %s\n", anEntry.c_str() ); std::map< std::string, SALOME_Parameter* >::const_iterator it = myParams.find( anEntry ); @@ -299,3 +310,59 @@ bool SALOME_Notebook::KeyHelper::operator == ( const std::string& theKey ) const { return myKey == theKey; } + +void SALOME_Notebook::Save( const char* theFileName ) +{ + //printf( "SALOME_Notebook::Save into %s\n", theFileName ); + + FILE* aFile = fopen( theFileName, "w" ); + + fprintf( aFile, "\n\nnotebook\n" ); + + //1. Save dependencies + fprintf( aFile, "Dependencies\n" ); + std::map< std::string, std::list >::const_iterator dit = myDeps.begin(), dlast = myDeps.end(); + for( ; dit!=dlast; dit++ ) + { + fprintf( aFile, "%s -> ", dit->first.c_str() ); + std::list::const_iterator it = dit->second.begin(), last = dit->second.end(); + for( ; it!=last; it++ ) + fprintf( aFile, "%s ", it->c_str() ); + fprintf( aFile, "\n" ); + } + + //2. Save parameters + fprintf( aFile, "Parameters\n" ); + std::map< std::string, SALOME_Parameter* >::const_iterator pit = myParams.begin(), plast = myParams.end(); + for( ; pit!=plast; pit++ ) + { + fprintf( aFile, pit->second->Save().c_str() ); + fprintf( aFile, "\n" ); + } + + //3. Save update list + fprintf( aFile, "Update\n" ); + std::list< KeyHelper >::const_iterator uit = myToUpdate.begin(), ulast = myToUpdate.end(); + for( ; uit!=ulast; uit++ ) + { + fprintf( aFile, uit->key().c_str() ); + fprintf( aFile, "\n" ); + } + + fclose( aFile ); +} + +CORBA::Boolean SALOME_Notebook::Load( const char* theFileName ) +{ + return false; +} + +bool SALOME_Notebook::CheckParamName( const std::string& theParamName ) const +{ + int len = theParamName.length(); + if( len == 0 ) + return false; + + SALOME_EvalExpr anExpr( theParamName ); + return anExpr.parser()->isMonoParam(); +} diff --git a/src/Notebook/SALOME_Notebook.hxx b/src/Notebook/SALOME_Notebook.hxx index aa8c399b4..6a2c36124 100644 --- a/src/Notebook/SALOME_Notebook.hxx +++ b/src/Notebook/SALOME_Notebook.hxx @@ -39,7 +39,7 @@ class SALOME_Parameter; class SALOME_Notebook : public virtual POA_SALOME::Notebook, public virtual SALOME::GenericObj_i { public: - SALOME_Notebook( SALOMEDS::Study_ptr theStudy ); + SALOME_Notebook( PortableServer::POA_ptr thePOA, SALOMEDS::Study_ptr theStudy ); virtual CORBA::Boolean AddDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef ); virtual void RemoveDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef ); @@ -52,6 +52,10 @@ public: virtual CORBA::Boolean AddValue( const char* theName, CORBA::Double theValue ); virtual void Remove( const char* theParamName ); virtual SALOME::Parameter_ptr Param( const char* theParamName ); + virtual SALOME::StringList* Params(); + + virtual void Save( const char* theFileName ); + virtual CORBA::Boolean Load( const char* theFileName ); SALOME_Parameter* ParamPtr( const char* theParamName ) const; @@ -60,6 +64,7 @@ protected: bool AddDependencies( SALOME_Parameter* theParam ); bool AddDependency( const std::string& theObjKey, const std::string& theRefKey ); void ClearDependencies( const std::string& theObjKey ); + bool CheckParamName( const std::string& theParamName ) const; private: std::string GetKey( SALOME::ParameterizedObject_ptr theObj ); diff --git a/src/Notebook/SALOME_NotebookDriver.cxx b/src/Notebook/SALOME_NotebookDriver.cxx new file mode 100644 index 000000000..705e96af8 --- /dev/null +++ b/src/Notebook/SALOME_NotebookDriver.cxx @@ -0,0 +1,145 @@ + +#include +#include +#include + +SALOME_NotebookDriver::SALOME_NotebookDriver() +{ +} + +SALOME_NotebookDriver::~SALOME_NotebookDriver() +{ +} + +std::string SALOME_NotebookDriver::GetFileName( SALOMEDS::SComponent_ptr theComponent, bool isMultiFile ) const +{ + // Prepare a file name to open + std::string aNameWithExt; + if( isMultiFile ) + aNameWithExt = SALOMEDS_Tool::GetNameFromPath( theComponent->GetStudy()->URL() ).c_str(); + aNameWithExt += "_Notebook.dat"; + return aNameWithExt; +} + +SALOMEDS::TMPFile* SALOME_NotebookDriver::Save( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile ) +{ + SALOMEDS::TMPFile_var aStreamFile; + + // Get a temporary directory to store a file + std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir(); + + // Create a list to store names of created files + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length( 1 ); + + std::string aNameWithExt = GetFileName( theComponent, isMultiFile ); + aSeq[0] = CORBA::string_dup( aNameWithExt.c_str() ); + + // Build a full file name of temporary file + std::string aFullName = std::string( aTmpDir.c_str() ) + aNameWithExt; + + // Save Notebook component into this file + theComponent->GetStudy()->GetNotebook()->Save( aFullName.c_str() ); + + // Convert a file to the byte stream + aStreamFile = SALOMEDS_Tool::PutFilesToStream( aTmpDir.c_str(), aSeq.in(), isMultiFile ); + + // Remove the created file and tmp directory + if( !isMultiFile ) + SALOMEDS_Tool::RemoveTemporaryFiles( aTmpDir.c_str(), aSeq.in(), true ); + + // Return the created byte stream + return aStreamFile._retn(); +} + +SALOMEDS::TMPFile* SALOME_NotebookDriver::SaveASCII( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile ) +{ + SALOMEDS::TMPFile_var aStreamFile = Save( theComponent, theURL, isMultiFile ); + return aStreamFile._retn(); +} + +CORBA::Boolean SALOME_NotebookDriver::Load( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, + const char* theURL, bool isMultiFile ) +{ + // Get a temporary directory for a file + std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir(); + + // Convert the byte stream theStream to a file and place it in tmp directory + SALOMEDS::ListOfFileNames_var aSeq = + SALOMEDS_Tool::PutStreamToFiles( theStream, aTmpDir.c_str(), isMultiFile ); + + // Prepare a file name to open + std::string aNameWithExt = GetFileName( theComponent, isMultiFile ); + std::string aFullName = std::string( aTmpDir.c_str() ) + aNameWithExt; + + // Open document + if( !theComponent->GetStudy()->GetNotebook()->Load( aFullName.c_str() ) ) + return false; + + // Remove the created file and tmp directory + if( !isMultiFile ) + SALOMEDS_Tool::RemoveTemporaryFiles( aTmpDir.c_str(), aSeq.in(), true ); + + return true; +} + +CORBA::Boolean SALOME_NotebookDriver::LoadASCII( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, + const char* theURL, bool isMultiFile ) +{ + return Load( theComponent, theStream, theURL, isMultiFile ); +} + +void SALOME_NotebookDriver::Close( SALOMEDS::SComponent_ptr theComponent ) +{ +} + +char* SALOME_NotebookDriver::ComponentDataType() +{ + return CORBA::string_dup( "NOTEBOOK" ); +} + +char* SALOME_NotebookDriver::IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject, const char* theIOR, + CORBA::Boolean isMultiFile, CORBA::Boolean isASCII ) +{ + return 0; +} + +char* SALOME_NotebookDriver::LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject, const char* theLocalPersistentID, + CORBA::Boolean isMultiFile, CORBA::Boolean isASCII ) +{ + return 0; +} + +bool SALOME_NotebookDriver::CanPublishInStudy( CORBA::Object_ptr theIOR ) +{ + return false; +} + +SALOMEDS::SObject_ptr SALOME_NotebookDriver::PublishInStudy( SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, const char* theName ) +{ + SALOMEDS::SObject_var aRes; + return aRes._retn(); +} + +CORBA::Boolean SALOME_NotebookDriver::CanCopy( SALOMEDS::SObject_ptr theObject ) +{ + return false; +} + +SALOMEDS::TMPFile* SALOME_NotebookDriver::CopyFrom ( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) +{ + return 0; +} + +CORBA::Boolean SALOME_NotebookDriver::CanPaste ( const char* theComponentName, CORBA::Long theObjectID ) +{ + return false; +} + +SALOMEDS::SObject_ptr SALOME_NotebookDriver::PasteInto( const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject ) +{ + SALOMEDS::SObject_var aRes; + return aRes._retn(); +} diff --git a/src/Notebook/SALOME_NotebookDriver.hxx b/src/Notebook/SALOME_NotebookDriver.hxx new file mode 100644 index 000000000..b53586272 --- /dev/null +++ b/src/Notebook/SALOME_NotebookDriver.hxx @@ -0,0 +1,42 @@ + +#ifndef SALOME_NOTEBOOK_DRIVER_HEADER +#define SALOME_NOTEBOOK_DRIVER_HEADER + +#include CORBA_SERVER_HEADER(SALOMEDS) +#include + +class SALOME_NotebookDriver : public POA_SALOMEDS::Driver +{ +public: + SALOME_NotebookDriver(); + virtual ~SALOME_NotebookDriver(); + + virtual SALOMEDS::TMPFile* Save ( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile ); + virtual SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile ); + virtual CORBA::Boolean Load ( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, + const char* theURL, bool isMultiFile ); + virtual CORBA::Boolean LoadASCII( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, + const char* theURL, bool isMultiFile ); + virtual void Close ( SALOMEDS::SComponent_ptr theComponent ); + + virtual char* ComponentDataType(); + virtual char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject, const char* theIOR, + CORBA::Boolean isMultiFile, CORBA::Boolean isASCII ); + virtual char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject, const char* theLocalPersistentID, + CORBA::Boolean isMultiFile, CORBA::Boolean isASCII ); + + virtual bool CanPublishInStudy ( CORBA::Object_ptr theIOR ); + virtual SALOMEDS::SObject_ptr PublishInStudy ( SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, const char* theName ); + + virtual CORBA::Boolean CanCopy ( SALOMEDS::SObject_ptr theObject ); + virtual SALOMEDS::TMPFile* CopyFrom ( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ); + virtual CORBA::Boolean CanPaste ( const char* theComponentName, CORBA::Long theObjectID ); + virtual SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject ); + +protected: + std::string GetFileName( SALOMEDS::SComponent_ptr theComponent, bool isMultiFile ) const; +}; + +#endif diff --git a/src/Notebook/SALOME_Parameter.cxx b/src/Notebook/SALOME_Parameter.cxx index 41a5bf2e7..04253c23d 100644 --- a/src/Notebook/SALOME_Parameter.cxx +++ b/src/Notebook/SALOME_Parameter.cxx @@ -170,3 +170,23 @@ SALOME_StringList SALOME_Parameter::Dependencies() const { return myIsCalculable ? myExpr.parser()->parameters() : SALOME_StringList(); } + +std::string SALOME_Parameter::Save() const +{ + char buf[256]; + sprintf( buf, "%s %i %i ", myName.c_str(), (int)myIsAnonimous, (int)myIsCalculable ); + std::string aRes = buf; + if( myIsCalculable ) + aRes += myExpr.expression(); + else + { + sprintf( buf, "%i %s", myResult.type(), myResult.toString().c_str() ); + aRes += buf; + } + return aRes; +} + +SALOME_Parameter* SALOME_Parameter::Load( const std::string& theData ) +{ + return 0; +} diff --git a/src/Notebook/SALOME_Parameter.hxx b/src/Notebook/SALOME_Parameter.hxx index 6defd3f3d..fd4ac2124 100644 --- a/src/Notebook/SALOME_Parameter.hxx +++ b/src/Notebook/SALOME_Parameter.hxx @@ -68,6 +68,9 @@ public: SALOME_StringList Dependencies() const; + std::string Save() const; + static SALOME_Parameter* Load( const std::string& theData ); + private: SALOME_Notebook* myNotebook; std::string myName; diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 4d851194c..f41cfc7a6 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -26,6 +26,7 @@ #include "SALOMEDS_SComponent_i.hxx" #include "SALOMEDS_Study_i.hxx" #include "SALOMEDS.hxx" +#include #include using namespace std; @@ -237,23 +238,41 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(SALOMEDSImpl_Study* theStudy // SALOMEDS_DriverFactory //############################################################################################################### +SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB) +{ + _orb = CORBA::ORB::_duplicate(theORB); + _name_service = new SALOME_NamingService(_orb); + + SALOME_NotebookDriver* aDriver = new SALOME_NotebookDriver(); + myNotebookDriver = aDriver->_this(); +} + +SALOMEDS_DriverFactory_i::~SALOMEDS_DriverFactory_i() +{ + delete _name_service; +} + SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const string& theComponentType) { CORBA::Object_var obj; string aFactoryType; - if (theComponentType == "SUPERV") aFactoryType = "SuperVisionContainer"; - else aFactoryType = "FactoryServer"; + if (theComponentType == "SUPERV") + aFactoryType = "SuperVisionContainer"; + else + aFactoryType = "FactoryServer"; SALOMEDS::unlock(); obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType.c_str(), theComponentType.c_str()); SALOMEDS::lock(); - if (CORBA::is_nil(obj)) { + if (CORBA::is_nil(obj)) + { obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", theComponentType.c_str()); } - if (!CORBA::is_nil(obj)) { + if (!CORBA::is_nil(obj)) + { SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); return new SALOMEDS_Driver_i(aDriver, _orb); } diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.hxx b/src/SALOMEDS/SALOMEDS_Driver_i.hxx index 369174fc6..09f69c398 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.hxx @@ -125,21 +125,17 @@ protected: public: - SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB) - { - _orb = CORBA::ORB::_duplicate(theORB); - _name_service = new SALOME_NamingService(_orb); - } + SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB); - ~SALOMEDS_DriverFactory_i() - { - delete _name_service; - } + ~SALOMEDS_DriverFactory_i(); virtual SALOMEDSImpl_Driver* GetDriverByType(const std::string& theComponentType); virtual SALOMEDSImpl_Driver* GetDriverByIOR(const std::string& theIOR); + +private: + SALOMEDS::Driver_var myNotebookDriver; }; #endif diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 7a09d7a49..d3e97bee6 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -125,7 +125,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) SALOMEDS_Study_i *Study_servant = SALOMEDS_Study_i::GetStudyServant(aStudyImpl, _orb); PortableServer::ObjectId_var servantid = _poa->activate_object(Study_servant); // to use poa registered in _mapOfPOA SALOMEDS::Study_var Study = Study_servant->_this(); - + // Register study in the naming service // Path to acces the study if(!_name_service->Change_Directory("/Study")) @@ -140,6 +140,8 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) _mapOfPOA[Study->StudyId()] = _poa; + Study->GetNotebook(); + return Study._retn(); } @@ -179,6 +181,8 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" ) else _name_service->Register(Study, CORBA::string_dup(aStudyImpl->Name().c_str())); + Study->GetNotebook(); + return Study._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 7544d0521..62e1b8428 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -43,6 +43,8 @@ #include "SALOMEDSImpl_ChildIterator.hxx" #include "SALOMEDSImpl_IParameters.hxx" +#include + #include "DF_Label.hxx" #include "DF_Attribute.hxx" @@ -955,9 +957,28 @@ SALOME::Notebook_ptr SALOMEDS_Study_i::GetNotebook() { if( CORBA::is_nil( myNotebook ) ) { - SALOME_Notebook* aNb = new SALOME_Notebook( _this() ); + SALOME_Notebook* aNb = new SALOME_Notebook( _default_POA(), _this() ); myNotebook = aNb->_this(); + + //Creation of default component for the Notebook + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::StudyBuilder_var aStudyBuilder = NewBuilder(); + SALOMEDS::SComponent_var aNotebookComponent = aStudyBuilder->NewComponent( "NOTEBOOK" ); + + anAttr = aStudyBuilder->FindOrCreateAttribute( aNotebookComponent, "AttributeName" ); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow( anAttr ); + aName->SetValue( "Notebook" ); + aName->Destroy(); + + anAttr = aStudyBuilder->FindOrCreateAttribute( aNotebookComponent, "AttributePixMap" ); + SALOMEDS::AttributePixMap_var aPixMap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixMap->SetPixMap( "ICON_OBJBROWSER_Notebook" ); + aPixMap->Destroy(); + + SALOME_NotebookDriver* aDriver = new SALOME_NotebookDriver(); + SALOMEDS::Driver_var aDriverVar = aDriver->_this(); + aStudyBuilder->DefineComponentInstance( aNotebookComponent, aDriverVar._retn() ); } - return myNotebook._retn(); + return SALOME::Notebook::_duplicate( myNotebook ); }