Example usage for com.vaadin.ui Alignment BOTTOM_RIGHT

List of usage examples for com.vaadin.ui Alignment BOTTOM_RIGHT

Introduction

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

Prototype

Alignment BOTTOM_RIGHT

To view the source code for com.vaadin.ui Alignment BOTTOM_RIGHT.

Click Source Link

Usage

From source file:de.symeda.sormas.ui.utils.PaginationList.java

License:Open Source License

protected void updatePaginationLayout() {
    // Remove or re-add the pagination layout based on the number of list entries
    if (entries.size() <= maxDisplayedEntries) {
        removeComponent(paginationLayout);
        return;//from  w w w. j a v  a  2s.c  o  m
    } else if (getComponentIndex(paginationLayout) == -1) {
        addComponent(paginationLayout);
        setComponentAlignment(paginationLayout, Alignment.BOTTOM_RIGHT);
    }

    int firstDisplayedEntryIndex = entries.indexOf(displayedEntries.get(0));
    int lastPageNumber = calculateLastPageNumber();

    // Enable/disable first and last page buttons
    firstPageButton.setEnabled(currentPage > 1);
    lastPageButton.setEnabled(currentPage < lastPageNumber);

    // Numbered button and gap labels visibility
    previousGapLabel.setVisible(currentPage >= 4);
    previousPreviousPageButton.setVisible(currentPage >= 3);
    previousPageButton.setVisible(currentPage >= 2);
    nextPageButton.setVisible(currentPage < lastPageNumber);
    nextNextPageButton.setVisible(currentPage < lastPageNumber - 1);
    nextGapLabel.setVisible(currentPage < lastPageNumber - 2);

    // Numbered button captions
    currentPageButton.setCaption(
            String.valueOf((int) Math.ceil((firstDisplayedEntryIndex + 1) / (double) maxDisplayedEntries)));
    if (previousPreviousPageButton.isVisible()) {
        previousPreviousPageButton.setCaption(String.valueOf(currentPage - 2));
    }
    if (previousPageButton.isVisible()) {
        previousPageButton.setCaption(String.valueOf(currentPage - 1));
    }
    if (nextPageButton.isVisible()) {
        nextPageButton.setCaption(String.valueOf(currentPage + 1));
    }
    if (nextNextPageButton.isVisible()) {
        nextNextPageButton.setCaption(String.valueOf(currentPage + 2));
    }
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showSimplePopupWindow(String caption, String contentText) {
    Window window = new Window(null);
    window.setModal(true);/*from   ww  w.  j a v  a  2s . c  o  m*/
    window.setSizeUndefined();
    window.setResizable(false);
    window.center();

    VerticalLayout popupLayout = new VerticalLayout();
    popupLayout.setMargin(true);
    popupLayout.setSpacing(true);
    popupLayout.setSizeUndefined();
    Label contentLabel = new Label(contentText);
    contentLabel.setWidth(100, Unit.PERCENTAGE);
    popupLayout.addComponent(contentLabel);
    Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay));
    okayButton.addClickListener(e -> {
        window.close();
    });
    CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY);
    popupLayout.addComponent(okayButton);
    popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT);

    window.setCaption(caption);
    window.setContent(popupLayout);

    UI.getCurrent().addWindow(window);

    return window;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showConfirmationPopup(String caption, Component content, String confirmCaption,
        String cancelCaption, Integer width, Consumer<Boolean> resultConsumer) {
    Window popupWindow = VaadinUiUtil.createPopupWindow();
    if (width != null) {
        popupWindow.setWidth(width, Unit.PIXELS);
    } else {/*from www.j  a v a2s .c  o m*/
        popupWindow.setWidthUndefined();
    }
    popupWindow.setCaption(caption);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    content.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(content);

    ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfirm() {
            popupWindow.close();
            resultConsumer.accept(true);
        }

        @Override
        protected void onCancel() {
            popupWindow.close();
            resultConsumer.accept(false);
        }
    };
    confirmationComponent.getConfirmButton().setCaption(confirmCaption);
    confirmationComponent.getCancelButton().setCaption(cancelCaption);

    popupWindow.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            confirmationComponent.getCancelButton().click();
        }
    });

    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setSpacing(true);
    popupWindow.setContent(layout);

    UI.getCurrent().addWindow(popupWindow);
    return popupWindow;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showDeleteConfirmationWindow(String content, Runnable callback) {
    Window popupWindow = VaadinUiUtil.createPopupWindow();

    VerticalLayout deleteLayout = new VerticalLayout();
    deleteLayout.setMargin(true);/*from  w w w.jav a 2s  . c  o  m*/
    deleteLayout.setSizeUndefined();
    deleteLayout.setSpacing(true);

    Label description = new Label(content);
    description.setWidth(100, Unit.PERCENTAGE);
    deleteLayout.addComponent(description);

    ConfirmationComponent deleteConfirmationComponent = new ConfirmationComponent(false) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfirm() {
            popupWindow.close();
            onDone();
            callback.run();
        }

        @Override
        protected void onCancel() {
            popupWindow.close();
        }
    };
    deleteConfirmationComponent.getConfirmButton().setCaption(I18nProperties.getString(Strings.yes));
    deleteConfirmationComponent.getCancelButton().setCaption(I18nProperties.getString(Strings.no));
    deleteLayout.addComponent(deleteConfirmationComponent);
    deleteLayout.setComponentAlignment(deleteConfirmationComponent, Alignment.BOTTOM_RIGHT);

    popupWindow.setCaption(I18nProperties.getString(Strings.headingConfirmDeletion));
    popupWindow.setContent(deleteLayout);
    UI.getCurrent().addWindow(popupWindow);

    return popupWindow;
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.Popup.java

