selecting a value from a selected column

I asked a question about selecting a value from a selected column. Thank you very much for your kind answer. I am sorry that I don’t understand all the information because I am a beginner.
I added the 3 procedures that you taught me:

  1. store a reference to the input table spec:
    knime-base/LogRegLearnerNodeDialogPane.java at master · knime/knime-base · GitHub 7
  2. Implement the code to update the selection model based on the domain data:
    knime-base/LogRegLearnerNodeDialogPane.java at master · knime/knime-base · GitHub 5
  3. Don’t forget to add an EventListener to your column selection widget:
    knime-base/LogRegLearnerNodeDialogPane.java at master · knime/knime-base · GitHub 1

However, the dialog disappears after I add them. I guess the reason is that something wrong with JComboBox m_targetReferenceCategory. Chould you please help me find the problem?
My code shows in the future below:


I am trying to select a ‘label column’ and then select a specified value from the column.
Thank you very much!

Best regards,
Chen

Hi @Chen_Zhang,

What do you mean by that? Is an exception thrown ? Is the dialog window closed or how does it disappear?

best,
Gabriel

1 Like

The dialog can’t be opened anymore. I can open it by double click or right click → configure before I add the code.
Before:
image

After:

And the errors like this:

Hi @Chen_Zhang,

Looks like you are trying to access an uninitialized variable in line 86. If you configure your eclipse to use a Java 17 VM to start your AP (supported from AP 4.6) it will tell you exactly what variable is causing this error. From the screenshots you sent, it looks like the m_selectionPanel is null during initialization.

best,
Gabriel

Hi, thanks for your reply.
Now I am trying to solve m_selectionPanel and meet this error. I switch Java 11 to 17 now but I didn’t see more support and I didn’t find what is ‘my AP’. How can I handle this?

I am trying to look through ColumnSelectionPanel. It looks like this.


Thank you very much.

Hi @Chen_Zhang,

With AP I mean KNIME Analytics Platform, the tool you are developing your extensions for.
Rergarding your error, there is a NominalValue interface and a class, make sure you imported the interface and not the class, as that one won’t work.
image

best,
Gabriel

1 Like

I have opened the dialog after importing the interface! Thanks!
Now the new dialog looks like making some space for the drop-down list but doesn’t show the reference category.


I haven’t add these codes:

updateTargetCategories(settings.getTargetReferenceCategory());
m_notSortTarget.setSelected(settings.getUseTargetDomainOrder());
m_notSortIncludes.setSelected(settings.getUseFeatureDomainOrder());

I know how to solve column selection:

	trainingColumnSettings = VennAbersNodeModel.createTrainingColumnSettings();
	testColumnSettings = VennAbersNodeModel.createTestColumnSettings();
	
	addDialogComponent(new DialogComponentColumnNameSelection(testColumnSettings, "Test object column for Y=1:", tableIndex,
			DataValue.class));
	addDialogComponent(new DialogComponentColumnNameSelection(trainingColumnSettings, "Training object column for Y=1:", tableIndex,
			DataValue.class));

Like this.
Can I do similar things in nodemodel for getTargetReferenceCategory(), getUseTargetDomainOrder() and getUseFeatureDomainOrder()?

Hi @Chen_Zhang,

To get a value out of the node settings, you need to use a settings model initialized with the same key. Then you can use m_settingsModel.load() on the settings object.

best,
Gabriel

1 Like

Thanks. It sounds quite general to me so what I can do is try to add ‘protected void loadSettingsFrom’ like the example.
The first problem is if I extend NodeDialogPane, then how can I fix this?

The second problem is that is it necessary to have a settings.java file? I am very new to this settings file. There is a nodemodel.java, nodefactory.java, and a nodedialog.java in the ‘.nodes’ packetage.

What parts are necessary to me in the settings.java?

Am I on the right way to the answer? Thank you for your tolerance for newbies.

Hi @Chen_Zhang,

If you want a simpler way to create the node dialog panel, use DefaultNodeSettingsPane, then you also do not need to worry about settings loading and saving.

The Settings classes are used for nodes that have specialized settings, if you develop a simpler node you won’t require it.

best,
Gabriel

1 Like

OK. Now I want to do a simpler node and meet this problem. I actually mixed up the complex one and the simpler one. I extend DefaultNodeSettingsPane now and I think I should remove these settings. I don’t know what I need for a simpler node. Could you please give me an example of a simpler node?


image

Hi @Chen_Zhang,

You can delete the loadSettingsFrom method from your class.
To see other implementations of the DefaultDialogPane, press F4 in Eclipse to open the type hierachy, then you can see other classes that inherit from that class and take a look how they do it.

best,
Gabriel

1 Like

Hi!

I opened the type hierarchy, and I checked inherited members.

However, I couldn’t find the ones I needed. which ones are needed for my case?
Thanks for your kind guidance.

Best regards,
Chen

You need to open it on the DefaultNodeSettingsPane itself, rightclick, select Focus On ...
image
Then you can see all implementations:

best,
Gabriel

1 Like

Hi,

Thanks for your reply. Now I can see all implementations. However, I don’t know which one I can use as my example because there are many node dialogs.

I have looked through many nodes in the KNIME platform but I didn’t find a similar one. Is there any existing node like the Logistic regression node that we can select a value from a selected column?

Best regards,
Chen

Hi,
Or could you kindly give me a method in DefaultNodeSettingsPane, which is for selecting a value from a selected column?

Best regards,
Chen

Hi,
Just a kind reminder.
Best regards,
Chen

Hi @Chen_Zhang,

Thank you for reminding me about this, I looked deeper into this issues and as far as I can tell, there is no easy way to do this with a default dialog pane.
The one node I found that has a similar behavior to what I think you want to do is the logistic regression learner, you can see the implementation of the dialog is a bit complicated though:

best,
Gabriel

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.