Example usage for com.vaadin.ui VerticalLayout setComponentAlignment

List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:de.fatalix.app.view.login.LoginView.java

public LoginView() {
    CssLayout rootLayout = new CssLayout();
    rootLayout.addStyleName("login-screen");

    Component loginForm = buildLoginForm();
    VerticalLayout centeringLayout = new VerticalLayout();
    centeringLayout.setStyleName("centering-layout");
    centeringLayout.addComponent(loginForm);
    centeringLayout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    CssLayout loginInformation = buildLoginInformation();

    rootLayout.addComponent(centeringLayout);
    rootLayout.addComponent(loginInformation);

    setCompositionRoot(rootLayout);//from  w  w w.  jav  a  2s.c o m
}

From source file:de.fatalix.bookery.AppHeader.java

License:Open Source License

private MHorizontalLayout createSmallNavBar() {
    Button homeButton = new Button("Home", new Button.ClickListener() {
        @Override//from   ww  w. j a  va2s. com
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(HomeView.id);
            //bookMenuLayout.setLayoutVisible(true);
        }
    });
    homeButton.addStyleName(ValoTheme.BUTTON_TINY);
    Button plainSearchButton = new Button("einfach stbern", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(SearchView.id + "/author");
        }
    });
    plainSearchButton.addStyleName(ValoTheme.BUTTON_TINY);
    Button newBooks = new Button("neue Bcher", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(SearchView.id + "/author/true");
        }
    });
    newBooks.addStyleName(ValoTheme.BUTTON_TINY);
    Button bestBooks = new Button("Die besten Bcher", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).getNavigator().navigateTo(SearchView.id + "/likes");
        }
    });
    bestBooks.addStyleName(ValoTheme.BUTTON_TINY);

    logoutButton = new Button("Hallo", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ((App) UI.getCurrent()).logout();
        }
    });
    logoutButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    logoutButton.addStyleName(ValoTheme.BUTTON_SMALL);

    VerticalLayout buttonLayout = new VerticalLayout(logoutButton);
    buttonLayout.setMargin(false);
    buttonLayout.setSpacing(false);
    buttonLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);

    MHorizontalLayout layout = new MHorizontalLayout(homeButton, plainSearchButton, newBooks, bestBooks,
            buttonLayout);
    layout.expand(buttonLayout);

    return layout;
}

From source file:de.fatalix.bookery.view.admin.AdminView.java

License:Open Source License

public HorizontalLayout createUserManagement() {
    userManagementLayout = new HorizontalLayout();
    userManagementLayout.addStyleName("wrapping");
    userManagementLayout.setSpacing(true);
    userManagementLayout.setMargin(true);

    Label label = new Label("Add new user...");
    label.setSizeUndefined();//  ww w  .jav a  2 s . c  o m
    label.addStyleName(ValoTheme.LABEL_LARGE);
    VerticalLayout emptyLayout = new VerticalLayout(label);
    emptyLayout.addStyleName("dashed-border");
    emptyLayout.setWidth(380, Unit.PIXELS);
    emptyLayout.setHeight(220, Unit.PIXELS);
    emptyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    emptyLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            AppUser appUser = presenter.createNewUser();
            AppUserCard appUserCard = appUserCardInstances.get();
            appUserCard.loadAppUser(appUser);
            appUserCard.addAppUserCardListener(AdminView.this);
            userManagementLayout.addComponent(appUserCard, userManagementLayout.getComponentCount() - 1);
        }
    });
    userManagementLayout.addComponent(emptyLayout);
    return userManagementLayout;
}

From source file:de.fatalix.bookery.view.admin.BatchJobsLayout.java

private Layout createEmptyLayout() {
    Label label = new Label("Add new job...");
    label.setSizeUndefined();/*from w  w  w  .j  a va  2 s  . co  m*/
    label.addStyleName(ValoTheme.LABEL_LARGE);

    VerticalLayout emptyLayout = new VerticalLayout(label);
    emptyLayout.addStyleName("dashed-border");
    emptyLayout.setWidth(380, Unit.PIXELS);
    emptyLayout.setHeight(220, Unit.PIXELS);
    emptyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    emptyLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            BatchJobConfiguration jobConfig = presenter.createBatchJob();
            BatchJobCard batchJobCard = batchJobCardInstances.get();
            batchJobCard.load(jobConfig);
            batchJobCard.addBatchJobCardListener(BatchJobsLayout.this);
            batchJobLayout.addComponent(batchJobCard, batchJobLayout.getComponentCount() - 1);
        }
    });
    return emptyLayout;
}

From source file:de.fatalix.bookery.view.common.BookDetailLayout.java

License:Open Source License

