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:org.eclipse.compare.internal.MergeSourceViewer.java

License:Open Source License

private RGB getColorFromStore(IPreferenceStore store, String key) {
    RGB rgb = null;//  w  w w  .  j a v  a  2  s .  co m
    if (store.contains(key)) {
        if (store.isDefault(key))
            rgb = PreferenceConverter.getDefaultColor(store, key);
        else
            rgb = PreferenceConverter.getColor(store, key);
    }
    return rgb;
}

From source file:org.eclipse.contribution.xref.ui.views.XReferenceView.java

License:Open Source License

private void persistSettings() {
    IPreferenceStore pstore = XReferenceUIPlugin.getDefault().getPreferenceStore();
    if (!pstore.contains(LINK_ID)) {
        pstore.setDefault(LINK_ID, true);
    }/*from   ww  w . j  a  v a  2s . co  m*/
    pstore.setValue(LINK_ID, linkingEnabled);

    if (!pstore.contains(XREFS_FOR_FILE_ID)) {
        pstore.setDefault(XREFS_FOR_FILE_ID, false);
    }
    pstore.setValue(XREFS_FOR_FILE_ID, showXRefsForFileEnabled);
    XReferenceUIPlugin.getDefault().savePluginPreferences();
}

From source file:org.eclipse.contribution.xref.ui.views.XReferenceView.java

License:Open Source License

private void restorePersistedSettings() {
    IPreferenceStore pstore = XReferenceUIPlugin.getDefault().getPreferenceStore();
    if (pstore.contains(LINK_ID)) {
        linkingEnabled = pstore.getBoolean(LINK_ID);
    }/*  w  w w .j ava  2s  .  c om*/

    if (pstore.contains(XREFS_FOR_FILE_ID)) {
        showXRefsForFileEnabled = pstore.getBoolean(XREFS_FOR_FILE_ID);
    }
}

From source file:org.eclipse.dltk.debug.ui.actions.ViewFilterAction.java

License:Open Source License

/**
 * Returns the value of this filters preference (on/off) for the given view.
 * //  www .j  a v  a  2 s  .  c  o  m
 * @param part
 * @return boolean
 */
protected boolean getPreferenceValue() {
    String key = getCompositeKey();
    IPreferenceStore store = getPreferenceStore();
    boolean value = false;
    if (store.contains(key)) {
        value = store.getBoolean(key);
    } else {
        value = store.getBoolean(getPreferenceKey());
    }
    return value;
}

From source file:org.eclipse.dltk.internal.debug.ui.ScriptDebugHover.java

License:Open Source License

/**
 * Returns the value of this filters preference (on/off) for the given view.
 * //from w w w .  j  a  va2 s . c  om
 * @param part
 * @return boolean
 */
public static boolean getBooleanPreferenceValue(String id, String preference) {
    String compositeKey = id + "." + preference; //$NON-NLS-1$
    IPreferenceStore store = DLTKDebugUIPlugin.getDefault().getPreferenceStore();
    boolean value = false;
    if (store.contains(compositeKey)) {
        value = store.getBoolean(compositeKey);
    } else {
        value = store.getBoolean(preference);
    }
    return value;
}

From source file:org.eclipse.dltk.internal.mylyn.DLTKUiBridgePlugin.java

License:Open Source License

/**
 * Startup order is critical.//from   w  ww.java  2  s  .  c o m
 */
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    INSTANCE = this;

    IPreferenceStore dltkPrefs = DLTKUIPlugin.getDefault().getPreferenceStore();
    // NOTE: moved out of wizard and first task activation to avoid bug
    // 194766
    int count = getPreferenceStore().getInt(MYLYN_RUN_COUNT);
    if (count < 1) {
        getPreferenceStore().setValue(MYLYN_RUN_COUNT, count + 1);

        // Mylyn 3.1 removes 2 computers, migrate JDT setting on first run
        // to avoid prevent JDT from displaying a warning dialog
        if (count == 0 && getPreferenceStore().contains(MYLYN_PREVIOUS_RUN)) {
            if (dltkPrefs.contains(NUM_COMPUTERS_PREF_KEY)) {
                int lastNumberOfComputers = dltkPrefs.getInt(NUM_COMPUTERS_PREF_KEY);
                if (lastNumberOfComputers > 0) {
                    dltkPrefs.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(lastNumberOfComputers - 2));
                }
            }
        }

        // try installing Task-Focused content assist twice
        new UIJob("Initialize Content Assist") { //$NON-NLS-1$
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
                DLTKUiUtil.installContentAssist(store, false);
                return Status.OK_STATUS;
            }
        }.schedule();
    }

    // the Task-Focused category should be disabled if the user reverts to
    // the default
    String defaultValue = dltkPrefs.getDefaultString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
    dltkPrefs.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES,
            defaultValue + DLTKUiUtil.ASSIST_MYLYN_ALL + DLTKUiUtil.SEPARATOR_CODEASSIST);
}

From source file:org.eclipse.dltk.mod.ui.actions.CustomFiltersActionGroup.java

License:Open Source License

