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.titan.log.viewer.preferences.FilteredSilentEventUtils.java

License:Open Source License

/**
 * @param preferenceStore the preference store
 * @return true is the resource has old filter silent event properties, otherwise false
 *///from w w  w.j a v a 2  s .  c  o m
public static boolean hasPreferencesOldFilteredSilentEvents(final IPreferenceStore preferenceStore) {
    Set<String> oldPrefKeys = OLD_TO_NEW_SILENT_EVENTS.keySet();
    for (String currPrefKey : oldPrefKeys) {
        if (preferenceStore.contains(currPrefKey)) {
            return true;
        }
    }
    return false;
}

From source file:org.eclipse.ui.internal.registry.PerspectiveRegistry.java

License:Open Source License

/**
 * Method hasCustomDefinition./*w  w w  .  jav a  2 s  . c  o  m*/
 * 
 * @param desc
 */
/* package */
boolean hasCustomDefinition(PerspectiveDescriptor desc) {
    IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
    return store.contains(desc.getId() + PERSP);
}

From source file:org.eclipse.ui.internal.statushandlers.InternalDialog.java

License:Open Source License

private boolean isPromptToClose() {
    IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
    if (!store.contains(PREF_SKIP_GOTO_ACTION_PROMPT)
            || !store.getString(PREF_SKIP_GOTO_ACTION_PROMPT).equals(MessageDialogWithToggle.ALWAYS)) {
        MessageDialogWithToggle dialog = MessageDialogWithToggle.open(MessageDialog.CONFIRM, getShell(),
                ProgressMessages.JobErrorDialog_CloseDialogTitle,
                ProgressMessages.JobErrorDialog_CloseDialogMessage,
                ProgressMessages.JobErrorDialog_DoNotShowAgainMessage, false, store,
                PREF_SKIP_GOTO_ACTION_PROMPT, SWT.SHEET);
        return dialog.getReturnCode() == Window.OK;
    }/*w  w w . j av  a 2  s . c om*/
    return true;
}

From source file:org.eclipse.ui.internal.texteditor.AnnotationColumn.java

License:Open Source License

/**
 * Initializes the given line number ruler column from the preference store.
 */// w  ww.j a va  2  s .c  o m
private void initialize() {
    if (fDelegate == null)
        fDelegate = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, new DefaultMarkerAnnotationAccess());
    IPreferenceStore store = getPreferenceStore();
    if (store != null && fDelegate instanceof AnnotationRulerColumn) {
        final AnnotationRulerColumn column = (AnnotationRulerColumn) fDelegate;
        // initial set up
        for (Iterator iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext();) {
            AnnotationPreference preference = (AnnotationPreference) iter2.next();
            String key = preference.getVerticalRulerPreferenceKey();
            boolean showAnnotation = true;
            if (key != null && store.contains(key))
                showAnnotation = store.getBoolean(key);
            if (showAnnotation)
                column.addAnnotationType(preference.getAnnotationType());
        }
        column.addAnnotationType(Annotation.TYPE_UNKNOWN);

        // link to preference store
        fPropertyListener = new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                String property = event.getProperty();
                AnnotationPreference annotationPreference = getVerticalRulerAnnotationPreference(property);
                if (annotationPreference != null
                        && property.equals(annotationPreference.getVerticalRulerPreferenceKey())) {
                    Object type = annotationPreference.getAnnotationType();
                    if (getPreferenceStore().getBoolean(property))
                        column.addAnnotationType(type);
                    else
                        column.removeAnnotationType(type);
                    column.redraw();
                }
            }
        };
        store.addPropertyChangeListener(fPropertyListener);
    }
}

From source file:org.eclipse.ui.internal.UIPreferenceInitializer.java

License:Open Source License

/**
 * Migrate any old internal preferences to the API store.
 *//*from   ww  w  . j  ava 2  s .c o  m*/
