mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
Add preferences for HPC/Batch scheduler Add Slurm and LSF support Add batch job monitor Support launcher specific user settings Use internal timer to refresh job state Add some more options to batch monitor Improve naming Add tests for job lists Change WSL handling for processes.
105 lines
3.6 KiB
C++
105 lines
3.6 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2025 Equinor 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 "RicDuplicateJobFeature.h"
|
|
|
|
#include "RicNewOpmFlowJobFeature.h"
|
|
|
|
#include "Jobs/RimEnsembleJob.h"
|
|
#include "Jobs/RimGenericJob.h"
|
|
#include "Jobs/RimJobCollection.h"
|
|
#include "Jobs/RimOpmFlowJob.h"
|
|
#include "RimTools.h"
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
#include <QAction>
|
|
#include <QDir>
|
|
#include <QFileInfo>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicDuplicateJobFeature, "RicDuplicateJobFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicDuplicateJobFeature::isCommandEnabled() const
|
|
{
|
|
if ( auto job = dynamic_cast<RimGenericJob*>( caf::SelectionManager::instance()->selectedItem() ) )
|
|
{
|
|
return !job->isChildJob();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicDuplicateJobFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
if ( auto job = dynamic_cast<RimOpmFlowJob*>( caf::SelectionManager::instance()->selectedItem() ) )
|
|
{
|
|
QString defaultDir = job->mainWorkingDirectory();
|
|
QFileInfo fi( defaultDir );
|
|
defaultDir = fi.dir().absolutePath();
|
|
|
|
QString workDir = RicNewOpmFlowJobFeature::workingFolder( defaultDir );
|
|
if ( workDir.isEmpty() ) return;
|
|
|
|
if ( auto copiedJob = job->copyObject<RimOpmFlowJob>() )
|
|
{
|
|
copiedJob->setWorkingDirectory( workDir );
|
|
copiedJob->setName( job->name() + " (copy)" );
|
|
|
|
auto jobColl = RimTools::jobCollection();
|
|
jobColl->addNewJob( copiedJob );
|
|
|
|
copiedJob->resolveReferencesRecursively();
|
|
copiedJob->initAfterCopy();
|
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( copiedJob );
|
|
}
|
|
}
|
|
else if ( auto job = dynamic_cast<RimEnsembleJob*>( caf::SelectionManager::instance()->selectedItem() ) )
|
|
{
|
|
if ( auto copiedJob = job->copyObject<RimEnsembleJob>() )
|
|
{
|
|
copiedJob->setName( job->name() + " (copy)" );
|
|
|
|
auto jobColl = RimTools::jobCollection();
|
|
jobColl->addNewJob( copiedJob );
|
|
|
|
copiedJob->resolveReferencesRecursively();
|
|
copiedJob->initAfterCopy();
|
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( copiedJob );
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicDuplicateJobFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setIcon( QIcon( ":/Copy.svg" ) );
|
|
actionToSetup->setText( "Duplicate..." );
|
|
}
|