Search in sources :

Example 71 with ContextMenu

use of javafx.scene.control.ContextMenu in project completable-reactor by ru-fix.

the class ProcessorNode method initializePopupMenu.

void initializePopupMenu() {
    ContextMenu contextMenu = buildTooltipContent();
    this.setOnContextMenuRequested(contextMenuEvent -> {
        contextMenu.show(this, contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY());
        contextMenuEvent.consume();
    });
}
Also used : ContextMenu(javafx.scene.control.ContextMenu)

Example 72 with ContextMenu

use of javafx.scene.control.ContextMenu in project completable-reactor by ru-fix.

the class StartPointNode method initializePopupMenu.

void initializePopupMenu() {
    ContextMenu contextMenu = new ContextMenu();
    MenuItem documentationMenuItem = new MenuItem();
    documentationMenuItem.setGraphic(buildTooltipContent());
    contextMenu.getItems().add(documentationMenuItem);
    documentationMenuItem.setOnAction(event -> {
        fireGoToSourceEvent();
    });
    this.setOnContextMenuRequested(contextMenuEvent -> {
        contextMenu.show(this, contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY());
        contextMenuEvent.consume();
    });
}
Also used : ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem)

Example 73 with ContextMenu

use of javafx.scene.control.ContextMenu in project completable-reactor by ru-fix.

the class SubgraphNode method buildTooltipContent.

ContextMenu buildTooltipContent() {
    ContextMenu contextMenu = new ContextMenu();
    MenuItem processorMenuItem = new MenuItem();
    VBox processorContent = new VBox();
    processorMenuItem.setGraphic(processorContent);
    processorMenuItem.setOnAction(event -> actionListener.goToSource(this.subgraph.getBuildSource()));
    contextMenu.getItems().add(processorMenuItem);
    processorContent.getChildren().add(new Text(serialize(this.subgraph.getIdentity())));
    Optional.ofNullable(subgraph.subgraphDoc).map(doc -> new Text(Arrays.stream(doc).collect(Collectors.joining("\n")))).ifPresent(processorContent.getChildren()::add);
    return contextMenu;
}
Also used : Text(javafx.scene.text.Text) ReactorGraphModel(ru.fix.completable.reactor.api.ReactorGraphModel) Arrays(java.util.Arrays) List(java.util.List) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) Font(javafx.scene.text.Font) lombok.val(lombok.val) Optional(java.util.Optional) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Text(javafx.scene.text.Text) VBox(javafx.scene.layout.VBox)

Example 74 with ContextMenu

use of javafx.scene.control.ContextMenu in project completable-reactor by ru-fix.

the class TransitionLine method initializePopupMenu.

void initializePopupMenu() {
    val contextMenu = buildTooltipContent();
    EventHandler<ContextMenuEvent> contextMenuHandler = contextMenuEvent -> {
        contextMenu.show(line, contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY());
        contextMenuEvent.consume();
    };
    labelsPane.setOnContextMenuRequested(contextMenuHandler);
    pointer.setOnContextMenuRequested(contextMenuHandler);
    line.setOnContextMenuRequested(contextMenuHandler);
    menuArea.setOnContextMenuRequested(contextMenuHandler);
}
Also used : lombok.val(lombok.val) EventHandler(javafx.event.EventHandler) ReactorGraphModel(ru.fix.completable.reactor.api.ReactorGraphModel) java.util(java.util) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Rotate(javafx.scene.transform.Rotate) Node(javafx.scene.Node) lombok.val(lombok.val) Polygon(javafx.scene.shape.Polygon) Group(javafx.scene.Group) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) Text(javafx.scene.text.Text) Line(javafx.scene.shape.Line) ContextMenu(javafx.scene.control.ContextMenu) lombok.experimental.var(lombok.experimental.var) Point2D(javafx.geometry.Point2D) ContextMenuEvent(javafx.scene.input.ContextMenuEvent)

Example 75 with ContextMenu

