Search in sources :

Example 1 with ComboFieldEditor

use of org.eclipse.jface.preference.ComboFieldEditor in project knime-core by knime.

the class MainPreferencePage method createFieldEditors.

/**
 * Creates the field editors. Field editors are abstractions of the common
 * GUI blocks needed to manipulate various types of preferences. Each field
 * editor knows how to save and restore itself.
 */
@Override
public void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    // Specify the minimum log level for the console
    m_consoleLogEditor = new RadioGroupFieldEditor(KNIMECorePlugin.P_LOGLEVEL_CONSOLE, "Console View Log Level", 4, new String[][] { { "&DEBUG", LEVEL.DEBUG.name() }, { "&INFO", LEVEL.INFO.name() }, { "&WARN", LEVEL.WARN.name() }, { "&ERROR", LEVEL.ERROR.name() } }, parent);
    addField(m_consoleLogEditor);
    addField(new HorizontalLineField(parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_CONFIRM_RESET, "Confirm Node Reset", parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_CONFIRM_DELETE, "Confirm Node/Connection Deletion", parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_CONFIRM_RECONNECT, "Confirm reconnection of already connected nodes", parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_CONFIRM_EXEC_NODES_NOT_SAVED, "Confirm if executing nodes are not saved", parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_CONFIRM_LOAD_NIGHTLY_BUILD_WORKFLOW, "Confirm when loading workflows created by a nightly build", parent));
    ComboFieldEditor dataAwareExecutePromptEditor = new ComboFieldEditor(PreferenceConstants.P_EXEC_NODES_DATA_AWARE_DIALOGS, "Execute upstream nodes when needed", new String[][] { { "Always", MessageDialogWithToggle.ALWAYS }, { "Never", MessageDialogWithToggle.NEVER }, { "Prompt", MessageDialogWithToggle.PROMPT } }, getFieldEditorParent());
    addField(dataAwareExecutePromptEditor);
    addField(new HorizontalLineField(parent));
    final BooleanFieldEditor enableAutoSaveBooleanField = new BooleanFieldEditor(PreferenceConstants.P_AUTO_SAVE_ENABLE, "Auto Save open workflows", parent) {

        @Override
        protected void valueChanged(final boolean old, final boolean neu) {
            m_autoSaveIntervalEditor.setEnabled(neu, parent);
            m_autoSaveWithDataEditor.setEnabled(neu, parent);
        }
    };
    m_autoSaveIntervalEditor = new IntegerFieldEditor(PreferenceConstants.P_AUTO_SAVE_INTERVAL, "Auto-Save Interval (in secs)", parent);
    m_autoSaveWithDataEditor = new BooleanFieldEditor(PreferenceConstants.P_AUTO_SAVE_DATA, "Save with data", parent);
    addField(enableAutoSaveBooleanField);
    addField(m_autoSaveIntervalEditor);
    addField(m_autoSaveWithDataEditor);
    addField(new HorizontalLineField(parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_WRAP_TABLE_HEADER, "Wrap Column Header in Table Views", parent));
    addField(new IntegerFieldEditor(PreferenceConstants.P_ANNOTATION_BORDER_SIZE, "Workflow Annotation border size (in px)", parent));
    addField(new HorizontalLineField(parent));
    ComboFieldEditor updateMetaNodeLinkOnLoadEditor = new ComboFieldEditor(PreferenceConstants.P_META_NODE_LINK_UPDATE_ON_LOAD, "Update metanode links when workflow loads", new String[][] { { "Always", MessageDialogWithToggle.ALWAYS }, { "Never", MessageDialogWithToggle.NEVER }, { "Prompt", MessageDialogWithToggle.PROMPT } }, getFieldEditorParent());
    addField(updateMetaNodeLinkOnLoadEditor);
    addField(new HorizontalLineField(parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING, "Suppress warnings about missing browser integration", parent));
    addField(new HorizontalLineField(parent));
    addField(new LabelField(parent, "Settings for the 'Favorite Nodes' view"));
    IntegerFieldEditor freqHistorySizeEditor = new IntegerFieldEditor(PreferenceConstants.P_FAV_FREQUENCY_HISTORY_SIZE, "Maximal size for most frequently used nodes", parent, 3);
    freqHistorySizeEditor.setValidRange(1, 50);
    freqHistorySizeEditor.setTextLimit(3);
    freqHistorySizeEditor.load();
    IntegerFieldEditor usedHistorySizeEditor = new IntegerFieldEditor(PreferenceConstants.P_FAV_LAST_USED_SIZE, "Maximal size for last used nodes", parent, 3);
    usedHistorySizeEditor.setValidRange(1, 50);
    usedHistorySizeEditor.setTextLimit(3);
    usedHistorySizeEditor.load();
    addField(usedHistorySizeEditor);
    addField(freqHistorySizeEditor);
}
Also used : RadioGroupFieldEditor(org.eclipse.jface.preference.RadioGroupFieldEditor) Composite(org.eclipse.swt.widgets.Composite) IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor)

