Search in sources :

Example 6 with ChoiceDialog

use of javafx.scene.control.ChoiceDialog in project Zong by Xenoage.

the class Demos method start.

@Override
public void start(Stage primaryStage) throws Exception {
    // demo given by parameter?
    Demo demo = null;
    if (getParameters().getUnnamed().size() > 0) {
        demo = EnumUtils.getEnumValue(getParameters().getUnnamed().get(0), Demo.values());
    } else {
        // show available demos in terminal
        System.out.println("Available demos, for direct launching:");
        for (Demo d : Demo.values()) System.out.println(" - task 'run" + d.name() + "': " + d.description);
    }
    // select demo in GUI
    if (demo == null) {
        List<String> choices = new ArrayList<>();
        for (Demo d : Demo.values()) choices.add(d.description);
        ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(Demo.defaultDemo), choices);
        dialog.setTitle(Zong.INSTANCE.getProjectFamilyName() + " Demos");
        dialog.setHeaderText("Please select a demo to run.");
        dialog.setContentText("Demo:");
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            int demoIndex = choices.indexOf(result.get());
            if (demoIndex > -1)
                demo = Demo.values()[demoIndex];
        }
    }
    if (demo == Demo.MinimalDemo) {
        MinimalDemo.main();
        Platform.exit();
    } else if (demo == Demo.SimpleGUIDemo) {
        SimpleGuiDemo.initZong();
        new SimpleGuiDemo().start(primaryStage);
    }
}
Also used : ChoiceDialog(javafx.scene.control.ChoiceDialog) MinimalDemo(com.xenoage.zong.demos.minimal.MinimalDemo) SimpleGuiDemo(com.xenoage.zong.demos.simplegui.SimpleGuiDemo) SimpleGuiDemo(com.xenoage.zong.demos.simplegui.SimpleGuiDemo) ArrayList(java.util.ArrayList)

Aggregations

ChoiceDialog (javafx.scene.control.ChoiceDialog)6 ArrayList (java.util.ArrayList)4 List (java.util.List)2 Optional (java.util.Optional)2 Node (javafx.scene.Node)2 Dragboard (javafx.scene.input.Dragboard)2 EmbeddedDisplayWidget (org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget)2 LabelWidget (org.csstudio.display.builder.model.widgets.LabelWidget)2 PictureWidget (org.csstudio.display.builder.model.widgets.PictureWidget)2 WebBrowserWidget (org.csstudio.display.builder.model.widgets.WebBrowserWidget)2 MinimalDemo (com.xenoage.zong.demos.minimal.MinimalDemo)1 SimpleGuiDemo (com.xenoage.zong.demos.simplegui.SimpleGuiDemo)1 Contractors (eu.ggnet.dwoss.mandator.api.value.Contractors)1 ResolveRepaymentController (eu.ggnet.dwoss.misc.repayment.ResolveRepaymentController)1 TradeName (eu.ggnet.dwoss.rules.TradeName)1 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 RenderingHints (java.awt.RenderingHints)1 Stroke (java.awt.Stroke)1