Search in sources :

Example 6 with DataValueRendererFactory

use of org.knime.core.data.renderer.DataValueRendererFactory in project knime-core by knime.

the class DataType method getRendererFactories.

/**
 * Returns the list of registered renderer factories, using an extension point driven mechanism to collect all
 * instances registered with the implemented data value interfaces. If no renderer was declared by the
 * {@link org.knime.core.data.DataValue} interfaces, this method will make sure that at least a default renderer
 * (using the {@link DataCell#toString()} method) is returned.
 *
 * @return an ordered, non-empty collection of factories.
 * @since 2.12
 */
public Collection<DataValueRendererFactory> getRendererFactories() {
    Map<String, DataValueRendererFactory> map = new LinkedHashMap<>();
    Collection<Class<? extends DataValue>> allValueClasses = new LinkedHashSet<>();
    // first value will be the preferred one - if any
    allValueClasses.addAll(m_valueClasses);
    allValueClasses.addAll(m_adapterValueList);
    for (Class<? extends DataValue> cl : allValueClasses) {
        UtilityFactory fac = getUtilityFor(cl);
        if (!(fac instanceof ExtensibleUtilityFactory)) {
            continue;
        }
        ExtensibleUtilityFactory efac = (ExtensibleUtilityFactory) fac;
        // make sure the preferred and default renderers come first
        DataValueRendererFactory prefRendererFac = efac.getPreferredRenderer();
        if (prefRendererFac != null) {
            map.put(prefRendererFac.getId(), prefRendererFac);
        }
        DataValueRendererFactory defaultRendererFac = efac.getDefaultRenderer();
        if (defaultRendererFac != null) {
            map.put(defaultRendererFac.getId(), defaultRendererFac);
        }
        for (DataValueRendererFactory rf : efac.getAvailableRenderers()) {
            map.put(rf.getId(), rf);
        }
    }
    if (map.isEmpty()) {
        DefaultDataValueRenderer.Factory f = new DefaultDataValueRenderer.Factory();
        map.put(f.getId(), f);
    }
    return map.values();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CollectionDataValue(org.knime.core.data.collection.CollectionDataValue) DefaultDataValueRenderer(org.knime.core.data.renderer.DefaultDataValueRenderer) UtilityFactory(org.knime.core.data.DataValue.UtilityFactory) DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory) LinkedHashMap(java.util.LinkedHashMap) UtilityFactory(org.knime.core.data.DataValue.UtilityFactory) DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory)

Example 7 with DataValueRendererFactory

use of org.knime.core.data.renderer.DataValueRendererFactory in project knime-core by knime.

the class ExtensibleUtilityFactory method getDefaultRenderer.

/**
 * Returns the default renderer for this data value. If no renderer is registered with the data value (highly
 * unlikely) <code>null</code> is returned.
 *
 * @return a renderer factory or <code>null</code>
 */
public DataValueRendererFactory getDefaultRenderer() {
    readRenderersFromExtensionPoint();
    String defaultId = CORE_DEFAULT_PREFS.get(getPreferenceKey(), null);
    DataValueRendererFactory matchedFactory = m_renderers.get(defaultId);
    if (matchedFactory != null) {
        return matchedFactory;
    } else {
        return null;
    }
}
Also used : DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory)

Example 8 with DataValueRendererFactory

use of org.knime.core.data.renderer.DataValueRendererFactory in project knime-core by knime.

the class ExtensibleUtilityFactory method getPreferredRenderer.

/**
 * Returns the preferred renderer for this data value. If no preferred renderer is set for the data value,
 * <code>null</code> is returned.
 *
 * @return a renderer factory or <code>null</code>
 */
public DataValueRendererFactory getPreferredRenderer() {
    readRenderersFromExtensionPoint();
    String prefId = CORE_PREFS.get(getPreferenceKey(), null);
    DataValueRendererFactory matchedFactory = m_renderers.get(prefId);
    if (matchedFactory != null) {
        return matchedFactory;
    } else {
        return null;
    }
}
Also used : DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory)

Aggregations

DataValueRendererFactory (org.knime.core.data.renderer.DataValueRendererFactory)8 HashMap (java.util.HashMap)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 ComboFieldEditor (org.eclipse.jface.preference.ComboFieldEditor)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)1 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 Section (org.eclipse.ui.forms.widgets.Section)1 UtilityFactory (org.knime.core.data.DataValue.UtilityFactory)1