use of org.csstudio.utility.singlesource.ResourceHelper 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.csstudio.utility.singlesource.ResourceHelper in project org.csstudio.display.builder by kasemir.
the class DataBrowserEditor method doSaveAs.
/**
* {@inheritDoc}
*/
@Override
public void doSaveAs() {
final Shell shell = getSite().getShell();
final ResourceHelper resources = SingleSourcePlugin.getResourceHelper();
final IPath original = resources.getPath(getEditorInput());
// Prompt & save until success or cancel
while (true) {
final IPath file = SingleSourcePlugin.getUIHelper().openSaveDialog(shell, original, Model.FILE_EXTENSION);
if (file == null)
return;
try {
final PathEditorInput new_input = new PathEditorInput(file);
try (final OutputStream stream = resources.getOutputStream(new_input)) {
save(new NullProgressMonitor(), stream);
}
// Set that file as editor's input, so that just 'save' instead of
// 'save as' is possible from now on
final DataBrowserModelEditorInput db_input = new DataBrowserModelEditorInput(new_input, model);
setInput(db_input);
setPartName(db_input.getName());
setTitleToolTip(db_input.getToolTipText());
return;
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(getSite().getShell(), Messages.Error, ex);
}
}
}
use of org.csstudio.utility.singlesource.ResourceHelper in project org.csstudio.display.builder by kasemir.
the class OpenDisplayFile method openDisplay.
/**
* {@inheritDoc}
*/
@Override
public void openDisplay(final String path, final String data) throws Exception {
final Model model = new Model();
// Read file
final ResourceHelper resources = SingleSourcePlugin.getResourceHelper();
final IPath ipath = resources.newPath(path);
try (final InputStream stream = resources.getInputStream(ipath)) {
new XMLPersistence().load(model, stream);
}
final IEditorInput input = new DataBrowserModelEditorInput(new PathEditorInput(ipath), model);
// Create new editor
final DataBrowserEditor editor = DataBrowserEditor.createInstance(input);
if (editor == null)
throw new Exception("Cannot create Data Browser");
}
use of org.csstudio.utility.singlesource.ResourceHelper in project org.csstudio.display.builder by kasemir.
the class ImportArchiveReader method getRawValues.
@Override
public ValueIterator getRawValues(final int key, final String name, final Instant start, final Instant end) throws UnknownChannelException, Exception {
if (values == null) {
// Locate file
final ResourceHelper resources = SingleSourcePlugin.getResourceHelper();
final IPath ipath = resources.newPath(path);
// Import data
values = importer.importValues(resources.getInputStream(ipath));
}
return new ArrayValueIterator(values);
}
Aggregations