]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
persistence implementation
authorasl <asl@opencascade.com>
Fri, 20 Nov 2009 14:58:28 +0000 (14:58 +0000)
committerasl <asl@opencascade.com>
Fri, 20 Nov 2009 14:58:28 +0000 (14:58 +0000)
12 files changed:
src/Makefile.am
src/Notebook/Makefile.am
src/Notebook/SALOME_Notebook.cxx
src/Notebook/SALOME_Notebook.hxx
src/Notebook/SALOME_NotebookDriver.cxx [new file with mode: 0644]
src/Notebook/SALOME_NotebookDriver.hxx [new file with mode: 0644]
src/Notebook/SALOME_Parameter.cxx
src/Notebook/SALOME_Parameter.hxx
src/SALOMEDS/SALOMEDS_Driver_i.cxx
src/SALOMEDS/SALOMEDS_Driver_i.hxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.cxx

index ba83ba54b7240a42bcf3e87aaf12844afaba6e41..6cf47e778243df0cabc546ab0e41be2842157ff8 100644 (file)
@@ -47,9 +47,9 @@ SUBDIR_CORBA = \
   Launcher \
   LifeCycleCORBA \
   LifeCycleCORBA_SWIG \
+  TOOLSDS \
   Notebook \
   SALOMEDSClient \
-  TOOLSDS \
   SALOMEDSImpl \
   SALOMEDS \
   ModuleGenerator \
index 36b4a145b3f62abba43c3ac0510e2b30d37124e2..5db33dd75010f2f9e1ba48b95d0f27eb84e30b72 100644 (file)
@@ -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  \
index ddd36aa807a6f31e2ff972680c7622ddbbbddbbf..592eee8476c28ca354ea5bbb29a11361e4c7045b 100644 (file)
@@ -27,7 +27,8 @@
 #include <SALOME_Notebook.hxx>
 #include <SALOME_Parameter.hxx>
 
-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<KeyHelper>::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<std::string> >::const_iterator dit = myDeps.begin(), dlast = myDeps.end();
+  for( ; dit!=dlast; dit++ )
+  {
+    fprintf( aFile, "%s -> ", dit->first.c_str() );
+    std::list<std::string>::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();
+}
index aa8c399b4247c5badc019e6b6915f13dbe90dfe2..6a2c36124ad029ae7ceabe3ba64e23e956655ecb 100644 (file)
@@ -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 (file)
index 0000000..705e96a
--- /dev/null
@@ -0,0 +1,145 @@
+
+#include <SALOME_NotebookDriver.hxx>
+#include <SALOMEDS_Tool.hxx>
+#include <stdio.h>
+
+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 (file)
index 0000000..b535862
--- /dev/null
@@ -0,0 +1,42 @@
+
+#ifndef SALOME_NOTEBOOK_DRIVER_HEADER
+#define SALOME_NOTEBOOK_DRIVER_HEADER
+
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include <string>
+
+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
index 41a5bf2e78a101a67f293d57fea47f6d30435c63..04253c23dac521f975c15e1b24dc1ce7f9d5754c 100644 (file)
@@ -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;
+}
index 6defd3f3dcf340836e56d2293b60ac5a50ae24a4..fd4ac212478d83653c34cd72e77dea0d71f76136 100644 (file)
@@ -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;
index 4d851194c51f40817cb654bfa3d11a759b6c2a8c..f41cfc7a6cbafefc18cc76fbde49f003bd6efc3e 100644 (file)
@@ -26,6 +26,7 @@
 #include "SALOMEDS_SComponent_i.hxx"
 #include "SALOMEDS_Study_i.hxx"
 #include "SALOMEDS.hxx"
+#include <SALOME_NotebookDriver.hxx>
 #include <stdlib.h>
 
 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);
   }
index 369174fc6389dcb24792d663e421a1a8599eb31a..09f69c398ae176eb1fb53ca3b41b4f2ec1d52ff7 100644 (file)
@@ -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 
index 7a09d7a4977aa2198044c9cf62bbb3a1f87f33c7..d3e97bee64e437edc4e9550736d44f28a08a420e 100644 (file)
@@ -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();
 }
 
index 7544d052165d24eb7ff57b93cb7e0bcb91ea14ed..62e1b842872b1569a43865e8405d73b212a8f31b 100644 (file)
@@ -43,6 +43,8 @@
 #include "SALOMEDSImpl_ChildIterator.hxx"
 #include "SALOMEDSImpl_IParameters.hxx"
 
+#include <SALOME_NotebookDriver.hxx>
+
 #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 );
 }