Java 类org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener 实例源码

项目:triquetrum    文件:Activator.java   
@Override
public void start(BundleContext context) throws Exception {
  final IEclipsePreferences node = getPreferencesRootNode();
  repoSvc = new WorkflowRepositoryServiceImpl(node.get(REPOSITORY_LOCATION_PREFNAME, REPOSITORY_LOCATION_DEFVALUE));
  preferenceChangeListener = new IPreferenceChangeListener() {
    @Override
    public void preferenceChange(PreferenceChangeEvent event) {
      if(REPOSITORY_LOCATION_PREFNAME.equals(event.getKey()) && (repoSvc != null)) {
        // it seems that when you Restore Defaults for preferences, this gives a new value null i.o. the default value!
        String newValue = (event.getNewValue()!=null)? (String) event.getNewValue() : REPOSITORY_LOCATION_DEFVALUE;
        repoSvc.setRootFolder(new File(newValue));
      }
    }
  };
  node.addPreferenceChangeListener(preferenceChangeListener);
  Hashtable<String, String> svcProps = new Hashtable<>();
  svcProps.put("type", "FILE");
  repoSvcReg = context.registerService(WorkflowRepositoryService.class, repoSvc, svcProps);
}
项目:eavp    文件:VizConnectionManager.java   
/**
 * Creates a listener that appropriately adds, updates, or removes
 * connections based on the values in the {@link #preferenceStore}.
 * 
 * @return A new property change listener that can be registered with the
 *         preference store.
 */
private IPreferenceChangeListener createPreferenceListener() {
    return new IPreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            String name = event.getKey();
            Object oldValue = event.getOldValue();
            Object newValue = event.getNewValue();

            // Add, update, or remove depending on whether the old/new
            // values are null.
            if (oldValue != null) {
                if (newValue != null) {
                    updateConnection(name, newValue.toString());
                } else {
                    removeConnection(name);
                }
            } else if (newValue != null) {
                addConnection(name, newValue.toString());
            }

            return;
        }
    };
}
项目:APICloud-Studio    文件:ConsoleThemer.java   
/**
 * listenForThemeChanges
 */
private void listenForThemeChanges()
{
    this.fThemeChangeListener = new IPreferenceChangeListener()
    {
        public void preferenceChange(PreferenceChangeEvent event)
        {
            if (event.getKey().equals(IThemeManager.THEME_CHANGED))
            {
                applyTheme();
            }
        }
    };

    EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID).addPreferenceChangeListener(this.fThemeChangeListener);
}
项目:tm4e    文件:ThemeManager.java   
/**
 * 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 = getPreferenceE4CSSTheme();
    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);
    }
}
项目:tm4e    文件:ThemeManager.java   
/**
 * Remove preference change listener to observe changed of Eclipse E4 Theme and
 * TextMate theme association with grammar.
 * 
 * @param themeChangeListener
 */
public void removePreferenceChangeListener(IPreferenceChangeListener themeChangeListener) {
    // Observe change of Eclipse E4 Theme
    IEclipsePreferences preferences = getPreferenceE4CSSTheme();
    if (preferences != null) {
        preferences.removePreferenceChangeListener(themeChangeListener);
    }
    // Observe change of TextMate Theme association
    preferences = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
    if (preferences != null) {
        preferences.removePreferenceChangeListener(themeChangeListener);
    }
}
项目:filesync4eclipse    文件:ProjectProperties.java   
void notifyListeners(IEclipsePreferences prefs) {
    for (int i = 0; i < prefListeners.size(); i++) {
        IPreferenceChangeListener listener = (IPreferenceChangeListener) prefListeners
                .get(i);
        IEclipsePreferences.PreferenceChangeEvent event = new IEclipsePreferences.PreferenceChangeEvent(
                prefs, KEY_PROJECT, project, project);
        listener.preferenceChange(event);
    }
}
项目:APICloud-Studio    文件:ControlThemer.java   
private void addThemeChangeListener()
{
    // TODO Just use one global listener that updates all instances?
    fThemeChangeListener = new IPreferenceChangeListener()
    {
        public void preferenceChange(PreferenceChangeEvent event)
        {
            if (event.getKey().equals(IThemeManager.THEME_CHANGED))
            {
                applyTheme();
            }
            else if (event.getKey().equals(IPreferenceConstants.INVASIVE_FONT))
            {
                // Handle the invasive font setting change
                if (Boolean.parseBoolean((String) event.getNewValue()))
                {
                    applyControlFont();
                }
                else
                {
                    unapplyControlFont();
                }
            }
            else if (event.getKey().equals(IPreferenceConstants.APPLY_TO_ALL_VIEWS))
            {
                if (Boolean.parseBoolean((String) event.getNewValue()))
                {
                    applyTheme();
                }
                else
                {
                    unapplyTheme();
                }
            }
        }
    };
    EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID).addPreferenceChangeListener(fThemeChangeListener);
}
项目:APICloud-Studio    文件:NodeModuleResolver.java   
protected synchronized IPath nodeSrcPath()
{
    // Cache value and hook pref listener
    if (fNodeSrcPathListener == null)
    {
        fNodeSrcPathListener = new IEclipsePreferences.IPreferenceChangeListener()
        {
            public void preferenceChange(PreferenceChangeEvent event)
            {
                if (IPreferenceConstants.NODEJS_SOURCE_PATH.equals(event.getKey()))
                {
                    String value = (String) event.getNewValue();
                    if (StringUtil.isEmpty(value))
                    {
                        fNodeSrcPath = null;
                    }
                    else
                    {
                        fNodeSrcPath = Path.fromOSString(value);
                    }
                }
            }
        };
        EclipseUtil.instanceScope().getNode(JSCorePlugin.PLUGIN_ID)
                .addPreferenceChangeListener(fNodeSrcPathListener);

        String value = Platform.getPreferencesService().getString(JSCorePlugin.PLUGIN_ID,
                IPreferenceConstants.NODEJS_SOURCE_PATH, null, null);
        if (StringUtil.isEmpty(value))
        {
            fNodeSrcPath = null;
        }
        else
        {
            fNodeSrcPath = Path.fromOSString(value);
        }
    }

    return fNodeSrcPath;
}
项目:Eclipse-Postfix-Code-Completion    文件:AllCleanUpsAction.java   
private void installPreferenceListener() {
   fPreferenceChangeListener= new IPreferenceChangeListener() {
    public void preferenceChange(PreferenceChangeEvent event) {
        if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) {
            updateActionLabel();
        }
    }
};
InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener);
  }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AllCleanUpsAction.java   
