use of org.eclipse.core.runtime.Preferences.PropertyChangeEvent in project yamcs-studio by yamcs.
the class OPIBuilderPlugin method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
resources = new ResourceHelper();
ui = new UIHelper();
// set this to resolve Xincludes in XMLs
System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", "org.apache.xerces.parsers.XIncludeParserConfiguration");
ScriptService.getInstance();
if (PreferencesHelper.isDisplaySystemOutput()) {
ConsoleService.getInstance().turnOnSystemOutput();
}
preferenceLisener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(PreferencesHelper.COLOR_FILE))
MediaService.getInstance().reloadColorFile();
else if (event.getProperty().equals(PreferencesHelper.FONT_FILE))
MediaService.getInstance().reloadFontFile();
else if (event.getProperty().equals(PreferencesHelper.OPI_GUI_REFRESH_CYCLE))
GUIRefreshThread.getInstance(true).reLoadGUIRefreshCycle();
else if (event.getProperty().equals(PreferencesHelper.DISABLE_ADVANCED_GRAPHICS)) {
// $NON-NLS-1$ //$NON-NLS-2$
String disabled = PreferencesHelper.isAdvancedGraphicsDisabled() ? "true" : "false";
// for swt.widgets
System.setProperty("org.csstudio.swt.widget.prohibit_advanced_graphics", // $NON-NLS-1$
disabled);
// for XYGraph
// $NON-NLS-1$
System.setProperty("prohibit_advanced_graphics", disabled);
} else if (event.getProperty().equals(PreferencesHelper.URL_FILE_LOADING_TIMEOUT))
System.setProperty(// $NON-NLS-1$
"org.csstudio.swt.widget.url_file_load_timeout", Integer.toString(PreferencesHelper.getURLFileLoadingTimeout()));
else if (event.getProperty().equals(PreferencesHelper.SCHEMA_OPI)) {
SchemaService.getInstance().reLoad();
} else if (event.getProperty().equals(PreferencesHelper.DISPLAY_SYSTEM_OUTPUT)) {
if (PreferencesHelper.isDisplaySystemOutput())
ConsoleService.getInstance().turnOnSystemOutput();
else
ConsoleService.getInstance().turnOffSystemOutput();
}
}
};
getPluginPreferences().addPropertyChangeListener(preferenceLisener);
@SuppressWarnings("serial")
class HackPropertyChangeEvent extends PropertyChangeEvent {
public HackPropertyChangeEvent(Object source, String property, Object oldValue, Object newValue) {
super(source, property, oldValue, newValue);
}
}
preferenceLisener.propertyChange(new HackPropertyChangeEvent(this, PreferencesHelper.DISABLE_ADVANCED_GRAPHICS, null, null));
preferenceLisener.propertyChange(new HackPropertyChangeEvent(this, PreferencesHelper.URL_FILE_LOADING_TIMEOUT, null, null));
}
use of org.eclipse.core.runtime.Preferences.PropertyChangeEvent in project eclipse.platform.runtime by eclipse.
the class PreferenceForwarderTest method testListenerOnRemove.
/* Comment this test out until we are able to use session tests
* with it. - ddw
* public void testPluginPrefs() {
IPluginRegistry registry = InternalPlatform.getPluginRegistry();
IPluginDescriptor resPlugin = registry.getPluginDescriptor("org.eclipse.core.resources");
Preferences perfs = null;
try {
perfs = resPlugin.getPlugin().getPluginPreferences();
} catch (CoreException ce) {
fail("0.1 core exception from getPlugin");
}
boolean oneBoolean = perfs.getBoolean("OneBoolean");
double oneDouble = perfs.getDouble("OneDouble");
float oneFloat = perfs.getFloat("OneFloat");
int oneInt = perfs.getInt("OneInt");
long oneLong = perfs.getLong("OneLong");
String oneString = perfs.getString("OneString");
assertTrue("1.0 boolean", oneBoolean);
assertTrue("2.0 double", oneDouble == 4);
assertTrue("3.0 float", oneFloat == 4.3f);
assertTrue("4.0 int", oneInt == 5);
assertTrue("5.0 long", oneLong == 6);
assertTrue("6.0 string", oneString.equals("A string from the plugin root directory"));
int a = 4;
int b = 3;
}
*/
/*
* Regression test for bug 178815.
*/
public void testListenerOnRemove() {
// create a new log listener that will fail if anything is written
ILogListener logListener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
CoreException ex = new CoreException(status);
fail("0.99", ex);
}
};
// set a preference value to get everything initialized
String id = getUniqueString();
Preferences ps = new PreferenceForwarder(id);
ps.setValue("key", "value");
// add a property change listener which will cause one to be
// added at the preference node level
IPropertyChangeListener listener = new Preferences.IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
}
};
ps.addPropertyChangeListener(listener);
ps.setValue("key2", "value2");
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(id);
// add our log listener and remove the node. nothing should be logged.
RuntimeLog.addLogListener(logListener);
try {
node.removeNode();
} catch (BackingStoreException e) {
fail("4.99", e);
} catch (IllegalStateException e) {
fail("5.00", e);
} finally {
RuntimeLog.removeLogListener(logListener);
}
}
Aggregations