List of usage examples for org.eclipse.jface.preference IPreferenceStore contains
boolean contains(String name);
From source file:org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer.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 www .j av a 2 s . co m protected static RGB createColor(IPreferenceStore store, String key) { if (!store.contains(key)) return null; if (store.isDefault(key)) return PreferenceConverter.getDefaultColor(store, key); return PreferenceConverter.getColor(store, key); }
From source file:org.eclipse.cdt.internal.ui.editor.CSourceViewer.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// w ww .j av a2 s . c om * @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 */ 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:org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage.java
License:Open Source License
public static void initDefaults(IPreferenceStore prefs) { if (!prefs.contains(PREF_CLEAR_CONSOLE)) prefs.setDefault(PREF_CLEAR_CONSOLE, true); if (!prefs.contains(PREF_AUTO_OPEN_CONSOLE)) prefs.setDefault(PREF_AUTO_OPEN_CONSOLE, true); if (!prefs.contains(PREF_CONSOLE_ON_TOP)) prefs.setDefault(PREF_CONSOLE_ON_TOP, false); if (!prefs.contains(PREF_BUILDCONSOLE_WRAP_LINES)) prefs.setDefault(PREF_BUILDCONSOLE_WRAP_LINES, false); if (!prefs.contains(PREF_BUILDCONSOLE_LINES)) prefs.setDefault(PREF_BUILDCONSOLE_LINES, 500); if (!prefs.contains(PREF_BUILDCONSOLE_TAB_WIDTH)) prefs.setDefault(PREF_BUILDCONSOLE_TAB_WIDTH, 4); if (!prefs.contains(PREF_BUILDCONSOLE_OUTPUT_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_OUTPUT_COLOR, new RGB(0, 0, 0)); if (!prefs.contains(PREF_BUILDCONSOLE_INFO_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_INFO_COLOR, new RGB(0, 0, 255)); if (!prefs.contains(PREF_BUILDCONSOLE_ERROR_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_ERROR_COLOR, new RGB(255, 0, 0)); if (!prefs.contains(PREF_BUILDCONSOLE_BACKGROUND_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_BACKGROUND_COLOR, new RGB(255, 255, 255)); if (!prefs.contains(PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR, new RGB(254, 231, 224)); if (!prefs.contains(PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR, new RGB(254, 243, 218)); if (!prefs.contains(PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR, new RGB(244, 247, 254)); if (!prefs.contains(PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR)) PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR, new RGB(255, 0, 0)); }
From source file:org.eclipse.cdt.internal.ui.text.TaskTagRule.java
License:Open Source License
/** * Creates a new task tag rule// w ww . j a v a 2 s . c om * @param token the token to return for words recognized as task tags * @param defaultToken * @param preferenceStore * @param corePreferenceStore */ public TaskTagRule(IToken token, IToken defaultToken, IPreferenceStore preferenceStore, IPreferenceStore corePreferenceStore) { super(new TaskTagDetector(), defaultToken); fMatcher = new TaskTagMatcher(token); addWordMatcher(fMatcher); String taskWords = null; if (preferenceStore.contains(TODO_TASK_TAGS)) { taskWords = preferenceStore.getString(TODO_TASK_TAGS); } else if (corePreferenceStore != null) { taskWords = corePreferenceStore.getString(TODO_TASK_TAGS); } if (taskWords != null) { addTaskTags(taskWords); } boolean isCaseSensitive = true; if (preferenceStore.contains(TODO_TASK_CASE_SENSITIVE)) { isCaseSensitive = preferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE); } else if (corePreferenceStore != null) { isCaseSensitive = corePreferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE); } fMatcher.setCaseSensitive(isCaseSensitive); }
From source file:org.eclipse.cdt.ui.actions.CustomFiltersActionGroup.java
License:Open Source License
private void initializeWithViewDefaults() { // get default values for view IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); // XXX: can be removed once bug 22533 is fixed. if (!store.contains(getPreferenceKey("TAG_DUMMY_TO_TEST_EXISTENCE")))//$NON-NLS-1$ return;/*from w w w .j a v a 2s. co m*/ // XXX: Uncomment once bug 22533 is fixed. // if (!store.contains(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED))) // return; fUserDefinedPatternsEnabled = store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED)); setUserDefinedPatterns(CustomFiltersDialog .convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR)); Iterator<String> iter = fEnabledFilterIds.keySet().iterator(); while (iter.hasNext()) { String id = iter.next(); Boolean isEnabled = new Boolean(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.cdt.ui.text.TaskTagRule.java
License:Open Source License
/** * Convenience method for extracting a list of words that should be recognized as * task labels from an {@link IPreferenceStore} and a backup {@link Preferences} * @param preferenceStore//from w ww. java2s . c om * @param corePreferences * @return a list of words that should be recognized as task labels in the format * expected by TaskTagRule */ public static String getTaskWords(IPreferenceStore preferenceStore, Preferences corePreferences) { String result = null; if (preferenceStore.contains(CCorePreferenceConstants.TODO_TASK_TAGS)) { result = preferenceStore.getString(CCorePreferenceConstants.TODO_TASK_TAGS); } else if (corePreferences != null) { result = corePreferences.getString(CCorePreferenceConstants.TODO_TASK_TAGS); } return result; }
From source file:org.eclipse.common_prefs.core.CommonPrefsHelper.java
License:Open Source License
/** * Read the preference files into the workspace. Report any errors as a * multi status object, allowing one file to fail but others to succeed. * * @param prefFiles/*from w ww. ja va 2 s .c o m*/ * @return MultiStatus */ public static MultiStatus loadPreferences() { // The ErrorLog will show the MultiStatus entry as one top level object // with children for each sub-entry. The top level error state will be // as the most sever of the child states. MultiStatus status = new MultiStatus(StartupPlugin.PLUGIN_ID, 0, "Log entries recorded when reading preference files", null); IPreferenceStore store = StartupPlugin.getDefault().getPreferenceStore(); boolean wsIsInitialized = false; if (store.contains(PreferenceInitializer.PREF_WS_INITIALIZED)) wsIsInitialized = store.getBoolean(PreferenceInitializer.PREF_WS_INITIALIZED); IPreferenceFilter[] transfers = getPreferenceFilters(); CommonPrefEPFResources prefFiles = StartupPlugin.getDefault().getCommonPrefFiles(status); for (Iterator<CommonPrefEPFResource> iter = prefFiles.iterator(); iter.hasNext();) { CommonPrefEPFResource prefFile = (CommonPrefEPFResource) iter.next(); // If ws is initialized, reinit only if pref file is changed long timeStampCurr = prefFile.getLastModified(); if (!prefFile.isForce()) { if (wsIsInitialized) { long timeStampOld = store.getLong(prefFile.getResourceName()); // 0 or value if (timeStampCurr <= timeStampOld) continue; else { status.add(new Status(Status.INFO, StartupPlugin.PLUGIN_ID, "Preference resource " + prefFile.getResourceName() + " is either new or has been updated. Will be read.")); } } } /* NOTE: When using the importPreferences method below, there was an issue when * loading a preference file; the search window in the preference dialog was gone. * This didn't occur when using the import wizard. Hence changed to use same method * as this, see the org.eclipse.ui.internal.wizards.preferences package and * class::method WizardPreferencesImportPage1::transfer method for code ... */ // IPath path = new Path(pathStr); // Preferences.importPreferences(path); status.add(loadPreferenceFile(prefFile, transfers)); // If init file, set timestamp if (!prefFile.isForce()) store.setValue(prefFile.getResourceName(), timeStampCurr); } // Mark workspace as initialized store.setValue(PreferenceInitializer.PREF_WS_INITIALIZED, true); return status; }
From source file:org.eclipse.common_prefs.preferences.CommonPrefPreferencePage.java
License:Open Source License
private boolean getEnbleRead() { IPreferenceStore store = StartupPlugin.getDefault().getPreferenceStore(); boolean readPrefs = true; if (store.contains(PreferenceInitializer.PREF_ENABLE_READ)) readPrefs = store.getBoolean(PreferenceInitializer.PREF_ENABLE_READ); return readPrefs; }
From source file:org.eclipse.common_prefs.preferences.CommonPrefPreferencePage.java
License:Open Source License
private boolean getShowCurrent() { IPreferenceStore store = StartupPlugin.getDefault().getPreferenceStore(); boolean showCurrent = true; if (store.contains(PreferenceInitializer.PREF_SHOW_CURRENT)) showCurrent = store.getBoolean(PreferenceInitializer.PREF_SHOW_CURRENT); return showCurrent; }
From source file:org.eclipse.common_prefs.StartupClass.java
License:Open Source License
/** * The method will check if common preference files are to be loaded. If so, they * will be loaded depending on what type of flag is set. * /*from w w w . j a v a2 s . c o m*/ * @see org.eclipse.ui.IStartup#earlyStartup() */ public void earlyStartup() { // Check if common preference reading is enabled IPreferenceStore store = StartupPlugin.getDefault().getPreferenceStore(); boolean readPrefs = true; if (store.contains(PreferenceInitializer.PREF_ENABLE_READ)) readPrefs = store.getBoolean(PreferenceInitializer.PREF_ENABLE_READ); if (!readPrefs) return; /* * Call to pref reading needs to be in context of code below since display * etc needs to be up when calling to have listeners react properly on updates. * * NOTE: Hence will not Common Prefs code affect headless invocations. */ final IWorkbench workbench = PlatformUI.getWorkbench(); final boolean wsIsInitialized = store.getBoolean(PreferenceInitializer.PREF_WS_INITIALIZED); workbench.getDisplay().asyncExec(new Runnable() { public void run() { IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return; // If debugging, record an entry in the log. Since also gives a // ms accurate timestamp it can be used for checking performance if (StartupPlugin.getDefault().isDebugging()) StartupPlugin.log(new Status(IStatus.INFO, StartupPlugin.PLUGIN_ID, "Common Preferences Plugin earlyStartup called.")); if (!wsIsInitialized) { CommonPrefsHelper.saveDefaultPreferences(); } IStatus status = CommonPrefsHelper.loadPreferences(); if (status.getChildren().length > 0) StartupPlugin.log(status); // If debugging, record an exit entry in the log if (StartupPlugin.getDefault().isDebugging()) StartupPlugin.log(new Status(IStatus.INFO, StartupPlugin.PLUGIN_ID, "Common Preferences Plugin earlyStartup finished.")); } }); }