Java tutorial
/* * 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 com.freebox.engeneering.application.view.state.StateConstants; import com.freebox.engeneering.application.web.common.AbstractController; import com.lexaden.webflow.StateEvent; import com.lexaden.webflow.annotation.OnEnterState; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; /** * This class is responsible for UI components collaborations on header part of the screen. * * @author Aliaksei Papou */ @SuppressWarnings("serial") public class HeaderController extends AbstractController<HorizontalLayout> { /** * Initializes view when system enters 'initView' action state. * * @param event - state event. */ @SuppressWarnings("rawtypes") public void initView(StateEvent event) { HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setSpacing(true); top.addStyleName("toolbar"); setView(top); } /** * Loads data into the form when system enters 'loadData' state. * * @param event - the state event. */ @SuppressWarnings("rawtypes") @OnEnterState(StateConstants.PROFILE) public void buildHeader(StateEvent event) { clearView(event); HorizontalLayout top = super.getView(); final Label title = new Label("My Freebox Manager"); title.setSizeUndefined(); title.addStyleName("h1"); top.addComponent(title); top.setComponentAlignment(title, Alignment.MIDDLE_LEFT); top.setExpandRatio(title, 1); Button notify = new Button(); notify.setDescription("Notifications"); notify.addStyleName("notifications"); notify.addStyleName("unread"); notify.addStyleName("icon-only"); notify.addStyleName("icon-bell"); top.addComponent(notify); top.setComponentAlignment(notify, Alignment.MIDDLE_LEFT); Button edit = new Button(); edit.addStyleName("icon-edit"); edit.addStyleName("icon-only"); edit.setDescription("Edit Dashboard"); top.addComponent(edit); top.setComponentAlignment(edit, Alignment.MIDDLE_LEFT); Button downloadB = new Button(); downloadB.addStyleName("icon-edit"); downloadB.addStyleName("icon-only"); downloadB.setDescription("Tlcharger un fichier"); top.addComponent(downloadB); top.setComponentAlignment(downloadB, Alignment.MIDDLE_LEFT); } @SuppressWarnings("rawtypes") @Override public void clearView(StateEvent stateEvent) { HorizontalLayout content = super.getView(); if (content != null) { content.removeAllComponents(); } } }