License:Apache License

private void init() {
    this.setModal(true);
    this.setHeight(325, Unit.PIXELS);
    this.setWidth(500, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from w w w  . ja v  a 2s .  com
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    Panel panel = new Panel();
    panel.setHeight(100, Unit.PERCENTAGE);
    panel.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(panel);
    layout.setExpandRatio(panel, 1);

    messageLabel = new Label();
    panel.setContent(messageLabel);

    Button close = new Button("Beenden", new Button.ClickListener() {
        private static final long serialVersionUID = -8385641161488292715L;

        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(Popup.this);
        }
    });

    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java

License:Open Source License

/**
 * // w ww .j  a  va 2 s  .  co  m
 * @param datahandler
 * @param request
 * @param user
 */
public void buildMainLayout(DataHandler datahandler, VaadinRequest request, String user) {
    State state = (State) UI.getCurrent().getSession().getAttribute("state");
    MultiscaleController multiscaleController = new MultiscaleController(datahandler.getOpenBisClient(), user);

    final HomeView homeView = new HomeView(datahandler, "Your Projects", user, state, resUrl,
            manager.getTmpFolder());
    DatasetView datasetView = new DatasetView(datahandler, state, resUrl);
    final SampleView sampleView = new SampleView(datahandler, state, resUrl, multiscaleController);
    // BarcodeView barcodeView =
    // new BarcodeView(datahandler.getOpenBisClient(), manager.getBarcodeScriptsFolder(),
    // manager.getBarcodePathVariable());
    final ExperimentView experimentView = new ExperimentView(datahandler, state, resUrl, multiscaleController);
    // ChangePropertiesView changepropertiesView = new ChangePropertiesView(datahandler);

    final AddPatientView addPatientView = new AddPatientView(datahandler, state, resUrl);

    final SearchResultsView searchResultsView = new SearchResultsView(datahandler, "Search results", user,
            state, resUrl);

    Submitter submitter = null;
    try {
        submitter = WorkflowSubmitterFactory.getSubmitter(Type.guseSubmitter, manager);
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    WorkflowViewController controller = new WorkflowViewController(submitter, datahandler, user);

    final ProjectView projectView = new ProjectView(datahandler, state, resUrl, controller, manager);
    final PatientView patientView = new PatientView(datahandler, state, resUrl, controller, manager);

    VerticalLayout navigatorContent = new VerticalLayout();
    // navigatorContent.setResponsive(true);

    final Navigator navigator = new Navigator(UI.getCurrent(), navigatorContent);

    navigator.addView(DatasetView.navigateToLabel, datasetView);
    navigator.addView(SampleView.navigateToLabel, sampleView);
    navigator.addView("", homeView);
    navigator.addView(ProjectView.navigateToLabel, projectView);
    // navigator.addView(BarcodeView.navigateToLabel, barcodeView);
    navigator.addView(ExperimentView.navigateToLabel, experimentView);
    navigator.addView(PatientView.navigateToLabel, patientView);
    navigator.addView(AddPatientView.navigateToLabel, addPatientView);
    navigator.addView(SearchResultsView.navigateToLabel, searchResultsView);

    setNavigator(navigator);

    // Production
    // mainLayout = new VerticalLayout();
    for (Window w : getWindows()) {
        w.setSizeFull();
    }

    mainLayout = new GridLayout(3, 3);
    mainLayout.setResponsive(true);
    mainLayout.setWidth(100, Unit.PERCENTAGE);

    mainLayout.addComponent(navigatorContent, 0, 1, 2, 1);
    mainLayout.setColumnExpandRatio(0, 0.2f);
    mainLayout.setColumnExpandRatio(1, 0.3f);
    mainLayout.setColumnExpandRatio(2, 0.5f);

    // Production
    // HorizontalLayout treeViewAndLevelView = new HorizontalLayout();
    // HorizontalLayout headerView = new HorizontalLayout();
    // headerView.setSpacing(false);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    // final HorizontalLayout labelLayout = new HorizontalLayout();
    // headerView.addComponent(buttonLayout);
    // headerView.addComponent(labelLayout);

    Button homeButton = new Button("Home");
    homeButton.setIcon(FontAwesome.HOME);
    homeButton.setResponsive(true);
    homeButton.setStyleName(ValoTheme.BUTTON_LARGE);
    homeButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            navigator.navigateTo("");
        }

    });

    // Production
    buttonLayout.addComponent(homeButton);
    // mainLayout.addComponent(homeButton, 0, 0);

    Boolean includePatientCreation = false;

    List<Project> projects = datahandler.getOpenBisClient().getOpenbisInfoService()
            .listProjectsOnBehalfOfUser(datahandler.getOpenBisClient().getSessionToken(), user);
    int numberOfProjects = 0;
    for (Project project : projects) {
        if (project.getSpaceCode().contains("IVAC")) {
            includePatientCreation = true;
        }
        numberOfProjects += 1;
    }

    // add patient button
    if (includePatientCreation) {
        Button addPatient = new Button("Add Patient");
        addPatient.setIcon(FontAwesome.PLUS);
        addPatient.setStyleName(ValoTheme.BUTTON_LARGE);
        addPatient.setResponsive(true);
        // addPatient.setStyleName("addpatient");

        addPatient.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(String.format(AddPatientView.navigateToLabel));
            }
        });

        // Production
        buttonLayout.addComponent(addPatient);
        // mainLayout.addComponent(addPatient, 1, 0);
    }

    mainLayout.addComponent(buttonLayout, 0, 0);

    Button header = new Button(String.format("Total number of projects: %s", numberOfProjects));
    header.setIcon(FontAwesome.HAND_O_RIGHT);
    header.setStyleName(ValoTheme.BUTTON_LARGE);
    header.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    // Production
    // labelLayout.addComponent(header);
    // labelLayout.setWidth(null);

    SearchEngineView searchBarView = new SearchEngineView(datahandler);

    // headerView.setWidth("100%");
    // Production
    // headerView.addComponent(searchBarView);
    // headerView.setComponentAlignment(searchBarView, Alignment.TOP_RIGHT);
    // searchBarView.setSizeUndefined();
    // treeViewAndLevelView.addComponent(navigatorContent);
    // mainLayout.addComponent(headerView);
    // mainLayout.addComponent(treeViewAndLevelView);

    mainLayout.addComponent(header, 1, 0);
    mainLayout.addComponent(searchBarView, 2, 0);

    // Production
    VerticalLayout versionLayout = new VerticalLayout();
    versionLayout.setWidth(100, Unit.PERCENTAGE);
    Label versionLabel = new Label(String.format("version: %s", version));
    Label revisionLabel = new Label(String.format("rev: %s", revision));
    revisionLabel.setWidth(null);
    versionLabel.setWidth(null);

    versionLayout.addComponent(versionLabel);
    if (!isInProductionMode()) {
        versionLayout.addComponent(revisionLabel);
    }
    // versionLayout.setMargin(new MarginInfo(true, false, false, false));
    // mainLayout.addComponent(versionLayout);
    mainLayout.addComponent(versionLayout, 0, 2, 2, 2);
    mainLayout.setRowExpandRatio(2, 1.0f);
    // mainLayout.setSpacing(true);

    versionLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_RIGHT);
    versionLayout.setComponentAlignment(revisionLabel, Alignment.BOTTOM_RIGHT);

    mainLayout.setComponentAlignment(searchBarView, Alignment.BOTTOM_RIGHT);

    setContent(mainLayout);
    // getContent().setSizeFull();

    // "Responsive design"
    /*
     * getPage().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
     * 
     * @Override public void browserWindowResized(BrowserWindowResizeEvent event) { int height =
     * event.getHeight(); int width = event.getWidth(); WebBrowser browser =
     * event.getSource().getWebBrowser(); // tv.rebuildLayout(height, width, browser); if
     * (currentView instanceof HomeView) { homeView.updateView(height, width, browser); } else if
     * (currentView instanceof ProjectView) { projectView.updateView(height, width, browser); } else
     * if (currentView instanceof ExperimentView) { experimentView.updateView(height, width,
     * browser); } else if (currentView instanceof PatientView) { patientView.updateView(height,
     * width, browser); } else if (currentView instanceof AddPatientView) {
     * addPatientView.updateView(height, width, browser); } } });
     * 
     * navigator.addViewChangeListener(new ViewChangeListener() {
     * 
     * @Override public boolean beforeViewChange(ViewChangeEvent event) { int height =
     * getPage().getBrowserWindowHeight(); int width = getPage().getBrowserWindowWidth(); WebBrowser
     * browser = getPage().getWebBrowser(); // View oldView = event.getOldView(); //
     * this.setEnabled(oldView, false);
     * 
     * currentView = event.getNewView(); if (currentView instanceof HomeView) {
     * homeView.updateView(height, width, browser); } if (currentView instanceof ProjectView) {
     * projectView.updateView(height, width, browser); } if (currentView instanceof ExperimentView)
     * { experimentView.updateView(height, width, browser); } if (currentView instanceof SampleView)
     * { sampleView.updateView(height, width, browser); } else if (currentView instanceof
     * PatientView) { patientView.updateView(height, width, browser); } else if (currentView
     * instanceof AddPatientView) { addPatientView.updateView(height, width, browser); } return
     * true; }
     * 
     * private void setEnabled(View view, boolean enabled) { // tv.setEnabled(enabled); if (view
     * instanceof HomeView) { homeView.setEnabled(enabled); } if (view instanceof ProjectView) {
     * projectView.setEnabled(enabled); } if (view instanceof ExperimentView) {
     * experimentView.setEnabled(enabled); } if (view instanceof SampleView) {
     * sampleView.setEnabled(enabled); } }
     * 
     * @Override public void afterViewChange(ViewChangeEvent event) { currentView =
     * event.getNewView(); // this.setEnabled(currentView, true); Object currentBean = null; if
     * (currentView instanceof ProjectView) { // TODO refactoring currentBean = new HashMap<String,
     * AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // Production // labelLayout.removeAllComponents(); Button header = new
     * Button(projectView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header); } else if (currentView instanceof HomeView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(homeView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header); // currentBean = projectView.getCurrentBean(); } else if
     * (currentView instanceof ExperimentView) { currentBean = experimentView.getCurrentBean();
     * 
     * } else if (currentView instanceof SampleView) { // TODO refactoring currentBean = new
     * HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(sampleView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header);
     * 
     * } else if (currentView instanceof DatasetView) { currentBean = new HashMap<String,
     * AbstractMap.SimpleEntry<String, Long>>(); } else if (currentView instanceof PatientView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new
     * Button(patientView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * // labelLayout.addComponent(header); } else if (currentView instanceof AddPatientView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(addPatientView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * // labelLayout.addComponent(header); } try { PortletSession portletSession =
     * QbicmainportletUI.getCurrent().getPortletSession(); if (portletSession != null) {
     * portletSession.setAttribute("qbic_download", currentBean, PortletSession.APPLICATION_SCOPE);
     * } } catch (NullPointerException e) { // nothing to do. during initialization that might
     * happen. Nothing to worry about }
     * 
     * 
     * }
     * 
     * });
     */

    /*
     * // go to correct page String requestParams = Page.getCurrent().getUriFragment();
     * 
     * // LOGGER.debug("used urifragement: " + requestParams); if (requestParams != null) {
     * navigator.navigateTo(requestParams.startsWith("!") ? requestParams.substring(1) :
     * requestParams); } else { navigator.navigateTo(""); }
     */
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.SearchEngineView.java

