From 8b6ff4231659581f8addd1a5ee1749d8292ac37c Mon Sep 17 00:00:00 2001 From: Neil C Smith Date: Mon, 8 Sep 2025 15:29:00 +0100 Subject: [PATCH 1/2] Remove use of deprecated Integer constructor in NotifyDescriptor This change keeps the existing value relationship with JOptionPane int constants, which involves managing YES and OK now having the same identity. It is no longer possible to maintain both aspects. --- .../netbeans/core/windows/services/NbPresenter.java | 13 ++++++++----- .../src/org/openide/NotifyDescriptor.java | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java b/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java index 74ed8553bf7c..2e87c0d4b950 100644 --- a/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java +++ b/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java @@ -661,13 +661,16 @@ protected final void initializeButtons() { } currentPrimaryButtons = new Component [primaryOptions.length]; for (int i = 0; i < primaryOptions.length; i++) { - if (primaryOptions[i] == NotifyDescriptor.YES_OPTION) { - currentPrimaryButtons[i] = stdYesButton; + if (primaryOptions[i] == NotifyDescriptor.OK_OPTION || + primaryOptions[i] == NotifyDescriptor.YES_OPTION) { + if (Arrays.asList(primaryOptions).contains(NotifyDescriptor.NO_OPTION)) { + currentPrimaryButtons[i] = stdYesButton; + } else { + currentPrimaryButtons[i] = stdOKButton; + stdOKButton.setEnabled(descriptor.isValid()); + } } else if (primaryOptions[i] == NotifyDescriptor.NO_OPTION) { currentPrimaryButtons[i] = stdNoButton; - } else if (primaryOptions[i] == NotifyDescriptor.OK_OPTION) { - currentPrimaryButtons[i] = stdOKButton; - stdOKButton.setEnabled(descriptor.isValid()); } else if (primaryOptions[i] == NotifyDescriptor.CANCEL_OPTION) { currentPrimaryButtons[i] = stdCancelButton; } else if (primaryOptions[i] == NotifyDescriptor.CLOSED_OPTION) { diff --git a/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java b/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java index 263ce9383694..dcd1ef2daccf 100644 --- a/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java +++ b/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java @@ -134,19 +134,19 @@ public class NotifyDescriptor extends Object { // /** Return value if YES is chosen. */ - public static final Object YES_OPTION = new Integer(JOptionPane.YES_OPTION); + public static final Object YES_OPTION = JOptionPane.YES_OPTION; /** Return value if NO is chosen. */ - public static final Object NO_OPTION = new Integer(JOptionPane.NO_OPTION); + public static final Object NO_OPTION = JOptionPane.NO_OPTION; /** Return value if CANCEL is chosen. */ - public static final Object CANCEL_OPTION = new Integer(JOptionPane.CANCEL_OPTION); + public static final Object CANCEL_OPTION = JOptionPane.CANCEL_OPTION; /** Return value if OK is chosen. */ - public static final Object OK_OPTION = new Integer(JOptionPane.OK_OPTION); + public static final Object OK_OPTION = JOptionPane.OK_OPTION; /** Return value if user closes the window without pressing any button. */ - public static final Object CLOSED_OPTION = new Integer(JOptionPane.CLOSED_OPTION); + public static final Object CLOSED_OPTION = JOptionPane.CLOSED_OPTION; // // Option types From c52de5d490fe5072e1fbef130c72d7cba7ff907e Mon Sep 17 00:00:00 2001 From: Neil C Smith Date: Mon, 8 Sep 2025 17:25:49 +0100 Subject: [PATCH 2/2] Remove YES and NO from dialog test. API does not specify these as supported options, and the implementation will no longer allow mixed with OK. --- .../jellytools/NbDialogOperatorTest.java | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/harness/jellytools.platform/test/qa-functional/src/org/netbeans/jellytools/NbDialogOperatorTest.java b/harness/jellytools.platform/test/qa-functional/src/org/netbeans/jellytools/NbDialogOperatorTest.java index 7890189fb021..324f0d6d1080 100644 --- a/harness/jellytools.platform/test/qa-functional/src/org/netbeans/jellytools/NbDialogOperatorTest.java +++ b/harness/jellytools.platform/test/qa-functional/src/org/netbeans/jellytools/NbDialogOperatorTest.java @@ -38,15 +38,11 @@ public class NbDialogOperatorTest extends JellyTestCase { "testBtCancel", "testBtClose", "testBtHelp", - "testBtNo", "testBtOK", - "testBtYes", "testCancel", "testClose", "testHelp", - "testNo", "testOK", - "testYes" }; /** constructor required by JUnit @@ -123,29 +119,6 @@ public void testCancel() { assertTrue("Cancel not pushed.", getResult().equals(DialogDescriptor.CANCEL_OPTION)); } - /** Test Yes button getter. */ - public void testBtYes() { - new NbDialogOperator(TEST_DIALOG_TITLE).btYes().push(); - assertTrue("Yes not detected correctly.", getResult().equals(DialogDescriptor.YES_OPTION)); - } - - /** Test Yes button pushing. */ - public void testYes() { - new NbDialogOperator(TEST_DIALOG_TITLE).yes(); - assertTrue("Yes not pushed.", getResult().equals(DialogDescriptor.YES_OPTION)); - } - - /** Test No button getter. */ - public void testBtNo() { - new NbDialogOperator(TEST_DIALOG_TITLE).btNo().push(); - assertTrue("No not detected correctly.", getResult().equals(DialogDescriptor.NO_OPTION)); - } - - /** Test No button pushing. */ - public void testNo() { - new NbDialogOperator(TEST_DIALOG_TITLE).no(); - assertTrue("No not pushed.", getResult().equals(DialogDescriptor.NO_OPTION)); - } private TestLabel label; /** Opens modal dialog with OK, Cancel, Yes, No, Close and Help buttons. @@ -155,8 +128,6 @@ protected void showTestDialog(String testDialogTitle) { Object[] options = new Object[]{ DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION, - DialogDescriptor.YES_OPTION, - DialogDescriptor.NO_OPTION, DialogDescriptor.CLOSED_OPTION }; label = new TestLabel(TEST_DIALOG_LABEL);