/**
 * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.eclipse.hawkbit.ui.management.dstable;

import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;

/**
 * Software module table layout.
 */
public class DistributionTableLayout extends AbstractTableLayout<DistributionTable> {

    private static final long serialVersionUID = 6464291374980641235L;

    public DistributionTableLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
            final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState,
            final DistributionSetManagement distributionSetManagement,
            final ManagementViewClientCriterion managementViewClientCriterion, final EntityFactory entityFactory,
            final UINotification notification, final TagManagement tagManagement,
            final SystemManagement systemManagement, final TargetManagement targetManagement,
            final DeploymentManagement deploymentManagement) {

        final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout = new DistributionAddUpdateWindowLayout(
                i18n, notification, eventBus, distributionSetManagement, systemManagement, entityFactory, null);

        final DsMetadataPopupLayout dsMetadataPopupLayout = new DsMetadataPopupLayout(i18n, notification, eventBus,
                distributionSetManagement, entityFactory, permissionChecker);

        final DistributionTable distributionTable = new DistributionTable(eventBus, i18n, permissionChecker,
                notification, managementUIState, managementViewClientCriterion, targetManagement, dsMetadataPopupLayout,
                distributionSetManagement, deploymentManagement);

        super.init(new DistributionTableHeader(i18n, permissionChecker, eventBus, managementUIState), distributionTable,
                new DistributionDetails(i18n, eventBus, permissionChecker, managementUIState, distributionSetManagement,
                        dsMetadataPopupLayout, entityFactory, notification, tagManagement,
                        distributionAddUpdateWindowLayout));
    }

}
