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

org.ikasan.dashboard.ui.visualisation.component.FlowOptionsDialog Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
package org.ikasan.dashboard.ui.visualisation.component;

import com.vaadin.flow.component.ClickEvent;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.H3;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import org.ikasan.dashboard.ui.general.component.AbstractCloseableResizableDialog;
import org.ikasan.dashboard.ui.util.ComponentSecurityVisibility;
import org.ikasan.dashboard.ui.util.SecurityConstants;
import org.ikasan.dashboard.ui.visualisation.model.flow.Flow;
import org.ikasan.dashboard.ui.visualisation.model.flow.Module;
import org.ikasan.spec.module.client.ConfigurationService;

public class FlowOptionsDialog extends AbstractCloseableResizableDialog
{
    protected ConfigurationService configurationRestService;
    protected Module module;
    protected Flow flow;
    private ModuleVisualisation moduleVisualisation;

    protected FlowOptionsDialog(Module module, Flow flow, ConfigurationService configurationRestService
        , ModuleVisualisation moduleVisualisation)
    {
        this.module = module;
        this.flow = flow;
        this.configurationRestService = configurationRestService;
        this.moduleVisualisation = moduleVisualisation;
        super.showResize(false);

        init();
    }

    private void init()
    {
        VerticalLayout verticalLayout = new VerticalLayout();

        Image mrSquidImage = new Image("/frontend/images/mr-squid-head.png", "");
        mrSquidImage.setHeight("35px");

        H3 flowOptions = new H3(String.format(getTranslation("label.flow-options", UI.getCurrent().getLocale())));

        HorizontalLayout header = new HorizontalLayout();
        header.add(mrSquidImage, flowOptions);
        header.setVerticalComponentAlignment(FlexComponent.Alignment.CENTER, mrSquidImage, flowOptions);

        verticalLayout.add(header);
        verticalLayout.setHorizontalComponentAlignment(FlexComponent.Alignment.CENTER, header);

        Button invokerConfigurationButton = new Button(getTranslation("button.flow-configuration", UI.getCurrent().getLocale()));
        invokerConfigurationButton.setWidthFull();
        invokerConfigurationButton.addClickListener((ComponentEventListener>)
            buttonClickEvent -> openFlowConfigurationDialog());

        ComponentSecurityVisibility.applySecurity(invokerConfigurationButton, SecurityConstants.ALL_AUTHORITY
            , SecurityConstants.PLATFORM_CONFIGURATION_ADMIN
            , SecurityConstants.PLATFORM_CONFIGURATION_READ
            , SecurityConstants.PLATFORM_CONFIGURATION_WRITE);

        verticalLayout.add(invokerConfigurationButton);

        this.setHeight("300px");
        this.setWidth("400px");

        this.content.add(verticalLayout);
    }

    private void openFlowConfigurationDialog()
    {
        FlowConfigurationDialog flowConfigurationDialog = new FlowConfigurationDialog(this.module, this.flow, this.configurationRestService
            , this.moduleVisualisation);
        flowConfigurationDialog.open();
        this.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy