diff --git a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp index 4e04afd650..b73faca782 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp @@ -19,9 +19,11 @@ #include "RicAddEclipseInputPropertyFeature.h" +#include "RimEclipseCellColors.h" #include "RimEclipseInputCase.h" #include "RimEclipseInputPropertyCollection.h" #include "RimEclipseResultCase.h" +#include "RimEclipseView.h" #include "RiaApplication.h" #include "Riu3DMainWindowTools.h" @@ -41,7 +43,9 @@ CAF_CMD_SOURCE_INIT( RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPrope bool RicAddEclipseInputPropertyFeature::isCommandEnabled() { return caf::SelectionManager::instance()->selectedItemOfType() || - caf::SelectionManager::instance()->selectedItemOfType(); + caf::SelectionManager::instance()->selectedItemOfType() || + caf::SelectionManager::instance()->selectedItemOfType() || + caf::SelectionManager::instance()->selectedItemOfType(); } //-------------------------------------------------------------------------------------------------- @@ -49,8 +53,11 @@ bool RicAddEclipseInputPropertyFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked ) { - RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType(); - if ( !eclipseCase ) return; + RimEclipseCase* eclipseCase = getEclipseCase(); + if ( !eclipseCase ) + { + return; + } RimEclipseInputPropertyCollection* inputPropertyCollection = eclipseCase->inputPropertyCollection(); if ( !inputPropertyCollection ) return; @@ -83,3 +90,37 @@ void RicAddEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup actionToSetup->setText( "Add Input Property" ); actionToSetup->setIcon( QIcon( ":/EclipseInput48x48.png" ) ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RicAddEclipseInputPropertyFeature::getEclipseCase() const +{ + RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType(); + if ( eclipseCase ) + { + return eclipseCase; + } + + RimEclipseCellColors* cellColors = caf::SelectionManager::instance()->selectedItemOfType(); + if ( cellColors ) + { + cellColors->firstAncestorOrThisOfType( eclipseCase ); + if ( eclipseCase ) + { + return eclipseCase; + } + } + + RimEclipseView* eclipseView = caf::SelectionManager::instance()->selectedItemOfType(); + if ( eclipseView ) + { + eclipseView->firstAncestorOrThisOfType( eclipseCase ); + if ( eclipseCase ) + { + return eclipseCase; + } + } + + return nullptr; +} diff --git a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h index f906370317..09960eddf6 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h +++ b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h @@ -21,8 +21,7 @@ #include "cafCmdFeature.h" -class RimEclipseInputPropertyCollection; -class QStringList; +class RimEclipseCase; //================================================================================================== /// @@ -38,7 +37,5 @@ protected: void setupActionLook( QAction* actionToSetup ) override; private: - RimEclipseInputPropertyCollection* selectedInputPropertyCollection() const; - static void addEclipseInputProperty( const QStringList& fileNames, - RimEclipseInputPropertyCollection* inputPropertyCollection ); + RimEclipseCase* getEclipseCase() const; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 800ab8b95d..0ad90fff58 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -207,6 +207,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicSaveEclipseResultAsInputPropertyFeature"; menuBuilder << "RicExportContourMapToTextFeature"; menuBuilder << "RicSaveEclipseInputVisibleCellsFeature"; + menuBuilder << "RicAddEclipseInputPropertyFeature"; } else if ( dynamic_cast( firstUiItem ) ) { @@ -269,6 +270,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicExportEclipseInputGridFeature"; menuBuilder << "RicSaveEclipseInputVisibleCellsFeature"; menuBuilder << "RicCreateGridCrossPlotFeature"; + menuBuilder << "RicAddEclipseInputPropertyFeature"; } else if ( dynamic_cast( firstUiItem ) ) {