本文整理汇总了Java中org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java IPreferenceChangeListener类的具体用法?Java IPreferenceChangeListener怎么用?Java IPreferenceChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPreferenceChangeListener类属于org.eclipse.core.runtime.preferences.IEclipsePreferences包,在下文中一共展示了IPreferenceChangeListener类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
@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);
}
示例2: createPreferenceListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
/**
* 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;
}
};
}
示例3: listenForThemeChanges
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
/**
* 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);
}
示例4: addPreferenceChangeListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
/**
* 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);
}
}
示例5: removePreferenceChangeListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
/**
* 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);
}
}
示例6: notifyListeners
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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);
}
}
示例7: addThemeChangeListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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);
}
示例8: nodeSrcPath
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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;
}
示例9: installPreferenceListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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);
}
示例10: AngularProject
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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();
}
}
});
}
示例11: start
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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);
}
示例12: ThemeManager
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
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;
}
}
}
});
}
示例13: listenForThemeChanges
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; //导入依赖的package包/类
/**
* 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);
}