mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#339) Added RicEditScriptFeature
This commit is contained in:
parent
28e7c8b19c
commit
a01618cc8e
@ -6,11 +6,12 @@ endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEditScriptFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCasePasteFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.h
|
||||
@ -49,11 +50,12 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEditScriptFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCasePasteFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.cpp
|
||||
|
88
ApplicationCode/Commands/RicEditScriptFeature.cpp
Normal file
88
ApplicationCode/Commands/RicEditScriptFeature.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicEditScriptFeature.h"
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicEditScriptFeature, "RicEditScriptFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditScriptFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCalcScript*> selection = selectedScripts();
|
||||
return selection.size() > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditScriptFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<RimCalcScript*> selection = selectedScripts();
|
||||
CVF_ASSERT(selection.size() > 0);
|
||||
|
||||
RimCalcScript* calcScript = selection[0];
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << calcScript->absolutePath;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
{
|
||||
QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Edit");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimCalcScript*> RicEditScriptFeature::selectedScripts()
|
||||
{
|
||||
std::vector<RimCalcScript*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
return selection;
|
||||
}
|
45
ApplicationCode/Commands/RicEditScriptFeature.h
Normal file
45
ApplicationCode/Commands/RicEditScriptFeature.h
Normal file
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimCalcScript;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEditScriptFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
std::vector<RimCalcScript*> selectedScripts();
|
||||
};
|
||||
|
||||
|
@ -656,6 +656,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
}
|
||||
else if (dynamic_cast<RimCalcScript*>(uiItem))
|
||||
{
|
||||
commandIds << "RicEditScriptFeature";
|
||||
commandIds << "RicExecuteScriptFeature";
|
||||
}
|
||||
}
|
||||
|
@ -509,6 +509,7 @@ void RimUiTreeView::slotAddSliceFilterK()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// OBSOLETE - see RicEditScriptFeature
|
||||
void RimUiTreeView::slotEditScript()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
|
Loading…
Reference in New Issue
Block a user