ResInsight/ApplicationLibCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp

67 lines
2.4 KiB
C++
Raw Normal View History

2015-08-19 11:17:45 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
2015-08-19 11:17:45 -05:00
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
2015-08-19 11:17:45 -05:00
// ResInsight 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 General Public License at <http://www.gnu.org/licenses/gpl.html>
2015-08-19 11:17:45 -05:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicEditScriptFeature.h"
2023-03-13 08:46:41 -05:00
#include "ApplicationCommands/RicOpenInTextEditorFeature.h"
#include "RicScriptFeatureImpl.h"
2015-08-19 11:17:45 -05:00
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimCalcScript.h"
2015-08-19 11:17:45 -05:00
#include "Riu3DMainWindowTools.h"
2015-08-19 11:17:45 -05:00
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicEditScriptFeature, "RicEditScriptFeature" );
2015-08-19 11:17:45 -05:00
//--------------------------------------------------------------------------------------------------
///
2015-08-19 11:17:45 -05:00
//--------------------------------------------------------------------------------------------------
bool RicEditScriptFeature::isCommandEnabled() const
2015-08-19 11:17:45 -05:00
{
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
2023-03-13 08:46:41 -05:00
return !selection.empty();
2015-08-19 11:17:45 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2015-08-19 11:17:45 -05:00
//--------------------------------------------------------------------------------------------------
void RicEditScriptFeature::onActionTriggered( bool isChecked )
2015-08-19 11:17:45 -05:00
{
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
2023-03-13 08:46:41 -05:00
CVF_ASSERT( !selection.empty() );
2015-08-19 11:17:45 -05:00
RimCalcScript* calcScript = selection[0];
2023-03-13 08:46:41 -05:00
RicOpenInTextEditorFeature::openFileInTextEditor( calcScript->absoluteFileName, this );
2015-08-19 11:17:45 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2015-08-19 11:17:45 -05:00
//--------------------------------------------------------------------------------------------------
void RicEditScriptFeature::setupActionLook( QAction* actionToSetup )
2015-08-19 11:17:45 -05:00
{
actionToSetup->setText( "Edit" );
2015-08-19 11:17:45 -05:00
}