@Override public void putPreferences(IEclipsePreferences preferences, ColorThemeSetting setting) { if (pluginKey.startsWith("editors/options/")) { Preferences pref = preferences.parent().node("de.walware.statet.base.ui/editors/options"); pref.put(pluginKey.substring(16), setting.getColor().asRGB()); } else { preferences.put(pluginKey, setting.getColor().asRGB()); } }
protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 2; i < segmentCount; i++) node = (EclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 2; i < segmentCount; i++) node = (IEclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
@Override protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 2; i < segmentCount; i++) node = (IEclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
@Override protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 5; i < segmentCount; i++) node = (EclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 4; i < segmentCount; i++) node = (EclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 5; i < segmentCount; i++) node = (EclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
@Override protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 2; i < segmentCount; i++) node = (IEclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
@Override protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 2; i < segmentCount; i++) node = (EclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
@Override protected IEclipsePreferences getLoadLevel() { if (loadLevel == null) { if (qualifier == null) return null; // Make it relative to this node rather than navigating to it from the root. // Walk backwards up the tree starting at this node. // This is important to avoid a chicken/egg thing on startup. IEclipsePreferences node = this; for (int i = 4; i < segmentCount; i++) node = (EclipsePreferences) node.parent(); loadLevel = node; } return loadLevel; }
@Override public void putPreferences(IEclipsePreferences preferences, ColorThemeSetting setting) { Preferences pref = preferences.parent().node("org.erlide.ui/" + pluginKey); int styleVal = 0; if (setting.isBoldEnabled() != null && setting.isBoldEnabled()) { styleVal += 1; } if (setting.isItalicEnabled() != null && setting.isItalicEnabled()) { styleVal += 2; } if (setting.isStrikethroughEnabled() != null && setting.isStrikethroughEnabled()) { styleVal += 536870912; } if (setting.isUnderlineEnabled() != null && setting.isUnderlineEnabled()) { styleVal += 1073741824; } pref.put("color", setting.getColor().asRGB()); pref.putInt("style", styleVal); } }
/** * Return true if the given node is in the specified scope and false otherwise. */ private boolean scopeMatches(String scope, IEclipsePreferences tree) { // the root isn't in any scope if (tree.parent() == null) return false; // fancy math to get the first segment of the path String path = tree.absolutePath(); int index = path.indexOf('/', 1); String sub = path.substring(1, index == -1 ? path.length() : index); return scope.equals(sub); }
/** * Return true if the given node is in the specified scope and false otherwise. */ private boolean scopeMatches(String scope, IEclipsePreferences tree) { // the root isn't in any scope if (tree.parent() == null) return false; // fancy math to get the first segment of the path String path = tree.absolutePath(); int index = path.indexOf('/', 1); String sub = path.substring(1, index == -1 ? path.length() : index); return scope.equals(sub); }
IEclipsePreferences getLoadLevel(IEclipsePreferences node) { String path = node.absolutePath(); int count = EclipsePreferences.getSegmentCount(path); // root or scope root if (count == 1 || count == 0) return null; // the load level we want if (count == 2) return node; for (int i = count; i > 2 && node.parent() != null; i--) node = (IEclipsePreferences) node.parent(); return node; }
/** * Dispose the node change listener. */ private void disposeNodeChangeListener() { if (nodeChangeListener != null) { IEclipsePreferences preferences = getStorePreferences(); if (preferences == null) { return; } IEclipsePreferences parent = (IEclipsePreferences) preferences.parent(); if (parent == null) return; parent.removeNodeChangeListener(nodeChangeListener); nodeChangeListener = null; } }
@Override public Preferences parent() { checkRemoved(); return manager.getWorkingCopy((IEclipsePreferences) getOriginal().parent()); }
/** * Create a new instance of the receiver. Store the values in context in the * node looked up by qualifier. * * @param context * the scope to store to * @param qualifier * the qualifer used to look up the preference node */ public ScopedPreferenceStore(IScopeContext context, String qualifier) { storeContext = context; this.nodeQualifier = qualifier; this.defaultQualifier = qualifier; ((IEclipsePreferences) getStorePreferences().parent()) .addNodeChangeListener(getNodeChangeListener()); }
@Override public void close() throws JavaModelException { if (JavaProject.hasJavaNature(this.project)) { // Get cached preferences if exist JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(this.project, false); if (perProjectInfo != null && perProjectInfo.preferences != null) { IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) perProjectInfo.preferences.parent(); if (this.preferencesNodeListener != null) { eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener); this.preferencesNodeListener = null; } if (this.preferencesChangeListener != null) { perProjectInfo.preferences.removePreferenceChangeListener(this.preferencesChangeListener); this.preferencesChangeListener = null; } } } super.close(); }