Search in sources :

Example 1 with ToggleButton

use of com.vaadin.componentfactory.ToggleButton in project furms by unity-idm.

the class ResourceAllocationsDetailsView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    Optional<ProjectAllocation> projectAllocation = ofNullable(parameter).flatMap(id -> handleExceptions(() -> projectAllocationService.findByProjectIdAndId(projectId, id))).flatMap(Function.identity());
    if (projectAllocation.isPresent()) {
        getContent().removeAll();
        breadCrumbParameter = new BreadCrumbParameter(parameter, projectAllocation.get().name, getTranslation("view.project-admin.resource-allocations.details.page.bread-crumb"));
        ToggleButton toggle = new ToggleButton("Show per-user breakdown");
        toggle.addValueChangeListener(evt -> {
            getContent().removeAll();
            if (evt.getValue())
                getContent().add(toggle, getResourceAllocationChartWithUsersUsage(projectAllocation.get()));
            else
                getContent().add(toggle, getBasicResourceAllocationChart(projectAllocation.get()));
        });
        getContent().add(toggle, getBasicResourceAllocationChart(projectAllocation.get()));
    }
}
Also used : ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ToggleButton(com.vaadin.componentfactory.ToggleButton) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) Optional.ofNullable(java.util.Optional.ofNullable) ResourceUsageJSONExporter(io.imunity.furms.api.export.ResourceUsageJSONExporter) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) Route(com.vaadin.flow.router.Route) OptionalParameter(com.vaadin.flow.router.OptionalParameter) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Optional(java.util.Optional) ResourceUsageCSVExporter(io.imunity.furms.api.export.ResourceUsageCSVExporter) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) ChartPowerService(io.imunity.furms.ui.charts.ChartPowerService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ToggleButton(com.vaadin.componentfactory.ToggleButton) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation)

Aggregations

ToggleButton (com.vaadin.componentfactory.ToggleButton)1 BeforeEvent (com.vaadin.flow.router.BeforeEvent)1 OptionalParameter (com.vaadin.flow.router.OptionalParameter)1 Route (com.vaadin.flow.router.Route)1 ResourceUsageCSVExporter (io.imunity.furms.api.export.ResourceUsageCSVExporter)1 ResourceUsageJSONExporter (io.imunity.furms.api.export.ResourceUsageJSONExporter)1 ProjectAllocationService (io.imunity.furms.api.project_allocation.ProjectAllocationService)1 ProjectAllocation (io.imunity.furms.domain.project_allocation.ProjectAllocation)1 ChartPowerService (io.imunity.furms.ui.charts.ChartPowerService)1 ResourceAllocationChart (io.imunity.furms.ui.charts.ResourceAllocationChart)1 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)1 PageTitle (io.imunity.furms.ui.components.PageTitle)1 BreadCrumbParameter (io.imunity.furms.ui.components.layout.BreadCrumbParameter)1 ResourceGetter.getCurrentResourceId (io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId)1 VaadinExceptionHandler.handleExceptions (io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions)1 ProjectAdminMenu (io.imunity.furms.ui.views.project.ProjectAdminMenu)1 Optional (java.util.Optional)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Function (java.util.function.Function)1