]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/CAF/CAF_Study.cxx
Salome HOME
Copyrights update
[modules/gui.git] / src / CAF / CAF_Study.cxx
index 5ddc2fe7d42e2561ec00915705ef8cbcad2e5f94..bb20185cae9f7be97b9101280189f25b8be767c5 100755 (executable)
@@ -1,3 +1,21 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
 #include "CAF_Study.h"
 
 #include "CAF_Tools.h"
@@ -13,6 +31,8 @@
 #include <TDF_Delta.hxx>
 #include <TDF_ListIteratorOfDeltaList.hxx>
 
+#include <Standard_ErrorHandler.hxx>
+
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
@@ -123,7 +143,7 @@ bool CAF_Study::saveDocumentAs( const QString& fname )
   return status && SUIT_Study::saveDocumentAs( fname );
 }
 
-bool CAF_Study::startOperation()
+bool CAF_Study::openTransaction()
 {
        if ( myStdDoc.IsNull() )
     return false;
@@ -142,40 +162,50 @@ bool CAF_Study::startOperation()
   return res;
 }
 
-void CAF_Study::abortOperation()
+bool CAF_Study::abortTransaction()
 {
        if ( myStdDoc.IsNull() )
-    return;
+    return false;
 
+  bool res = true;
        try {
     myStdDoc->AbortCommand();
                update();
   }
   catch ( Standard_Failure ) {
+    res = false;
   }
+  return res;
 }
 
-void CAF_Study::commitOperation()
+bool CAF_Study::commitTransaction( const QString& name )
 {
        if ( myStdDoc.IsNull() )
-    return;
+    return false;
 
+  bool res = true;
        try {
     myStdDoc->CommitCommand();
 
     if ( canUndo() )
     {
-      CAF_Operation* cafOp = 0;
-      if ( activeOperation() && activeOperation()->inherits( "CAF_Operation" ) )
-        cafOp = (CAF_Operation*)activeOperation();
-
       Handle(TDF_Delta) d = myStdDoc->GetUndos().Last();
-                       if ( cafOp && !d.IsNull() )
-        d->SetName( CAF_Tools::toExtString( cafOp->getName() ) );
+                       if ( !d.IsNull() )
+        d->SetName( CAF_Tools::toExtString( name ) );
     }
   }
   catch ( Standard_Failure ) {
+    res = false;
   }
+  return res;
+}
+
+bool CAF_Study::hasTransaction() const
+{
+       if ( myStdDoc.IsNull() )
+    return false;
+
+  return myStdDoc->HasOpenCommand();
 }
 
 /*!