Example usage for org.eclipse.jface.preference BooleanFieldEditor setEnabled

List of usage examples for org.eclipse.jface.preference BooleanFieldEditor setEnabled

Introduction

In this page you can find the example usage for org.eclipse.jface.preference BooleanFieldEditor setEnabled.

Prototype

@Override
    public void setEnabled(boolean enabled, Composite parent) 

Source Link

Usage

From source file:com.ggasoftware.indigo.knime.plugin.IndigoPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    final Composite parent = getFieldEditorParent();

    final BooleanFieldEditor enableRenderer = new BooleanFieldEditor(
            IndigoPreferenceInitializer.PREF_ENABLE_RENDERER, "Enable rendering", parent);
    final BooleanFieldEditor coloredRendering = new BooleanFieldEditor(
            IndigoPreferenceInitializer.PREF_COLORING, "Colored rendering", parent);
    final BooleanFieldEditor showImplH = new BooleanFieldEditor(
            IndigoPreferenceInitializer.PREF_SHOW_IMPLICIT_HYDROGENS, "Show implicit hydrogens", parent);
    final IntegerFieldEditor bondLength = new IntegerFieldEditor(IndigoPreferenceInitializer.PREF_BOND_LENGTH,
            "Desired bond length in pixels", parent);
    final IntegerFieldEditor imageWidth = new IntegerFieldEditor(
            IndigoPreferenceInitializer.PREF_MOL_IMAGE_WIDTH, "Molecule image width in pixels", parent);
    final IntegerFieldEditor imageHeight = new IntegerFieldEditor(
            IndigoPreferenceInitializer.PREF_MOL_IMAGE_HEIGHT, "Molecule image height in pixels", parent);

    ((Button) enableRenderer.getDescriptionControl(parent)).addSelectionListener(new SelectionListener() {
        @Override//from  ww w  . ja  v  a  2 s  .com
        public void widgetSelected(SelectionEvent e) {
            boolean enabled = enableRenderer.getBooleanValue();

            coloredRendering.setEnabled(enabled, parent);
            showImplH.setEnabled(enabled, parent);
            bondLength.setEnabled(enabled, parent);
            imageWidth.setEnabled(enabled, parent);
            imageHeight.setEnabled(enabled, parent);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    addField(enableRenderer);

    boolean enabled = IndigoPlugin.getDefault().getPreferenceStore()
            .getBoolean(IndigoPreferenceInitializer.PREF_ENABLE_RENDERER);

    addField(coloredRendering);
    addField(showImplH);
    addField(bondLength);
    addField(imageWidth);
    addField(imageHeight);

    coloredRendering.setEnabled(enabled, parent);
    showImplH.setEnabled(enabled, parent);
    bondLength.setEnabled(enabled, parent);
    imageWidth.setEnabled(enabled, parent);
    imageHeight.setEnabled(enabled, parent);
}

From source file:it.unibz.instasearch.prefs.InstaSearchPreferencePage.java

License:Open Source License

/**
 * 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./*from  w  w  w  .ja  v  a 2s.c  o  m*/
 */
@Override
public void createFieldEditors() {

    String[] fileValues = new String[] { "5", "10", "15", "25", "50" };
    addField(new ComboFieldEditor(PreferenceConstants.P_SHOWN_FILES_COUNT, "Shown results (initially)",
            getArrayOfPairs(fileValues), getFieldEditorParent()));

    String[] lineValues = new String[] { "3", "4", "5", "7", "10", "15", "25" };
    addField(new ComboFieldEditor(PreferenceConstants.P_SHOWN_LINES_COUNT, "Preview lines",
            getArrayOfPairs(lineValues), getFieldEditorParent()));

    addBoolField(PreferenceConstants.P_SHOW_MATCH_COUNT, "Show number of matches");

    addBoolField(PreferenceConstants.P_SHOW_FULL_PATH, "Show full file path in results");

    addBoolField(PreferenceConstants.P_DIALOG_ON_SHORTCUT, "Open search dialog with shortcut key (Ctrl+Alt+I)");

    StringButtonFieldEditor extensions = new ExtensionsFieldEditor(getFieldEditorParent());
    extensions.setChangeButtonText("...");
    extensions.setEmptyStringAllowed(true);
    addField(extensions);

    addBoolField(PreferenceConstants.P_INDEX_EMPTY_EXTENSION, "Index files without extension");

    BooleanFieldEditor indexJars = new BooleanFieldEditor(PreferenceConstants.P_INDEX_ARCHIVES,
            "Index JAR Source Attachements (beta)", getFieldEditorParent());
    addField(indexJars);
    indexJars.setEnabled(false, getFieldEditorParent());

    if (InstaSearchPlugin.getInstaSearch() != null
            && InstaSearchPlugin.getInstaSearch().getIndexer() instanceof WorkspaceIndexerJDT)
        indexJars.setEnabled(true, getFieldEditorParent());

    addBoolField(PreferenceConstants.P_FUZZY_SEARCH_AUTO, "Find similar matches when no exact matches found");

    String version = InstaSearchPlugin.getVersion();
    addBoolField(PreferenceConstants.P_CHECK_UPDATES, "Notify about updates (ver. " + version + ")");

    periodicReindexEnabled = addBoolField(PreferenceConstants.P_INDEX_UPDATE_ENABLED,
            "Enable Automatic-Reindex");
    periodicReindexInterval = new IntegerFieldEditor(PreferenceConstants.P_INDEX_UPDATE_INTERVAL,
            "Automatic Reindex interval", getFieldEditorParent());
    periodicReindexInterval.setValidRange(0, Integer.MAX_VALUE);
    addField(periodicReindexInterval);

    addField(new WorkspacePathEditor(PreferenceConstants.P_EXCLUDE_DIRS, "Exclude folders from index",
            "Select folder to exclude from indexing", getFieldEditorParent()));
    //new Label(getFieldEditorParent(), SWT.NONE).setText("Note: Folders with Derived flag are excluded");

    Link annotationsLink = new Link(getFieldEditorParent(), SWT.NONE);
    annotationsLink.setText("See <a>Annotations</a> to set Search Results highlight color");
    annotationsLink.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            PreferencesUtil.createPreferenceDialogOn(getShell(),
                    "org.eclipse.ui.editors.preferencePages.Annotations", null, null).open();
        }
    });
}