License:Open Source License

public void initUI() {

    mainlayout = new Panel();
    mainlayout.addStyleName(ValoTheme.PANEL_BORDERLESS);

    // Search bar
    // *----------- search text field .... search button-----------*
    VerticalLayout searchbar = new VerticalLayout();
    searchbar.setWidth(100, Unit.PERCENTAGE);
    setResponsive(true);/*from   w ww.jav a 2 s .  c o  m*/
    searchbar.setResponsive(true);
    // searchbar.setWidth();

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setResponsive(true);
    buttonLayout.setWidth(75, Unit.PERCENTAGE);

    // searchbar.setSpacing(true);
    final TextField searchfield = new TextField();
    searchfield.setHeight("44px");
    searchfield.setImmediate(true);
    searchfield.setResponsive(true);
    searchfield.setWidth(75, Unit.PERCENTAGE);

    buttonLayout.setSpacing(true);

    searchfield.setInputPrompt("search DB");
    // searchfield.setCaption("QSearch");
    // searchfield.setWidth(25.0f, Unit.EM);
    // searchfield.setWidth(60, Unit.PERCENTAGE);

    // TODO would be nice to have a autofill or something similar
    // searchFieldLayout.addComponent(searchfield);
    searchbar.addComponent(searchfield);
    searchbar.setComponentAlignment(searchfield, Alignment.MIDDLE_RIGHT);

    final NativeSelect navsel = new NativeSelect();
    navsel.addItem("Whole DB");
    navsel.addItem("Projects Only");
    navsel.addItem("Experiments Only");
    navsel.addItem("Samples Only");
    navsel.setValue("Whole DB");
    navsel.setHeight("20px");
    navsel.setNullSelectionAllowed(false);
    navsel.setResponsive(true);
    navsel.setWidth(100, Unit.PERCENTAGE);

    navsel.addValueChangeListener(new Property.ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -6896454887050432147L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // TODO Auto-generated method stub
            Notification.show((String) navsel.getValue());

            switch ((String) navsel.getValue()) {
            case "Whole DB":
                datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples"));
                break;
            case "Projects Only":
                datahandler.setShowOptions(Arrays.asList("Projects"));
                break;
            case "Experiments Only":
                datahandler.setShowOptions(Arrays.asList("Experiments"));
                break;
            case "Samples Only":
                datahandler.setShowOptions(Arrays.asList("Samples"));
                break;
            default:
                datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples"));
                break;
            }

        }
    });

    searchbar.addComponent(buttonLayout);
    searchbar.setComponentAlignment(buttonLayout, Alignment.MIDDLE_RIGHT);
    Button searchOk = new Button("");
    searchOk.setStyleName(ValoTheme.BUTTON_TINY);
    // searchOk.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    searchOk.setIcon(FontAwesome.SEARCH);
    searchOk.setSizeUndefined();
    // searchOk.setWidth(15.0f, Unit.EM);
    searchOk.setResponsive(true);
    searchOk.setHeight("20px");

    searchOk.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -2409450448301908214L;

        @Override
        public void buttonClick(ClickEvent event) {
            String queryString = (String) searchfield.getValue().toString();

            LOGGER.debug("the query was " + queryString);

            if (searchfield.getValue() == null || searchfield.getValue().toString().equals("")
                    || searchfield.getValue().toString().trim().length() == 0) {
                Notification.show("Query field was empty!", Type.WARNING_MESSAGE);
            } else {

                try {
                    /**
                     * Sample foundSample = datahandler.getOpenBisClient() .getSampleByIdentifier(
                     * matcher.group(0).toString());
                     */

                    datahandler.setSampleResults(querySamples(queryString));
                    datahandler.setExpResults(queryExperiments(queryString));
                    datahandler.setProjResults(queryProjects(queryString));
                    datahandler.setLastQueryString(queryString);

                    State state = (State) UI.getCurrent().getSession().getAttribute("state");
                    ArrayList<String> message = new ArrayList<String>();
                    message.add("clicked");
                    message.add("view" + queryString);
                    message.add("searchresults");
                    state.notifyObservers(message);

                } catch (Exception e) {
                    LOGGER.error("after query: ", e);
                    Notification.show("No Sample found for given barcode.", Type.WARNING_MESSAGE);
                }
            }

        }

    });

    // setClickShortcut() would add global shortcut, instead we
    // 'scope' the shortcut to the panel:
    mainlayout.addAction(new com.vaadin.ui.Button.ClickShortcut(searchOk, KeyCode.ENTER));
    // searchfield.addItems(this.getSearchResults("Q"));
    searchfield.setDescription(infotext);
    searchfield.addValidator(new NullValidator("Field must not be empty", false));
    searchfield.setValidationVisible(false);

    buttonLayout.addComponent(navsel);
    // buttonLayout.addComponent(new Label(""));
    buttonLayout.addComponent(searchOk);

    // searchFieldLayout.setComponentAlignment(searchOk, Alignment.TOP_RIGHT);
    // buttonLayout.setExpandRatio(searchOk, 1);
    // buttonLayout.setExpandRatio(navsel, 1);

    // searchFieldLayout.setSpacing(true);
    buttonLayout.setComponentAlignment(searchOk, Alignment.BOTTOM_RIGHT);
    // buttonLayout.setComponentAlignment(navsel, Alignment.BOTTOM_LEFT);

    buttonLayout.setExpandRatio(searchOk, 1);
    buttonLayout.setExpandRatio(navsel, 2);

    // searchbar.setMargin(new MarginInfo(true, false, true, false));
    mainlayout.setContent(searchbar);
    // mainlayout.setComponentAlignment(searchbar, Alignment.MIDDLE_RIGHT);
    // mainlayout.setWidth(100, Unit.PERCENTAGE);
    setCompositionRoot(mainlayout);
}