private void installPreferenceListener() {
   fPreferenceChangeListener= new IPreferenceChangeListener() {
    public void preferenceChange(PreferenceChangeEvent event) {
        if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) {
            updateActionLabel();
        }
    }
};
InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener);
  }
项目:angularjs-eclipse    文件:AngularProject.java   
AngularProject(IIDETernProject ternProject) throws CoreException {
    this.ternProject = ternProject;
    this.outlineProvider = new AngularOutlineProvider(ternProject);
    this.folders = new HashMap<ITernScriptPath, List<BaseModel>>();
    this.customDirectives = new CustomAngularModulesRegistry(ternProject.getProject());
    AngularModulesManager.getInstance().addRegistry(this, customDirectives);
    ternProject.setData(ANGULAR_PROJECT, this);
    ternProject.addServerListener(new TernServerAdapter() {
        @Override
        public void onStop(ITernServer server) {
            customDirectives.clear();
        }
    });
    // initialize symbols from project preferences
    initializeSymbols();
    AngularCorePreferencesSupport.getInstance().getEclipsePreferences(ternProject.getProject())
            .addPreferenceChangeListener(new IPreferenceChangeListener() {

                @Override
                public void preferenceChange(PreferenceChangeEvent event) {
                    if (AngularCoreConstants.EXPRESSION_START_SYMBOL.equals(event.getKey())) {
                        AngularProject.this.startSymbol = event.getNewValue().toString();
                    } else if (AngularCoreConstants.EXPRESSION_END_SYMBOL.equals(event.getKey())) {
                        AngularProject.this.endSymbol = event.getNewValue().toString();
                    }
                }
            });
}
项目:APICloud-Studio    文件:ThemePlugin.java   
public void start(BundleContext context) throws Exception
    {
        super.start(context);
        plugin = this;

//      if (OS.isMacintosh()) {
//            IEclipsePreferences prefs1 = EclipseUtil.instanceScope().getNode("org.eclipse.jdt.ui");
//            String path = Platform.getInstanceLocation().getURL().getPath();
//            String path1 = "/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs";
//            String prefspath = path + path1;
//            File prefFile = new File(prefspath);
//            if (!(prefFile.exists()))
//            {
//              prefFile.createNewFile();
//            }
//            IEclipsePreferences prefs2 = EclipseUtil.instanceScope().getNode("org.eclipse.ui.workbench");
//
//            String fontsize = prefs1.get("org.eclipse.jface.textfont", "");
//            prefs2.put("org.eclipse.jface.textfont", fontsize);
//      }       

        // Listen to when invasive themes is turned on or off and cache the value for perf sake
        fThemeChangeListener = new IPreferenceChangeListener()
        {
            public void preferenceChange(PreferenceChangeEvent event)
            {
                if (IPreferenceConstants.APPLY_TO_ALL_VIEWS.equals(event.getKey()))
                {
                    fApplyThemeToAllViews = Platform.getPreferencesService().getBoolean(ThemePlugin.PLUGIN_ID,
                            IPreferenceConstants.APPLY_TO_ALL_VIEWS, false, null);
                }
                else if (IPreferenceConstants.APPLY_TO_ALL_EDITORS.equals(event.getKey()))
                {
                    fApplyThemeToAllEditors = Platform.getPreferencesService().getBoolean(ThemePlugin.PLUGIN_ID,
                            IPreferenceConstants.APPLY_TO_ALL_EDITORS, false, null);
                }
            }
        };
        EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID).addPreferenceChangeListener(fThemeChangeListener);
        fApplyThemeToAllViews = Platform.getPreferencesService().getBoolean(ThemePlugin.PLUGIN_ID,
                IPreferenceConstants.APPLY_TO_ALL_VIEWS, false, null);
        fApplyThemeToAllEditors = Platform.getPreferencesService().getBoolean(ThemePlugin.PLUGIN_ID,
                IPreferenceConstants.APPLY_TO_ALL_EDITORS, false, null);

        themeHijacker = new InvasiveThemeHijacker();
        themeHijacker.apply();

        // Listen for changes to eclipse editor colors and synch them back to our theme
        fEclipseColorsListener = new EditorColorSyncher();
        EclipseUtil.instanceScope().getNode("org.eclipse.ui.editors") //$NON-NLS-1$
                .addPreferenceChangeListener(fEclipseColorsListener);
    }