private void initializeWithViewDefaults() {
    // get default values for view
    IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();

    // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=22533
    if (!store.contains(getPreferenceKey(TAG_DUMMY_TO_TEST_EXISTENCE)))
        return;//from w w w.j  a  v a2s  . c  o m

    fUserDefinedPatternsEnabled = store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED));
    setUserDefinedPatterns(CustomFiltersDialog
            .convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR));

    Iterator iter = fEnabledFilterIds.entrySet().iterator();
    while (iter.hasNext()) {
        Entry entry = (Entry) iter.next();
        String id = (String) entry.getKey();
        // set default to value from plugin contributions (fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=73991 ):
        store.setDefault(id, ((Boolean) entry.getValue()).booleanValue());
        Boolean isEnabled = Boolean.valueOf(store.getBoolean(id));
        fEnabledFilterIds.put(id, isEnabled);
    }

    fLRUFilterIdsStack.clear();
    String lruFilterIds = store.getString(TAG_LRU_FILTERS);
    StringTokenizer tokenizer = new StringTokenizer(lruFilterIds, SEPARATOR);
    while (tokenizer.hasMoreTokens()) {
        String id = tokenizer.nextToken();
        if (fFilterDescriptorMap.containsKey(id) && !fLRUFilterIdsStack.contains(id))
            fLRUFilterIdsStack.push(id);
    }
}

From source file:org.eclipse.e4.ui.css.legacy.presentation.CSSPresentationFactory.java

License:Open Source License

public StackPresentation createEditorPresentation(Composite parent, IStackPresentationSite site) {
    CSSTabFolder folder = new CSSTabFolder(parent, editorTabPosition | SWT.BORDER,
            site.supportsState(IStackPresentationSite.STATE_MINIMIZED),
            site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));

    /*// w  ww  .  ja va  2s  .  com
     * Set the minimum characters to display, if the preference is something
     * other than the default. This is mainly intended for RCP applications
     * or for expert users (i.e., via the plug-in customization file).
     * 
     * Bug 32789.
     */
    final IPreferenceStore store = PlatformUI.getPreferenceStore();
    if (store.contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) {
        final int minimumCharacters = store.getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS);
        if (minimumCharacters >= 0) {
            folder.setMinimumCharacters(minimumCharacters);
        }
    }

    PresentablePartFolder partFolder = new PresentablePartFolder(folder);

    TabbedStackPresentation result = new TabbedStackPresentation(site, partFolder,
            new StandardEditorSystemMenu(site));

    new DefaultMultiTabListener(result.getApiPreferences(),
            IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);

    new DefaultSimpleTabListener(result.getApiPreferences(),
            IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, folder);

    return result;
}

From source file:org.eclipse.edt.ide.ui.internal.preferences.SQLRetrievePreferencePage.java

License:Open Source License

/**
 * Initializes states of the controls from the preference store.
 *///from ww  w. j a  v  a 2 s.com
private void initializeValues() {
    IPreferenceStore store = getPreferenceStore();
    boolean selectionSet = false;

    String option = store.getString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_CHAR_CONTROL_OPTION);
    /*for (int i = 0; i < SQLPlugin.EGL_CHAR_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
       if (SQLPlugin.EGL_CHAR_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
    charTypeControlButtons[i].setSelection(true);
       else
    charTypeControlButtons[i].setSelection(false);
    }*/

    option = store.getString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_NATIONAL_CHAR_CONTROL_OPTION);
    /*for (int i = 0; i < SQLPlugin.EGL_NATIONAL_CHAR_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
       if (SQLPlugin.EGL_NATIONAL_CHAR_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
    nationalCharControlButtons[i].setSelection(true);
       else
    nationalCharControlButtons[i].setSelection(false);
    }*/

    option = store.getString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_NAME_CASE_CONTROL_OPTION);
    for (int i = 0; i < SQLPlugin.NAME_CASE_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
        if (SQLPlugin.NAME_CASE_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
            caseControlButtons[i].setSelection(true);
        else
            caseControlButtons[i].setSelection(false);
    }

    option = store.getString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_NAME_UNDERSCORE_CONTROL_OPTION);
    for (int i = 0; i < SQLPlugin.NAME_UNDERSCORE_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
        if (SQLPlugin.NAME_UNDERSCORE_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option)) {
            underscoreControlButtons[i].setSelection(true);
            selectionSet = true;
        } else
            underscoreControlButtons[i].setSelection(false);
    }
    if (!selectionSet) {
        underscoreControlButtons[0].setSelection(true);
    }

    retrievePrimaryKeys.setSelection(store.getBoolean(ISQLPreferenceConstants.SQL_RETRIEVE_PRIMARY_KEY_OPTION));
    sqlPromptButton
            .setSelection(store.getBoolean(ISQLPreferenceConstants.SQL_PROMPT_USERID_AND_PASSWORD_OPTION));
    addSqlDataCode
            .setSelection(store.getBoolean(ISQLPreferenceConstants.SQL_RETRIEVE_ADD_SQL_DATA_CODE_OPTION));

    if (store.getBoolean(ISQLPreferenceConstants.SQL_RETRIEVE_USE_CHAR_FOR_DATE_OPTION)) {
        // The old preference is set to true, so use char.
        option = IEGLConstants.KEYWORD_CHAR;
    } else if (store.contains(ISQLPreferenceConstants.SQL_RETRIEVE_USE_CHAR_FOR_DATE_OPTION)) {
        // The old preference is set to false, so use "".
        option = "";
    } else {
        // The old preference is not set, so use the new preference.
        option = store.getString(ISQLPreferenceConstants.SQL_RETRIEVE_USE_TEXT_TYPE_FOR_DATE_OPTION);
    }

    for (int i = 0; i < SQLPlugin.TEXT_TYPE_FOR_DATE_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
        if (SQLPlugin.TEXT_TYPE_FOR_DATE_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
            typeForDateTypesButtons[i].setSelection(true);
        else
            typeForDateTypesButtons[i].setSelection(false);
    }

    addSqlDataCode.setEnabled(!typeForDateTypesButtons[0].getSelection());
}

From source file:org.eclipse.edt.ide.ui.internal.preferences.StylePreferencePage.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.
 *///from w  ww  .  j av  a  2  s .co m
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;
}