private void migrateInternalPreferences() {

    IPreferenceStore internalStore = WorkbenchPlugin.getDefault().getPreferenceStore();
    IPreferenceStore apiStore = PlatformUI.getPreferenceStore();
    // Is there a value there?
    if (internalStore.contains(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION)) {
        apiStore.setValue(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION,
                internalStore.getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION));
        internalStore.setToDefault(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
    }

    // Is there a value there?
    if (internalStore.contains(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION)) {

        apiStore.setValue(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION,
                internalStore.getInt(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION));
        internalStore.setToDefault(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION);
    }

    // As default is true we need to check if a value was set

    if (internalStore.contains(IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS)) {
        apiStore.setValue(IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS,
                internalStore.getBoolean(IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS));
        internalStore.setToDefault(IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS);
    }
}

From source file:org.eclipse.ui.presentations.WorkbenchPresentationFactory.java

License:Open Source License

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

    /*/*from w ww . j a  v a  2 s  . c o  m*/
     * 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));

    DefaultThemeListener themeListener = new DefaultThemeListener(folder, result.getTheme());
    result.getTheme().addListener(themeListener);

    // RAP [bm]: 
    if (!Workbench.getInstance().isClosing()) {
        final DefaultMultiTabListener defaultMultiTabListener = new DefaultMultiTabListener(
                result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);
        result.getControl().addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent event) {
                defaultMultiTabListener.attach(null, IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS,
                        true);
            }
        });
    }
    // RAPEND: [bm] 

    // RAP [bm]: tab style cannot change 
    //      new DefaultSimpleTabListener(result.getApiPreferences(),
    //            IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
    //            folder);
    //      TODO: needs UISessionListener too when activated
    // RAPEND: [bm] 

    return result;
}

From source file:org.eclipse.ui.texteditor.ChainedPreferenceStore.java

License:Open Source License

/**
 * Returns the preference store from which the given property's value
 * is visible.//from   ww w  . j av  a2 s .  c  o m
 *
 * @param property the name of the property
 * @return the preference store from which the property's value is visible,
 *    <code>null</code> if the property is unknown
 */
private IPreferenceStore getVisibleStore(String property) {
    IPreferenceStore visibleStore = null;

    for (int i = 0, length = fPreferenceStores.length; i < length && visibleStore == null; i++) {
        IPreferenceStore store = fPreferenceStores[i];
        if (store.contains(property))
            visibleStore = store;
    }
    return visibleStore;
}

From source file:org.eclipse.ui.texteditor.spelling.SpellingService.java

License:Open Source License

/**
 * Returns the descriptor of the active spelling engine based on the
 * value of the <code>PREFERENCE_SPELLING_ENGINE</code> preference
 * in the given preferences.//  ww w .jav a2 s.c  o m
 *
 * @param preferences the preferences
 * @return the descriptor of the active spelling engine or
 *         <code>null</code> if none could be found
 * @see SpellingService#PREFERENCE_SPELLING_ENGINE
 */
public SpellingEngineDescriptor getActiveSpellingEngineDescriptor(IPreferenceStore preferences) {
    SpellingEngineRegistry registry = getSpellingEngineRegistry();
    if (registry == null)
        return null;

    SpellingEngineDescriptor descriptor = null;
    if (preferences.contains(PREFERENCE_SPELLING_ENGINE))
        descriptor = registry.getDescriptor(preferences.getString(PREFERENCE_SPELLING_ENGINE));
    if (descriptor == null)
        descriptor = registry.getDefaultDescriptor();
    return descriptor;
}

From source file:org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin.java

License:Open Source License

/**
 * Installs backwards compatibility for the preference store.
 *///from  w  w w. j  a  v a2s.  c  o  m
