use of org.csstudio.display.builder.model.macros.Macros in project org.csstudio.display.builder by kasemir.
the class ActionUtil method resolve.
private static String resolve(final Widget source_widget, final String path) throws Exception {
// Path to resolve, after expanding macros
final Macros macros = source_widget.getEffectiveMacros();
final String expanded_path = MacroHandler.replace(macros, path);
// Resolve file relative to the source widget model (not 'top'!)
final DisplayModel widget_model = source_widget.getDisplayModel();
final String parent_file = widget_model.getUserData(DisplayModel.USER_DATA_INPUT_FILE);
return ModelResourceUtil.resolveResource(parent_file, expanded_path);
}
use of org.csstudio.display.builder.model.macros.Macros in project org.csstudio.display.builder by kasemir.
the class ScriptUtil method openDisplay.
// ====================
// open/close displays
/**
* Open a new display
*
* @param widget Widget in 'current' display, used to resolve relative paths
* @param file Path to the display
* @param target Where to show the display: "REPLACE", "TAB", "WINDOW", "STANDALONE"
* @param macros Macros, may be <code>null</code>
*/
public static void openDisplay(final Widget widget, final String file, final String target, final Map<String, String> macros) {
OpenDisplayActionInfo.Target the_target;
try {
the_target = OpenDisplayActionInfo.Target.valueOf(target);
} catch (Throwable ex) {
the_target = OpenDisplayActionInfo.Target.TAB;
}
final Macros the_macros;
if (macros == null || macros.isEmpty())
the_macros = null;
else {
the_macros = new Macros();
for (String name : macros.keySet()) the_macros.add(name, macros.get(name));
}
final OpenDisplayActionInfo open = new OpenDisplayActionInfo("Open from script", file, the_macros, the_target);
ActionUtil.handleAction(widget, open);
}
use of org.csstudio.display.builder.model.macros.Macros in project org.csstudio.display.builder by kasemir.
the class WidgetInfoDialog method createMacros.
private Tab createMacros(Macros orig_macros) {
final Macros macros = (orig_macros == null) ? new Macros() : orig_macros;
// Use text field to allow copying the name and value
// Table uses list of macro names as input
// Name column just displays the macro name,..
final TableColumn<String, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
name.setCellFactory(TextFieldTableCell.forTableColumn());
name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue()));
// .. value column fetches the macro value
final TableColumn<String, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
value.setCellFactory(TextFieldTableCell.forTableColumn());
value.setCellValueFactory(param -> new ReadOnlyStringWrapper(macros.getValue(param.getValue())));
final TableView<String> table = new TableView<>(FXCollections.observableArrayList(macros.getNames()));
table.getColumns().add(name);
table.getColumns().add(value);
table.setEditable(true);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
return new Tab(Messages.WidgetInfoDialog_TabMacros, table);
}
use of org.csstudio.display.builder.model.macros.Macros in project org.csstudio.display.builder by kasemir.
the class DisplayInfoXMLUtil method readDisplayInfo.
/**
* Read display info
* @param macros_xml
* @param resolve
* @throws Exception on error
* @return {@link DisplayInfo}
*/
public static DisplayInfo readDisplayInfo(final Element display, final boolean resolve) throws Exception {
final String path = XMLUtil.getChildString(display, XMLTags.FILE).orElseThrow(() -> new Exception("Missing display path"));
final String name = XMLUtil.getChildString(display, XMLTags.NAME).orElse(path);
final Element macros_xml = XMLUtil.getChildElement(display, XMLTags.MACROS);
final Macros macros = macros_xml == null ? new Macros() : MacroXMLUtil.readMacros(macros_xml);
return new DisplayInfo(path, name, macros, resolve);
}
use of org.csstudio.display.builder.model.macros.Macros in project org.csstudio.display.builder by kasemir.
the class ArrayWidget method defineProperties.
@Override
protected void defineProperties(final List<WidgetProperty<?>> properties) {
super.defineProperties(properties);
properties.add(macros = propMacros.createProperty(this, new Macros()));
properties.add(children = new ArrayWidgetChildrenProperty(this));
properties.add(foreground = propForegroundColor.createProperty(this, WidgetColorService.getColor(NamedWidgetColors.TEXT)));
properties.add(background = propBackgroundColor.createProperty(this, WidgetColorService.getColor(NamedWidgetColors.BACKGROUND)));
properties.add(insets = runtimePropInsets.createProperty(this, new int[] { 0, 0 }));
}
Aggregations