Example 2 with ComboFieldEditor

use of org.eclipse.jface.preference.ComboFieldEditor in project knime-core by knime.

the class PreferredRendererPreferencePage method createFieldEditors.

/**
 * {@inheritDoc}
 */
@Override
protected void createFieldEditors() {
    Map<String, List<ExtensibleUtilityFactory>> groupedUtilityFactories = new HashMap<String, List<ExtensibleUtilityFactory>>();
    // TODO retrieve the utility factories from the data type extension point once we have it
    for (ExtensibleUtilityFactory fac : ExtensibleUtilityFactory.getAllFactories()) {
        List<ExtensibleUtilityFactory> groupList = groupedUtilityFactories.get(fac.getGroupName());
        if (groupList == null) {
            groupList = new ArrayList<ExtensibleUtilityFactory>(16);
            groupedUtilityFactories.put(fac.getGroupName(), groupList);
        }
        groupList.add(fac);
    }
    List<String> groupNames = new ArrayList<String>(groupedUtilityFactories.keySet());
    Collections.sort(groupNames);
    for (String group : groupNames) {
        final Section sectionExpander = new Section(getFieldEditorParent(), ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
        sectionExpander.setText(group);
        final Composite section = new Composite(sectionExpander, SWT.NONE);
        sectionExpander.setClient(section);
        sectionExpander.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(final ExpansionEvent e) {
                Composite comp = section;
                while (!(comp instanceof ScrolledComposite)) {
                    comp = comp.getParent();
                }
                // this is to fix a bug in Eclipse, no scrollbar is shown when this is true
                ((ScrolledComposite) comp).setExpandVertical(false);
                comp = section;
                while (!(comp instanceof ScrolledComposite)) {
                    comp.setSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                    comp.layout();
                    comp = comp.getParent();
                }
            }
        });
        List<ExtensibleUtilityFactory> utilityFactories = groupedUtilityFactories.get(group);
        Collections.sort(utilityFactories, utilityFactoryComparator);
        for (ExtensibleUtilityFactory utilFac : utilityFactories) {
            List<DataValueRendererFactory> rendererFactories = new ArrayList<DataValueRendererFactory>(utilFac.getAvailableRenderers());
            Collections.sort(rendererFactories, rendererFactoryComparator);
            String[][] comboEntries = new String[utilFac.getAvailableRenderers().size()][2];
            int i = 0;
            for (DataValueRendererFactory rendFac : rendererFactories) {
                comboEntries[i++] = new String[] { rendFac.getDescription(), rendFac.getId() };
            }
            ComboFieldEditor c = new ComboFieldEditor(utilFac.getPreferenceKey(), utilFac.getName(), comboEntries, section);
            c.setEnabled(comboEntries.length > 1, section);
            addField(c);
            m_fieldEditors.put(utilFac.getPreferenceKey(), c);
        }
        // add a dummy control which occupies the second column so that the next expander is in a new row
        new Label(getFieldEditorParent(), SWT.NONE);
    }
    DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(DataValueRendererFactory.class).getSymbolicName()).addPreferenceChangeListener(this);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) Section(org.eclipse.ui.forms.widgets.Section) ExtensibleUtilityFactory(org.knime.core.data.ExtensibleUtilityFactory) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ArrayList(java.util.ArrayList) List(java.util.List) DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 3 with ComboFieldEditor

