X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FATOMICGUI%2FATOMICGUI_ImportExportOp.cxx;fp=src%2FATOMICGUI%2FATOMICGUI_ImportExportOp.cxx;h=beee34885faa25174ec31e4ad51a1fe549888fb4;hb=ee81df44e638f9c22f7c2b5814166e02cf77211b;hp=0000000000000000000000000000000000000000;hpb=17217f19acf83ce74978f6e7684cfe64cea90661;p=samples%2Fatomic.git diff --git a/src/ATOMICGUI/ATOMICGUI_ImportExportOp.cxx b/src/ATOMICGUI/ATOMICGUI_ImportExportOp.cxx new file mode 100644 index 0000000..beee348 --- /dev/null +++ b/src/ATOMICGUI/ATOMICGUI_ImportExportOp.cxx @@ -0,0 +1,77 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include +#include + +#include +#include + +/*! Constructor */ +ATOMICGUI_ImportExportOp::ATOMICGUI_ImportExportOp( const bool import ) +: ATOMICGUI_Operation(), + myIsImport( import ) +{ +} + +/*! Destructor */ +ATOMICGUI_ImportExportOp::~ATOMICGUI_ImportExportOp() +{ +} + +/*! Operation itself. Imports or exports the data structure + * calling the corresponing methods of Data Model. */ +void ATOMICGUI_ImportExportOp::startOperation() +{ + ATOMICGUI_DataModel* dm = dataModel(); + if ( !dm ) + { + abort(); + return; + } + + QStringList filtersList; + filtersList.append( tr( "XML_FILES" ) ); + + // Select a file to be imported + QString aFileName = module()->getApp()->getFileName( myIsImport, QString::null, + filtersList.join( ";;" ), + tr( myIsImport ? "ATOMICGUI_IMPORT_XML" : "ATOMICGUI_EXPORT_XML" ), 0 ); + + if( !aFileName.isEmpty() ) + { + if( ( myIsImport && dm->importFile( aFileName ) ) || + ( !myIsImport && dm->exportFile( aFileName ) ) ) + { + commit(); + return; + } + else + SUIT_MessageBox::warning( application()->desktop(), + tr( "WRN_WARNING" ), + tr( myIsImport ? "WRN_IMPORT_FAILED" : "WRN_EXPORT_FAILED" ), + tr( "BUT_OK" ) ); + } + abort(); +}