项目:APICloud-Studio    文件:ThemeManager.java   
private ThemeManager()
{
    EclipseUtil.instanceScope().getNode("org.eclipse.ui.editors").addPreferenceChangeListener( //$NON-NLS-1$
            new IPreferenceChangeListener()
            {

                public void preferenceChange(PreferenceChangeEvent event)
                {
                    // Listen to see if the user is modifying the annotations through Annotations pref page
                    for (String prefix : annotationKeyPrefixes)
                    {
                        if (event.getKey().startsWith(prefix))
                        {
                            final String scopeSelector = "override." + prefix; //$NON-NLS-1$
                            // If it's color and getting set to null, then it probably means that user
                            // chose to restore defaults. Does that mean we should remove override?
                            if (event.getNewValue() == null && event.getKey().endsWith("Color")) //$NON-NLS-1$
                            {
                                // Do we need to run this in a delayed job to avoid clashes when the other pref
                                // changes come through at same time...?
                                Job job = new UIJob("Restoring overrides of Annotation") //$NON-NLS-1$
                                {
                                    @Override
                                    public IStatus runInUIThread(IProgressMonitor monitor)
                                    {
                                        ThemeRule rule = getCurrentTheme().getRuleForSelector(
                                                new ScopeSelector(scopeSelector));
                                        if (rule != null)
                                        {
                                            getCurrentTheme().remove(rule);
                                        }
                                        return Status.OK_STATUS;
                                    }
                                };
                                EclipseUtil.setSystemForJob(job);
                                job.setPriority(Job.DECORATE);
                                job.schedule();
                            }
                            else
                            {
                                if (!getCurrentTheme().hasEntry(scopeSelector))
                                {
                                    // Store that the user has overridden this annotation in this theme
                                    int index = getCurrentTheme().getTokens().size();
                                    getCurrentTheme().addNewRule(index, "Annotation Override - " + prefix, //$NON-NLS-1$
                                            new ScopeSelector(scopeSelector), null);
                                }

                            }
                            break;
                        }
                    }
                }
            });
}
项目:APICloud-Studio    文件:CommonEditorPlugin.java   
/**
 * Hook up a listener for theme changes, and change the PHP occurrence colors!
 */
private void listenForThemeChanges()
{
    Job job = new UIJob("Set occurrence colors to theme") //$NON-NLS-1$
    {
        private void setOccurrenceColors()
        {
            IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("org.eclipse.ui.editors"); //$NON-NLS-1$
            Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();

            prefs.put("OccurrenceIndicationColor", StringConverter.asString(theme.getSearchResultColor())); //$NON-NLS-1$

            try
            {
                prefs.flush();
            }
            catch (BackingStoreException e)
            {
                // ignore
            }
        }

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor)
        {
            fThemeChangeListener = new IPreferenceChangeListener()
            {
                public void preferenceChange(PreferenceChangeEvent event)
                {
                    if (event.getKey().equals(IThemeManager.THEME_CHANGED))
                    {
                        setOccurrenceColors();
                    }
                }
            };

            setOccurrenceColors();

            EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID)
                    .addPreferenceChangeListener(fThemeChangeListener);

            return Status.OK_STATUS;
        }
    };

    EclipseUtil.setSystemForJob(job);
    job.schedule(2000);
}