mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merged in changes from maintenance branch
This commit is contained in:
@@ -12,6 +12,7 @@ ${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewScriptFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicScriptFeatureImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicRefreshScriptsFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -22,6 +23,7 @@ ${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewScriptFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicScriptFeatureImpl.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicRefreshScriptsFeature.cpp
|
||||
)
|
||||
|
||||
set (QT_MOC_HEADERS
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
|
||||
#include "RicAddScriptPathFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RicRefreshScriptsFeature.h"
|
||||
#include "RicScriptFeatureImpl.h"
|
||||
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
@@ -62,6 +64,8 @@ void RicAddScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
RiaApplication::instance()->preferences()->scriptDirectories = filePathString;
|
||||
RiaApplication::instance()->applyPreferences();
|
||||
|
||||
RicRefreshScriptsFeature::refreshScriptFolders();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
|
||||
#include "RicDeleteScriptPathFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RicRefreshScriptsFeature.h"
|
||||
#include "RicScriptFeatureImpl.h"
|
||||
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
@@ -69,6 +71,8 @@ void RicDeleteScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
RiaApplication::instance()->preferences()->scriptDirectories = filePathString;
|
||||
RiaApplication::instance()->applyPreferences();
|
||||
|
||||
RicRefreshScriptsFeature::refreshScriptFolders();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,20 @@
|
||||
|
||||
#include "RicNewScriptFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicRefreshScriptsFeature.h"
|
||||
#include "RicScriptFeatureImpl.h"
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewScriptFeature, "RicNewScriptFeature");
|
||||
@@ -38,8 +42,7 @@ CAF_CMD_SOURCE_INIT(RicNewScriptFeature, "RicNewScriptFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewScriptFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
|
||||
return selection.size() > 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -55,7 +58,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
QString fullPathNewScript;
|
||||
|
||||
if (calcScript )
|
||||
if (calcScript)
|
||||
{
|
||||
QFileInfo existingScriptFileInfo(calcScript->absolutePath());
|
||||
fullPathNewScript = existingScriptFileInfo.absolutePath();
|
||||
@@ -79,19 +82,40 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked)
|
||||
num++;
|
||||
}
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
bool ok;
|
||||
fullPathFilenameNewScript = QInputDialog::getText(NULL, "Specify new script file", "File name", QLineEdit::Normal, fullPathFilenameNewScript, &ok);
|
||||
|
||||
if (ok && !fullPathFilenameNewScript.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
QFile file(fullPathFilenameNewScript);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RicRefreshScriptsFeature::refreshScriptFolders();
|
||||
|
||||
if (calcScript)
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(calcScript);
|
||||
}
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// 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 "RicRefreshScriptsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicRefreshScriptsFeature, "RicRefreshScriptsFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicRefreshScriptsFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRefreshScriptsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
refreshScriptFolders();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRefreshScriptsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Refresh");
|
||||
actionToSetup->setIcon(QIcon(":/Refresh-32.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRefreshScriptsFeature::refreshScriptFolders()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
proj->setScriptDirectories(prefs->scriptDirectories());
|
||||
proj->updateConnectedEditors();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// 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 RicRefreshScriptsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void refreshScriptFolders();
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
};
|
||||
|
||||
|
||||
@@ -67,11 +67,15 @@ void RicCloseCaseFeature::onActionTriggered(bool isChecked)
|
||||
if (userConfirmedGridCaseGroupChange(casesToBeDeleted))
|
||||
{
|
||||
deleteEclipseCase(eclipseCase);
|
||||
|
||||
RiuMainWindow::instance()->cleanupGuiCaseClose();
|
||||
}
|
||||
}
|
||||
else if (geoMechCase)
|
||||
{
|
||||
deleteGeoMechCase(geoMechCase);
|
||||
|
||||
RiuMainWindow::instance()->cleanupGuiCaseClose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user