use of org.eclipse.jface.preference.ComboFieldEditor in project yamcs-studio by yamcs.

the class OPIRuntimePreferencePage method createFieldEditors.

@Override
protected void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    macrosEditor = new StringTableFieldEditor(PreferencesHelper.RUN_MACROS, "Macros: ", parent, new String[] { "Name", "Value" }, new boolean[] { true, true }, new MacroEditDialog(parent.getShell()), new int[] { 120, 120 }) {

        @Override
        public boolean isValid() {
            String reason;
            for (String[] row : items) {
                reason = Verifier.checkElementName(row[0]);
                if (reason != null) {
                    wrongMacroName = row[0];
                    return false;
                }
            }
            return true;
        }

        @Override
        protected void doStore() {
            if (!isValid())
                return;
            super.doStore();
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns);
            tableEditor.getTableViewer().getTable().addKeyListener(new KeyAdapter() {

                @Override
                public void keyReleased(KeyEvent e) {
                    boolean valid = isValid();
                    fireStateChanged(IS_VALID, !valid, valid);
                }
            });
            tableEditor.getTableViewer().getTable().addFocusListener(new FocusListener() {

                @Override
                public void focusLost(FocusEvent e) {
                    boolean valid = isValid();
                    fireStateChanged(IS_VALID, !valid, valid);
                }

                @Override
                public void focusGained(FocusEvent e) {
                    boolean valid = isValid();
                    fireStateChanged(IS_VALID, !valid, valid);
                }
            });
        }
    };
    addField(macrosEditor);
    IntegerFieldEditor guiRefreshCycleEditor = new IntegerFieldEditor(PreferencesHelper.OPI_GUI_REFRESH_CYCLE, "OPI GUI Refresh Cycle (ms)", parent);
    guiRefreshCycleEditor.setValidRange(10, 5000);
    guiRefreshCycleEditor.getTextControl(parent).setToolTipText("The fastest refresh cycle for OPI GUI in millisecond");
    addField(guiRefreshCycleEditor);
    IntegerFieldEditor pulsingMinorPeriodFieldEditor = new IntegerFieldEditor(PreferencesHelper.PULSING_ALARM_MINOR_PERIOD, "Time period of MINOR alarm if pulsing alarm selected (ms)", parent);
    pulsingMinorPeriodFieldEditor.setValidRange(100, 10000);
    pulsingMinorPeriodFieldEditor.getTextControl(parent).setToolTipText("If the pulsing alarm box is checked for a widget that monitors a PV, " + "then what is the time period of the pulse with the PV is in MINOR alarm severity");
    addField(pulsingMinorPeriodFieldEditor);
    IntegerFieldEditor pulsingMajorPeriodFieldEditor = new IntegerFieldEditor(PreferencesHelper.PULSING_ALARM_MAJOR_PERIOD, "Time period of MAJOR alarm if pulsing alarm selected (ms)", parent);
    pulsingMajorPeriodFieldEditor.setValidRange(100, 10000);
    pulsingMajorPeriodFieldEditor.getTextControl(parent).setToolTipText("If the pulsing alarm box is checked for a widget that monitors a PV, " + "then what is the time period of the pulse with the PV is in MAJOR alarm severity");
    addField(pulsingMajorPeriodFieldEditor);
    String[] allPVFactories = SimplePVLayer.getAllPVFactoryExtensions();
    String[][] entries = new String[allPVFactories.length][2];
    for (int i = 0; i < allPVFactories.length; i++) {
        entries[i][0] = allPVFactories[i];
        entries[i][1] = allPVFactories[i];
    }
    ComboFieldEditor pvConnectionLayerEditor = new ComboFieldEditor(PreferencesHelper.PV_CONNECTION_LAYER, "PV Connection Layer", entries, parent);
    addField(pvConnectionLayerEditor);
    ComboFieldEditor popupConsoleEditor = new ComboFieldEditor(PreferencesHelper.POPUP_CONSOLE, "Console Popup Level", new String[][] { { "Error, Warning and Info", ConsolePopupLevel.ALL.toString() }, { "Only Info", ConsolePopupLevel.ONLY_INFO.toString() }, { "Don't Popup", ConsolePopupLevel.NO_POP.toString() } }, parent);
    addField(popupConsoleEditor);
    StringFieldEditor pythonPathEditor = new StringFieldEditor(PreferencesHelper.PYTHON_PATH, "PYTHONPATH", parent);
    pythonPathEditor.getTextControl(parent).setToolTipText("The path to search python modules");
    addField(pythonPathEditor);
    BooleanFieldEditor showCompactModeDialogEditor = new BooleanFieldEditor(PreferencesHelper.SHOW_COMPACT_MODE_DIALOG, "Show tip dialog about how to exit compact mode", parent);
    addField(showCompactModeDialogEditor);
    BooleanFieldEditor showFullScreenDialogEditor = new BooleanFieldEditor(PreferencesHelper.SHOW_FULLSCREEN_DIALOG, "Show tip dialog about how to exit fullscreen", parent);
    addField(showFullScreenDialogEditor);
    BooleanFieldEditor startWindowInCompactEditor = new BooleanFieldEditor(PreferencesHelper.START_WINDOW_IN_COMPACT_MODE, "Start application window in compact mode.", parent);
    addField(startWindowInCompactEditor);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor) FocusListener(org.eclipse.swt.events.FocusListener)

