Java Code Examples for org.eclipse.core.runtime.preferences.IEclipsePreferences#addPreferenceChangeListener()
The following examples show how to use
org.eclipse.core.runtime.preferences.IEclipsePreferences#addPreferenceChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThemeManager.java From tm4e with Eclipse Public License 1.0 | 5 votes |
/** * Add preference change listener to observe changed of Eclipse E4 Theme and * TextMate theme association with grammar. * * @param themeChangeListener */ public void addPreferenceChangeListener(IPreferenceChangeListener themeChangeListener) { // Observe change of Eclipse E4 Theme IEclipsePreferences preferences = PreferenceUtils.getE4PreferenceStore(); if (preferences != null) { preferences.addPreferenceChangeListener(themeChangeListener); } // Observe change of TextMate Theme association preferences = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID); if (preferences != null) { preferences.addPreferenceChangeListener(themeChangeListener); } }
Example 2
Source File: PreferenceKey.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void addChangeListener(IScopeContext context, IWorkingCopyManager manager, String qualifier, IPreferenceChangeListener listener) { IEclipsePreferences node= context.getNode(qualifier); if (manager != null) { node = manager.getWorkingCopy(node); } node.addPreferenceChangeListener(listener); }
Example 3
Source File: RendererPreferences.java From depan with Apache License 2.0 | 5 votes |
/** * Create a new updater for the user's Eclipse preferences, and configure * it to keep the OGL renderer up to date. */ public static RendererPreferences preparePreferences(GLPanel glPanel) { RendererPreferences result = new RendererPreferences(glPanel); result.setPreferences(); // Register the new instance for preference changes IEclipsePreferences prefs = PreferencesIds.getInstanceNode(); prefs.addPreferenceChangeListener(result); return result; }
Example 4
Source File: UIPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Adds a listener to changes in the Project->Build Automatically changes. */ private void addAutoBuildListener() { IEclipsePreferences node = EclipseUtil.instanceScope().getNode(ResourcesPlugin.PI_RESOURCES); autoBuildListener = new AutoBuildListener(); node.addPreferenceChangeListener(autoBuildListener); }
Example 5
Source File: ConfigPropertyWidgetMultiCheck.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override protected Control getValueWidget(Composite parent) { if (mTable == null) { mTranslateTokens = CheckstyleUIPluginPrefs .getBoolean(CheckstyleUIPluginPrefs.PREF_TRANSLATE_TOKENS); mSortTokens = CheckstyleUIPluginPrefs.getBoolean(CheckstyleUIPluginPrefs.PREF_SORT_TOKENS); IEclipsePreferences instanceScope = InstanceScope.INSTANCE .getNode(CheckstyleUIPlugin.PLUGIN_ID); instanceScope.addPreferenceChangeListener(this); mTable = CheckboxTableViewer.newCheckList(parent, SWT.V_SCROLL | SWT.BORDER); mTable.setContentProvider(new ArrayContentProvider()); mTable.setLabelProvider(new TokenLabelProvider()); installSorter(mSortTokens); mTable.setInput(mTokens); mTable.setCheckedElements(getInitialValues().toArray()); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 150; mTable.getControl().setLayoutData(gd); // deregister the listener on widget dipose mTable.getControl().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { IEclipsePreferences prefStore = InstanceScope.INSTANCE .getNode(CheckstyleUIPlugin.PLUGIN_ID); prefStore.removePreferenceChangeListener(ConfigPropertyWidgetMultiCheck.this); } }); } return mTable.getControl(); }
Example 6
Source File: PreferenceRecorder.java From workspacemechanic with Eclipse Public License 1.0 | 4 votes |
private void addListener(IEclipsePreferences node) { node.addNodeChangeListener(listener); node.addPreferenceChangeListener(listener); recordedNodes.add(node); }
Example 7
Source File: InvasiveThemeHijacker.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void apply() { earlyStartup(); IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID); prefs.addPreferenceChangeListener(this); }
Example 8
Source File: JavaProject.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Returns the project custom preference pool. * Project preferences may include custom encoding. * @return IEclipsePreferences or <code>null</code> if the project * does not have a java nature. */ public IEclipsePreferences getEclipsePreferences() { if (!JavaProject.hasJavaNature(this.project)) return null; // Get cached preferences if exist JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(this.project, true); if (perProjectInfo.preferences != null) return perProjectInfo.preferences; // Init project preferences IScopeContext context = new ProjectScope(getProject()); final IEclipsePreferences eclipsePreferences = context.getNode(JavaCore.PLUGIN_ID); updatePreferences(eclipsePreferences); perProjectInfo.preferences = eclipsePreferences; // Listen to new preferences node final IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) eclipsePreferences.parent(); if (eclipseParentPreferences != null) { if (this.preferencesNodeListener != null) { eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener); } this.preferencesNodeListener = new IEclipsePreferences.INodeChangeListener() { public void added(IEclipsePreferences.NodeChangeEvent event) { // do nothing } public void removed(IEclipsePreferences.NodeChangeEvent event) { if (event.getChild() == eclipsePreferences) { JavaModelManager.getJavaModelManager().resetProjectPreferences(JavaProject.this); } } }; eclipseParentPreferences.addNodeChangeListener(this.preferencesNodeListener); } // Listen to preferences changes if (this.preferencesChangeListener != null) { eclipsePreferences.removePreferenceChangeListener(this.preferencesChangeListener); } this.preferencesChangeListener = new IEclipsePreferences.IPreferenceChangeListener() { public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) { String propertyName = event.getKey(); JavaModelManager manager = JavaModelManager.getJavaModelManager(); if (propertyName.startsWith(JavaCore.PLUGIN_ID)) { if (propertyName.equals(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH) || propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS) || propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) || propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) || propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) || propertyName.equals(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE) || propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL) || propertyName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) { manager.deltaState.addClasspathValidation(JavaProject.this); } manager.resetProjectOptions(JavaProject.this); JavaProject.this.resetCaches(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233568 } } }; eclipsePreferences.addPreferenceChangeListener(this.preferencesChangeListener); return eclipsePreferences; }
Example 9
Source File: ConsoleColorCache.java From Pydev with Eclipse Public License 1.0 | 4 votes |
private ConsoleColorCache() { IEclipsePreferences node = new InstanceScope().getNode("org.eclipse.debug.ui"); node.addPreferenceChangeListener(this); }
Example 10
Source File: DebugEarlyStartup.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void earlyStartup() { //Note: preferences are in the PydevPlugin, not in the debug plugin. IEclipsePreferences preferenceStore = PydevPrefs.getEclipsePreferences(); preferenceStore.addPreferenceChangeListener(new IPreferenceChangeListener() { @Override public void preferenceChange(PreferenceChangeEvent event) { if (DebugPluginPrefsInitializer.DEBUG_SERVER_STARTUP.equals(event.getKey())) { //On a change in the preferences, re-check if it should be always on... checkAlwaysOnJob.schedule(200); } } }); RemoteDebuggerServer.getInstance().addListener(new IRemoteDebuggerListener() { @Override public void stopped(RemoteDebuggerServer remoteDebuggerServer) { //When it stops, re-check if it should be always on. checkAlwaysOnJob.schedule(200); } }); checkAlwaysOnJob.schedule(500); //wait a little bit more to enable on startup. DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() { @Override public void handleDebugEvents(DebugEvent[] events) { if (events != null) { for (DebugEvent debugEvent : events) { if (debugEvent.getKind() == DebugEvent.SUSPEND) { if (debugEvent.getDetail() == DebugEvent.BREAKPOINT) { if (debugEvent.getSource() instanceof PyThread) { IPreferenceStore preferenceStore2 = PyDevUiPrefs.getPreferenceStore(); final int forceOption = preferenceStore2 .getInt(DebugPluginPrefsInitializer.FORCE_SHOW_SHELL_ON_BREAKPOINT); if (forceOption != DebugPluginPrefsInitializer.FORCE_SHOW_SHELL_ON_BREAKPOINT_MAKE_NOTHING) { Runnable r = new Runnable() { @Override public void run() { Shell activeShell = UIUtils.getActiveShell(); if (activeShell != null) { forceActive(activeShell, forceOption); } } }; boolean runNowIfInUiThread = true; RunInUiThread.async(r, runNowIfInUiThread); } } } } } } } }); }