ch.vorburger.vaadin.designer.samplescreen.SampleFixedScreenComponent.java Source code

Java tutorial

Introduction

Here is the source code for ch.vorburger.vaadin.designer.samplescreen.SampleFixedScreenComponent.java

Source

/**
 *  Copyright 2012 Michael Vorburger (http://www.vorburger.ch)
 *  
 *  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.
 */

/*******************************************************************************
 * Copyright (c) 2012 Michael Vorburger (http://www.vorburger.ch).
 * 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 ch.vorburger.vaadin.designer.samplescreen;

import ch.vorburger.vaadin.beans.dragdroplayouts.DDAbsoluteLayoutWithBeanPositionChange;

import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

import fi.jasoft.dragdroplayouts.client.ui.LayoutDragMode;
import fi.jasoft.dragdroplayouts.drophandlers.DefaultAbsoluteLayoutDropHandler;

@SuppressWarnings("serial")
public class SampleFixedScreenComponent extends CustomComponent {

    // TODO This class shouldn't be here, must inverse the dependency - ch.vorburger.vaadin.designer.samplescreen should depend on ch.vorburger.vaadin.designer (requires web.xml clean-up...)

    @AutoGenerated
    private VerticalLayout mainLayout;
    @AutoGenerated
    private TabSheet tabSheet;
    @AutoGenerated
    private Table table_1;
    @AutoGenerated
    private DDAbsoluteLayoutWithBeanPositionChange absoluteLayout;
    @AutoGenerated
    private TextField textField_2;
    @AutoGenerated
    private TextField textField_1;
    @AutoGenerated
    private Label screenTitle;

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public SampleFixedScreenComponent() {
        buildMainLayout();
        setCompositionRoot(mainLayout);

        // TODO add user code here
    }

    public DDAbsoluteLayoutWithBeanPositionChange getAbsoluteLayout() {
        return absoluteLayout;
    }

    public Label getScreenTitle() {
        return screenTitle;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("100%");
        mainLayout.setHeight("100%");
        mainLayout.setMargin(false);

        // top-level component properties
        setWidth("100.0%");
        setHeight("100.0%");

        screenTitle = new Label();
        screenTitle.setImmediate(false);
        screenTitle.setWidth("-1px");
        screenTitle.setHeight("-1px");
        mainLayout.addComponent(screenTitle);

        // tabSheet
        tabSheet = buildTabSheet();
        mainLayout.addComponent(tabSheet);
        mainLayout.setExpandRatio(tabSheet, 1.0f);

        return mainLayout;
    }

    @AutoGenerated
    private TabSheet buildTabSheet() {
        // common part: create layout
        tabSheet = new TabSheet();
        tabSheet.setImmediate(true);
        tabSheet.setWidth("100.0%");
        tabSheet.setHeight("100.0%");

        // absoluteLayout
        absoluteLayout = buildAbsoluteLayout();
        tabSheet.addTab(absoluteLayout, "Tab1", null);

        //      // table_1
        //      table_1 = new Table();
        //      table_1.setImmediate(false);
        //      table_1.setWidth("-1px");
        //      table_1.setHeight("100.0%");
        //      table_1.setContainerDataSource(ExampleUtil.getISO3166Container());
        //      table_1.setColumnHeaders(new String[] { "Country", "Code", "Icon file" });
        //      tabSheet.addTab(table_1, "Tab2", null);

        return tabSheet;
    }

    @AutoGenerated
    private DDAbsoluteLayoutWithBeanPositionChange buildAbsoluteLayout() {
        // common part: create layout
        absoluteLayout = new DDAbsoluteLayoutWithBeanPositionChange();
        // absoluteLayout.setImmediate(false);
        // absoluteLayout.setSizeFull();
        absoluteLayout.setWidth("100.0%");
        absoluteLayout.setHeight("100.0%");
        absoluteLayout.setMargin(false);

        absoluteLayout.setDragMode(LayoutDragMode.CLONE);
        absoluteLayout.setDropHandler(new DefaultAbsoluteLayoutDropHandler());

        return absoluteLayout;
    }

}