Search in sources :

Example 6 with ExtensibleUtilityFactory

use of org.knime.core.data.ExtensibleUtilityFactory in project knime-core by knime.

the class ExtensibleUtilityFactoryTest method testNoRegisteredRenderers.

/**
 * Tests basic functionality of the extension point.
 */
@Test
public void testNoRegisteredRenderers() {
    ExtensibleUtilityFactory utilityFactory = Test2DataValue.UTILITY;
    assertThat("Wrong utility factory retrieved via data type", DataType.getUtilityFor(Test2DataValue.class), is((UtilityFactory) utilityFactory));
    Collection<DataValueRendererFactory> availableRenderers = utilityFactory.getAvailableRenderers();
    assertThat("Wrong number of available renderers", availableRenderers.size(), is(0));
    assertThat("Unexpected preferred renderer", utilityFactory.getPreferredRenderer(), is(IsNull.nullValue()));
}
Also used : ExtensibleUtilityFactory(org.knime.core.data.ExtensibleUtilityFactory) UtilityFactory(org.knime.core.data.DataValue.UtilityFactory) ExtensibleUtilityFactory(org.knime.core.data.ExtensibleUtilityFactory) Test(org.junit.Test)

Example 7 with ExtensibleUtilityFactory

use of org.knime.core.data.ExtensibleUtilityFactory in project knime-core by knime.

the class PreferenceInitializer method initializeDefaultPreferences.

/**
 * {@inheritDoc}
 */
@Override
public void initializeDefaultPreferences() {
    // get the preference store for the UI plugin
    IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
    store.setDefault(PreferenceConstants.P_HIDE_TIPS_AND_TRICKS, false);
    store.setDefault(PreferenceConstants.P_CONFIRM_RESET, true);
    store.setDefault(PreferenceConstants.P_CONFIRM_DELETE, true);
    store.setDefault(PreferenceConstants.P_CONFIRM_RECONNECT, true);
    store.setDefault(PreferenceConstants.P_CONFIRM_EXEC_NODES_NOT_SAVED, true);
    store.setDefault(PreferenceConstants.P_CONFIRM_LOAD_NIGHTLY_BUILD_WORKFLOW, true);
    store.setDefault(PreferenceConstants.P_EXEC_NODES_DATA_AWARE_DIALOGS, MessageDialogWithToggle.PROMPT);
    store.setDefault(PreferenceConstants.P_FAV_FREQUENCY_HISTORY_SIZE, 10);
    store.setDefault(PreferenceConstants.P_FAV_LAST_USED_SIZE, 10);
    store.setDefault(PreferenceConstants.P_DEFAULT_NODE_LABEL, "Node");
    final Display defaultDisplay = Display.getDefault();
    store.setDefault(PreferenceConstants.P_NODE_LABEL_FONT_SIZE, 8);
    // run this async as there were strange exception on windows, even if in swt thread, see bug 6401
    defaultDisplay.asyncExec(new Runnable() {

        @Override
        public void run() {
            Font systemFont = defaultDisplay.getSystemFont();
            FontData[] systemFontData = systemFont.getFontData();
            if (systemFontData.length >= 1) {
                store.setDefault(PreferenceConstants.P_NODE_LABEL_FONT_SIZE, systemFontData[0].getHeight());
            }
        }
    });
    store.setDefault(PreferenceConstants.P_META_NODE_LINK_UPDATE_ON_LOAD, MessageDialogWithToggle.PROMPT);
    store.setDefault(PreferenceConstants.P_GRID_SHOW, Boolean.TRUE);
    store.setDefault(PreferenceConstants.P_GRID_SNAP_TO, Boolean.TRUE);
    store.setDefault(PreferenceConstants.P_GRID_SIZE_X, PreferenceConstants.P_GRID_DEFAULT_SIZE_X);
    store.setDefault(PreferenceConstants.P_GRID_SIZE_Y, PreferenceConstants.P_GRID_DEFAULT_SIZE_Y);
    store.setDefault(PreferenceConstants.P_CURVED_CONNECTIONS, PreferenceConstants.P_DEFAULT_CURVED_CONNECTIONS);
    store.setDefault(PreferenceConstants.P_CONNECTIONS_LINE_WIDTH, PreferenceConstants.P_DEFAULT_CONNECTION_LINE_WIDTH);
    store.setDefault(PreferenceConstants.P_AUTO_SAVE_ENABLE, PreferenceConstants.P_AUTO_SAVE_DEFAULT_ENABLE);
    store.setDefault(PreferenceConstants.P_AUTO_SAVE_INTERVAL, PreferenceConstants.P_AUTO_SAVE_DEFAULT_INTERVAL_SECS);
    store.setDefault(PreferenceConstants.P_AUTO_SAVE_DATA, PreferenceConstants.P_AUTO_SAVE_DEFAULT_WITH_DATA);
    store.setDefault(PreferenceConstants.P_WRAP_TABLE_HEADER, PreferenceConstants.P_WRAP_TABLE_HEADER_DEFAULT);
    store.setDefault(PreferenceConstants.P_ANNOTATION_BORDER_SIZE, PreferenceConstants.P_ANNOTATION_BORDER_SIZE_DEFAULT);
    // this loads all registered renderers and initializes the default value
    for (ExtensibleUtilityFactory fac : ExtensibleUtilityFactory.getAllFactories()) {
        // this sets the default preference for the renderer for this data type
        fac.getDefaultRenderer();
    }
    TableStoreFormatRegistry.getInstance().getDefaultTableStoreFormat();
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Font(org.eclipse.swt.graphics.Font) Display(org.eclipse.swt.widgets.Display) ExtensibleUtilityFactory(org.knime.core.data.ExtensibleUtilityFactory)

Aggregations

ExtensibleUtilityFactory (org.knime.core.data.ExtensibleUtilityFactory)7 UtilityFactory (org.knime.core.data.DataValue.UtilityFactory)5 Test (org.junit.Test)3 JCheckBox (javax.swing.JCheckBox)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 ComboFieldEditor (org.eclipse.jface.preference.ComboFieldEditor)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 Font (org.eclipse.swt.graphics.Font)1 Composite (org.eclipse.swt.widgets.Composite)1 Display (org.eclipse.swt.widgets.Display)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 DataColumnSpec (org.knime.core.data.DataColumnSpec)1