Example 4 with ComboFieldEditor

use of org.eclipse.jface.preference.ComboFieldEditor in project eclipse.platform.text by eclipse.

the class SearchPreferencePage method createFieldEditors.

@Override
protected void createFieldEditors() {
    addField(new BooleanFieldEditor(REUSE_EDITOR, SearchMessages.SearchPreferencePage_reuseEditor, getFieldEditorParent()));
    addField(new BooleanFieldEditor(BRING_VIEW_TO_FRONT, SearchMessages.SearchPreferencePage_bringToFront, getFieldEditorParent()));
    fIgnorePotentialMatchesCheckbox = new BooleanFieldEditor(IGNORE_POTENTIAL_MATCHES, SearchMessages.SearchPreferencePage_ignorePotentialMatches, getFieldEditorParent());
    addField(fIgnorePotentialMatchesCheckbox);
    fEmphasizedCheckbox = new BooleanFieldEditor(EMPHASIZE_POTENTIAL_MATCHES, SearchMessages.SearchPreferencePage_emphasizePotentialMatches, getFieldEditorParent());
    addField(fEmphasizedCheckbox);
    fColorEditor = new ColorFieldEditor(POTENTIAL_MATCH_FG_COLOR, SearchMessages.SearchPreferencePage_potentialMatchFgColor, getFieldEditorParent());
    addField(fColorEditor);
    fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored(), getFieldEditorParent());
    fColorEditor.setEnabled(!arePotentialMatchesIgnored() && arePotentialMatchesEmphasized(), getFieldEditorParent());
    handleDeletedPerspectives();
    String[][] perspectiveNamesAndIds = getPerspectiveNamesAndIds();
    ComboFieldEditor comboEditor = new ComboFieldEditor(DEFAULT_PERSPECTIVE, SearchMessages.SearchPreferencePage_defaultPerspective, perspectiveNamesAndIds, getFieldEditorParent());
    addField(comboEditor);
    // in case we have a contributed engine, let the user choose.
    TextSearchEngineRegistry reg = SearchPlugin.getDefault().getTextSearchEngineRegistry();
    String[][] engineNamesAndIds = reg.getAvailableEngines();
    if (engineNamesAndIds.length > 1) {
        comboEditor = new ComboFieldEditor(TEXT_SEARCH_ENGINE, SearchMessages.SearchPreferencePage_textSearchEngine, engineNamesAndIds, getFieldEditorParent());
        addField(comboEditor);
    }
}
Also used : ColorFieldEditor(org.eclipse.jface.preference.ColorFieldEditor) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) TextSearchEngineRegistry(org.eclipse.search.internal.core.text.TextSearchEngineRegistry)

