Example usage for com.vaadin.ui HorizontalLayout addListener

List of usage examples for com.vaadin.ui HorizontalLayout addListener

Introduction

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

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:edu.kit.dama.ui.commons.util.PaginationLayout.java

License:Apache License

/**
 * Update the layout. This method is either called internally when scrolling
 * or//from  w ww .j a  va2  s  .c o  m
 */
public final void update() {
    //remove all components (old result page and navigation)
    removeAllComponents();

    //add current results
    renderPage();

    //build pagination
    int pages = overallEntries / entriesPerPage;
    if (overallEntries % entriesPerPage > 0) {
        pages++;
    }

    final int overallPages = pages;
    HorizontalLayout navigation = new HorizontalLayout();
    //add "JumpToFirstPage" button
    final NativeButton first = new NativeButton();
    first.setIcon(firstIcon);
    if (firstIcon == null) {
        first.setCaption("<<");
    }
    first.setDescription("First Page");
    first.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = 0;
            update();
        }
    });
    //add "PreviousPage" button
    final NativeButton prev = new NativeButton();
    prev.setIcon(prevIcon);
    if (prevIcon == null) {
        prev.setCaption("<");
    }
    prev.setDescription("Previous Page");
    prev.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage > 0) {
                currentPage--;
                update();
            }
        }
    });
    //add "NextPage" button
    final NativeButton next = new NativeButton();
    next.setIcon(nextIcon);
    if (nextIcon == null) {
        next.setCaption(">");
    }
    next.setDescription("Next Page");
    next.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage + 1 < overallPages) {
                currentPage++;
                update();
            }
        }
    });
    //add "JumpToLastPage" button
    final NativeButton last = new NativeButton();
    last.setIcon(endIcon);
    if (endIcon == null) {
        next.setCaption(">>");
    }
    last.setDescription("Last Page");
    last.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = overallPages - 1;
            update();
        }
    });

    //enable/disable buttons depending on the current page
    if (overallPages == 0) {
        first.setEnabled(false);
        prev.setEnabled(false);
        next.setEnabled(false);
        last.setEnabled(false);
    } else {
        first.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        prev.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
        last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
    }

    //at first, put the page size selection box into the navigation
    final ComboBox entriesPerPageBox = new ComboBox();
    entriesPerPageBox.setItemCaptionPropertyId("name");
    entriesPerPageBox.addContainerProperty("name", String.class, null);
    entriesPerPageBox.addItem(5);
    entriesPerPageBox.getContainerProperty(5, "name").setValue("5 Entries / Page");
    entriesPerPageBox.addItem(10);
    entriesPerPageBox.getContainerProperty(10, "name").setValue("10 Entries / Page");
    entriesPerPageBox.addItem(15);
    entriesPerPageBox.getContainerProperty(15, "name").setValue("15 Entries / Page");
    entriesPerPageBox.addItem(20);
    entriesPerPageBox.getContainerProperty(20, "name").setValue("20 Entries / Page");

    entriesPerPageBox.setValue(entriesPerPage);
    entriesPerPageBox.setNullSelectionAllowed(false);
    entriesPerPageBox.setImmediate(true);

    entriesPerPageBox.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            entriesPerPage = (Integer) entriesPerPageBox.getValue();
            update();
        }
    });

    navigation.addComponent(entriesPerPageBox);

    //filler labels are added to the beginning and to the end to keep the navigation in the middle
    Label leftFiller = new Label();
    leftFiller.setWidth("25px");
    navigation.addComponent(leftFiller);
    navigation.addComponent(first);
    navigation.addComponent(prev);

    //Show max. 10 pages at once for performance and layout reasons.
    //If there are more than 10 pages, "move" the to show 10 pages based on the current page.
    int start = currentPage - 5;
    start = (start < 0) ? 0 : start;
    int end = start + 10;
    end = (end > pages) ? pages : end;

    if (end - start < 10 && pages > 10) {
        start = end - 10;
    }

    if (overallPages == 0) {
        Label noEntryLabel = new Label("<i>No entries</i>", Label.CONTENT_XHTML);
        //noEntryLabel.setWidth("80px");
        noEntryLabel.setSizeUndefined();
        navigation.addComponent(noEntryLabel);
        navigation.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER);
    }
    //build the actual page entries
    for (int i = start; i < end; i++) {
        if (i == currentPage) {
            //the current page is marked with a special style
            Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", Label.CONTENT_XHTML);
            pageLink.setStyleName("currentpage");
            pageLink.setWidth("15px");
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        } else {
            //otherwise normal links are added, click-events are handled via LayoutClickListener 
            Link pageLink = new Link(Integer.toString(i + 1), null);
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        }
    }
    //add right navigation buttons
    navigation.addComponent(next);
    navigation.addComponent(last);
    //...and fill the remaining space 
    Label rightFiller = new Label();
    navigation.addComponent(rightFiller);
    //  navigation.setExpandRatio(leftFiller, 1.0f);
    navigation.setExpandRatio(rightFiller, 1.0f);
    navigation.setSpacing(true);

    //put everything ot the middle
    navigation.setComponentAlignment(first, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(prev, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(last, Alignment.MIDDLE_CENTER);

    //add layout click listener to be able to navigate by clicking the single pages
    navigation.addListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {

            // Get the child component which was clicked
            Component child = event.getChildComponent();

            if (child == null) {
                // Not over any child component
            } else {
                // Over a child component
                if (child instanceof Link) {
                    // Over a valid child element
                    currentPage = Integer.parseInt(((Link) child).getCaption()) - 1;
                    update();
                }
            }
        }
    });

    //finalize
    navigation.setWidth("100%");
    navigation.setHeight("25px");

    //add navigation and align it right below the result page
    addComponent(page);
    setExpandRatio(page, 1f);
    if (overallEntries > 0) {
        addComponent(navigation);
        setComponentAlignment(navigation, Alignment.BOTTOM_CENTER);
        setExpandRatio(navigation, .05f);
    }
    requestRepaint();
}

