-
Notifications
You must be signed in to change notification settings - Fork 5
UIEXT-3554: Split legacy API from EffectPredicateProvider #198
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * ------------------------------------------------------------------------ | ||
| * | ||
| * 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 15, 2026 (Paul Bärnreuther): created | ||
| */ | ||
| package org.knime.core.webui.node.dialog.defaultdialog.impl.predicates; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.function.Function; | ||
|
|
||
| import org.knime.node.parameters.updates.EffectPredicate; | ||
| import org.knime.node.parameters.updates.PredicateInitializerExtension; | ||
|
|
||
| /** | ||
| * Registry for {@link PredicateInitializerExtension} factories. Extensions are registered at plugin startup (e.g. in | ||
| * {@code CoreUIPlugin#start}) and created on demand by the predicate initializer implementation. | ||
| * | ||
| * @author Paul Bärnreuther | ||
| */ | ||
| public final class PredicateInitializerExtensionPoint { | ||
|
|
||
| /** | ||
| * Factory that creates extension instances given a predicate creation capability. | ||
| * | ||
| * @param <T> the extension type | ||
| */ | ||
| @FunctionalInterface | ||
| public interface ExtensionFactory<T extends PredicateInitializerExtension> { | ||
|
Check warning on line 72 in org.knime.core.ui/src/eclipse/org/knime/core/webui/node/dialog/defaultdialog/impl/predicates/PredicateInitializerExtensionPoint.java
|
||
| /** | ||
| * @param predicateCreator maps a reference class to a function that creates predicates from conditions | ||
| * @return the extension instance | ||
| */ | ||
| T create(Function<Class<?>, Function<Condition, EffectPredicate>> predicateCreator); | ||
|
Check warning on line 77 in org.knime.core.ui/src/eclipse/org/knime/core/webui/node/dialog/defaultdialog/impl/predicates/PredicateInitializerExtensionPoint.java
|
||
| } | ||
|
|
||
| private static final Map<Class<? extends PredicateInitializerExtension>, ExtensionFactory<?>> REGISTRY = | ||
| new ConcurrentHashMap<>(); | ||
|
|
||
| private PredicateInitializerExtensionPoint() { | ||
| } | ||
|
|
||
| /** | ||
| * Registers an extension factory for the given type. | ||
| * | ||
| * @param <T> the extension type | ||
| * @param type the extension class | ||
| * @param factory creates extension instances given predicate creation capability | ||
| */ | ||
| public static <T extends PredicateInitializerExtension> void register(final Class<T> type, | ||
| final ExtensionFactory<T> factory) { | ||
| REGISTRY.put(type, factory); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an extension instance using the registered factory. | ||
| * | ||
| * @param <T> the extension type | ||
| * @param type the extension class | ||
| * @param predicateCreator maps a reference class to a function that creates predicates from conditions | ||
| * @return the extension instance | ||
| * @throws IllegalArgumentException if no factory is registered for the type | ||
| */ | ||
| @SuppressWarnings("unchecked") | ||
| public static <T extends PredicateInitializerExtension> T createExtension(final Class<T> type, | ||
| final Function<Class<?>, Function<Condition, EffectPredicate>> predicateCreator) { | ||
| final var factory = (ExtensionFactory<T>)REGISTRY.get(type); | ||
| if (factory == null) { | ||
| throw new IllegalArgumentException("No PredicateInitializerExtension registered for " + type.getName()); | ||
| } | ||
| return factory.create(predicateCreator); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * ------------------------------------------------------------------------ | ||
| * | ||
| * 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 15, 2026 (Paul Bärnreuther): created | ||
| */ | ||
| package org.knime.node.parameters.legacy.widget.file; | ||
|
|
||
| import org.knime.node.parameters.updates.EffectPredicateProvider.PredicateInitializer; | ||
| import org.knime.node.parameters.updates.EffectPredicateProvider.PredicateInitializer.EnumReference; | ||
| import org.knime.node.parameters.updates.ParameterReference; | ||
| import org.knime.node.parameters.updates.PredicateInitializerExtension; | ||
| import org.knime.node.parameters.updates.ValueReference; | ||
| import org.knime.node.parameters.widget.file.MultiFileSelectionMode; | ||
|
|
||
| /** | ||
| * Extension for {@link PredicateInitializer} providing predicate support for {@link LegacyMultiFileSelection} fields. | ||
| * Retrieve via {@link PredicateInitializer#getRegisteredPredicateInitializer(Class)}. | ||
| * | ||
| * @author Paul Bärnreuther | ||
| */ | ||
| public interface LegacyMultiFileSelectionPredicateInitializer extends PredicateInitializerExtension { | ||
|
|
||
| /** | ||
| * Returned by {@link #getLegacyMultiFileSelection} | ||
| */ | ||
| interface LegacyMultiFileSelectionReference { | ||
|
|
||
| EnumReference<MultiFileSelectionMode> getSelectionMode(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * @param reference bound to exactly one {@link LegacyMultiFileSelection} field via {@link ValueReference} | ||
| * @return an object that can be further transformed to a predicate using one of its methods | ||
| */ | ||
| LegacyMultiFileSelectionReference | ||
| getLegacyMultiFileSelection(Class<? extends ParameterReference<LegacyMultiFileSelection>> reference); | ||
|
Check warning on line 80 in org.knime.core.ui/src/eclipse/org/knime/node/parameters/legacy/widget/file/LegacyMultiFileSelectionPredicateInitializer.java
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.