Example usage for org.eclipse.jface.preference IPreferenceStore contains

List of usage examples for org.eclipse.jface.preference IPreferenceStore contains

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore contains.

Prototype

boolean contains(String name);

Source Link

Document

Returns whether the named preference is known to this preference store.

Usage

From source file:de.itemis.tooling.terminology.ui.generator.TerminologyGenerators.java

License:Open Source License

public List<TerminologyGeneratorParticipant> getGenerators(IProject context) {
    //context plays a role only if there are project specific settings
    IPreferenceStore preferences = preferenceStoreAccess.getContextPreferenceStore(context);
    if (!preferences.getBoolean(OptionsConfigurationBlock.IS_PROJECT_SPECIFIC)) {
        preferences = preferenceStoreAccess.getContextPreferenceStore(null);
    }/*  www.  java 2 s .c om*/
    if (generators == null) {
        generators = Lists.newArrayList();
        //Injection does not really make sense as here only classes from the terminology plugin could be injected
        //         Injector injector = TerminologyActivator.getInstance().getInjector(TerminologyActivator.DE_ITEMIS_TOOLING_TERMINOLOGY_TERMINOLOGY);
        IConfigurationElement[] configs = Platform.getExtensionRegistry()
                .getConfigurationElementsFor("de.itemis.tooling.terminology.generator");
        for (IConfigurationElement config : configs) {
            try {
                TerminologyGeneratorParticipant generator = (TerminologyGeneratorParticipant) config
                        .createExecutableExtension("class");
                //               injector.injectMembers(generator);
                if (preferences.contains(generator.getId() + "_folder")) {
                    generator.setFolder(preferences.getString(generator.getId() + "_folder"));
                } else {
                    generator.setFolder(generator.getDefaultFolder());
                }
                boolean active = preferences.getBoolean(generator.getId() + "_active");
                generator.setActive(active);
                generators.add(generator);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return generators;
}

From source file:de.loskutov.eclipseskins.preferences.PreferenceInitializer.java

License:Open Source License

private static void setInt(IPreferenceStore store, ThemeWrapper theme, String key) {
    if (store.contains(key)) {
        theme.setInt(key, store.getInt(key));
    }//from w  w  w.  j  av a2  s  . c o m
}

From source file:de.loskutov.eclipseskins.preferences.PreferenceInitializer.java

License:Open Source License

private static void setBoolean(IPreferenceStore store, ThemeWrapper theme, String key) {
    if (store.contains(key)) {
        theme.setBoolean(key, store.getBoolean(key));
    }//w  w  w  . j  av a 2 s.  c om
}

From source file:de.loskutov.eclipseskins.preferences.SkinsPreferencePage.java

License:Open Source License

private void setValue(IPreferenceStore store, String key, int value) {
    boolean hasValue = store.contains(key);
    store.setValue(key, value);/*from w ww .  j a  va 2  s .  co  m*/
    if (!hasValue) {
        Integer integer = new Integer(value);
        store.firePropertyChangeEvent(key, null, integer);
        // problems with reading 0 values - they are the same as default
        store.putValue(key, "" + value);
    }
}

From source file:de.loskutov.eclipseskins.preferences.SkinsPreferencePage.java

License:Open Source License

private void setValue(IPreferenceStore store, String key, boolean value) {
    boolean hasValue = store.contains(key);
    store.setValue(key, value);/*from   ww  w.j a v  a  2 s .c om*/
    if (!hasValue || !value) {
        /*
         * if default value is the same as given argument, then store
         * doesn't set it and later we can't recognize if the value was
         * customized by user... So we set it first to opposite value,
         * and then to the desired one.
         */
        if (!hasValue) {
            store.setValue(key, !value);
            store.setValue(key, value);
        }
        // this set an string value as WORKAROUND
        store.putValue(key, "" + value);
    }
}

From source file:de.tobject.findbugs.FindbugsPlugin.java

License:Open Source License

/**
 * Removes all consequent enumerated keys from given store staring with given prefix
 *//* w ww.  ja  v a 2  s  . c  o m*/
private static void resetStore(IPreferenceStore store, String prefix) {
    int start = 0;
    // 99 is paranoia.
    while (start < 99) {
        String name = prefix + start;
        if (store.contains(name)) {
            store.setToDefault(name);
        } else {
            break;
        }
        start++;
    }
}

From source file:descent.internal.ui.javaeditor.JavaSourceViewer.java

License:Open Source License

/**
 * Creates a color from the information stored in the given preference store.
 * Returns <code>null</code> if there is no such information available.
 *
 * @param store the store to read from//from  ww w.j  a  va  2  s .com
 * @param key the key used for the lookup in the preference store
 * @param display the display used create the color
 * @return the created color according to the specification in the preference store
 * @since 3.0
 */
private Color createColor(IPreferenceStore store, String key, Display display) {

    RGB rgb = null;

    if (store.contains(key)) {

        if (store.isDefault(key))
            rgb = PreferenceConverter.getDefaultColor(store, key);
        else
            rgb = PreferenceConverter.getColor(store, key);

        if (rgb != null)
            return new Color(display, rgb);
    }

    return null;
}

From source file:eu.numberfour.n4js.ui.editor.StyledTextDescriptor.java

License:Open Source License

/**
 * Creates and returns with a new {@link StyledText styled text} instance hooked up to the given parent composite.
 *
 * @param parent/*from w ww.  j  a va  2 s. c o m*/
 *            the parent of the styled text control.
 * @param style
 *            style bits for the new text control.
 * @return a new styled text control initialized from the descriptor.
 */
default StyledText toStyledText(final Composite parent, final int style) {

    final StyledText text = new StyledText(parent, READ_ONLY | style);
    text.setText(getText());
    text.setStyleRanges(getRanges());
    text.setFont(getFont());
    text.setEditable(false);
    text.setEnabled(false);

    final AtomicReference<Color> colorRef = new AtomicReference<>();
    final IPreferenceStore prefStore = EditorsUI.getPreferenceStore();
    if (null == prefStore || prefStore.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {

        colorRef.set(getDefault().getSystemColor(COLOR_LIST_BACKGROUND));

    } else {

        RGB rgb = null;
        if (prefStore.contains(PREFERENCE_COLOR_BACKGROUND)) {
            if (prefStore.isDefault(PREFERENCE_COLOR_BACKGROUND)) {
                rgb = getDefaultColor(prefStore, PREFERENCE_COLOR_BACKGROUND);
            } else {
                rgb = getColor(prefStore, PREFERENCE_COLOR_BACKGROUND);
            }
            if (rgb != null) {
                colorRef.set(new Color(text.getDisplay(), rgb));
            }
        }

    }

    if (null != colorRef.get()) {
        text.setBackground(colorRef.get());
        text.addDisposeListener(e -> {
            if (!colorRef.get().isDisposed()) {
                colorRef.get().dispose();
            }
        });
    }

    text.pack();
    return text;
}

From source file:eu.numberfour.n4js.ui.preferences.AbstractN4JSPreferencePage.java

License:Open Source License

private void setDescriptorValuesFromPreferences(IPreferenceStore preferenceStore, String outputName,
        DESCR_TYPE newCompilerDescriptor) {
    for (IComponentProperties<DESCR_TYPE> prop : getComponentPropertiesValues()) {
        if (preferenceStore.contains(prop.getKey(outputName))) {
            if (prop.getType() == Boolean.class) {
                prop.setValueInCompilerDescriptor(newCompilerDescriptor, outputName,
                        preferenceStore.getBoolean(prop.getKey(outputName)));
            } else { // String
                prop.setValueInCompilerDescriptor(newCompilerDescriptor, outputName,
                        preferenceStore.getString(prop.getKey(outputName)));
            }/*from  w ww . j  ava2 s . c  o  m*/
        }
    }
}

From source file:ext.org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerRegistry.java

License:Open Source License

private void updateUninstalledComputerCount() {
    IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore();
    fIsFirstTimeCheckForUninstalledComputers = !preferenceStore.contains(NUM_COMPUTERS_PREF_KEY);
    int lastNumberOfComputers = preferenceStore.getInt(NUM_COMPUTERS_PREF_KEY);
    int currNumber = fDescriptors.size();
    fHasUninstalledComputers = lastNumberOfComputers > currNumber;
    preferenceStore.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(currNumber));
    JavaPlugin.flushInstanceScope();//  www.  ja v a  2 s . co  m
}