From source file:fr.univlorraine.mondossierweb.views.RechercheMobileView.java

License:Apache License

/**
 * Initialise la vue//from  ww w  .  java2s  .  c  om
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        // On rinitialise la vue
        removeAllComponents();

        // Style
        setSizeFull();
        addStyleName("v-noscrollableelement");

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        returnButton = new Button();
        returnButton.setIcon(FontAwesome.ARROW_LEFT);
        returnButton.setStyleName("v-nav-button");
        returnButton.addClickListener(e -> {
            MdwTouchkitUI.getCurrent().backFromSearch();
        });
        navbar.addComponent(returnButton);
        navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelTrombi = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        //BOUTON DE RECHERCHE
        btnRecherche = new Button();
        btnRecherche.setIcon(FontAwesome.SEARCH);
        btnRecherche.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnRecherche.addStyleName("v-popover-button");
        btnRecherche.addStyleName("v-button-without-padding");
        btnRecherche.setEnabled(true);
        btnRecherche.addClickListener(e -> search(false));

        //CHAMP DE RECHERCHE
        champRechercheLayout = new HorizontalLayout();
        champRechercheLayout.setWidth("100%");
        mainVerticalLayout = new VerticalLayout();
        mainVerticalLayout.setImmediate(true);
        mainVerticalLayout.setSizeFull();

        //Init connexion  ES, pour gain perf au premiere lettre tapes
        if (ElasticSearchService.initConnexion(true)) {

            //Cration du champ autoComplete
            champRecherche = new AutoComplete();
            champRecherche.setWidth(100, Unit.PERCENTAGE);
            champRecherche.setEnabled(true);
            champRecherche.setImmediate(true);
            champRecherche.focus();
            champRecherche.setTextChangeEventMode(TextChangeEventMode.EAGER);
            champRecherche.addTextChangeListener(new TextChangeListener() {
                @Override
                public void textChange(TextChangeEvent event) {
                    /*if(event.getText()!=null){
                    resetButton.setIcon(FontAwesome.TIMES);
                    }*/

                    champRecherche.showChoices(quickSearch(event.getText()), mainVerticalLayout, btnRecherche,
                            true);

                }
            });
            champRecherche.setImmediate(true);
            champRecherche.addShortcutListener(
                    new ShortcutListener("Enter Shortcut", ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                //Si on tait sur une ligne propose sous le champ de recherche
                                if (champRecherche.getSelectedItem() > 0) {
                                    //On remplie d'abord le champ avec la ligne slectionne
                                    champRecherche.setValue(champRecherche.getChoices()
                                            .getItem(champRecherche.getSelectedItem()).getItemProperty("lib")
                                            .getValue().toString());
                                }
                                search(false);
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Bottom Arrow", ShortcutAction.KeyCode.ARROW_DOWN, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    champRecherche.getChoices().setValue(champRecherche.getNextItem());

                                }
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Top Arrow", ShortcutAction.KeyCode.ARROW_UP, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    Integer champSelectionne = champRecherche.getPreviousItem();
                                    if (champSelectionne > 0) {
                                        champRecherche.getChoices().setValue(champSelectionne);
                                    } else {
                                        champRecherche.getChoices().setValue(null);
                                    }

                                }
                            }
                        }
                    });

            champRechercheLayout.addComponent(champRecherche);
            champRechercheLayout.setComponentAlignment(champRecherche, Alignment.MIDDLE_LEFT);

            //BOUTON RESET
            champRecherche.addStyleName("textfield-resetable");
            resetButton = new Button();
            resetButton.setIcon(FontAwesome.TIMES);
            resetButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
            resetButton.addStyleName("v-popover-button");
            resetButton.addStyleName("v-button-without-padding");
            resetButton.addStyleName("btn-reset");
            resetButton.addClickListener(e -> {
                champRecherche.setValue("");
                //search1.setValue("");
                resetButton.setIcon(FontAwesome.TIMES);
                champRecherche.focus();
            });
            champRechercheLayout.addComponent(resetButton);
            champRechercheLayout.setComponentAlignment(resetButton, Alignment.MIDDLE_LEFT);

            //Ajout du bouton de recherche au layout
            champRechercheLayout.addComponent(btnRecherche);
            mainVerticalLayout.addComponent(champRechercheLayout);
            mainVerticalLayout.setComponentAlignment(champRechercheLayout, Alignment.MIDDLE_LEFT);
            champRechercheLayout.setMargin(true);
            champRechercheLayout.setExpandRatio(champRecherche, 1);

            HorizontalLayout checkBoxVetLayout = new HorizontalLayout();
            Label etapeLabel = new Label(
                    applicationContext.getMessage(NAME + ".etapes.checkbox", null, getLocale()));
            etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxVetLayout.addComponent(etapeLabel);

            HorizontalLayout checkBoxElpLayout = new HorizontalLayout();
            Label elpLabel = new Label(
                    applicationContext.getMessage(NAME + ".elps.checkbox", null, getLocale()));
            elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxElpLayout.addComponent(elpLabel);

            HorizontalLayout checkBoxEtuLayout = new HorizontalLayout();
            Label etuLabel = new Label(
                    applicationContext.getMessage(NAME + ".etudiants.checkbox", null, getLocale()));
            etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxEtuLayout.addComponent(etuLabel);

            checkBoxVetLayout.setSizeFull();
            checkBoxElpLayout.setSizeFull();
            checkBoxEtuLayout.setSizeFull();

            if (casesAcocherVet) {
                checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                etapeLabel.addStyleName("label-line-through");
            }

            if (casesAcocherElp) {
                checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                elpLabel.addStyleName("label-line-through");
            }

            if (casesAcocherEtudiant) {
                checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                etuLabel.addStyleName("label-line-through");
            }

            checkBoxVetLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherVet) {
                        casesAcocherVet = false;
                        checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                        etapeLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherVet = true;
                        checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                        etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxElpLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherElp) {
                        casesAcocherElp = false;
                        checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                        elpLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherElp = true;
                        checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                        elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxEtuLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherEtudiant) {
                        casesAcocherEtudiant = false;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                        etuLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherEtudiant = true;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                        etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            HorizontalLayout checkBoxLayout = new HorizontalLayout();
            checkBoxLayout.setWidth("100%");
            checkBoxLayout.setHeight("50px");
            checkBoxLayout.setMargin(true);
            checkBoxLayout.setSpacing(true);
            checkBoxLayout.addComponent(checkBoxVetLayout);
            checkBoxLayout.addComponent(checkBoxElpLayout);
            checkBoxLayout.addComponent(checkBoxEtuLayout);

            mainVerticalLayout.addComponent(checkBoxLayout);

            //TABLE DE RESULTATS
            rrContainer = new HierarchicalContainer();
            rrContainer.addContainerProperty("lib", String.class, "");
            rrContainer.addContainerProperty("code", String.class, "");
            rrContainer.addContainerProperty("type", String.class, "");
            tableResultats = new TreeTable();
            tableResultats.setWidth("100%");
            tableResultats.setSelectable(false);
            tableResultats.setMultiSelect(false);
            tableResultats.setImmediate(true);
            columnHeaders = new String[FIELDS_ORDER.length];
            for (int fieldIndex = 0; fieldIndex < FIELDS_ORDER.length; fieldIndex++) {
                columnHeaders[fieldIndex] = applicationContext
                        .getMessage("result.table." + FIELDS_ORDER[fieldIndex], null, Locale.getDefault());
            }

            tableResultats.addGeneratedColumn("type", new DisplayTypeColumnGenerator());
            tableResultats.addGeneratedColumn("lib", new DisplayNameColumnGenerator());
            tableResultats.setContainerDataSource(rrContainer);
            tableResultats.setVisibleColumns(FIELDS_ORDER);
            tableResultats.setStyleName("nohscrollabletable");
            tableResultats.setColumnHeaders(columnHeaders);
            tableResultats.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
            tableResultats.setColumnWidth("type", 100);

            /*mainVerticalLayout.addComponent(searchBoxFilter);
            mainVerticalLayout.setComponentAlignment(searchBoxFilter, Alignment.MIDDLE_RIGHT);*/
            VerticalLayout tableVerticalLayout = new VerticalLayout();
            tableVerticalLayout.setMargin(true);
            tableVerticalLayout.setSizeFull();
            tableVerticalLayout.addComponent(tableResultats);
            mainVerticalLayout.addComponent(tableVerticalLayout);
            mainVerticalLayout.setExpandRatio(tableVerticalLayout, 1);
            tableResultats.setVisible(false);

            addComponent(mainVerticalLayout);
            setExpandRatio(mainVerticalLayout, 1);
        } else {
            //Message fonctionnalit indisponible
            addComponent(
                    new Label(applicationContext.getMessage(NAME + ".indisponible.message", null, getLocale()),
                            ContentMode.HTML));
        }
    }
}

