Search in sources :

Example 1 with OpenDisplayActionInfo

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);
}
Also used : OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)

Example 2 with OpenDisplayActionInfo

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");
}
Also used : ActionsDialog(org.csstudio.display.builder.representation.javafx.ActionsDialog) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) Widget(org.csstudio.display.builder.model.Widget) ActionInfos(org.csstudio.display.builder.model.properties.ActionInfos) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo) ExecuteScriptActionInfo(org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) ExecuteScriptActionInfo(org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo) Macros(org.csstudio.display.builder.model.macros.Macros) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)

Example 3 with OpenDisplayActionInfo

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;
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) ActionButtonWidget(org.csstudio.display.builder.model.widgets.ActionButtonWidget) ActionInfos(org.csstudio.display.builder.model.properties.ActionInfos) ActionButtonWidget(org.csstudio.display.builder.model.widgets.ActionButtonWidget) Macros(org.csstudio.display.builder.model.macros.Macros) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) ModelWriter(org.csstudio.display.builder.model.persist.ModelWriter)

Example 4 with OpenDisplayActionInfo

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);
}
Also used : Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) Toggle(javafx.scene.control.Toggle) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)

Example 5 with OpenDisplayActionInfo

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());
}
Also used : Action(org.eclipse.jface.action.Action) RuntimeAction(org.csstudio.display.builder.runtime.RuntimeAction) Node(javafx.scene.Node) Widget(org.csstudio.display.builder.model.Widget) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Scene(javafx.scene.Scene) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) GroupMarker(org.eclipse.jface.action.GroupMarker) RuntimeAction(org.csstudio.display.builder.runtime.RuntimeAction) Separator(org.eclipse.jface.action.Separator)

Aggregations

OpenDisplayActionInfo (org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)7 Macros (org.csstudio.display.builder.model.macros.Macros)3 Widget (org.csstudio.display.builder.model.Widget)2 ActionInfo (org.csstudio.display.builder.model.properties.ActionInfo)2 ActionInfos (org.csstudio.display.builder.model.properties.ActionInfos)2 Target (org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target)2 FileOutputStream (java.io.FileOutputStream)1 Node (javafx.scene.Node)1 Scene (javafx.scene.Scene)1 Toggle (javafx.scene.control.Toggle)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 ModelWriter (org.csstudio.display.builder.model.persist.ModelWriter)1 ExecuteScriptActionInfo (org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo)1 ScriptInfo (org.csstudio.display.builder.model.properties.ScriptInfo)1 WritePVActionInfo (org.csstudio.display.builder.model.properties.WritePVActionInfo)1 ActionButtonWidget (org.csstudio.display.builder.model.widgets.ActionButtonWidget)1 DisplayInfo (org.csstudio.display.builder.rcp.DisplayInfo)1 ActionsDialog (org.csstudio.display.builder.representation.javafx.ActionsDialog)1 RuntimeAction (org.csstudio.display.builder.runtime.RuntimeAction)1 Action (org.eclipse.jface.action.Action)1