本文整理汇总了Java中org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java IEclipsePreferences.IPreferenceChangeListener方法的具体用法?Java IEclipsePreferences.IPreferenceChangeListener怎么用?Java IEclipsePreferences.IPreferenceChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.preferences.IEclipsePreferences
的用法示例。
在下文中一共展示了IEclipsePreferences.IPreferenceChangeListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChangeListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences; //导入方法依赖的package包/类
/**
* return the listener for preferences changes.
* @return the change listener
*/
private IEclipsePreferences.IPreferenceChangeListener getChangeListener() {
if (changeListener==null) {
changeListener = new IEclipsePreferences.IPreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent pce) {
if (debug==true) System.out.println("Property '" + pce.getKey() + "' changed from " + pce.getOldValue() + " to "+ pce.getNewValue());
switch(pce.getKey()) {
case DEF_RUNAS:
boolean changedExecutionMode = (pce.getOldValue()!=null && pce.getNewValue()!=pce.getOldValue());
if (changedExecutionMode==true) {
if (debug==true) System.out.println("Changed Execution Mode: changed from " + pce.getOldValue() + " to "+ pce.getNewValue());
//TODO if the preference dialog was set to SWT!
}
}
}
};
}
return changeListener;
}
示例2: initializePreferencesListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences; //导入方法依赖的package包/类
/**
* Initialize the preferences listener.
*/
private void initializePreferencesListener() {
if (preferencesListener == null) {
preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
*/
public void preferenceChange(PreferenceChangeEvent event) {
if (silentRunning) {
return;
}
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
String key = event.getKey();
if (newValue == null) {
newValue = getDefault(key, oldValue);
} else if (oldValue == null) {
oldValue = getDefault(key, newValue);
}
firePropertyChangeEvent(event.getKey(), oldValue, newValue);
}
};
getStorePreferences().addPreferenceChangeListener(
preferencesListener);
}
}
示例3: initializePreferencesListener
import org.eclipse.core.runtime.preferences.IEclipsePreferences; //导入方法依赖的package包/类
/**
* Initialize the preferences listener.
*/
private void initializePreferencesListener() {
if (preferencesListener == null) {
preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
*/
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (silentRunning) {
return;
}
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
String key = event.getKey();
if (newValue == null) {
newValue = getDefault(key, oldValue);
} else if (oldValue == null) {
oldValue = getDefault(key, newValue);
}
firePropertyChangeEvent(event.getKey(), oldValue, newValue);
}
};
getStorePreferences().addPreferenceChangeListener(
preferencesListener);
}
}
示例4: nodeSrcPath
import org.eclipse.core.runtime.preferences.IEclipsePreferences; //导入方法依赖的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;
}
示例5: initializeValues
import org.eclipse.core.runtime.preferences.IEclipsePreferences; //导入方法依赖的package包/类
/**
* Add a pref change listener for changes to values, set up starting values. This is a performance change so we
* don't lookup the preference values repeatedly.
*/
protected synchronized static void initializeValues()
{
if (fgPrefListener == null)
{
final IScopeContext[] contexts = new IScopeContext[] { EclipseUtil.instanceScope(),
EclipseUtil.defaultScope() };
try
{
fgPrefListener = new IEclipsePreferences.IPreferenceChangeListener()
{
public void preferenceChange(PreferenceChangeEvent event)
{
if (ICorePreferenceConstants.TASK_TAGS_CASE_SENSITIVE.equals(event.getKey()))
{
fgCaseSensitive = Platform.getPreferencesService().getBoolean(PREF_PLUGIN_ID,
ICorePreferenceConstants.TASK_TAGS_CASE_SENSITIVE, true, contexts);
}
else if (ICorePreferenceConstants.TASK_TAG_PRIORITIES.equals(event.getKey())
|| ICorePreferenceConstants.TASK_TAG_NAMES.equals(event.getKey()))
{
fgTaskTags = getCurrentTaskTags();
}
}
};
EclipseUtil.instanceScope().getNode(PREF_PLUGIN_ID).addPreferenceChangeListener(fgPrefListener);
}
catch (Exception e)
{
IdeLog.logError(CorePlugin.getDefault(), "Failed to attach preference listener for task tag prefs", e); //$NON-NLS-1$
fgPrefListener = null;
}
fgCaseSensitive = Platform.getPreferencesService().getBoolean(PREF_PLUGIN_ID,
ICorePreferenceConstants.TASK_TAGS_CASE_SENSITIVE, true, contexts);
}
if (fgTaskTags == null)
{
fgTaskTags = getCurrentTaskTags();
}
}