-
Notifications
You must be signed in to change notification settings - Fork 5
UIEXT-3570: Add examples framework #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PaulBrnrther
wants to merge
2
commits into
master
Choose a base branch
from
todo/UIEXT-3570-lay-out-document-by-example-framework
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
org.knime.core.ui/src/eclipse/org/knime/node/parameters/examples/FileSelectionExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * ------------------------------------------------------------------------ | ||
| * | ||
| * Copyright by KNIME AG, Zurich, Switzerland | ||
| * Website: http://www.knime.com; Email: contact@knime.com | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License, Version 3, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but | ||
| * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, see <http://www.gnu.org/licenses>. | ||
| * | ||
| * Additional permission under GNU GPL version 3 section 7: | ||
| * | ||
| * KNIME interoperates with ECLIPSE solely via ECLIPSE's plug-in APIs. | ||
| * Hence, KNIME and ECLIPSE are both independent programs and are not | ||
| * derived from each other. Should, however, the interpretation of the | ||
| * GNU GPL Version 3 ("License") under any applicable laws result in | ||
| * KNIME and ECLIPSE being a combined program, KNIME AG herewith grants | ||
| * you the additional permission to use and propagate KNIME together with | ||
| * ECLIPSE with only the license terms in place for ECLIPSE applying to | ||
| * ECLIPSE and the GNU GPL Version 3 applying for KNIME, provided the | ||
| * license terms of ECLIPSE themselves allow for the respective use and | ||
| * propagation of ECLIPSE together with KNIME. | ||
| * | ||
| * Additional permission relating to nodes for KNIME that extend the Node | ||
| * Extension (and in particular that are based on subclasses of NodeModel, | ||
| * NodeDialog, and NodeView) and that only interoperate with KNIME through | ||
| * standard APIs ("Nodes"): | ||
| * Nodes are deemed to be separate and independent programs and to not be | ||
| * covered works. Notwithstanding anything to the contrary in the | ||
| * License, the License does not apply to Nodes, you are not required to | ||
| * license Nodes under the License, and you are granted a license to | ||
| * prepare and propagate Nodes, in each case even if such Nodes are | ||
| * propagated with or for interoperation with KNIME. The owner of a Node | ||
| * may freely choose the license terms applicable to such Node, including | ||
| * when such Node is propagated with or for interoperation with KNIME. | ||
| * --------------------------------------------------------------------- | ||
| * | ||
| * History | ||
| * Apr 16, 2026 (paulbaernreuther): created | ||
| */ | ||
| package org.knime.node.parameters.examples; | ||
|
|
||
| import org.knime.node.parameters.Widget; | ||
| import org.knime.node.parameters.examples.impl.ExampleNodeParameters; | ||
| import org.knime.node.parameters.examples.impl.ExampleNodeParameters.NodeParametersExample; | ||
| import org.knime.node.parameters.widget.file.FileReaderWidget; | ||
| import org.knime.node.parameters.widget.file.FileSelection; | ||
| import org.knime.node.parameters.widget.file.FileSelectionWidget; | ||
| import org.knime.node.parameters.widget.file.FileSystemOption; | ||
| import org.knime.node.parameters.widget.file.FileWriterWidget; | ||
| import org.knime.node.parameters.widget.file.SingleFileSelectionMode; | ||
| import org.knime.node.parameters.widget.file.WithFileSystem; | ||
|
|
||
| /** | ||
| * Demonstrates {@link FileSelection} fields for file chooser widgets. A file reader accepts CSV and TXT files from all | ||
| * file systems, while a folder writer restricts to LOCAL and SPACE. | ||
| * | ||
| * @author Paul Bärnreuther | ||
| */ | ||
| @NodeParametersExample(name = "File Selection", searchTags = {"file", "reader", "writer", "folder", "path"}) | ||
| public final class FileSelectionExample implements ExampleNodeParameters { | ||
|
|
||
| @Widget(title = "Input file", description = "Select a CSV or TXT file to read from any available file system.") | ||
| @FileReaderWidget(fileExtensions = {"csv", "txt"}) | ||
| FileSelection m_inputFile = new FileSelection(); | ||
|
|
||
| @Widget(title = "Output folder", | ||
| description = "Select a folder to write to. Only LOCAL and SPACE file systems are available.") | ||
| @FileWriterWidget | ||
| @FileSelectionWidget(SingleFileSelectionMode.FOLDER) | ||
| @WithFileSystem({FileSystemOption.LOCAL, FileSystemOption.SPACE}) | ||
| FileSelection m_outputFolder = new FileSelection(); | ||
|
|
||
| } |
193 changes: 193 additions & 0 deletions
193
...i/src/eclipse/org/knime/node/parameters/examples/IndexedConfigKeysPersistenceExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| /* | ||
| * ------------------------------------------------------------------------ | ||
| * | ||
| * Copyright by KNIME AG, Zurich, Switzerland | ||
| * Website: http://www.knime.com; Email: contact@knime.com | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License, Version 3, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but | ||
| * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, see <http://www.gnu.org/licenses>. | ||
| * | ||
| * Additional permission under GNU GPL version 3 section 7: | ||
| * | ||
| * KNIME interoperates with ECLIPSE solely via ECLIPSE's plug-in APIs. | ||
| * Hence, KNIME and ECLIPSE are both independent programs and are not | ||
| * derived from each other. Should, however, the interpretation of the | ||
| * GNU GPL Version 3 ("License") under any applicable laws result in | ||
| * KNIME and ECLIPSE being a combined program, KNIME AG herewith grants | ||
| * you the additional permission to use and propagate KNIME together with | ||
| * ECLIPSE with only the license terms in place for ECLIPSE applying to | ||
| * ECLIPSE and the GNU GPL Version 3 applying for KNIME, provided the | ||
| * license terms of ECLIPSE themselves allow for the respective use and | ||
| * propagation of ECLIPSE together with KNIME. | ||
| * | ||
| * Additional permission relating to nodes for KNIME that extend the Node | ||
| * Extension (and in particular that are based on subclasses of NodeModel, | ||
| * NodeDialog, and NodeView) and that only interoperate with KNIME through | ||
| * standard APIs ("Nodes"): | ||
| * Nodes are deemed to be separate and independent programs and to not be | ||
| * covered works. Notwithstanding anything to the contrary in the | ||
| * License, the License does not apply to Nodes, you are not required to | ||
| * license Nodes under the License, and you are granted a license to | ||
| * prepare and propagate Nodes, in each case even if such Nodes are | ||
| * propagated with or for interoperation with KNIME. The owner of a Node | ||
| * may freely choose the license terms applicable to such Node, including | ||
| * when such Node is propagated with or for interoperation with KNIME. | ||
| * --------------------------------------------------------------------- | ||
| * | ||
| * History | ||
| * Apr 16, 2026 (paulbaernreuther): created | ||
| */ | ||
| package org.knime.node.parameters.examples; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.function.Consumer; | ||
|
|
||
| import org.knime.core.node.InvalidSettingsException; | ||
| import org.knime.core.node.NodeSettingsRO; | ||
| import org.knime.core.node.NodeSettingsWO; | ||
| import org.knime.node.parameters.NodeParameters; | ||
| import org.knime.node.parameters.Widget; | ||
| import org.knime.node.parameters.examples.impl.ExampleNodeParameters; | ||
| import org.knime.node.parameters.examples.impl.ExampleNodeParameters.NodeParametersExample; | ||
| import org.knime.node.parameters.experimental.persistence.array.ArrayPersistor; | ||
| import org.knime.node.parameters.experimental.persistence.array.ElementFieldPersistor; | ||
| import org.knime.node.parameters.experimental.persistence.array.PersistArray; | ||
| import org.knime.node.parameters.experimental.persistence.array.PersistArrayElement; | ||
|
|
||
| /** | ||
| * Demonstrates the indexed config keys pattern for custom array persistence. Array elements are persisted with config | ||
| * keys that include the element's index (e.g. "value0", "value1", "number0", "number1"). This is useful for | ||
| * compatibility with existing settings formats that use indexed keys. | ||
| * | ||
| * @author Paul Bärnreuther | ||
| */ | ||
| @NodeParametersExample(name = "Indexed Config Keys Persistence", | ||
| searchTags = {"array", "persistence", "custom", "legacy", "indexed"}) | ||
| public final class IndexedConfigKeysPersistenceExample implements ExampleNodeParameters { | ||
|
|
||
| @Widget(title = "Indexed items", | ||
| description = "Each element is persisted with indexed config keys (e.g. value0, number0, value1, number1).") | ||
| @PersistArray(IndexedArrayPersistor.class) | ||
| Item[] m_items = new Item[0]; | ||
|
|
||
| /** | ||
| * Element class representing a single item with indexed persistence. | ||
| */ | ||
| public static final class Item implements NodeParameters { | ||
|
|
||
| @Widget(title = "Value", description = "A string value persisted as 'valueN'.") | ||
| @PersistArrayElement(ValuePersistor.class) | ||
| String m_value = ""; | ||
|
|
||
| @Widget(title = "Number", description = "An integer value persisted as 'numberN'.") | ||
| @PersistArrayElement(NumberPersistor.class) | ||
| int m_number; | ||
| } | ||
|
|
||
| static final class IndexedSaveDTO { | ||
| private final int m_index; | ||
|
|
||
| private final List<Consumer<NodeSettingsWO>> m_nodeSettingsConsumers = new ArrayList<>(); | ||
|
|
||
| IndexedSaveDTO(final int index) { | ||
| m_index = index; | ||
| } | ||
|
|
||
| int getIndex() { | ||
| return m_index; | ||
| } | ||
|
|
||
| void addNodeSettingsModification(final Consumer<NodeSettingsWO> consumer) { | ||
| m_nodeSettingsConsumers.add(consumer); | ||
| } | ||
|
|
||
| List<Consumer<NodeSettingsWO>> getNodeSettingsConsumers() { | ||
| return m_nodeSettingsConsumers; | ||
| } | ||
| } | ||
|
|
||
| static final class IndexedArrayPersistor implements ArrayPersistor<Integer, IndexedSaveDTO> { | ||
|
|
||
| private static final String NUMBER_OF_ITEMS = "numberOfItems"; | ||
|
|
||
| @Override | ||
| public int getArrayLength(final NodeSettingsRO nodeSettings) { | ||
| return nodeSettings.getInt(NUMBER_OF_ITEMS, 0); | ||
| } | ||
|
|
||
| @Override | ||
| public Integer createElementLoadContext(final int index) { | ||
| return index; | ||
| } | ||
|
|
||
| @Override | ||
| public IndexedSaveDTO createElementSaveDTO(final int index) { | ||
| return new IndexedSaveDTO(index); | ||
| } | ||
|
|
||
| @Override | ||
| public void save(final List<IndexedSaveDTO> savedElements, final NodeSettingsWO nodeSettings) { | ||
| nodeSettings.addInt(NUMBER_OF_ITEMS, savedElements.size()); | ||
| for (IndexedSaveDTO saveDTO : savedElements) { | ||
| for (Consumer<NodeSettingsWO> consumer : saveDTO.getNodeSettingsConsumers()) { | ||
| consumer.accept(nodeSettings); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static final class ValuePersistor implements ElementFieldPersistor<String, Integer, IndexedSaveDTO> { | ||
|
|
||
| private static final String VALUE_KEY = "value"; | ||
|
|
||
| @Override | ||
| public String load(final NodeSettingsRO nodeSettings, final Integer loadContext) | ||
| throws InvalidSettingsException { | ||
| return nodeSettings.getString(VALUE_KEY + loadContext); | ||
| } | ||
|
|
||
| @Override | ||
| public void save(final String param, final IndexedSaveDTO saveDTO) { | ||
| final var index = saveDTO.getIndex(); | ||
| saveDTO.addNodeSettingsModification(settings -> settings.addString(VALUE_KEY + index, param)); | ||
| } | ||
|
|
||
| @Override | ||
| public String[][] getConfigPaths() { | ||
| return new String[][]{{VALUE_KEY + ARRAY_INDEX_PLACEHOLDER}}; | ||
| } | ||
| } | ||
|
|
||
| static final class NumberPersistor implements ElementFieldPersistor<Integer, Integer, IndexedSaveDTO> { | ||
|
|
||
| private static final String NUMBER_KEY = "number"; | ||
|
|
||
| @Override | ||
| public Integer load(final NodeSettingsRO nodeSettings, final Integer loadContext) | ||
| throws InvalidSettingsException { | ||
| return nodeSettings.getInt(NUMBER_KEY + loadContext); | ||
| } | ||
|
|
||
| @Override | ||
| public void save(final Integer param, final IndexedSaveDTO saveDTO) { | ||
| final var index = saveDTO.getIndex(); | ||
| saveDTO.addNodeSettingsModification(settings -> settings.addInt(NUMBER_KEY + index, param)); | ||
| } | ||
|
|
||
| @Override | ||
| public String[][] getConfigPaths() { | ||
| return new String[][]{{NUMBER_KEY + ARRAY_INDEX_PLACEHOLDER}}; | ||
| } | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change replaces the registered hidden node factory (
HiddenFeaturesNodeFactory) withDefaultNodeDialogExamplesNodeFactory, effectively removing the existing “hidden features” node from the repository extension. If the old node is still needed for QA/UX workflows, it should remain registered (e.g., as an additional hidden node) or the PR description should explicitly call out the removal/migration plan.