From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java

public ArchiveView() {
    HorizontalLayout optionsLayout = new HorizontalLayout();
    optionsLayout.setWidth("100%");

    Grid<Clipping> gridClippings = new Grid<>();
    Set<Clipping> clippings = ClippingUtils.getUserClippings(UserUtils.getCurrent(),
            LocalDate.now(ZoneId.of("Europe/Berlin")));
    gridClippings.setItems(clippings);// w  w w .j ava  2s .  co m

    InlineDateTimeField datePicker = new InlineDateTimeField();
    datePicker.setValue(LocalDateTime.now(ZoneId.of("Europe/Berlin")));
    datePicker.setLocale(Locale.GERMANY);
    datePicker.setResolution(DateTimeResolution.DAY);
    datePicker.addValueChangeListener(date -> {
        Set<Clipping> clippingsOfDate = ClippingUtils.getUserClippings(UserUtils.getCurrent(),
                date.getValue().toLocalDate());
        gridClippings.setItems(clippingsOfDate);
        gridClippings.getDataProvider().refreshAll();
    });

    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM);
    formatter.withZone(ZoneId.of("Europe/Berlin"));
    Column columnTime = gridClippings.addColumn(c -> {
        return c.getDate().format(formatter);
    });
    Language.setCustom(Word.TIME, s -> columnTime.setCaption(s));
    Column columnAmountArticles = gridClippings.addColumn(c -> {
        long amountArticles = c.getArticles().values().stream().flatMap(l -> l.stream()).count();
        amountArticles += c.getArticlesFromGroup().values().stream().flatMap(l -> l.stream()).count();
        if (amountArticles != 1) {
            return amountArticles + " " + Language.get(Word.ARTICLES);
        } else {
            return amountArticles + " " + Language.get(Word.ARTICLE);
        }
    });
    Language.setCustom(Word.ARTICLES, s -> {
        columnAmountArticles.setCaption(s);
        gridClippings.getDataProvider().refreshAll();
    });

    gridClippings.setHeight("100%");
    gridClippings.setSelectionMode(Grid.SelectionMode.SINGLE);
    gridClippings.addSelectionListener(c -> {
        if (c.getFirstSelectedItem().isPresent()) {
            currentClipping = c.getFirstSelectedItem().get();
            showClippingBy(currentClipping, currentSort);
        }
    });

    optionsLayout.addComponents(datePicker, gridClippings);
    optionsLayout.setComponentAlignment(datePicker, Alignment.BOTTOM_CENTER);
    optionsLayout.setComponentAlignment(gridClippings, Alignment.BOTTOM_RIGHT);
    optionsLayout.setExpandRatio(gridClippings, 5);

    VerticalLayout sortLayout = new VerticalLayout();

    comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY));
    Language.setCustom(Word.SORT_BY, s -> {
        comboBoxSortOptions.setCaption(s);
        comboBoxSortOptions.getDataProvider().refreshAll();
    });
    comboBoxSortOptions.setItems(EnumSet.allOf(ClippingView.SortOptions.class));
    comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName());
    comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon());
    comboBoxSortOptions.setValue(currentSort);
    comboBoxSortOptions.setTextInputAllowed(false);
    comboBoxSortOptions.setEmptySelectionAllowed(false);
    comboBoxSortOptions.addStyleName("comboboxsort");
    comboBoxSortOptions.addValueChangeListener(e -> {
        currentSort = e.getValue();
        showClippingBy(currentClipping, currentSort);
    });
    comboBoxSortOptions.setVisible(false);

    sortLayout.setMargin(false);
    sortLayout.setSpacing(false);
    sortLayout.addComponent(comboBoxSortOptions);

    clippingArticlesLayout = new VerticalLayout();
    clippingArticlesLayout.setSpacing(true);
    clippingArticlesLayout.setMargin(false);
    clippingArticlesLayout.setSizeFull();

    addComponents(optionsLayout, sortLayout, clippingArticlesLayout);
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.login.LogInScreenViewImplv2.java

