com.freebox.engeneering.application.web.layout.FooterController.java Source code

Java tutorial

Introduction

Here is the source code for com.freebox.engeneering.application.web.layout.FooterController.java

Source

/*
 * Copyright 2012 Lexaden.com
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package com.freebox.engeneering.application.web.layout;

import java.util.Calendar;

import com.freebox.engeneering.application.view.state.EventConstants;
import com.freebox.engeneering.application.web.common.AbstractController;
import com.lexaden.webflow.StateEvent;
import com.lexaden.webflow.annotation.OnEnterState;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;

/**
 * This class is responsible for UI components collaborations on footer part of the screen.
 *
 * @author Aliaksei Papou
 */
@SuppressWarnings("serial")
public class FooterController extends AbstractController<VerticalLayout> {

    /**
     * Initializes view when system enters 'initView' action state.
     *
     * @param event -  state event.
     */
    public void initView(StateEvent event) {
        VerticalLayout content = new VerticalLayout();
        setView(content);
    }

    /**
     * Loads data into the form while entering 'loadData' state.
     *
     * @param stateEvent the state event.
     */
    @OnEnterState(EventConstants.LOAD_DATA)
    public void buildFooterView(StateEvent stateEvent) {
        clearView(stateEvent);
        final Label htmlLabel = new Label(
                "&copy; " + Calendar.getInstance().get(Calendar.YEAR) + " Lexaden.com  All rights reserved",
                ContentMode.HTML);
        htmlLabel.setStyleName(Reindeer.LABEL_SMALL);
        htmlLabel.setSizeUndefined();
        final VerticalLayout view = getView();
        view.addComponent(htmlLabel);
        view.setComponentAlignment(htmlLabel, Alignment.MIDDLE_CENTER);
        view.setMargin(new MarginInfo(false, false, true, false));
    }

    /**
     * This method can be called when it is required to clean up the view
     *
     * @param stateEvent - state event
     */
    @Override
    public void clearView(StateEvent stateEvent) {
        VerticalLayout content = super.getView();
        if (content != null) {
            content.removeAllComponents();
        }
    }
}