de.symeda.sormas.ui.events.EventDataView.java Source code

Java tutorial

Introduction

Here is the source code for de.symeda.sormas.ui.events.EventDataView.java

Source

/*******************************************************************************
 * SORMAS - Surveillance Outbreak Response Management & Analysis System
 * Copyright  2016-2018 Helmholtz-Zentrum fr Infektionsforschung GmbH (HZI)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *******************************************************************************/
package de.symeda.sormas.ui.events;

import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.VerticalLayout;

import de.symeda.sormas.api.task.TaskContext;
import de.symeda.sormas.ui.ControllerProvider;
import de.symeda.sormas.ui.task.TaskListComponent;
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
import de.symeda.sormas.ui.utils.CssStyles;
import de.symeda.sormas.ui.utils.LayoutUtil;

public class EventDataView extends AbstractEventView {

    private static final long serialVersionUID = -1L;

    public static final String VIEW_NAME = ROOT_VIEW_NAME + "/data";

    public static final String EVENT_LOC = "event";
    public static final String TASKS_LOC = "tasks";

    public EventDataView() {
        super(VIEW_NAME);
    }

    @Override
    public void enter(ViewChangeEvent event) {
        super.enter(event);
        setHeightUndefined();

        String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EVENT_LOC),
                LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TASKS_LOC));

        VerticalLayout container = new VerticalLayout();
        container.setWidth(100, Unit.PERCENTAGE);
        container.setMargin(true);
        setSubComponent(container);
        CustomLayout layout = new CustomLayout();
        layout.addStyleName(CssStyles.ROOT_COMPONENT);
        layout.setTemplateContents(htmlLayout);
        layout.setWidth(100, Unit.PERCENTAGE);
        layout.setHeightUndefined();
        container.addComponent(layout);

        CommitDiscardWrapperComponent<?> editComponent = ControllerProvider.getEventController()
                .getEventDataEditComponent(getEventRef().getUuid());
        editComponent.setMargin(false);
        editComponent.setWidth(100, Unit.PERCENTAGE);
        editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
        editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
        layout.addComponent(editComponent, EVENT_LOC);

        TaskListComponent taskList = new TaskListComponent(TaskContext.EVENT, getEventRef());
        taskList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(taskList, TASKS_LOC);
    }
}