License:Open Source License

/**
 * Diese Methode setzt den Titel (im Browser-Fenster) zu
 * "Business Horizon 2" und erstellt die LogIn Maske mit Listener. Der
 * Listener prft ruft die im LogIn Event gesammelten LogIn-Daten und
 * bergibt sie dem presenter zur Kontrolle. Je nach ausgang der Konrolle
 * wird dann eine Fehlermeldung aufgerufen. Zudem wird mittels dem
 * "registrieren" Button und dessen Listener eine Dialogfenster
 * bereitgestellt mit dessen sich ein neuer Anwender registrieren kann.
 * /*from   w ww.ja v a 2s.  c  o  m*/
 * @author Christian Scherer
 */
private void generateUi() {
    setCaption("Business Horizon 3");
    logger.debug("berschrift fr Browser erstellt");

    horizontal = new HorizontalLayout();

    vSplitPanel = new VerticalSplitPanel();
    vSplitPanel.setSplitPosition(70, Sizeable.UNITS_PERCENTAGE);
    vSplitPanel.setLocked(true);

    verticalTop = new VerticalLayout();
    verticalTop.setSizeFull();
    verticalTop.setMargin(true, true, true, true);
    verticalTop.setStyleName("loginTop");

    //Erzeugt ein Label mit dem Willkommens-Text neben dem Logo
    welcome = new Label("Willkommen bei");
    welcome.setStyleName("welcomeSlogan");

    //Erezeugt ein Label mit dem Beschreibungstext
    welcomeText = new Label(
            "Mithilfe dieser Software knnen Sie Ihre zuknftige Unternehmenswerte berechnen lassen. Hierzu stehen Ihnen verschiedene Methoden zur Verfgung, die Ihnen unterschiedliche Herangehensweisen ermglichen  je nachdem, welche Daten Ihnen zur Verfgung stehen. ");
    welcomeText.setStyleName("welcomeText");
    welcomeText.setSizeFull();

    textLayout = new HorizontalLayout();
    textLayout.setWidth(50, Sizeable.UNITS_PERCENTAGE);
    textLayout.addComponent(welcomeText);
    textLayout.setComponentAlignment(welcomeText, Alignment.TOP_RIGHT);

    iconLabel = new Label();
    iconLabel.setIcon(new ThemeResource("images/Logo_businesshorizon.png"));
    iconLabel.setWidth(40, Sizeable.UNITS_PERCENTAGE);
    iconLabel.setStyleName("logo");

    welcomeLayout = new HorizontalLayout();
    welcomeLayout.setSizeFull();
    welcomeLayout.addComponent(welcome);
    welcomeLayout.setComponentAlignment(welcome, Alignment.BOTTOM_CENTER);

    welcomeLayout.addComponent(iconLabel);
    welcomeLayout.setComponentAlignment(iconLabel, Alignment.BOTTOM_RIGHT);

    //Fgt den Beschreibungs-Text dem Bildschirm hinzu
    verticalTop.addComponent(textLayout);
    verticalTop.setComponentAlignment(textLayout, Alignment.TOP_RIGHT);

    verticalTop.addComponent(welcomeLayout);
    verticalTop.setComponentAlignment(welcomeLayout, Alignment.BOTTOM_RIGHT);

    login = new LoginForm();
    //Zur Anmeldung muss die Mailadresse als Benutzername angegeben werden
    login.setUsernameCaption("Mailadresse");
    login.setPasswordCaption("Passwort");
    login.setWidth(null);
    login.setStyleName("login_form");
    login.addListener(new LoginForm.LoginListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onLogin(LoginEvent event) {
            presenter.doLogin(event.getLoginParameter("username"), event.getLoginParameter("password"));

        }
    });

    //VerticalLayout login = generateLogin();

    horizontal.addComponent(login);
    horizontal.setComponentAlignment(login, Alignment.TOP_CENTER);

    HorizontalLayout landingBtnLayout = new HorizontalLayout();

    loginBtnLayout = new VerticalLayout();
    loginBtn = new Button("", this);
    loginBtn.setWidth(100, Sizeable.UNITS_PIXELS);
    loginBtn.setHeight(100, Sizeable.UNITS_PIXELS);
    loginBtn.addStyleName("loginBtn");

    loginBtnLabel = new Label("Login");
    loginBtnLabel.setWidth(100, Sizeable.UNITS_PIXELS);
    loginBtnLabel.addStyleName("loginBtnLabel");

    loginBtnLayout.addComponent(loginBtn);
    loginBtnLayout.addComponent(loginBtnLabel);

    //      landingBtnLayout.addComponent(loginBtnLayout);

    //horizontal.addComponent(loginBtnLayout);
    //horizontal.setComponentAlignment(loginBtnLayout, Alignment.TOP_RIGHT);

    registerBtnLayout = new VerticalLayout();
    registerBtnLayout.setSizeUndefined();

    registerBtn = new Button("", this);
    registerBtn.setSizeUndefined();
    registerBtn.setHeight(100, Sizeable.UNITS_PIXELS);
    registerBtn.setWidth(100, Sizeable.UNITS_PIXELS);
    registerBtn.addStyleName("registerBtn");

    registerBtnLabel = new Label("Registrieren");
    registerBtnLabel.setWidth(100, Sizeable.UNITS_PIXELS);
    addStyleName("registerBtnLabel");

    registerBtnLayout.addComponent(registerBtn);
    registerBtnLayout.addComponent(registerBtnLabel);

    landingBtnLayout.addComponent(registerBtnLayout);

    passwordForgotBtn = new Button("Passwort vergessen", this);
    passwordForgotBtn.setEnabled(false);

    horizontal.addComponent(landingBtnLayout);
    horizontal.setComponentAlignment(landingBtnLayout, Alignment.TOP_RIGHT);
    horizontal.setMargin(new MarginInfo(true, true, true, true));
    horizontal.setSizeFull();
    //vertical.addComponent(passwordForgotBtn);
    //vertical.setComponentAlignment(passwordForgotBtn, Alignment.MIDDLE_CENTER);

    logger.debug("LogIn UI erstellt und Listener gesetzt");

    vSplitPanel.setFirstComponent(verticalTop);
    vSplitPanel.setSecondComponent(horizontal);

    setContent(vSplitPanel);
}