private HorizontalLayout createImageLayout() {
    image = new Image();
    image.setImmediate(true);/*  ww w .j a v  a2  s. c  o  m*/
    image.setHeight("200px");
    image.setWidth("130px");

    downloadButton = new Button("download", FontAwesome.DOWNLOAD);
    downloadButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    downloadButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                loadData(presenter.updateShared(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString()));
            } catch (SolrServerException | IOException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    fileDownloader = new FileDownloader(new StreamResource(new BookStreamSource(null), "blbla.epub"));
    fileDownloader.extend(downloadButton);

    sendToKindleButton = new Button("Kindle", FontAwesome.BOOK);
    sendToKindleButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    sendToKindleButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.shareBookWithKindle(bookEntry, SecurityUtils.getSubject().getPrincipal().toString());
                Notification.show("Book is sent to kindle", Notification.Type.HUMANIZED_MESSAGE);
                loadData(presenter.updateShared(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString()));
            } catch (SolrServerException | IOException | MessagingException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    likeButton = new Button("0 likes", FontAwesome.THUMBS_O_UP);
    likeButton.addStyleName(ValoTheme.BUTTON_LINK);
    likeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                BookEntry updatedEntry = presenter.updateLike(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString());
                loadData(updatedEntry);
            } catch (SolrServerException | IOException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    watchListButton = new Button("merken", FontAwesome.STAR_O);
    watchListButton.addStyleName(ValoTheme.BUTTON_LINK);
    watchListButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            presenter.addRemoveFromWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString());
            loadData(bookEntry);
        }
    });
    downloadCount = new Label("0 downloads");

    VerticalLayout rightLayout = new VerticalLayout(sendToKindleButton, downloadButton, watchListButton,
            likeButton, downloadCount);
    rightLayout.setComponentAlignment(downloadCount, Alignment.MIDDLE_CENTER);
    rightLayout.setSpacing(true);

    HorizontalLayout layout = new HorizontalLayout(image, rightLayout);
    layout.setSpacing(true);
    return layout;
}

From source file:de.fatalix.bookery.view.common.BookSearchLayout.java

License:Open Source License

private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) {
    Image image = new Image();
    image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor());
    image.setHeight("200px");
    image.setWidth("130px");
    image.setImmediate(true);/*from  w  w w.j a  va  2 s  .  com*/
    if (bookEntry.getThumbnail() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail());
        image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png"));
    } else if (bookEntry.getCover() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover());
        image.setSource(new StreamResource(source, bookEntry.getId() + ".png"));
    }

    final MButton watchListButton = new MButton()
            .withIcon(presenter.isOnWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString())
                    ? FontAwesome.STAR
                    : FontAwesome.STAR_O)
            .withStyleName(ValoTheme.BUTTON_LINK);
    watchListButton.addStyleName("quick-action");

    watchListButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            watchListButton.setIcon(presenter.addRemoveFromWatchList(bookEntry,
                    SecurityUtils.getSubject().getPrincipal().toString()) ? FontAwesome.STAR
                            : FontAwesome.STAR_O);
        }
    });

    final MButton likeButton = new MButton().withCaption("" + bookEntry.getLikes())
            .withIcon(FontAwesome.THUMBS_O_UP).withStyleName(ValoTheme.BUTTON_LINK);
    likeButton.addStyleName("quick-action");

    likeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                BookEntry updatedBook = presenter.updateLike(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString());
                bookEntry.setLikes(updatedBook.getLikes());
                bookEntry.setLikedby(updatedBook.getLikedby());
                likeButton.setCaption("" + bookEntry.getLikes());
            } catch (SolrServerException | IOException ex) {
                java.util.logging.Logger.getLogger(BookSearchLayout.class.getName()).log(Level.SEVERE, null,
                        ex);
            }

        }
    });
    final MButton downloadsButton = new MButton().withCaption("" + bookEntry.getDownloads())
            .withIcon(FontAwesome.DOWNLOAD).withStyleName(ValoTheme.BUTTON_LINK);
    downloadsButton.addStyleName("quick-action");
    HorizontalLayout quickActionLayout = new HorizontalLayout(watchListButton, likeButton, downloadsButton);
    quickActionLayout.addStyleName("quick-action-layout");

    VerticalLayout result = new VerticalLayout(image, quickActionLayout);
    //result.setHeight("210px");
    //result.setWidth("140px");
    result.addStyleName("pointer-cursor");
    result.addStyleName("book-card");
    result.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            bookDetailLayout.loadData(bookEntry);
            bookDetailLayout.setLayoutVisible(true);
            //BookDetailDialog dialogInstance = bookDetail.get();
            //dialogInstance.loadData(bookEntry);
            //UI.getCurrent().addWindow(dialogInstance);
        }
    });
    return result;
}

