System command command file merger (#4845)

* Move Import WellPaths command-file functionality into RicImportWellPaths

* Add new RICF_init macros for command file objects

* Make project save commands available in Python

* Fix RiaLogging build errors

* Move RiaLogging include from RiaGrpcServer.h to cpp file
This commit is contained in:
Gaute Lindkvist
2019-10-15 15:46:19 +02:00
committed by GitHub
parent f24543ce56
commit d3140b6aac
18 changed files with 349 additions and 237 deletions

View File

@@ -18,13 +18,37 @@
#include "RicSaveProjectAsFeature.h"
#include "RicSaveProjectFeature.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RicSaveProjectFeature.h"
#include "Riu3DMainWindowTools.h"
#include <QAction>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT( RicSaveProjectAsFeature, "RicSaveProjectAsFeature" );
RICF_SOURCE_INIT( RicSaveProjectAsFeature, "RicSaveProjectAsFeature", "saveProjectAs" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSaveProjectAsFeature::RicSaveProjectAsFeature()
{
RICF_InitFieldNoDefault( &m_filePath, "filePath", "", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandResponse RicSaveProjectAsFeature::execute()
{
this->disableModelChangeContribution();
QString errorMessage;
if ( !RiaApplication::instance()->saveProjectAs( m_filePath(), &errorMessage ) )
{
return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, errorMessage );
}
return RicfCommandResponse();
}
//--------------------------------------------------------------------------------------------------
///
@@ -39,12 +63,25 @@ bool RicSaveProjectAsFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicSaveProjectAsFeature::onActionTriggered( bool isChecked )
{
this->disableModelChangeContribution();
RiaGuiApplication* app = RiaGuiApplication::instance();
if ( app )
{
app->saveProjectPromptForFileName();
m_filePath = app->promptForProjectSaveAsFileName();
if ( m_filePath().isEmpty() )
{
return;
}
auto response = execute();
if ( response.status() != RicfCommandResponse::COMMAND_OK )
{
QString displayMessage = response.messages().join( "\n" );
if ( RiaGuiApplication::isRunning() )
{
QMessageBox::warning( nullptr, "Error when saving project file", displayMessage );
}
RiaLogging::error( displayMessage );
}
}
}