private void ensurePreferenceStoreBackwardsCompatibility() {

    IPreferenceStore store = getPreferenceStore();

    // must add here to guarantee that it is the first in the listener list
    fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
    fMembersOrderPreferenceCache.install(store);

    /*
     * Installs backwards compatibility: propagate the Java editor font from a
     * pre-2.1 plug-in to the Platform UI's preference store to preserve
     * the Java editor font from a pre-2.1 workspace. This is done only
     * once.
     */
    String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$
    if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
        if (!store.getBoolean(fontPropagatedKey))
            PreferenceConverter.setValue(getDeprecatedWorkbenchPreferenceStore(),
                    PreferenceConstants.EDITOR_TEXT_FONT,
                    PreferenceConverter.getFontDataArray(store, JFaceResources.TEXT_FONT));
    }
    store.setValue(fontPropagatedKey, true);

    /*
     * Backwards compatibility: set the Java editor font in this plug-in's
     * preference store to let older versions access it. Since 2.1 the
     * Java editor font is managed by the workbench font preference page.
     */
    PreferenceConverter.putValue(store, JFaceResources.TEXT_FONT,
            JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));

    fFontPropertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty()))
                PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT,
                        JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
        }
    };
    JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);

    /*
     * Backwards compatibility: propagate the Java editor tab width from a
     * pre-3.0 plug-in to the new preference key. This is done only once.
     */
    final String oldTabWidthKey = DEPRECATED_EDITOR_TAB_WIDTH;
    final String newTabWidthKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH;
    String tabWidthPropagatedKey = "tabWidthPropagated"; //$NON-NLS-1$
    if (store.contains(oldTabWidthKey) && !store.isDefault(oldTabWidthKey)) {
        if (!store.getBoolean(tabWidthPropagatedKey))
            store.setValue(newTabWidthKey, store.getInt(oldTabWidthKey));
    }
    store.setValue(tabWidthPropagatedKey, true);

    /*
     * Backwards compatibility: set the Java editor tab width in this plug-in's
     * preference store with the old key to let older versions access it.
     * Since 3.0 the tab width is managed by the extended text editor and
     * uses a new key.
     */
    store.putValue(oldTabWidthKey, store.getString(newTabWidthKey));

    fPropertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (newTabWidthKey.equals(event.getProperty())) {
                IPreferenceStore prefStore = getPreferenceStore();
                prefStore.putValue(oldTabWidthKey, prefStore.getString(newTabWidthKey));
            }
        }
    };
    store.addPropertyChangeListener(fPropertyChangeListener);

    /*
     * Backward compatibility for the refactoring preference key. 
     */
    //      store.setValue(
    //         PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, 
    //         RefactoringCore.getConditionCheckingFailedSeverity());

    // The commented call above triggers the eager loading of the LTK core plug-in
    // Since the condition checking failed severity is guaranteed to be of RefactoringStatus.SEVERITY_WARNING,
    // we directly insert the inlined value of this constant
    store.setToDefault(DEPRECATED_REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD);

    if (!store.getBoolean(JavaDocLocations.PREF_JAVADOCLOCATIONS_MIGRATED)) {
        JavaDocLocations.migrateToClasspathAttributes();
    }

    FormatterProfileStore.checkCurrentOptionsVersion();

    /*
     * Backward compatibility: migrate "alphabetic ordering" preference to point the sorter
     * preference to the alphabetic sorter.
     */
    String proposalOrderMigrated = "proposalOrderMigrated"; //$NON-NLS-1$

    if (store.contains(DEPRECATED_CODEASSIST_ORDER_PROPOSALS)) {
        if (!store.getBoolean(proposalOrderMigrated)) {
            boolean alphabetic = store.getBoolean(DEPRECATED_CODEASSIST_ORDER_PROPOSALS);
            if (alphabetic)
                store.setValue(PreferenceConstants.CODEASSIST_SORTER,
                        "org.eclipse.wst.jsdt.ui.AlphabeticSorter"); //$NON-NLS-1$
        }
    }
    store.setValue(proposalOrderMigrated, true);

}

From source file:org.eclipse.wst.jsdt.ui.actions.CustomFiltersActionGroup.java

License:Open Source License

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

    // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=22533
    if (!store.contains(getPreferenceKey(TAG_DUMMY_TO_TEST_EXISTENCE)))
        return;/*w  ww.  ja v a  2s.c  o  m*/

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

    for (Iterator iterator = fFilterItems.values().iterator(); iterator.hasNext();) {
        FilterItem item = (FilterItem) iterator.next();
        String id = item.id;
        // set default to value from plugin contributions (fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=73991 ):
        store.setDefault(id, item.descriptor.isEnabled());
        item.enabled = store.getBoolean(id);
    }

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