All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.datafx.controller.flow.context.LinkActionResourceConsumer Maven / Gradle / Ivy

package org.datafx.controller.flow.context;

import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import org.datafx.controller.context.ViewContext;
import org.datafx.controller.context.resource.ControllerResourceConsumer;
import org.datafx.controller.flow.action.LinkAction;

public class LinkActionResourceConsumer implements ControllerResourceConsumer {

    @Override
    public void consumeResource(LinkAction annotation, Object resource, ViewContext context) {
        FlowActionHandler actionHandler = context.getRegisteredObject(ViewFlowContext.class).getRegisteredObject(FlowActionHandler.class);
        if (resource != null) {
            if (resource instanceof MenuItem) {
                actionHandler.attachLinkEventHandler((MenuItem) resource, annotation.value());
            } else if (resource instanceof Node) {
                actionHandler.attachLinkEventHandler((Node) resource, annotation.value());
            }
        }
    }

    @Override
    public Class getSupportedAnnotation() {
        return LinkAction.class;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy