Search in sources :

Example 6 with XMLPersistence

use of org.csstudio.trends.databrowser3.persistence.XMLPersistence in project org.csstudio.display.builder by kasemir.

the class DataBrowserWidgetJFX method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_file.checkAndClear()) {
        // This is being done here because the load function causes effects that need to happen on the FxUserThread
        final InputStream safe_stream = model_file_stream;
        model_file_stream = null;
        // Clear model that might already contain items
        final Model db_model = model_widget.getDataBrowserModel();
        db_model.clear();
        // Load new model
        if (safe_stream != null)
            try {
                db_model.setMacros(model_widget.getMacrosOrProperties());
                new XMLPersistence().load(db_model, safe_stream);
                // Override settings in *.plt file with those of widget
                db_model.setToolbarVisible(model_widget.propShowToolbar().getValue());
            } catch (Exception ex) {
                logger.log(Level.WARNING, "Error loading data browser content", ex);
            }
    }
    if (dirty_opts.checkAndClear())
        plot.getPlot().showToolbar(model_widget.propShowToolbar().getValue());
    if (dirty_size.checkAndClear())
        plot.getPlot().setPrefSize(model_widget.propWidth().getValue(), model_widget.propHeight().getValue());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Model(org.csstudio.trends.databrowser3.model.Model) XMLPersistence(org.csstudio.trends.databrowser3.persistence.XMLPersistence)

Example 7 with XMLPersistence

use of org.csstudio.trends.databrowser3.persistence.XMLPersistence in project org.csstudio.display.builder by kasemir.

the class DataBrowserWidgedModel method createDataBrowserModel.

/**
 * Create a Data Browser model, loaded with the configuration file
 *  @return Data Browser Model
 *  @throws Exception
 */
public Model createDataBrowserModel() throws CoreException, Exception {
    final Model model = new Model();
    final IMacroTableProvider opi_macros = getAllMacros();
    final MacroValueProvider db_macros = name -> opi_macros.getMacroValue(name);
    model.setMacros(db_macros);
    try (final InputStream input = SingleSourcePlugin.getResourceHelper().getInputStream(getExpandedFilename())) {
        new XMLPersistence().load(model, input);
    }
    return model;
}
Also used : XMLPersistence(org.csstudio.trends.databrowser3.persistence.XMLPersistence) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) StringProperty(org.csstudio.opibuilder.properties.StringProperty) HashMap(java.util.HashMap) CoreException(org.eclipse.core.runtime.CoreException) Level(java.util.logging.Level) MacroUtil(org.csstudio.apputil.macros.MacroUtil) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) IPath(org.eclipse.core.runtime.IPath) BooleanProperty(org.csstudio.opibuilder.properties.BooleanProperty) Map(java.util.Map) Model(org.csstudio.trends.databrowser3.model.Model) IMacroTableProvider(org.csstudio.apputil.macros.IMacroTableProvider) Logger(java.util.logging.Logger) InfiniteLoopException(org.csstudio.apputil.macros.InfiniteLoopException) MacroTable(org.csstudio.apputil.macros.MacroTable) WidgetPropertyCategory(org.csstudio.opibuilder.properties.WidgetPropertyCategory) SingleSourcePlugin(org.csstudio.utility.singlesource.SingleSourcePlugin) List(java.util.List) MacrosInput(org.csstudio.opibuilder.util.MacrosInput) Path(org.eclipse.core.runtime.Path) MacroValueProvider(org.csstudio.display.builder.model.macros.MacroValueProvider) BorderStyle(org.csstudio.opibuilder.visualparts.BorderStyle) FilePathProperty(org.csstudio.opibuilder.properties.FilePathProperty) Collections(java.util.Collections) InputStream(java.io.InputStream) MacroValueProvider(org.csstudio.display.builder.model.macros.MacroValueProvider) InputStream(java.io.InputStream) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) Model(org.csstudio.trends.databrowser3.model.Model) XMLPersistence(org.csstudio.trends.databrowser3.persistence.XMLPersistence) IMacroTableProvider(org.csstudio.apputil.macros.IMacroTableProvider)

Aggregations

XMLPersistence (org.csstudio.trends.databrowser3.persistence.XMLPersistence)7 InputStream (java.io.InputStream)5 Model (org.csstudio.trends.databrowser3.model.Model)5 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)2 PVItem (org.csstudio.trends.databrowser3.model.PVItem)2 IPath (org.eclipse.core.runtime.IPath)2 PartInitException (org.eclipse.ui.PartInitException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Instant (java.time.Instant)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 IMacroTableProvider (org.csstudio.apputil.macros.IMacroTableProvider)1 InfiniteLoopException (org.csstudio.apputil.macros.InfiniteLoopException)1 MacroTable (org.csstudio.apputil.macros.MacroTable)1 MacroUtil (org.csstudio.apputil.macros.MacroUtil)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1