Search in sources :

Example 1 with MacrosInput

use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.

the class OpenDisplayAction method configureProperties.

@Override
protected void configureProperties() {
    addProperty(new FilePathProperty(PROP_PATH, "File Path", WidgetPropertyCategory.Basic, new Path(""), new String[] { "opi" }, false) {

        @Override
        public Object readValueFromXML(Element propElement) {
            handleLegacySettings(propElement);
            return super.readValueFromXML(propElement);
        }
    });
    addProperty(new MacrosProperty(PROP_MACROS, "Macros", WidgetPropertyCategory.Basic, new MacrosInput(new LinkedHashMap<String, String>(), true)));
    addProperty(new ComboProperty(PROP_MODE, "Mode", WidgetPropertyCategory.Basic, DisplayMode.stringValues(), DisplayMode.REPLACE.ordinal()));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MacrosInput(org.csstudio.opibuilder.util.MacrosInput) ComboProperty(org.csstudio.opibuilder.properties.ComboProperty) Element(org.jdom.Element) FilePathProperty(org.csstudio.opibuilder.properties.FilePathProperty) MacrosProperty(org.csstudio.opibuilder.properties.MacrosProperty)

Example 2 with MacrosInput

use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.

the class OpenDisplayAction method getMacrosInput.

protected MacrosInput getMacrosInput() {
    MacrosInput result = new MacrosInput(new LinkedHashMap<String, String>(), true);
    MacrosInput macrosInput = ((MacrosInput) getPropertyValue(PROP_MACROS)).getCopy();
    if (macrosInput.isInclude_parent_macros()) {
        Map<String, String> macrosMap = getWidgetModel() instanceof AbstractContainerModel ? ((AbstractContainerModel) getWidgetModel()).getParentMacroMap() : getWidgetModel().getParent().getMacroMap();
        result.getMacrosMap().putAll(macrosMap);
    }
    result.getMacrosMap().putAll(macrosInput.getMacrosMap());
    return result;
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel)

Example 3 with MacrosInput

use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.

the class MacrosProperty method readValueFromXML.

@Override
public MacrosInput readValueFromXML(Element propElement) {
    LinkedHashMap<String, String> macros = new LinkedHashMap<String, String>();
    boolean b = true;
    for (Object oe : propElement.getChildren()) {
        Element se = (Element) oe;
        if (se.getName().equals(XML_ELEMENT_INCLUDE_PARENT_MACROS))
            b = Boolean.parseBoolean(se.getText());
        else
            macros.put(se.getName(), se.getText());
    }
    return new MacrosInput(macros, b);
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) Element(org.jdom.Element) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with MacrosInput

use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.

the class MacrosProperty method writeToXML.

@Override
public void writeToXML(Element propElement) {
    MacrosInput macros = (MacrosInput) propertyValue;
    Element be = new Element(XML_ELEMENT_INCLUDE_PARENT_MACROS);
    // $NON-NLS-1$
    be.setText("" + macros.isInclude_parent_macros());
    propElement.addContent(be);
    for (String key : macros.getMacrosMap().keySet()) {
        Element newElement = new Element(key);
        newElement.setText(macros.getMacrosMap().get(key));
        propElement.addContent(newElement);
    }
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) Element(org.jdom.Element)

Example 5 with MacrosInput

use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.

the class OPIRuntimeDelegate method fillDisplayModelInJob.

private void fillDisplayModelInJob(final IEditorInput input, final Display display, final IWorkbenchPartSite site) {
    Job job = new Job("Loading OPI...") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Connecting to " + input, IProgressMonitor.UNKNOWN);
            try {
                display.asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (viewer != null) {
                            viewer.getControl().addPaintListener(loadingMessagePaintListener);
                            viewer.getControl().redraw();
                        }
                    }
                });
                final InputStream stream = ((IRunnerInput) input).getInputStream();
                display.asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            if (viewer != null) {
                                viewer.getControl().removePaintListener(loadingMessagePaintListener);
                            }
                            MacrosInput macrosInput = ((IRunnerInput) input).getMacrosInput();
                            XMLUtil.fillDisplayModelFromInputStream(stream, displayModel, null, macrosInput);
                            displayModel.setOpiRuntime(opiRuntime);
                            displayModelFilled = true;
                            addRunnerInputMacros(input);
                            if (viewer != null) {
                                viewer.setContents(displayModel);
                                displayModel.setViewer(viewer);
                            }
                            updateEditorTitle();
                            hideCloseButton(site);
                        } catch (Exception e) {
                            ErrorHandlerUtil.handleError("Failed to load widget from " + input, e, true, true);
                        }
                    }
                });
            } catch (final Exception e) {
                display.asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (viewer != null && viewer.getControl() != null) {
                            viewer.getControl().removePaintListener(loadingMessagePaintListener);
                            viewer.getControl().addPaintListener(errorMessagePaintListener);
                            viewer.getControl().redraw();
                        }
                        ErrorHandlerUtil.handleError("Failed to open opi file: " + input, e, true, true);
                    }
                });
            }
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) InputStream(java.io.InputStream) Job(org.eclipse.core.runtime.jobs.Job) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

MacrosInput (org.csstudio.opibuilder.util.MacrosInput)14 LinkedHashMap (java.util.LinkedHashMap)4 IPath (org.eclipse.core.runtime.IPath)4 PartInitException (org.eclipse.ui.PartInitException)3 Element (org.jdom.Element)3 InputStream (java.io.InputStream)2 MacrosProperty (org.csstudio.opibuilder.properties.MacrosProperty)2 Path (org.eclipse.core.runtime.Path)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ProcessVariable (org.csstudio.csdata.ProcessVariable)1 PrintDisplayAction (org.csstudio.opibuilder.actions.PrintDisplayAction)1 RefreshOPIAction (org.csstudio.opibuilder.actions.RefreshOPIAction)1 NotImplementedException (org.csstudio.opibuilder.datadefinition.NotImplementedException)1 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)1