use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class DisplayEditorPart method loadWidgetClasses.
/**
* Re-load widget classes and apply to model
*/
public void loadWidgetClasses() {
// Trigger re-load of classes
org.csstudio.display.builder.rcp.Plugin.reloadConfigurationFiles();
// On separate thread..
ModelThreadPool.getExecutor().execute(() -> {
// get widget classes and apply to model
final DisplayModel model = editor.getModel();
if (model != null)
WidgetClassesService.getWidgetClasses().apply(model);
});
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class DisplayEditorPart method doLoadModel.
private DisplayModel doLoadModel(final IFile file) {
try {
final String ws_location = file.getFullPath().toOSString();
final DisplayModel new_model = ModelLoader.loadModel(ws_location);
modification_marker = file.getModificationStamp();
return new_model;
} catch (Exception ex) {
final String message = "Cannot load display " + file;
logger.log(Level.WARNING, message, ex);
final Shell shell = getSite().getShell();
// Also show error to user
shell.getDisplay().asyncExec(() -> ExceptionDetailsErrorDialog.openError(shell, message, ex));
return null;
}
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class OpenDisplayInEditor method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final RuntimeViewPart view = RuntimeViewPart.getActiveDisplay();
if (view != null) {
try {
final Widget widget = view.getActiveWidget();
final DisplayModel model = widget.getDisplayModel();
final String path;
// Options:
if (widget instanceof EmbeddedDisplayWidget) {
// c) Widget is an embedded widget.
// -> User probably wanted to edit the _body_ of that embedded widget
final EmbeddedDisplayWidget embedded = (EmbeddedDisplayWidget) widget;
path = ModelResourceUtil.resolveResource(model, embedded.propFile().getValue());
} else {
// b) Widget is one of the widgets in the body of an embedded widget:
// -> Get the body display, _not_ the top-level display
// a) Widget is in the top-level display, or the display itself:
// -> Use that that
path = model.getUserData(DisplayModel.USER_DATA_INPUT_FILE);
}
try {
open(path);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot open in editor: " + path, ex);
}
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot open display in editor", ex);
}
}
return null;
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class SetDisplaySize method run.
@Override
public void run() {
final DisplayModel model = editor.getModel();
final Rectangle2D bounds = GeometryTools.getBounds(model.getChildren());
final CompoundUndoableAction resize = new CompoundUndoableAction(getText());
resize.add(new SetWidgetPropertyAction<Integer>(model.propWidth(), (int) (2 * bounds.getMinX() + bounds.getWidth())));
resize.add(new SetWidgetPropertyAction<Integer>(model.propHeight(), (int) (2 * bounds.getMinY() + bounds.getHeight())));
editor.getUndoableActionManager().execute(resize);
}
use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.
the class PropertyPanel method updatePropertiesView.
private void updatePropertiesView(final Set<WidgetProperty<?>> properties, final List<Widget> other) {
final String search = searchField.getText().trim();
final Set<WidgetProperty<?>> filtered;
if (search.trim().isEmpty())
filtered = properties;
else {
// Filter properties, but preserve order (LinkedHashSet)
filtered = new LinkedHashSet<>();
for (WidgetProperty<?> prop : properties) if (prop.getDescription().toLowerCase().contains(search.toLowerCase()))
filtered.add(prop);
}
final DisplayModel model = editor.getModel();
section.clear();
section.setClassMode(model != null && model.isClassModel());
section.fill(editor.getUndoableActionManager(), filtered, other);
}
Aggregations