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()));
}
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;
}
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);
}
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);
}
}
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();
}
Aggregations