use of org.csstudio.display.builder.model.properties.OpenDisplayActionInfo in project org.csstudio.display.builder by kasemir.
the class ActionButtonRepresentation method handleAction.
/**
* @param action Action that the user invoked
*/
private void handleAction(ActionInfo action) {
if (!enabled)
return;
logger.log(Level.FINE, "{0} pressed", model_widget);
if (action instanceof OpenDisplayActionInfo && target_modifier.isPresent()) {
final OpenDisplayActionInfo orig = (OpenDisplayActionInfo) action;
action = new OpenDisplayActionInfo(orig.getDescription(), orig.getFile(), orig.getMacros(), target_modifier.get());
}
toolkit.fireAction(model_widget, action);
}
use of org.csstudio.display.builder.model.properties.OpenDisplayActionInfo in project org.csstudio.display.builder by kasemir.
the class JFXActionsDialogDemo method start.
@Override
public void start(final Stage stage) {
final Widget widget = new Widget("demo");
final Macros macros = new Macros();
macros.add("S", "Test");
macros.add("N", "17");
final ActionInfos actions = new ActionInfos(Arrays.asList(new OpenDisplayActionInfo("Related Display", "../opi/some_file.opi", macros, Target.TAB), new WritePVActionInfo("Reset", "Test:CS:Reset", "1"), new ExecuteScriptActionInfo("Script", new ScriptInfo(ScriptInfo.EMBEDDED_PYTHON, "print 'hi'", false, Collections.emptyList()))));
final ActionsDialog dialog = new ActionsDialog(widget, actions);
final Optional<ActionInfos> result = dialog.showAndWait();
if (result.isPresent()) {
if (result.get().isExecutedAsOne())
System.out.println("Execute all commands as one:");
for (ActionInfo info : result.get().getActions()) {
if (info instanceof ExecuteScriptActionInfo) {
final ExecuteScriptActionInfo action = (ExecuteScriptActionInfo) info;
System.out.println("Execute " + action.getDescription() + ", " + action.getInfo() + ": " + action.getInfo().getText());
} else
System.out.println(info);
}
} else
System.out.println("Cancelled");
}
use of org.csstudio.display.builder.model.properties.OpenDisplayActionInfo in project org.csstudio.display.builder by kasemir.
the class AllWidgetsAllProperties method main.
public static void main(String[] args) throws Exception {
final DisplayModel model = new DisplayModel();
for (final WidgetDescriptor widget_type : WidgetFactory.getInstance().getWidgetDescriptions()) {
Widget widget = widget_type.createWidget();
widget.setPropertyValue("name", widget_type.getName() + " 1");
// For some widgets, adjust default values
if (widget_type == ActionButtonWidget.WIDGET_DESCRIPTOR) {
ActionButtonWidget button = (ActionButtonWidget) widget;
final Macros macros = new Macros();
macros.add("S", "Test");
macros.add("N", "2");
button.propActions().setValue(new ActionInfos(Arrays.asList(new OpenDisplayActionInfo("Display", "other.opi", macros, Target.REPLACE))));
}
model.runtimeChildren().addChild(widget);
}
ModelWriter.skip_defaults = false;
try {
final ModelWriter writer = new ModelWriter(new FileOutputStream(EXAMPLE_FILE));
writer.writeModel(model);
writer.close();
} finally {
ModelWriter.skip_defaults = true;
}
}
use of org.csstudio.display.builder.model.properties.OpenDisplayActionInfo in project org.csstudio.display.builder by kasemir.
the class ActionsDialog method getOpenDisplayAction.
/**
* @return {@link OpenDisplayActionInfo} from sub pane
*/
private OpenDisplayActionInfo getOpenDisplayAction() {
Target target = Target.REPLACE;
List<Toggle> modes = open_display_targets.getToggles();
for (int i = 0; i < modes.size(); ++i) if (modes.get(i).isSelected()) {
target = Target.values()[i];
break;
}
return new OpenDisplayActionInfo(open_display_description.getText(), open_display_path.getText().trim(), open_display_macros.getMacros(), target);
}
use of org.csstudio.display.builder.model.properties.OpenDisplayActionInfo in project org.csstudio.display.builder by kasemir.
the class ContextMenuSupport method fillContextMenu.
private void fillContextMenu(final IMenuManager manager) {
final Widget context_menu_widget = view.getActiveWidget();
if (context_menu_widget == null) {
logger.log(Level.WARNING, "Missing context_menu_widget");
manager.add(new Action("No widget") {
});
} else {
// Widget info
manager.add(new WidgetInfoAction(context_menu_widget));
// Actions of the widget
for (ActionInfo info : context_menu_widget.propActions().getValue().getActions()) {
if (info.getType() == ActionType.OPEN_DISPLAY) {
// Add variant for all the available Target types: Replace, new Tab, ...
final OpenDisplayActionInfo open_info = (OpenDisplayActionInfo) info;
for (Target target : Target.values()) {
// STANDALONE can be achieved via StandaloneAction on new display
if (target == Target.STANDALONE)
continue;
final String desc = target == Target.REPLACE ? open_info.getDescription() : open_info.getDescription() + " (" + target + ")";
manager.add(new ActionInfoWrapper(context_menu_widget, new OpenDisplayActionInfo(desc, open_info.getFile(), open_info.getMacros(), target)));
}
} else
manager.add(new ActionInfoWrapper(context_menu_widget, info));
}
// Actions of the widget runtime
final WidgetRuntime<Widget> runtime = RuntimeUtil.getRuntime(context_menu_widget);
if (runtime == null)
throw new NullPointerException("Missing runtime for " + context_menu_widget);
for (RuntimeAction info : runtime.getRuntimeActions()) manager.add(new RuntimeActionWrapper(context_menu_widget, info));
}
// Placeholder for ProcessVariable object contributions
manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
manager.add(new Separator());
if (context_menu_widget != null) {
final Node node = JFXBaseRepresentation.getJFXNode(context_menu_widget);
final Scene scene = node.getScene();
manager.add(new SaveSnapshotAction(shell, scene));
manager.add(new PrintAction(shell, scene));
manager.add(new SendEMailAction(shell, scene));
manager.add(new SendLogbookAction(shell, scene));
manager.add(new FullScreenAction(view.getSite().getPage()));
if (support_standalone)
manager.add(new StandaloneAction(view));
}
// Placeholder for the display editor.
// If editor.rcp plugin is included, it adds "Open in editor"
manager.add(new Separator("display_editor"));
manager.add(new ReloadDisplayAction());
}
Aggregations