From source file:de.fatalix.bookery.view.common.SuggestLaneLayout.java

License:Open Source License

private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) {
    Image image = new Image();
    image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor());
    image.setHeight("200px");
    image.setWidth("130px");
    image.setImmediate(true);/*from  w w w  .j  a  v  a 2s.  c o  m*/
    if (bookEntry.getThumbnail() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail());
        image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png"));
    } else if (bookEntry.getCover() != null) {
        StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover());
        image.setSource(new StreamResource(source, bookEntry.getId() + ".png"));
    }

    VerticalLayout result = new VerticalLayout(image);
    result.setHeight("210px");
    result.addStyleName("pointer-cursor");
    result.addStyleName("book-cover");
    result.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            bookDetailLayout.loadData(bookEntry);
            bookDetailLayout.setLayoutVisible(true);
        }
    });
    return result;
}

From source file:de.fatalix.bookery.view.common.SuggestLaneLayout.java

License:Open Source License

private VerticalLayout createEmptyDummy() {
    Label label = new Label("hab nix gfundn");
    label.addStyleName(ValoTheme.LABEL_H2);
    label.addStyleName(ValoTheme.LABEL_COLORED);
    label.setSizeUndefined();// w  w  w. j ava 2 s.c  o  m
    VerticalLayout dummyLayout = new VerticalLayout(label);
    dummyLayout.setHeight("150px");
    dummyLayout.setWidth("800px");
    dummyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    return dummyLayout;
}

From source file:de.fatalix.bookery.view.login.LoginView.java

License:Open Source License

public LoginView() {
    setSizeFull();/* ww w  .  j a v a2s.  c  om*/
    CssLayout rootLayout = new CssLayout();
    rootLayout.addStyleName("login-screen");

    Component loginForm = buildLoginForm();

    VerticalLayout centeringLayout = new VerticalLayout();
    centeringLayout.setStyleName("centering-layout");
    centeringLayout.addComponent(loginForm);
    centeringLayout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    CssLayout loginInformation = buildLoginInformation();

    rootLayout.addComponent(centeringLayout);
    rootLayout.addComponent(loginInformation);

    setCompositionRoot(rootLayout);

}

From source file:de.fzi.fhemapi.view.vaadin.ui.DeviceDetailsPanel.java

License:Apache License

@AutoGenerated
private VerticalLayout buildMainLayout() {
    // common part: create layout
    VerticalLayout layout = new VerticalLayout();
    layout.setImmediate(false);/*from   w  ww. j a va2s  .c  om*/
    layout.setWidth("100.0%");
    layout.setHeight("-1");
    layout.setMargin(false);

    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setImmediate(false);
    titleLayout.setWidth("-1");
    titleLayout.setHeight("50");
    titleLayout.setMargin(false);
    layout.addComponent(titleLayout);
    layout.setComponentAlignment(titleLayout, Alignment.TOP_CENTER);

    // deviceTitle
    deviceTitle = new TextField();
    deviceTitle.setImmediate(true);
    deviceTitle.setWidth("100%");
    deviceTitle.setHeight("-1px");
    deviceTitle.setValue(device.getName());
    deviceTitle.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (((String) event.getProperty().getValue()).length() > 1) {
                device.rename((String) event.getProperty().getValue());
                parent.reloadTree();
            }
        }
    });
    titleLayout.addComponent(deviceTitle);
    titleLayout.setComponentAlignment(deviceTitle, Alignment.TOP_CENTER);

    ComboBox combobox = new ComboBox();
    String[] classes = DeviceFactory.getAvailableDevicetypes();
    for (String name : classes) {
        combobox.addItem(name);
    }
    combobox.select(device.getClass().getSimpleName());
    combobox.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            setDeviceType((String) event.getProperty().getValue());
        }
    });
    combobox.setImmediate(true);

    deviceTypeHoriLayout = UIHelper.buildAttributePanel("Device Type", combobox);
    layout.addComponent(deviceTypeHoriLayout);
    layout.setComponentAlignment(deviceTypeHoriLayout, Alignment.TOP_CENTER);
    layout.setExpandRatio(deviceTypeHoriLayout, 1);

    ioDevHoriLayout = buildAttributePanel("IO Device", device.getType());
    layout.addComponent(ioDevHoriLayout);
    layout.setComponentAlignment(ioDevHoriLayout, Alignment.TOP_CENTER);
    layout.setExpandRatio(ioDevHoriLayout, 1);

    addDeviceDetails(DevicePanelManager.getDeviceDetails(device, this), layout);

    return layout;
}