From source file:org.escidoc.browser.elabsmodul.views.InstrumentView.java

License:Open Source License

/**
 * Build the specific editable layout of the eLabsElement.
 *///  w  w w . ja v a 2 s.co m
private void buildPanelGUI() {

    final String supervisorId = this.instrumentBean.getDeviceSupervisor();
    String supervisorText = null;
    if (supervisorId != null) {
        for (Iterator<UserBean> iterator = ELabsCache.getUsers().iterator(); iterator.hasNext();) {
            UserBean user = iterator.next();
            if (user.getId().equals(supervisorId)) {
                supervisorText = user.getComplexId();
                break;
            }
        }
    }

    final String instituteId = this.instrumentBean.getInstitute();
    String instituteText = null;
    if (instituteId != null) {
        for (Iterator<OrgUnitBean> iterator = ELabsCache.getOrgUnits().iterator(); iterator.hasNext();) {
            OrgUnitBean unit = iterator.next();
            if (unit.getId().equals(instituteId)) {
                instituteText = unit.getComplexId();
                break;
            }
        }
    }

    this.dynamicLayout.setStyleName(ELabsViewContants.STYLE_ELABS_FORM);

    this.buttonLayout = LabsLayoutHelper.createButtonLayout();
    HorizontalLayout h1 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_TITLE, getPojoItem().getItemProperty(ELabsViewContants.P_INSTRUMENT_TITLE),
            true);
    HorizontalLayout h2 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_DESCRIPTION, getPojoItem().getItemProperty(ELabsViewContants.P_INSTRUMENT_DESC),
            true);
    HorizontalLayout h3 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndCheckBoxData(
            ELabsViewContants.L_INSTRUMENT_CONFIGURATION_KEY,
            ELabsViewContants.L_INSTRUMENT_CONFIGURATION_VALUE,
            getPojoItem().getItemProperty(ELabsViewContants.P_INSTRUMENT_CONFIGURATION), false);
    HorizontalLayout h4 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndCheckBoxData(
            ELabsViewContants.L_INSTRUMENT_CALIBRATION_KEY, ELabsViewContants.L_INSTRUMENT_CALIBRATION_VALUE,
            getPojoItem().getItemProperty(ELabsViewContants.P_INSTRUMENT_CALIBRATION), false);
    HorizontalLayout h5 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndStaticComboData(
            ELabsViewContants.L_INSTRUMENT_ESYNC_DAEMON, instrumentBean.getESyncDaemon(), true);
    HorizontalLayout h6 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_INSTRUMENT_FOLDER,
            getPojoItem().getItemProperty(ELabsViewContants.P_INSTRUMENT_FOLDER), true);
    HorizontalLayout h7 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_INSTRUMENT_FILE_FORMAT,
            getPojoItem().getItemProperty(ELabsViewContants.P_INSTRUMENT_FILEFORMAT), false);
    HorizontalLayout h8 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelComplexData(
            ELabsViewContants.L_INSTRUMENT_DEVICE_SUPERVISOR, supervisorText, false);
    HorizontalLayout h9 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelComplexData(
            ELabsViewContants.L_INSTRUMENT_INSTITUTE, instituteText, false);

    h5.addListener(new ESyncDaemonEndpointSelectionLayoutListener(this, this));
    if (!ELabsCache.getFileFormats().isEmpty()) {
        h7.addListener(new FileFormatSelectionLayoutListener(this));
    }
    h8.addListener(new DeviceSupervisorSelectionLayoutListener(this));
    h9.addListener(new InstituteSelectionLayoutListener(this));

    this.registeredComponents.add(h1);
    this.registeredComponents.add(h2);
    this.registeredComponents.add(h3);
    this.registeredComponents.add(h4);
    this.registeredComponents.add(h5);
    this.registeredComponents.add(h6);
    this.registeredComponents.add(h7);
    this.registeredComponents.add(h8);
    this.registeredComponents.add(h9);

    this.dynamicLayout.addComponent(h1, 0);
    this.dynamicLayout.addComponent(h2, 1);
    this.dynamicLayout.addComponent(h3, 2);
    this.dynamicLayout.addComponent(h4, 3);
    this.dynamicLayout.addComponent(h5, 4);
    this.dynamicLayout.addComponent(h6, 5);
    this.dynamicLayout.addComponent(h7, 6);
    this.dynamicLayout.addComponent(h8, 7);
    this.dynamicLayout.addComponent(h9, 8);
    this.dynamicLayout.addComponent(new HorizontalLayout(), 9);

    this.dynamicLayout.setComponentAlignment(h1, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h2, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h3, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h4, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h5, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h6, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h7, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h8, Alignment.MIDDLE_LEFT);
    this.dynamicLayout.setComponentAlignment(h9, Alignment.MIDDLE_LEFT);

    this.mainLayout.addComponent(this.dynamicLayout);
    this.mainLayout.setExpandRatio(this.dynamicLayout, 9.0f);
    this.mainLayout.attach();
    this.mainLayout.requestRepaintAll();
}

