Example usage for com.vaadin.ui Embedded Embedded

List of usage examples for com.vaadin.ui Embedded Embedded

Introduction

In this page you can find the example usage for com.vaadin.ui Embedded Embedded.

Prototype

public Embedded(String caption) 

Source Link

Document

Creates a new empty Embedded object with caption.

Usage

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.InitialScreenViewImpl.java

License:Open Source License

/**
 * Diese Methode setzt das Layout fr den Screen fest sowie den Titel der Anwendung.
 * Zustzlich wird hier noch das Men erzeugt und die Buttons, um ein Projekt zu bearbeiten,
 * ein neues anzulegen oder ein bestehendes zu lschen.
 *
 * @author Christian Scherer, Mirko Gpfrich, Marco Glaser
 *//*from   w  w  w .jav a 2 s . c  om*/
private void generateUi() {

    mainLayout = new VerticalLayout();
    leftLayout = new HorizontalLayout();
    rightLayout = new VerticalLayout();
    topRightLayout = new HorizontalLayout();
    leftContentLayout = new VerticalLayout();
    bottomLeftLayout = new VerticalLayout();
    bottomRightLayout = new VerticalLayout();
    bottomRightLayout.setHeight(90, UNITS_PERCENTAGE);
    bottomRightLayout.setWidth(100, UNITS_PERCENTAGE);
    bottomRightLayout.addStyleName("horizontalBottom");
    bottomLayout = new VerticalLayout();
    gap = new Label();
    leftContainerSpacing = new VerticalLayout();
    progressBar = new Embedded(null);
    progressBarGap = new Label();
    splitter = new Label("<hr style='border:none;background-color:black;height:2px'>", Label.CONTENT_XHTML);
    splitter2 = new Label("<hr style='border:none;background-color:black;height:2px'>", Label.CONTENT_XHTML);
    menuButtonsLayout = new HorizontalLayout();
    homeButtonLayout = new VerticalLayout();
    logoutButtonLayout = new VerticalLayout();
    homeButton = new Button();
    logoutButton = new Button();
    homeButtonLabel = new Label("Startseite");
    logoutButtonLabel = new Label("Ausloggen");
    descriptionLayout = new VerticalLayout();
    bottomGap = new Label();
    faqLayout = new HorizontalLayout();
    homeIcon = new Embedded(null, new ThemeResource("./images/icons/newIcons/1418766062_house_home-128.png"));
    middleGap = new Label();

    mainLayout.setSizeFull();
    mainLayout.setStyleName("mainLayout");
    leftLayout.setSizeFull();
    leftLayout.setStyleName("leftContainer");
    rightLayout.setSizeFull();
    rightLayout.setStyleName("rightContainer");
    bottomLayout.setSizeFull();
    bottomLeftLayout.setSizeFull();
    //      bottomRightLayout.setWidth(90, UNITS_PERCENTAGE);
    //      bottomRightLayout.setStyleName("projectDetailsLayout");
    topRightLayout.setSizeFull();
    leftContentLayout.setSizeFull();
    progressBar.setSizeUndefined();
    progressBar.setVisible(false);
    //   leftContentLayout.setHeight(Sizeable.SIZE_UNDEFINED, 0);

    leftLogoLayout = new VerticalLayout();
    logo = new Embedded(null, new ThemeResource("images/logo_businesshorizon_vertical.png"));

    gap.setHeight("10px");
    bottomGap.setHeight("40px");
    middleGap.setHeight("10px");
    progressBarGap.setHeight("15px");
    leftContainerSpacing.setSizeFull();

    homeIcon.setWidth(70, UNITS_PIXELS);
    homeIcon.setHeight(70, UNITS_PIXELS);

    seitenLabel = new Label("Startseite");
    seitenLabel.setStyleName("seitenLabel");
    seitenLabel.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    descriptionLabel = new Label("bersicht ber alle Projekte");
    descriptionLabel.setStyleName("descriptionLabel");
    descriptionLabel.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
    descriptionLayout.setHeight(80, UNITS_PIXELS);
    splitter.setWidth(98, UNITS_PERCENTAGE);
    splitter2.setWidth(98, UNITS_PERCENTAGE);
    menuButtonsLayout.setWidth(100, UNITS_PERCENTAGE);
    menuButtonsLayout.setHeight(Sizeable.SIZE_UNDEFINED, 0);
    homeButtonLayout.setSizeFull();
    logoutButtonLayout.setSizeFull();
    homeButton.setHeight(30, UNITS_PIXELS);
    homeButton.setWidth(30, UNITS_PIXELS);
    homeButton.setStyleName("homeButton");
    logoutButton.setHeight(30, UNITS_PIXELS);
    logoutButton.setWidth(30, UNITS_PIXELS);
    logoutButton.setStyleName("logoutButton");
    homeButtonLabel.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    homeButtonLabel.setStyleName("topBarButtonLabel");
    logoutButtonLabel.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    logoutButtonLabel.setStyleName("topBarButtonLabel");
    faqLayout.setWidth(100, UNITS_PERCENTAGE);
    faqLayout.setHeight(50, UNITS_PIXELS);

    horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSplitPosition(30, UNITS_PERCENTAGE);
    horizontalSplitPanel.setLocked(true);
    horizontalSplitPanel.setStyleName("horizontalMain");
    verticalSplitPanel = new VerticalSplitPanel();
    verticalSplitPanel.setSplitPosition(126, UNITS_PIXELS);
    verticalSplitPanel.setLocked(true);
    verticalSplitPanel.setWidth(90, UNITS_PERCENTAGE);
    verticalSplitPanel.setHeight(100, UNITS_PERCENTAGE);
    horizontalSplitPanelRight = new HorizontalSplitPanel();
    horizontalSplitPanelRight.setSplitPosition(30, UNITS_PERCENTAGE);
    horizontalSplitPanelRight.setLocked(true);
    horizontalSplitPanelRight.addStyleName("horizontalBottom");
    horizontalSplitPanelRight.setHeight(90, UNITS_PERCENTAGE);
    horizontalSplitPanelRight.setWidth(100, UNITS_PERCENTAGE);

    descriptionLayout.addComponent(descriptionLabel);
    leftLogoLayout.addComponent(logo);
    leftContentLayout.addComponent(gap);
    leftContentLayout.addComponent(homeIcon);
    leftContentLayout.addComponent(seitenLabel);
    leftContentLayout.addComponent(splitter);
    leftContentLayout.addComponent(descriptionLayout);
    leftContentLayout.addComponent(splitter2);
    leftContentLayout.addComponent(middleGap);
    leftContentLayout.addComponent(menuButtonsLayout);
    leftContentLayout.addComponent(progressBarGap);
    leftContentLayout.addComponent(progressBar);
    leftContentLayout.addComponent(leftContainerSpacing);
    leftContentLayout.addComponent(bottomGap);
    leftContentLayout.setExpandRatio(leftContainerSpacing, 1.0f);
    leftLayout.addComponent(leftLogoLayout);
    leftLayout.addComponent(leftContentLayout);
    leftLayout.setExpandRatio(leftContentLayout, 1.0f);
    descriptionLayout.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_CENTER);
    leftLogoLayout.setComponentAlignment(logo, Alignment.MIDDLE_CENTER);
    leftContentLayout.setComponentAlignment(homeIcon, Alignment.TOP_CENTER);
    leftContentLayout.setComponentAlignment(seitenLabel, Alignment.TOP_CENTER);
    leftContentLayout.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    //      leftContentLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_CENTER);
    menuButtonsLayout.addComponent(homeButtonLayout);
    menuButtonsLayout.addComponent(logoutButtonLayout);
    homeButtonLayout.addComponent(homeButton);
    homeButtonLayout.addComponent(homeButtonLabel);
    logoutButtonLayout.addComponent(logoutButton);
    logoutButtonLayout.addComponent(logoutButtonLabel);

    homeButtonLayout.setComponentAlignment(homeButton, Alignment.TOP_CENTER);
    homeButtonLayout.setComponentAlignment(homeButtonLabel, Alignment.MIDDLE_CENTER);
    logoutButtonLayout.setComponentAlignment(logoutButton, Alignment.TOP_CENTER);
    logoutButtonLayout.setComponentAlignment(logoutButtonLabel, Alignment.MIDDLE_CENTER);

    leftLogoLayout.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    leftLogoLayout.setHeight(100, UNITS_PERCENTAGE);
    leftContentLayout.setSizeFull();

    rightLayout.addComponent(verticalSplitPanel);
    bottomLayout.addComponent(horizontalSplitPanelRight);

    horizontalSplitPanel.addComponent(leftLayout);
    horizontalSplitPanel.addComponent(rightLayout);

    verticalSplitPanel.addComponent(topRightLayout);
    verticalSplitPanel.addComponent(bottomLayout);

    //      horizontalSplitPanelRight.setSecondComponent(bottomRightLayout);

    rightLayout.setComponentAlignment(verticalSplitPanel, Alignment.MIDDLE_CENTER);
    bottomLayout.setComponentAlignment(horizontalSplitPanelRight, Alignment.MIDDLE_CENTER);

    mainLayout.addComponent(horizontalSplitPanel);

    homeButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialog.show(event.getButton().getWindow(), "Warnung",
                    "Beim Abbruch gehen Ihre Eingaben verloren! Mchten Sie zur Startseite zurckkehren?",
                    "Okay", "Abbrechen", new ConfirmDialog.Listener() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                presenter.showInitialScreen();
                            } else {

                            }
                        }
                    });

        }

    });

    logoutButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialog.show(event.getButton().getWindow(), "Warnung",
                    "Mchten Sie sich wirklich ausloggen?", "Okay", "Abbrechen", new ConfirmDialog.Listener() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                presenter.doLogout();
                            } else {

                            }
                        }
                    });
        }

    });

    setContent(mainLayout);

    addProjectButton = new TopBarButton("addProjectButton", "Neues Projekt");
    addProjectButton.addLabel("hinzufgen");
    addProjectButtonListener = new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.showProjectCreationScreen();
            String[] desc = new String[2];
            desc[0] = "Geben Sie hier den Namen und";
            desc[1] = "eine Beschreibung ein";
            setPageDescription("./images/icons/newIcons/1418831401_circle_add_plus-128.png",
                    "Neues Projekt anlegen", desc);
        }

    };
    addTopButton(addProjectButton, addProjectButtonListener);

    editProjectButton = new TopBarButton("editProjectButton", "Projekt bearbeiten");
    editProjectButtonListener = new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.showProjectEditScreen();
            String[] desc = new String[2];
            desc[0] = "ndern Sie hier Name oder";
            desc[1] = "Beschreibung des Projekts";
            setPageDescription("./images/icons/newIcons/1418765965_editor_pencil_pen_edit_write-128.png",
                    "Projekt bearbeiten", desc);
        }

    };
    addTopButton(editProjectButton, editProjectButtonListener);
    deleteProjectButton = new TopBarButton("deleteProjectButton", "Projekt lschen");
    deleteProjectButton.setButtonWidth(25);
    deleteProjectButtonListener = new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            final Project project = projectProxy.getSelectedProject();

            logger.debug("Projekt-loeschen Button aus dem Hauptfenster aufgerufen.");

            ConfirmDialog.show(getWindow(), project.getName() + " lschen?",
                    "Wollen sie das Projekt wirklich lschen?", "Ja", "Nein", new ConfirmDialog.Listener() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                presenter.removeProject(project);
                            } else {

                            }
                        }
                    });

        }

    };
    addTopButton(deleteProjectButton, deleteProjectButtonListener);

    createImportButton();
    topRightLayout.addComponent(importButton);
    topRightLayout.setComponentAlignment(importButton, Alignment.MIDDLE_CENTER);

    exportButton = new TopBarButton("exportButton", "Projekte");
    exportButton.addLabel("exportieren");
    exportButtonListener = new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            File exportFile = presenter.exportProjects();
            event.getButton().getWindow().open(new Downloader(exportFile, getApplication()));
        }

    };
    addTopButton(exportButton, exportButtonListener);

    topBarSpacing = new VerticalLayout();
    topBarSpacing.setSizeFull();
    topRightLayout.addComponent(topBarSpacing);
    topRightLayout.setExpandRatio(topBarSpacing, 1.0f);

}