Example 5 with ComboFieldEditor

use of org.eclipse.jface.preference.ComboFieldEditor in project knime-core by knime.

the class WorkflowEditorPreferencePage method createFieldEditors.

/**
 * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various
 * types of preferences. Each field editor knows how to save and restore itself.
 */
@Override
public void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    m_emptyNodeLabel = new BooleanFieldEditor(PreferenceConstants.P_SET_NODE_LABEL, "Set node label prefix", parent) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected void valueChanged(final boolean old, final boolean neu) {
            m_nodeLabelPrefix.setEnabled(neu, parent);
        }
    };
    m_nodeLabelPrefix = new StringFieldEditor(PreferenceConstants.P_DEFAULT_NODE_LABEL, "Default node label (prefix): ", parent);
    addField(m_emptyNodeLabel);
    addField(m_nodeLabelPrefix);
    IntegerFieldEditor fontSizeEditor = new IntegerFieldEditor(PreferenceConstants.P_NODE_LABEL_FONT_SIZE, "Change node name and label font size", parent);
    addField(fontSizeEditor);
    addField(new HorizontalLineField(parent));
    addField(new LabelField(parent, "These grid preferences apply to new workflows only."));
    addField(new BooleanFieldEditor(PreferenceConstants.P_GRID_SHOW, "Show grid", parent));
    addField(new BooleanFieldEditor(PreferenceConstants.P_GRID_SNAP_TO, "Snap to grid", parent));
    IntegerFieldEditor gridSizeXEditor = new IntegerFieldEditor(PreferenceConstants.P_GRID_SIZE_X, "Horiz. grid size (in px)", parent);
    gridSizeXEditor.setValidRange(3, 500);
    gridSizeXEditor.setTextLimit(3);
    gridSizeXEditor.load();
    addField(gridSizeXEditor);
    IntegerFieldEditor gridSizeYEditor = new IntegerFieldEditor(PreferenceConstants.P_GRID_SIZE_Y, "Vertic. grid size (in px)", parent);
    gridSizeYEditor.setValidRange(3, 500);
    gridSizeYEditor.setTextLimit(3);
    gridSizeYEditor.load();
    addField(gridSizeYEditor);
    addField(new LabelField(parent, "To change the grid settings of a workflow,\nuse the 'Workflow Editor Settings' " + "toolbar button."));
    addField(new HorizontalLineField(parent));
    addField(new LabelField(parent, "These node connection settings apply to new workflows only."));
    addField(new BooleanFieldEditor(PreferenceConstants.P_CURVED_CONNECTIONS, "Curved connections", parent));
    ComboFieldEditor lineWidthEditor = new ComboFieldEditor(PreferenceConstants.P_CONNECTIONS_LINE_WIDTH, "Node connections line width", new String[][] { { "1", "1" }, { "2", "2" }, { "3", "3" } }, parent);
    lineWidthEditor.load();
    addField(lineWidthEditor);
    addField(new LabelField(parent, "To change the node connection settings of a workflow,\nuse the 'Workflow Editor Settings' " + "toolbar button."));
}
Also used : StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) Composite(org.eclipse.swt.widgets.Composite) IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor)

Aggregations

ComboFieldEditor (org.eclipse.jface.preference.ComboFieldEditor)6 BooleanFieldEditor (org.eclipse.jface.preference.BooleanFieldEditor)5 Composite (org.eclipse.swt.widgets.Composite)4 IntegerFieldEditor (org.eclipse.jface.preference.IntegerFieldEditor)3 StringFieldEditor (org.eclipse.jface.preference.StringFieldEditor)2 Label (org.eclipse.swt.widgets.Label)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ColorFieldEditor (org.eclipse.jface.preference.ColorFieldEditor)1 RadioGroupFieldEditor (org.eclipse.jface.preference.RadioGroupFieldEditor)1 TextSearchEngineRegistry (org.eclipse.search.internal.core.text.TextSearchEngineRegistry)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 GridData (org.eclipse.swt.layout.GridData)1 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)1 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)1