From source file:org.escidoc.browser.elabsmodul.views.InvestigationView.java

License:Open Source License

/**
 * Build the specific editable layout of the eLabsElement.
 *///  ww w.  j  a  v  a 2 s. com
private void buildPanelGUI() {
    final String investigatorId = investigationBean.getInvestigator();
    String investigatorText = null;
    if (investigatorId != null) {
        for (Iterator<UserBean> iterator = ELabsCache.getUsers().iterator(); iterator.hasNext();) {
            UserBean user = iterator.next();
            if (user.getId().equals(investigatorId)) {
                investigatorText = user.getComplexId();
            }
        }
    }
    this.dynamicLayout.setStyleName(ELabsViewContants.STYLE_ELABS_FORM);
    this.buttonLayout = LabsLayoutHelper.createButtonLayout();
    final HorizontalLayout h1 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_TITLE, this.pojoItem.getItemProperty(ELabsViewContants.P_INVESTIGATION_TITLE),
            true);
    final HorizontalLayout h2 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_DESCRIPTION,
            this.pojoItem.getItemProperty(ELabsViewContants.P_INVESTIGATION_DESC), true);
    final HorizontalLayout h3 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndStaticComboData(
            ELabsViewContants.L_INVESTIGATION_DEPOSIT_SERVICE, investigationBean.getDepositEndpoint(), true);
    final HorizontalLayout h4 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelComplexData(
            ELabsViewContants.L_INVESTIGATION_INVESTIGATOR, investigatorText, false);
    final HorizontalLayout h5 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_INVESTIGATION_DURATION,
            this.pojoItem.getItemProperty(ELabsViewContants.P_INVESTIGATION_DURATION), true);
    final HorizontalLayout h6 = LabsLayoutHelper.createHorizontalLayoutWithELabsLabelAndLabelData(
            ELabsViewContants.L_INVESTIGATION_RIG,
            this.pojoItem.getItemProperty(ELabsViewContants.P_INVESTIGATION_RIG), true);

    h3.addListener(new DepositEndpointSelectionLayoutListener(this, this));
    h4.addListener(new DepositorSelectionLayoutListener(this));
    h5.addListener(new DurationSelectionLayoutListener(this, this));
    h6.addListener(new RigSelectionLayoutListener(this.controller, this));

    this.registeredComponents.add(h1);
    this.registeredComponents.add(h2);
    this.registeredComponents.add(h3);
    this.registeredComponents.add(h4);
    this.registeredComponents.add(h5);
    this.registeredComponents.add(h6);

    this.dynamicLayout.addComponent(h1, 0);
    this.dynamicLayout.addComponent(h2, 1);
    this.dynamicLayout.addComponent(h3, 2);
    this.dynamicLayout.addComponent(h4, 3);
    this.dynamicLayout.addComponent(h5, 4);
    this.dynamicLayout.addComponent(h6, 5);
    this.dynamicLayout.addComponent(new HorizontalLayout(), 6);

    rightCell(this.dynamicLayout);
    this.mainLayout.addComponent(this.directMemberInvestigationContainer);
    this.mainLayout.setExpandRatio(this.directMemberInvestigationContainer, 1.0f);
    this.mainLayout.attach();
    this.mainLayout.requestRepaintAll();
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java

