Skip to content

Refactor PushButtonEditor fields to use addNewButton pattern#673

Draft
Copilot wants to merge 14 commits intodevfrom
copilot/refactor-pushbuttoneditor-fields
Draft

Refactor PushButtonEditor fields to use addNewButton pattern#673
Copilot wants to merge 14 commits intodevfrom
copilot/refactor-pushbuttoneditor-fields

Conversation

Copy link

Copilot AI commented Feb 14, 2026

Replaces deprecated PdmField + PdmUiPushButtonEditorAttribute pattern with direct addNewButton() calls in 13 classes.

Pattern Change

Before:

// Header
caf::PdmField<bool> m_buttonField;

// Constructor
CAF_PDM_InitField(&m_buttonField, "ButtonField", false, "");
m_buttonField.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());

// defineEditorAttribute
if (field == &m_buttonField) {
    auto* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
    attrib->m_buttonText = "Button Text";
}

// fieldChangedByUi
if (changedField == &m_buttonField) {
    performAction();
    m_buttonField = false;
}

After:

// defineUiOrdering only
uiOrdering.addNewButton("Button Text", [this]() { performAction(); });

Changes

  • 13 classes refactored: RiaMemoryCleanup, RimFracture, RimCloudDataSourceCollection, RimFlowCharacteristicsPlot, RimWellAllocationOverTimePlot, RimGeoMechCase, RimGeoMechFaultReactivationResult, RimStatisticsContourMap, RimDeltaSummaryEnsemble, RimEnsembleCurveFilter, RimEnsembleCurveFilterCollection, RimEnsembleCurveSet, RicSummaryPlotEditorUi

  • Removed:

    • 23 PdmField button declarations from headers
    • Button initialization from constructors
    • defineEditorAttribute methods or button-specific code
    • Button state reset logic from fieldChangedByUi
  • Added:

    • addNewButton() calls in defineUiOrdering with lambda callbacks
    • Helper methods for complex button actions (e.g., RimFlowCharacteristicsPlot::onShowRegionClicked)

Net reduction: ~150 lines of boilerplate code.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactoring Guide: PushButtonEditor Fields</issue_title>
<issue_description>## The following pattern is used in some classes

A PdmField m_pushbButton is used to display a push button.

This code is used in defineEditorAttributes to modify the appearance of the button.

 if ( field == &m_pushbButton )
    {
        if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
        {
            attrib->m_buttonText = "Edit";
        }
    }

The state of the field is reset in fieldChangedByUi.

Replace this pattern with a dynamic push button like this:

        group->addNewButton( "Edit",
                             [this]() { RimPolygonTools::activate3dEditOfPolygonInView( m_cellFilterPolygon(), this ); },
                             { .newRow = false } );


Keep the following classes unchanged

RimUserDefinedPolylinesAnnotation
RimExtrudedCurveIntersection
RimPolygonInView
RimGridCalculationVariable
RimSummaryCalculationVariable

Refactor the following classes

Here is a list of candidates to refactor. Mark them as complete when done.

RiaMemoryCleanup
RicSummaryPlotEditorUi
RimCloudDataSourceCollection
RimFracture
RimStatisticsContourMap
RimFlowCharacteristicsPlot
RimWellAllocationOverTimePlot
RimGeoMechCase
RimGeoMechFaultReactivationResult
RimHistogramMultiPlot
RimCustomObjectiveFunctionWeight
RimEclipseStatisticsCase
RimRegularLegendConfig
RimTernaryLegendConfig
RimWellTargetMapping
RimDeltaSummaryEnsemble
RimEnsembleCurveFilter
RimEnsembleCurveFilterCollection
RimEnsembleCurveSet
LineEditAndPushButtons
DemoPdmObject </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 13 commits February 14, 2026 15:33
…itorAttribute with addNewButton

Co-authored-by: magnesj <1793152+magnesj@users.noreply.github.com>
…Attribute with addNewButton

Co-authored-by: magnesj <1793152+magnesj@users.noreply.github.com>
…tribute with addNewButton

Co-authored-by: magnesj <1793152+magnesj@users.noreply.github.com>
…rAttribute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ditorAttribute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…itorAttribute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ute with addNewButton

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: magnesj <1793152+magnesj@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor PushButtonEditor fields to dynamic button Refactor PushButtonEditor fields to use addNewButton pattern Feb 14, 2026
Copilot AI requested a review from magnesj February 14, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactoring Guide: PushButtonEditor Fields

2 participants

Comments