use of javafx.scene.control.ContextMenu in project completable-reactor by ru-fix.

the class TransitionLine method buildTooltipContent.

ContextMenu buildTooltipContent() {
    // documentation
    Map<String, String[]> mergeStatusDocumentation = new HashMap<>();
    this.transition.map(transitionItem -> transitionItem.mergeStatuses).ifPresent(statuses -> statuses.forEach(status -> mergeStatusDocumentation.put(status, new String[] {})));
    this.transition.map(transitionItem -> transitionItem.transitionsDoc).ifPresent(docs -> docs.forEach(doc -> {
        mergeStatusDocumentation.put(doc.mergeStatus, doc.docs);
    }));
    // menu controls
    ContextMenu contextMenu = new ContextMenu();
    for (String status : mergeStatusDocumentation.keySet()) {
        VBox content = new VBox();
        MenuItem documentationMenuItem = new MenuItem();
        documentationMenuItem.setGraphic(content);
        contextMenu.getItems().add(documentationMenuItem);
        this.transition.map(transitionItem -> transitionItem.transitionOnStatusSource).map(onStatusSources -> onStatusSources.get(status)).ifPresent(source -> documentationMenuItem.setOnAction(event -> actionListener.goToSource(source)));
        // menu item content
        content.getChildren().add(new Text(status));
        Optional.ofNullable(mergeStatusDocumentation.get(status)).map(statusDocs -> new Text(Arrays.stream(statusDocs).collect(Collectors.joining("\n")))).ifPresent(content.getChildren()::add);
    }
    if (this.transition.isPresent()) {
        ReactorGraphModel.Transition transitionItem = this.transition.get();
        if (transitionItem.isOnAny) {
            MenuItem onAnyMenuItem = new MenuItem();
            VBox content = new VBox();
            onAnyMenuItem.setGraphic(content);
            content.getChildren().add(new Text("<Any>"));
            content.getChildren().add(new Text("Transition activated by any status."));
            contextMenu.getItems().add(onAnyMenuItem);
            ReactorGraphModel.Source source = transitionItem.transitionOnAnySource;
            if (source != null) {
                onAnyMenuItem.setOnAction(event -> {
                    actionListener.goToSource(source);
                });
            }
        }
    }
    return contextMenu;
}
Also used : EventHandler(javafx.event.EventHandler) ReactorGraphModel(ru.fix.completable.reactor.api.ReactorGraphModel) java.util(java.util) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Rotate(javafx.scene.transform.Rotate) Node(javafx.scene.Node) lombok.val(lombok.val) Polygon(javafx.scene.shape.Polygon) Group(javafx.scene.Group) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) Text(javafx.scene.text.Text) Line(javafx.scene.shape.Line) ContextMenu(javafx.scene.control.ContextMenu) lombok.experimental.var(lombok.experimental.var) Point2D(javafx.geometry.Point2D) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Text(javafx.scene.text.Text) ReactorGraphModel(ru.fix.completable.reactor.api.ReactorGraphModel) VBox(javafx.scene.layout.VBox)

Aggregations

ContextMenu (javafx.scene.control.ContextMenu)81 MenuItem (javafx.scene.control.MenuItem)69 ActionEvent (javafx.event.ActionEvent)21 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)20 Menu (javafx.scene.control.Menu)18 Label (javafx.scene.control.Label)15 List (java.util.List)13 Collectors (java.util.stream.Collectors)13 File (java.io.File)12 VBox (javafx.scene.layout.VBox)11 ObservableList (javafx.collections.ObservableList)9 ArrayList (java.util.ArrayList)8 EventHandler (javafx.event.EventHandler)8 FXCollections (javafx.collections.FXCollections)7 Optional (java.util.Optional)6 Node (javafx.scene.Node)6 Scene (javafx.scene.Scene)6 Text (javafx.scene.text.Text)6 IOException (java.io.IOException)5 Arrays (java.util.Arrays)5