From source file:org.ect.reo.prefs.ui.AnimationPreferencePage.java

License:Open Source License

/**
 * 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./*from  ww  w  .j a  v  a  2 s .  c  om*/
 */
public void createFieldEditors() {

    if (ColouringEngines.getDescriptions().size() > 1) {
        createEnginesGroup();
    }

    CustomRadioGroupFieldEditor colourEditor = new CustomRadioGroupFieldEditor(ReoPreferenceConstants.COLOURS,
            "&Colours", 1, new String[][] { { "2", "2" }, { "3", "3" } }, getFieldEditorParent());
    addField(colourEditor);

    CustomRadioGroupFieldEditor traversalEditor = new CustomRadioGroupFieldEditor(
            ReoPreferenceConstants.TRAVERSAL_TYPE, "&Traversal", 1,
            new String[][] { { "Depth-first (recommended)", TraversalType.DEPTH_FIRST.toString() },
                    { "Breadth-first", TraversalType.BREADTH_FIRST.toString() }, },
            getFieldEditorParent());
    addField(traversalEditor);

    //addField(new ColorFieldEditor(ReoPreferenceConstants.ANIMATION_BACKGROUND_COLOR, "&Background color:", getFieldEditorParent()));
    //addField(new ColorFieldEditor(ReoPreferenceConstants.ANIMATION_LINE_COLOR, "&Line color:", getFieldEditorParent()));

    addField(new BooleanFieldEditor(ReoPreferenceConstants.DRAW_CONNECTOR_CONTAINERS,
            "Draw &connector containers", BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
    addField(new BooleanFieldEditor(ReoPreferenceConstants.USE_MODULE_SCOPE, "Module scope",
            BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
    addField(new BooleanFieldEditor(ReoPreferenceConstants.DRAW_NODES, "Draw &nodes",
            BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
    addField(new BooleanFieldEditor(ReoPreferenceConstants.SHOW_NO_FLOW_ARROW, "Show no-flow &arrows",
            BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
    addField(new BooleanFieldEditor(ReoPreferenceConstants.SHOW_NO_FLOW_ANIMS, "Show no-flow &steps",
            BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
    addField(new BooleanFieldEditor(ReoPreferenceConstants.USE_SAME_TOKEN_COLOR, "&Use same token color",
            BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
    addField(new BooleanFieldEditor(ReoPreferenceConstants.LOOP_ANIMATIONS, "&Loop animations",
            BooleanFieldEditor.DEFAULT, getFieldEditorParent()));

    BooleanFieldEditor editor = new BooleanFieldEditor(ReoPreferenceConstants.MULTI_CORE_SUPPORT,
            "&Enable multi-core support", BooleanFieldEditor.DEFAULT, getFieldEditorParent());
    editor.setEnabled(Runtime.getRuntime().availableProcessors() > 1, getFieldEditorParent());
    addField(editor);

    IntegerFieldEditor maxlength = new IntegerFieldEditor(ReoPreferenceConstants.MAX_ANIMATION_LENGTH,
            "&Max number of steps", getFieldEditorParent());
    maxlength.setValidRange(-1, 100);
    addField(maxlength);

    IntegerFieldEditor maxcount = new IntegerFieldEditor(ReoPreferenceConstants.MAX_ANIMATION_COUNT,
            "&Max number of animations", getFieldEditorParent());
    maxcount.setValidRange(1, 100);
    addField(maxcount);

    IntegerFieldEditor speed = new IntegerFieldEditor(ReoPreferenceConstants.ANIMATION_SPEED,
            "&Animation speed", getFieldEditorParent());
    speed.setValidRange(1, 20);
    addField(speed);

    addField(new DoubleFieldEditor(ReoPreferenceConstants.SCALE_FACTOR, "&Zoom", getFieldEditorParent(), 0.1,
            5.0));

    FileFieldEditor font = new FileFieldEditor(ReoPreferenceConstants.ANIMATION_FONT, "&Font",
            getFieldEditorParent());
    font.setFileExtensions(new String[] { "*.swf" });
    addField(font);

}

From source file:org.key_project.key4eclipse.common.ui.preference.page.StarterPreferencePage.java

License:Open Source License

/**
 * Creates a tab./*from  w  w  w. jav a 2 s.  c  o m*/
 * @param starterKindsTabFolder The {@link TabFolder} to fill.
 * @param tabTitle The tab title.
 * @param starterDescriptions The available {@link StarterDescription}s.
 * @param selectedStarterProperty The property to store the selected {@link StarterDescription}.
 * @param dontAskAgainProperty The property to store the do not ask again value.
 * @param disableProperty The property to store the disabled value.
 */
protected <I> void createTab(TabFolder starterKindsTabFolder, String tabTitle,
        final ImmutableList<StarterDescription<I>> starterDescriptions, String selectedStarterProperty,
        String dontAskAgainProperty, String disableProperty) {
    final Composite globalStarterTabComposite = new Composite(starterKindsTabFolder, SWT.NONE);
    globalStarterTabComposite.setLayout(new GridLayout(1, false));

    final String[][] globalStarterEntries = new String[starterDescriptions.size()][];
    int i = 0;
    for (StarterDescription<I> sd : starterDescriptions) {
        globalStarterEntries[i] = new String[] { sd.getName(), sd.getId() };
        i++;
    }
    final ComboFieldEditor selectedGlobalStarterEditor = new ComboFieldEditor(selectedStarterProperty,
            "Selected Application", globalStarterEntries, globalStarterTabComposite);
    addField(selectedGlobalStarterEditor);

    Group descriptionGroup = new Group(globalStarterTabComposite, SWT.NONE);
    GridData descriptionGroupData = new GridData(GridData.FILL_BOTH);
    descriptionGroupData.widthHint = 400;
    descriptionGroup.setLayoutData(descriptionGroupData);
    descriptionGroup.setText("Description");
    descriptionGroup.setLayout(new FillLayout());
    final Text descriptionText = new Text(descriptionGroup, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI | SWT.WRAP);
    descriptionText.setEditable(false);
    StarterDescription<I> initialSd = StarterUtil.searchStarter(starterDescriptions,
            getPreferenceStore().getString(selectedStarterProperty));
    if (initialSd == null && !starterDescriptions.isEmpty()) {
        initialSd = starterDescriptions.head();
    }
    if (initialSd != null) {
        SWTUtil.setText(descriptionText, initialSd.getDescription());
    }
    try {
        final Combo combo = (Combo) ObjectUtil.get(selectedGlobalStarterEditor, "fCombo");
        combo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                int index = combo.getSelectionIndex();
                if (index >= 0 && index < starterDescriptions.size()) {
                    SWTUtil.setText(descriptionText, starterDescriptions.take(index).head().getDescription());
                } else {
                    descriptionText.setText(StringUtil.EMPTY_STRING);
                }
            }
        });
    } catch (Exception e) {
        LogUtil.getLogger().logError(e);
    }

    final BooleanFieldEditor dontAskEditor = new BooleanFieldEditor(dontAskAgainProperty, "&Do not ask",
            globalStarterTabComposite);
    addField(dontAskEditor);

    BooleanFieldEditor disabledEditor = new BooleanFieldEditor(disableProperty, "D&isable functionality",
            globalStarterTabComposite);
    addField(disabledEditor);
    try {
        final Button button = (Button) ObjectUtil.get(disabledEditor, "checkBox");
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean disabled = button.getSelection();
                selectedGlobalStarterEditor.setEnabled(!disabled, globalStarterTabComposite);
                descriptionText.setEnabled(!disabled);
                dontAskEditor.setEnabled(!disabled, globalStarterTabComposite);
            }
        });
    } catch (Exception e) {
        LogUtil.getLogger().logError(e);
    }

    TabItem globalStarterTabItem = new TabItem(starterKindsTabFolder, SWT.NONE);
    globalStarterTabItem.setText(tabTitle);
    globalStarterTabItem.setControl(globalStarterTabComposite);

    boolean disabled = getPreferenceStore().getBoolean(disableProperty);
    selectedGlobalStarterEditor.setEnabled(!disabled, globalStarterTabComposite);
    descriptionText.setEnabled(!disabled);
    dontAskEditor.setEnabled(!disabled, globalStarterTabComposite);
}

From source file:org.key_project.sed.key.ui.preference.page.KeYLaunchSymbolicDebugPreferencePage.java

License:Open Source License

/**
 * {@inheritDoc}//from   ww w.j  a  va2s .co  m
 */
@Override
protected void createFieldEditors() {
    // Group style was copied from org.eclipse.debug.internal.ui.preferences.LaunchingPreferencePage
    Group group = SWTFactory.createGroup(getFieldEditorParent(), "Symbolic Execution Tree", 1, 1,
            GridData.FILL_HORIZONTAL);
    final Composite spacer = SWTFactory.createComposite(group, 1, 1, GridData.FILL_HORIZONTAL);
    BooleanFieldEditor returnEdit = new BooleanFieldEditor(
            KeYSEDPreferences.SHOW_METHOD_RETURN_VALUES_IN_DEBUG_NODES,
            "&Show method return values in debug nodes", SWT.NONE, spacer);
    addField(returnEdit);
    BooleanFieldEditor mergeEdit = new BooleanFieldEditor(KeYSEDPreferences.MERGE_BRANCH_CONDITIONS,
            "&Merge branch conditions", SWT.NONE, spacer);
    addField(mergeEdit);
    final ObservableBooleanFieldEditor ppEdit = new ObservableBooleanFieldEditor(
            KeYSEDPreferences.USE_PRETTY_PRINTING, "Use &pretty printing", SWT.NONE, spacer);
    addField(ppEdit);
    final BooleanFieldEditor unicodeEdit = new BooleanFieldEditor(KeYSEDPreferences.USE_UNICODE,
            "Use &unicode symbols", SWT.NONE, spacer);
    addField(unicodeEdit);
    ppEdit.addFieldEditorValueListener(new IFieldEditorValueListener() {
        @Override
        public void shownValueChanged(FieldEditorValueEvent e) {
            unicodeEdit.setEnabled(ppEdit.getBooleanValue(), spacer);
        }
    });
    BooleanFieldEditor sigEdit = new BooleanFieldEditor(KeYSEDPreferences.SHOW_SIGNATURE_ON_METHOD_RETURN_NODES,
            "Show signature instead of only the name on method &return nodes", SWT.NONE, spacer);
    addField(sigEdit);
    BooleanFieldEditor truthEvaluationEdit = new BooleanFieldEditor(
            KeYSEDPreferences.TRUTH_VALUE_EVALUATION_ENABLED,
            "Truth value evaluation enabled (EXPERIMENTAL, not all rules are correctly supported)", SWT.NONE,
            spacer);
    addField(truthEvaluationEdit);

    group = SWTFactory.createGroup(getFieldEditorParent(), "Variables", 1, 1, GridData.FILL_HORIZONTAL);
    final Composite variablesSpacer = SWTFactory.createComposite(group, 2, 1, GridData.FILL_HORIZONTAL);
    final ObservableBooleanFieldEditor varEdit = new ObservableBooleanFieldEditor(
            KeYSEDPreferences.SHOW_VARIABLES_OF_SELECTED_DEBUG_NODE, "Show &variables of selected debug node",
            SWT.NONE, variablesSpacer);
    varEdit.fillIntoGrid(variablesSpacer, 2);
    addField(varEdit);
    final ComboFieldEditor variablesEditor = new ComboFieldEditor(
            KeYSEDPreferences.VARIABLES_ARE_COMPUTED_FROM_UPDATES, "Variables &computation",
            new String[][] { { "Based on visible type structure", "false" }, { "Based on sequent", "true" } },
            variablesSpacer);
    addField(variablesEditor);
    varEdit.addFieldEditorValueListener(new IFieldEditorValueListener() {
        @Override
        public void shownValueChanged(FieldEditorValueEvent e) {
            variablesEditor.setEnabled(varEdit.getBooleanValue(), variablesSpacer);
        }
    });

    group = SWTFactory.createGroup(getFieldEditorParent(), "Source Code", 1, 1, GridData.FILL_HORIZONTAL);
    Composite sourceCodeSpacer = SWTFactory.createComposite(group, 1, 1, GridData.FILL_HORIZONTAL);
    BooleanFieldEditor highlightReachedCode = new BooleanFieldEditor(
            KeYSEDPreferences.HIGHLIGHT_REACHED_SOURCE_CODE,
            "Highlight reached source code during symbolic execution", SWT.NONE, sourceCodeSpacer);
    addField(highlightReachedCode);

    group = SWTFactory.createGroup(getFieldEditorParent(), "KeY", 1, 1, GridData.FILL_HORIZONTAL);
    Composite keySpacer = SWTFactory.createComposite(group, 1, 1, GridData.FILL_HORIZONTAL);
    BooleanFieldEditor mainWindowEdit = new BooleanFieldEditor(KeYSEDPreferences.SHOW_KEY_MAIN_WINDOW,
            "Show &KeY's main window (only for experienced user)", SWT.NONE, keySpacer);
    addField(mainWindowEdit);
}

From source file:org.springframework.tooling.boot.ls.XmlConfigPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    Composite fieldEditorParent = getFieldEditorParent();
    final boolean xmlEnabled = getPreferenceStore().getBoolean(Constants.PREF_SUPPORT_SPRING_XML_CONFIGS);
    updateXmlSettingControlsEnablement = new ArrayList<>();

    enableEditor = new BooleanFieldEditor(Constants.PREF_SUPPORT_SPRING_XML_CONFIGS,
            "Enable Spring XML Config files support", fieldEditorParent);
    addField(enableEditor);/*from   www  .  j  a v  a  2 s  .c  o  m*/

    Label label = new Label(fieldEditorParent, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setLayoutData(
            GridDataFactory.swtDefaults().grab(true, false).span(2, 1).align(SWT.FILL, SWT.BEGINNING).create());

    Composite settingsComposite = new Composite(fieldEditorParent, SWT.NONE);
    settingsComposite.setLayoutData(
            GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.BEGINNING).create());
    settingsComposite.setLayout(new GridLayout(1, false));

    BooleanFieldEditor caFieldEditor = new BooleanFieldEditor(Constants.PREF_XML_CONFIGS_CONTENT_ASSIST,
            "Content Assist in editor", settingsComposite);
    addField(caFieldEditor);
    caFieldEditor.setEnabled(xmlEnabled, settingsComposite);
    updateXmlSettingControlsEnablement
            .add(() -> caFieldEditor.setEnabled(enableEditor.getBooleanValue(), settingsComposite));

    BooleanFieldEditor hyperlinkEditor = new BooleanFieldEditor(Constants.PREF_XML_CONFIGS_HYPERLINKS,
            "Hyperlinks in editor", settingsComposite);
    addField(hyperlinkEditor);
    hyperlinkEditor.setEnabled(xmlEnabled, settingsComposite);
    updateXmlSettingControlsEnablement
            .add(() -> hyperlinkEditor.setEnabled(enableEditor.getBooleanValue(), settingsComposite));

    Composite scanFoldersComposite = new Composite(settingsComposite, SWT.NONE);
    scanFoldersComposite.setFont(settingsComposite.getFont());
    scanFoldersComposite.setLayoutData(GridDataFactory.swtDefaults().span(2, 1)
            .align(GridData.FILL, GridData.BEGINNING).grab(true, false).create());
    scanFoldersComposite.setLayout(new GridLayout(2, false));
    StringFieldEditor scanGlobEditor = new StringFieldEditor(Constants.PREF_XML_CONFIGS_SCAN_FOLDERS,
            "Scan XML in folders for symbols:", scanFoldersComposite);
    addField(scanGlobEditor);
    scanGlobEditor.setEnabled(xmlEnabled, scanFoldersComposite);
    updateXmlSettingControlsEnablement
            .add(() -> scanGlobEditor.setEnabled(enableEditor.getBooleanValue(), scanFoldersComposite));

}