From source file:edu.kit.dama.ui.admin.administration.user.MembershipRoleEditorWindow.java

License:Apache License

/**
 * Get the main layout.//from  w  ww  .  j  a va  2 s .  com
 *
 * @return The main layout.
 */
private GridLayout getMainLayout() {
    if (mainPanel == null) {
        String id = "mainPanel";
        LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

        UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2);

        builder.addComponent(getMembershipsTable(), 0, 0);
        Label l = new Label(
                "To update the membership role of the selected group(s) select the new role below and click <i>'Apply New Role'</i>. The new role is limited by the user's maximum role.",
                ContentMode.HTML);
        Label spacer = new Label("<br/>", ContentMode.HTML);

        Button closeButton = new Button("Close");
        closeButton.addClickListener((event) -> {
            close();
        });

        VerticalLayout actionLayout = new VerticalLayout(l, spacer, getRoleComboBox(), getCommitChangeButton());
        actionLayout.setComponentAlignment(l, Alignment.TOP_CENTER);
        actionLayout.setComponentAlignment(getRoleComboBox(), Alignment.TOP_RIGHT);
        actionLayout.setComponentAlignment(getCommitChangeButton(), Alignment.TOP_RIGHT);
        actionLayout.setComponentAlignment(getCommitChangeButton(), Alignment.TOP_RIGHT);
        actionLayout.setSpacing(true);
        actionLayout.setSizeFull();

        builder.addComponent(actionLayout, 1, 0);
        builder.addComponent(closeButton, Alignment.BOTTOM_RIGHT, 1, 1, 1, 1);

        mainPanel = builder.getLayout();
        mainPanel.setId(DEBUG_ID_PREFIX + id);
        mainPanel.setSizeFull();

        mainPanel.setColumnExpandRatio(0, .7f);
        mainPanel.setColumnExpandRatio(1, .3f);
        mainPanel.setRowExpandRatio(0, .99f);
        mainPanel.setRowExpandRatio(1, .01f);
        mainPanel.setSpacing(true);
        mainPanel.setMargin(true);
        updateMainPanel();
    }
    return mainPanel;
}