net.gvcc.jgoffice.templates.SingleForm.java Source code

Java tutorial

Introduction

Here is the source code for net.gvcc.jgoffice.templates.SingleForm.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package net.gvcc.jgoffice.templates;

/**
 *
 * @author ernst_sgv
 */
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.VerticalLayout;
import net.gvcc.jgoffice.dbnavigatorbar.DbNavigatorBar;
import net.gvcc.jgoffice.dbnavigatorbar.NavigatorButtons;
import net.gvcc.jgoffice.dbnavigatorbar.interfaces.IDBNavigatorForm;

/**
 *
 * @author ernst_sgv
 */
public class SingleForm extends CustomComponent {

    private VerticalLayout mainLayout;
    private HorizontalLayout navigationBarLayout;
    private VerticalLayout detailLayout;

    private final DbNavigatorBar navigationBar;

    private Component mainForm;

    private boolean mainFormNavigationBar = true;

    public SingleForm() {

        navigationBar = new DbNavigatorBar();
        setCompositionRoot(buildMainLayout());
    }

    private VerticalLayout buildMainLayout() {
        /*
         * the global layout for the entire form
         */
        mainLayout = new VerticalLayout();
        mainLayout.setStyleName("g-module");
        mainLayout.setImmediate(false);
        mainLayout.setWidth("100%");
        mainLayout.setHeight("100%");
        mainLayout.setMargin(true);

        /*
         * the layout for the navigationbar
         */
        navigationBarLayout = new HorizontalLayout();
        navigationBarLayout.setImmediate(false);
        navigationBarLayout.setWidth("-1px");
        navigationBarLayout.setHeight("-1px");
        navigationBarLayout.setMargin(false);
        navigationBarLayout.addComponent(navigationBar);

        detailLayout = new VerticalLayout();
        detailLayout.setSizeFull();
        /*
         * global settings
         */
        setWidth("100.0%");
        setHeight("100.0%");

        return mainLayout;
    }

    public void initializeForm() {
        if (mainFormNavigationBar) {
            mainLayout.addComponent(navigationBarLayout);
            //navigationBar.setNavigatorButtonStatus(DBOperations.FIRST);
        }

        mainLayout.addComponent(detailLayout);
        mainLayout.setExpandRatio(detailLayout, 1);
    }

    public DbNavigatorBar getNavigationBar() {
        return navigationBar;
    }

    public Component getMainForm() {
        return mainForm;
    }

    public void setMainForm(Component form) {
        this.mainForm = form;
        detailLayout.addComponent(form);
    }

    public void mainFormHasNavigationBar(boolean hasNavigationBar) {
        mainFormNavigationBar = hasNavigationBar;
    }

    public boolean isMainFormNavigationBarActive() {
        return mainFormNavigationBar;
    }

}