Want to disable DialogComponentButton,setEnabled() method is deprecated and suggest use correspond SettingsModel to disable the button.But did not find correspond SettingsModel
thanks
I think what they mean is:
org.knime.core.node.defaultnodesettings.DialogComponent.getModel()
thanks,you mean override the method ?
org.knime.core.node.defaultnodesettings.DialogComponent.getModel()
No, overriding is not necessary, just do org.knime.core.node.defaultnodesettings.SettingsModel.setEnabled(boolean)
on it.
SettingsModel it’s abstactc class can not call the method org.knime.core.node.defaultnodesettings.SettingsModel.setEnabled(boolean)
directly.
thanks
This is what I meant to say
DialogComponentButton button = new DialogComponentButton("Button");
button.getModel().setEnabled(true);
Best,
Philipp
thanks
just tried your solution,but got error
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.AssertionError
at org.knime.core.node.defaultnodesettings.DialogComponent$EmptySettingsModel.setEnabled(DialogComponent.java:410)
at com.gw.knime.connector.tsdb.TSDBNodeDialog.createTSDBQueryParamTab(TSDBNodeDialog.java:80)
at com.gw.knime.connector.tsdb.TSDBNodeDialog.(TSDBNodeDialog.java:38)
at com.gw.knime.connector.tsdb.TSDBNodeFactory.createNodeDialogPane(TSDBNodeFactory.java:48)
at org.knime.core.node.Node$1.run(Node.java:2148)
at org.knime.core.node.util.ViewUtils$3.run(ViewUtils.java:353)
at org.knime.core.node.util.ViewUtils$2.run(ViewUtils.java:155)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
For the DialogComponentButton
, you have to user the deprecated setEnabled()
method. The reason is that is you look in the source code, you will see that it uses EmptySettingsModel
:
which never expects to be enabled/disabled - in fact, buried in the source code for EmptySettingsModel
is this warning:
Specifically, ‘Do not call any methods of this model’… as you can see for the setEnabled(boolean)
method, that’s going to throw an AssertionException whenever you call it, rather than do anything useful:
The setEnabled(boolean)
method of DialogComponentButton
does behave as expected:
The same caveats also apply to DialogComponentLabel
.
Steve
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.