public class MyPreferenceInitializer extends AbstractPreferenceInitializer { @Override public void initializeDefaultPreferences() { IPreferenceStore store = Plugin.getPlugin().getPreferenceStore(); store.setDefault(MyPreferencePage.PREF_USE_METRIC_UNITS, true); store.setDefault(MyPreferencePage.PREF_AUTO_UPDATE, false); String userHome = System.getProperty("user.home"); String defaultPath = userHome + "\\Local Settings\\Temp\\"; store.setDefault(MyPreferencePage.PREF_USER_FILES_DIR, defaultPath); store.setDefault(MyPreferencePage.PREF_FAVORITE_ANIMAL, "platypus"); } }
@Override protected void performDefaults() { getPreferenceStore().setToDefault("colorTheme"); colorThemeManager.clearImportedThemes(); reloadThemeSelectionList(); getPreferenceStore().setToDefault("forceDefaultBG"); super.performDefaults(); }
public void clearImportedThemes() { IPreferenceStore store = getPreferenceStore(); for (int i = 1; store.contains("importedColorTheme" + i); i++) store.setToDefault("importedColorTheme" + i); themes.clear(); readStockThemes(themes); }
String activeThemeName = getPreferenceStore().getString("colorTheme"); if (colorThemeManager.getTheme(activeThemeName) == null) activeThemeName = "Default"; forceDefaultBG.setSelection(getPreferenceStore().getBoolean("forceDefaultBG")); forceDefaultBG.setToolTipText("Forces the background color of all color styles to be 'background' color of the theme");
@Override protected void doStore() { if (fValue == null) { getPreferenceStore().setToDefault(getPreferenceName()); return; } getPreferenceStore().setValue(getPreferenceName(), fValue); }
@Override protected void doStore() { if (value == null) { getPreferenceStore().setToDefault(getPreferenceName()); return; } getPreferenceStore().setValue(getPreferenceName(), value); }
@Override public void map(Map<String, ColorThemeSetting> theme, Map<String, ColorThemeMapping> overrideMappings) { // put preferences according to mappings IPreferenceStore store = Activator.getDefault().getPreferenceStore(); if (store.getBoolean("forceDefaultBG")) { defaultBackground = theme.get("background"); } else { defaultBackground = new ColorThemeSetting(); } for (String pluginKey : mappings.keySet()) { ColorThemeMapping mapping = (overrideMappings != null && overrideMappings.containsKey(pluginKey)) ? overrideMappings.get(pluginKey) : mappings.get(pluginKey); ColorThemeSetting setting = theme.get(mapping.getThemeKey()); if (setting != null) { mapping.putPreferences(preferences, setting); } } }
private void readImportedThemes(Map<String, ColorTheme> themes) { IPreferenceStore store = getPreferenceStore(); for (int i = 1;; i++) { String xml = store.getString("importedColorTheme" + i); if (xml == null || xml.length() == 0) break; try { ParsedTheme theme = parseTheme(new ByteArrayInputStream(xml.getBytes("UTF-8")), false); amendThemeEntries(theme.getTheme().getEntries()); themes.put(theme.getTheme().getName(), theme.getTheme()); } catch (Exception e) { System.err.println("Error while parsing imported theme"); e.printStackTrace(); } } }
@Override protected void doLoad() { if (colorSelector == null) { return; } colorSelector.setColorValue(PreferenceConverter.getColor( getPreferenceStore(), getPreferenceName())); }
/** * Adds the color theme to the list and saves it to the preferences. * Existing themes will be overwritten with the new content. * @param input The input for theme file. * @throws TransformerException * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public void saveTheme(InputStream input) throws ParserConfigurationException, SAXException, IOException, TransformerException { ParsedTheme theme = parseTheme(input, true); themes.put(theme.getTheme().getName(), theme.getTheme()); IPreferenceStore store = getPreferenceStore(); for (int i = 1;; i++) if (!store.contains("importedColorTheme" + i)) { store.putValue("importedColorTheme" + i, theme.getSource()); break; } }
protected void doLoadDefault() { if (colorSelector == null) { return; } colorSelector.setColorValue(PreferenceConverter.getDefaultColor( getPreferenceStore(), getPreferenceName())); }
public void widgetSelected(SelectionEvent e) { ListItem item= getSelectedItem(); PreferenceConverter.setValue(getPreferenceStore(), item.colorKey, fAnnotationForegroundColorEditor.getColorValue()); } });
@Override public void setVisible(boolean visible) { super.setVisible(visible); if (visible && invalidFieldEditor != null) { invalidFieldEditor.setFocus(); } } }
/** * Store the default preference for the field * being edited */ protected void setToDefault() { FontData[] defaultFontData = PreferenceConverter .getDefaultFontDataArray(getPreferenceStore(), getPreferenceName()); PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), defaultFontData); }
protected void doLoadDefault() { if (changeFontButton == null) { return; } updateFont(PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(), getPreferenceName())); }
@Override public Object getParent(Object element) {//must be an instance of <code>IPreferenceNode</code>. IPreferenceNode targetNode = (IPreferenceNode) element; IPreferenceNode root = manager.getRoot(); return findParent(root, targetNode); }
@Override public void initializeDefaultPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); store.setDefault("colorTheme", "default"); store.setDefault("forceDefaultBG", false); } }
protected void doLoad() { if (colorSelector == null) { return; } colorSelector.setColorValue(PreferenceConverter.getColor( getPreferenceStore(), getPreferenceName())); }