Miscellaneous Node Development Questions

How do I make ports of a node take tuples as inputs or outputs? What is the PortObject parameter I’ve seen in some nodes?

Should I be using AWT and Swing for my dialog components or should I be using components in KNIME? (For example, the FileSelectionDialog class: org.knime.filehandling.core.defaultnodesettings.fileselection)

How do I access the state of the dialog in the model?

How do I let my users modify ports with a Meatball menu?
image

Any other resources for developing KNIME nodes would be appreciated.

Hi @azsb1g19

  1. what do you mean with tuples? several tables?
  2. PortObject is more general than BufferedDataTable, its for other port types like Models
  3. Dialogcomponents is easiest. The other options require you to handle your preferences manually
  4. What kind of state do you want to access? Usually you configure the node, then you use the configured preferences in the node model
  5. The port meatball is the result of using a special NodeFactory class, see this community node for an example continental-nodes-for-knime/XlsFormatterApplyNodeFactory.java at master · continental/continental-nodes-for-knime · GitHub

Thanks! I understand 3 and 5 but here are my responses and questions about the others points you’ve raised.

  1. I want to pass a bunch of variables across nodes but I only want one connection port. The tuple/dictionary/whatever I specifically want at the moment consists of: An object which is a subset of the Workflow object output by the Integrated Deployment ‘Capture Workflow End’ node, an integer, and a graph.

  2. I looked through the source code of PortObject and I’m unclear what can be a PortObject. For example, can an integer or boolean be a PortObject? Can a dictionary/tuple be a PortObject? Can any object be a PortObject? The reason I’d like to know this is to pass along a bunch of variables with just one port.

  3. I sort of understand this but not practically. Say I have a checkbox in my node Dialog and I want to get that state in the Model, how could I do that?

  1. You need to create a new PortObject class that provides this functionality, which also answers 2), PortObjects are the classes that define the connection ports of nodes. They can consist of complex types such as tuples of other PortObjects.

  2. You use the same settingsmodel in both dialog:
    knime-examples/NumberFormatterNodeDialog.java at master · knime/knime-examples · GitHub
    and NodeModel:
    knime-examples/NumberFormatterNodeModel.java at master · knime/knime-examples · GitHub

I recommend you to read through all the comments in that example project, as they are very detailed.

best,
Gabriel

2 Likes

Hey thanks!
I have some questions regarding 1.

When I was trying to make my own class that implemented the PortObject interface I looked at the FileSystemPortObject class. That class extends AbstractSimplePortObject and in that class. I believe I should extend this class, is that correct? And then I need to make a PortObjectSpec class that extends AbstractSimplePortObjectSpec, and this would be the class that has my variables using models?

Also, what are ModelContentRO and ModelContentWO? I believe I need to read and write state using ‘models’ but what actually are they?

I can see methods in those model classes for accessing and modifying fundamental data types and arrays, but how do I add those complex types like tuples, PortObjects and tables?

Thanks again,

Hi I’m still struggling with understanding how to build complex types for PortObject… Would you be able to answer my questions above :slight_smile: ?

@azsb1g19 Only the OP (in this case: you) get notifications per default if new answers are posted. If you want to make sure your post is read by specific users, it’s a good idea to mention them directly.

I’ll do it right away: @gab1one

Hi @azsb1g19

The best way to start with creating a new port object is to add a org.knime.core.PortType extension point to your plugin:


This tells you which classes you need to implement. When you click on the underlined elements in the ExtensionPointDetails, it will open a new class dialog, pre-populated with the correct interfaces.

These interfaces should also contain the documentation in their javadoc that tells you what you need.

best,
Gabriel

2 Likes

Thanks @gab1one,
I followed those steps and I’m not able to resolve this import:
image
I can’t find it to add to my dependencies… Any ideas?
image