use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class PropertyPanel method setSelectedWidgets.
/**
* Populate UI with properties of widgets
* @param widgets Widgets to configure
*/
private void setSelectedWidgets(final List<Widget> widgets) {
final DisplayModel model = editor.getModel();
searchField.setDisable(widgets.isEmpty() && model == null);
if (widgets.isEmpty()) {
// Use the DisplayModel
if (model != null)
updatePropertiesView(model.getProperties(), Collections.emptyList());
} else {
// Determine common properties
final List<Widget> other = new ArrayList<>(widgets);
final Widget primary = other.remove(0);
final Set<WidgetProperty<?>> properties = commonProperties(primary, other);
updatePropertiesView(properties, other);
}
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class FilenameSupport method promptForRelativePath.
/**
* Prompt for file name
* @param widget Widget that needs a file name
* @param initial Initial value
* @return Selected file name or <code>null</code>
*/
public static String promptForRelativePath(final Widget widget, final String initial) throws Exception {
final String filename = file_prompt.apply(widget, initial);
if (filename == null)
return null;
final DisplayModel model = widget.getDisplayModel();
final String parent_file = model.getUserData(DisplayModel.USER_DATA_INPUT_FILE);
return ModelResourceUtil.getRelativePath(parent_file, filename);
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class JFXStageRepresentation method handleCloseRequest.
private void handleCloseRequest(final Scene scene, final Consumer<DisplayModel> close_request_handler) {
final Parent root = getModelParent();
final DisplayModel model = (DisplayModel) root.getProperties().get(ACTIVE_MODEL);
try {
if (model != null)
close_request_handler.accept(model);
} catch (final Exception ex) {
logger.log(Level.WARNING, "Close request handler failed", ex);
}
shutdown();
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class DataBrowserWidget method getExpandedFilename.
public String getExpandedFilename(String base_path) throws Exception {
// expand macros in the file name
final String expanded_path = MacroHandler.replace(this.getMacrosOrProperties(), base_path);
// Resolve new image file relative to the source widget model (not 'top'!)
// Get the display model from the widget tied to this representation
final DisplayModel widget_model = this.getDisplayModel();
// Resolve the path using the parent model file path
return ModelResourceUtil.resolveResource(widget_model, expanded_path);
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class JFXRepresentation method handleViewportChanges.
/**
* Handle changes in on-screen size of this representation
*/
private void handleViewportChanges() {
final int view_width = (int) model_root.getWidth();
final int view_height = (int) model_root.getHeight();
final int model_width, model_height;
final DisplayModel copy = model;
if (copy == null)
model_width = model_height = 0;
else {
model_width = copy.propWidth().getValue();
model_height = copy.propHeight().getValue();
}
// If on-screen viewport is larger than model,
// grow the scroll_body so that the complete area is
// filled with the background color
// and - in edit mode - the grid.
// If the viewport is smaller, use the model's size
// to get appropriate scrollbars.
final int show_x = view_width >= model_width ? view_width - SCROLLBAR_ADJUST : model_width;
final int show_y = view_height >= model_height ? view_height - SCROLLBAR_ADJUST : model_height;
// Does not consider zooming.
// If the widget_parent is zoomed 'out', e.g. 50%,
// the widget_parent will only be half as large
// as we specify here in pixels
// -> Ignore. If user zooms out a lot, there'll be an
// area a gray area at the right and bottom of the display.
// But user tends to zoom out to see the complete set of widgets,
// so there is very little gray area.
// widget_parent.setMinWidth(show_x / zoom);
// widget_parent.setMinHeight(show_y / zoom);
widget_parent.setMinSize(show_x, show_y);
}
Aggregations