DialogComponentButton and setEnabled() --> java.lang.AssertionError

Hi,

I got an java exception when I try to disable a DialogComponentButton using

DialogComponentButton button = new DialogComponentButton("test");

button.getModel().setEnabled(false);
button.setEnabled(false);

in the Constructor of a class which extends DefaultNodeSettingsPane.

java.lang.AssertionError
    at org.knime.core.node.defaultnodesettings.DialogComponent$EmptySettingsModel.setEnabled(DialogComponent.java:413)
    at path.to.my.package.FileSelectorNodeDialog.<init>(FileSelectorNodeDialog.java:80)
    at path.to.my.package.FastaSelectorNodeDialog.<init>(FastaSelectorNodeDialog.java:19)
    at path.to.my.package.FastaSelectorNodeFactory.createNodeDialogPane(FastaSelectorNodeFactory.java:52)
    at org.knime.core.node.Node$1.run(Node.java:1901)
    at org.knime.core.node.util.ViewUtils$3.run(ViewUtils.java:309)
    at org.knime.core.node.util.ViewUtils$2.run(ViewUtils.java:130)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:682)
    at java.awt.EventQueue$3.run(EventQueue.java:680)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

Any idea what might be the problem ?

Greetings, Michael

This seems to be a problem of the underlying EmptySettingsModel. We encourage people to use #setEnabled(boolean) on the dialog components directly, however, the underlying settings model does not support #setEnabled(boolean). I will open a bug report. In the meantime, you would need to derive the DialogComponentButton add make the method #setEnabledComponents(boolean) public which you then can call from your dialog pane.

In case anyone is wondering: Seven years later the class still throws a totally stupid assertion error and the button can only be disabled by creating another subclass. Oh well.

1 Like