License:Mozilla Public License

private void buildResultsPage(final Panel resultsPanel, final int startIndex, final int endIndex) {
    resultsPanel.removeAllComponents();//from  www.j  a v  a 2s . c  o  m
    for (int n = startIndex; (n < endIndex && n < searchResults.size()); n++) {
        final SearchResultType r = searchResults.get(n);
        final Tree cTree = application.getContainmentTreePanel().getContainmentTree();
        final HorizontalLayout hl1 = new HorizontalLayout();
        hl1.setData(r.getInstanceIdentity());
        hl1.addListener(new LayoutClickListener() {
            private void expandAllAncestors(final TreeNode rootNode, final TreeNode node2Select) {
                if (!rootNode.equals(node2Select)) {
                    final TreeNode parentNode = (TreeNode) cTree.getParent(node2Select);
                    cTree.expandItem(parentNode);
                    expandAllAncestors(rootNode, parentNode);
                }
            }

            public void layoutClick(final LayoutClickEvent event) {
                if (event.getSource() instanceof HorizontalLayout) {
                    final HorizontalLayout layout = (HorizontalLayout) event.getSource();
                    final InstanceIdentityType id = (InstanceIdentityType) layout.getData();
                    //Fetch and deserialize outershell instances if they are not available in memory
                    application.getContainmentTreePanel().recreateOutshellInstances();
                    application.getContainmentTreePanel().update();
                    if (cTree.rootItemIds().size() > 0) {
                        final TreeNode rootNode = (TreeNode) cTree.rootItemIds().iterator().next();
                        cTree.collapseItemsRecursively(rootNode);
                        //select a corresponding tree node
                        final Set set = Reconstitution.getSetFromLocalMemory(
                                Reconstitution.reconstituteIdentity(id.getName(), id.getPluralName(),
                                        UUID.fromString(id.getUuid()), UUID.fromString(id.getUuid())));
                        // TODO name based equivalence test needs to be replaced by isEqualToRepresentation()
                        if (!set.identity().name()
                                .equals((S23MSemanticDomains.semanticErr_ThisSetIsNotAvailableInMemory
                                        .identity().name()))) {

                            TreeNode node2Select = null;
                            if (set.properClass().isEqualTo(S23MKernel.coreGraphs.edge)) {
                                node2Select = new TreeNode(
                                        set.container().identity().uniqueRepresentationReference().toString(),
                                        TreeNode.NO_SET);
                            } else {
                                node2Select = new TreeNode(id.getUuid(), TreeNode.NO_SET);
                            }
                            expandAllAncestors(rootNode, node2Select);
                            cTree.setValue(node2Select);
                        }
                    }
                }
            }//
        });

        final HorizontalLayout hl2 = new HorizontalLayout();

        final Label lblMeta = new Label();
        lblMeta.setStyleName("meta-element");
        final Label lblInstance = new Label();
        lblInstance.setStyleName("instance-element");

        final Label lblArtifact = new StyledLabel("part of: " + r.getContainerIdentity().getName(),
                StyledLabel.VALUE_TAG_STYLE);
        final Label lblNameTag = new StyledLabel("name:", StyledLabel.NAME_TAG_STYLE);
        final Label lblName = new StyledLabel(r.getInstanceIdentity().getName(), StyledLabel.VALUE_TAG_STYLE);
        final Label lblPlNameTag = new StyledLabel("plural name:", StyledLabel.NAME_TAG_STYLE);
        final Label lblPlName = new StyledLabel(r.getInstanceIdentity().getPluralName(),
                StyledLabel.VALUE_TAG_STYLE);
        if (r.getMetaInstanceIdentity().getName() != null) {
            lblMeta.setValue(r.getMetaInstanceIdentity().getName() + " : ");
        } else {
            final Set metaSet = Reconstitution.getSetFromLocalMemory(Reconstitution.reconstituteIdentity("", "",
                    UUID.fromString(r.getMetaInstanceIdentity().getUuid()),
                    UUID.fromString(r.getMetaInstanceIdentity().getUuid())));
            // TODO name based equivalence test needs to be replaced by isEqualToRepresentation()
            if (!metaSet.identity().name().equals(
                    (S23MSemanticDomains.semanticErr_ThisSetIsNotAvailableInMemory.identity().name()))) {

                lblMeta.setValue(metaSet.identity().name() + " : ");
            } else {
                lblMeta.setValue(" : ");
            }
        }
        lblInstance.setValue(r.getInstanceIdentity().getName());

        hl1.addComponent(lblMeta);
        hl1.addComponent(lblInstance);
        hl2.addComponent(lblArtifact);
        hl2.addComponent(lblNameTag);
        hl2.addComponent(lblName);
        hl2.addComponent(lblPlNameTag);
        hl2.addComponent(lblPlName);

        resultsPanel.addComponent(hl1);
        resultsPanel.addComponent(hl2);
    }
    if (searchResults.size() > PAGE_SIZE) {
        createPagebar(resultsPanel, searchResults.size());
    }
}

From source file:org.vaadin.notifique.Notifique.java

License:Apache License

public Message add(Resource icon, Component component, String style, boolean showCloseButton) {

    HorizontalLayout lo = new HorizontalLayout();
    lo.setSpacing(true);//from  ww w  .  j a va  2  s . c o m
    lo.setWidth("100%");

    final Message i = createMessage(lo, style);
    publish(i);

    // Add icon if given
    if (icon != null) {
        lo.addComponent(new Embedded(null, icon));
    }

    lo.addComponent(component);
    lo.setExpandRatio(component, 1f);
    lo.setComponentAlignment(component, Alignment.MIDDLE_LEFT);

    // Close button if requested
    if (showCloseButton) {
        Button close = createCloseButtonFor(i);
        if (close != null) {
            lo.addComponent(close);
        }
    }

    // Listen for clicks
    lo.addListener(new LayoutClickListener() {
        private static final long serialVersionUID = 7524442205441374595L;

        public void layoutClick(LayoutClickEvent event) {
            if (getClickListener() != null) {
                getClickListener().messageClicked(i);
            }
        }
    });

    return i;
}

From source file:pt.ist.vaadinframework.ui.PaginatedSorterViewer.java

License:Open Source License

private static Component makeControlsLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*from w  w  w  .  ja v  a2s .  c  o  m*/
    layout.setVisible(false);
    ControlVisibilityListener controlVisibilityListener = new ControlVisibilityListener();
    layout.addListener((ComponentAttachListener) controlVisibilityListener);
    layout.addListener((ComponentDetachListener) controlVisibilityListener);
    return layout;
}