Example usage for com.vaadin.ui Alignment MIDDLE_CENTER

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

Introduction

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

Prototype

Alignment MIDDLE_CENTER

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

Click Source Link

Usage

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initPicture() {
    StreamResource imageresource = new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 1L;

        public InputStream getStream() {
            return picture.getInputStream();
        }//from   w  ww. java 2s .  c  om
    }, user.getId());
    imageresource.setCacheTime(0);

    Embedded picture = new Embedded(null, imageresource);
    picture.setType(Embedded.TYPE_IMAGE);
    picture.setHeight(200, UNITS_PIXELS);
    picture.setWidth(200, UNITS_PIXELS);
    picture.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);

    imageLayout.addComponent(picture);
    imageLayout.setWidth(picture.getWidth() + 5, picture.getWidthUnits());

    // Change picture button
    if (isCurrentLoggedInUser) {
        Upload changePictureButton = initChangePictureButton();
        imageLayout.addComponent(changePictureButton);
        imageLayout.setComponentAlignment(changePictureButton, Alignment.MIDDLE_CENTER);
    }
}

From source file:com.klwork.explorer.web.MyNavigationUI.java

License:Apache License

/**
 * Exception on action/* w ww. ja  v a2 s  . c o m*/
 */
@Override
public void error(com.vaadin.server.ErrorEvent event) {
    // connector event
    if (event.getThrowable().getCause() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable().getCause();
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);

        // Cleanup view. Now Vaadin ignores errors and always shows the view.  :-(
        // since beta10
        setContent(null);
        return;
    }

    // Error on page load. Now it doesn't work. User sees standard error page.
    if (event.getThrowable() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable();

        Label label = new Label(exception.getMessage());
        label.setWidth(-1, Unit.PERCENTAGE);

        Link goToMain = new Link("Go to main", new ExternalResource("/"));

        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(label);
        layout.addComponent(goToMain);
        layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER);

        VerticalLayout mainLayout = new VerticalLayout();
        mainLayout.setSizeFull();
        mainLayout.addComponent(layout);
        mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

        setContent(mainLayout);
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);
        return;
    }

    DefaultErrorHandler.doDefault(event);
}

From source file:com.liferay.mail.vaadin.PasswordPrompt.java

License:Open Source License

public PasswordPrompt(Account account) {
    this.account = account;

    setCaption(Lang.get("please-enter-your-password-for-x", new String[] { account.getAddress() }));
    setWidth("400px");
    setResizable(false);/*from   w w w . j av  a2 s  .co  m*/
    setModal(true);
    setClosable(false);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    password.setSecret(true);
    password.setWidth("100%");
    addComponent(password);

    savePassword.setValue(account.isSavePassword());
    addComponent(savePassword);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(loginBtn);
    buttons.setComponentAlignment(loginBtn, Alignment.MIDDLE_CENTER);
    buttons.addComponent(cancelBtn);
    buttons.setComponentAlignment(cancelBtn, Alignment.MIDDLE_CENTER);
    addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

}

From source file:com.lizardtech.expresszip.vaadin.MapToolbarViewComponent.java

License:Apache License

public MapToolbarViewComponent() {
    hznToolbar.setMargin(true);//w w w  . j  a va2 s .  co m
    hznToolbar.setSpacing(true);

    help = new ExpressZipButton("Help", Style.MENU, this);
    restart = new ExpressZipButton("Start Over", Style.MENU, this);

    txtZoomTo.setInputPrompt("Search...");
    txtZoomTo.setDescription("Geocoding courtesy of Open Street Map");
    txtZoomTo.addStyleName("searchbox");
    txtZoomTo.setWidth("260px");
    txtZoomTo.setImmediate(true);

    btnJobQueueStatus.setDescription("Job Manager");
    ThemeResource gear = new ThemeResource("img/JobManagementStandard23px.png");
    btnJobQueueStatus.setIcon(gear);
    btnJobQueueStatus.setStyleName(Button.STYLE_LINK);
    btnJobQueueStatus.addListener(this);

    Embedded logo = new Embedded(null, new ThemeResource("img/ExpZip_Logo161x33px.png"));
    hznToolbar.addComponent(logo);
    hznToolbar.setComponentAlignment(logo, Alignment.MIDDLE_LEFT);
    hznToolbar.setExpandRatio(logo, 0.35f);
    hznToolbar.addComponent(txtZoomTo);
    hznToolbar.setComponentAlignment(txtZoomTo, Alignment.MIDDLE_LEFT);
    hznToolbar.setExpandRatio(txtZoomTo, 0.25f);
    hznToolbar.addComponent(help);
    hznToolbar.setComponentAlignment(help, Alignment.MIDDLE_RIGHT);
    hznToolbar.setExpandRatio(help, 0.3f);
    hznToolbar.addComponent(restart);
    hznToolbar.setComponentAlignment(restart, Alignment.MIDDLE_LEFT);
    hznToolbar.setExpandRatio(restart, 0.15f);
    hznToolbar.addComponent(btnJobQueueStatus);
    hznToolbar.setComponentAlignment(btnJobQueueStatus, Alignment.MIDDLE_CENTER);
    hznToolbar.setExpandRatio(btnJobQueueStatus, 0.15f);

    hznToolbar.setSizeFull();

    hznToolbar.addStyleName("header");

    setCompositionRoot(hznToolbar);

    // textFieldListener puts a marker with given input
    txtZoomTo.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = 8461586871780709805L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            String target = txtZoomTo.getValue().toString();
            markAddress(target);
        }
    });
}

From source file:com.lst.deploymentautomation.vaadin.core.AppView.java

License:Open Source License

/**
 * Sets the view content.//w  ww.j a va 2s  . co  m
 * @param content
 */
protected void setContent(Component content) {
    while (layout.getComponentCount() > 1) {
        layout.removeComponent(layout.getComponent(1));
    }

    try {
        layout.addComponent(content);
        layout.setExpandRatio(content, 1);
        content.setSizeFull();

    } catch (RuntimeException e) {
        //remove the invalid content
        layout.removeComponent(content);

        //add a sad face to show how sorry we are
        Label fail = new Label(":-(");
        fail.addStyleName("screen-failed-to-render");
        layout.addComponent(fail);
        layout.setExpandRatio(fail, 1);
        layout.setComponentAlignment(fail, Alignment.MIDDLE_CENTER);

        throw e;
    }
}

From source file:com.m1kah.ui.TodoComponent.java

License:Open Source License

private void initFooter() {
    itemsLeftLabel = new Label("0 items left");
    filterOptionGroup = new OptionGroup();
    filterOptionGroup.setId("filter-radio");
    for (TodoFilter todoFilter : TodoFilter.values()) {
        filterOptionGroup.addItem(todoFilter);
    }//from  w  ww.  ja  v a 2 s.c o  m
    filterOptionGroup.setValue(filter);
    clearCompletedButton = new Button("Clear completed");

    HorizontalLayout footerLayout = new HorizontalLayout(itemsLeftLabel, filterOptionGroup,
            clearCompletedButton);
    footerLayout.setWidth(100.0f, Unit.PERCENTAGE);
    footerLayout.setComponentAlignment(itemsLeftLabel, Alignment.MIDDLE_LEFT);
    footerLayout.setComponentAlignment(filterOptionGroup, Alignment.MIDDLE_CENTER);
    footerLayout.setComponentAlignment(clearCompletedButton, Alignment.MIDDLE_RIGHT);
    footerLayout.setExpandRatio(itemsLeftLabel, 0.25f);
    footerLayout.setExpandRatio(filterOptionGroup, 0.5f);
    footerLayout.setExpandRatio(clearCompletedButton, 0.25f);
    addComponent(footerLayout);
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds audio library for current filter.
 * //from   w w  w . ja  va 2  s  .co  m
 * @param grid
 *            The object to locate the audio covers.
 * @param filter
 *            The filter to extract need music files.
 */
private void buildAudioLibrary(GridLayout grid, String filter) {
    AudioCollection audio = new AudioCollection();

    for (final AudioFile audioFile : audio.getAudioCollection(filter)) {

        CssLayout select = new CssLayout();
        select.addStyleName(Runo.CSSLAYOUT_SELECTABLE);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createImageCover(audioFile.getCover()));
        select.addComponent(musicFile);

        musicFile.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 5789650754220216969L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                buildInformationPanel(audioFile);
            }
        });

        grid.addComponent(select);
        grid.setComponentAlignment(select, Alignment.MIDDLE_CENTER);
    }

    Label text = new Label("Note: This track are on Crative Common license.");
    text.addStyleName(Runo.LABEL_SMALL);
    text.setWidth("90%");
    grid.addComponent(text);
    grid.setComponentAlignment(text, Alignment.MIDDLE_CENTER);

}

From source file:com.mcparland.john.AligningDemo.java

License:Apache License

public AligningDemo() {
    final Button leftButton = new Button("Top Left");
    addComponent(leftButton);/*from  w  w  w .  j  a v  a2s  .  c o  m*/
    setComponentAlignment(leftButton, Alignment.TOP_LEFT);

    final Button centerButton = new Button("Middle Center");
    addComponent(centerButton);
    setComponentAlignment(centerButton, Alignment.MIDDLE_CENTER);

    final Button rightButton = new Button("Bottom Right");
    addComponent(rightButton);
    setComponentAlignment(rightButton, Alignment.BOTTOM_RIGHT);

    setMargin(true);
    setSizeFull();
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.about.AboutView.java

License:Apache License

public AboutView() {
    CustomLayout aboutContent = new CustomLayout("aboutview");
    aboutContent.setStyleName("about-content");

    // you can add Vaadin components in predefined slots in the custom
    // layout//from ww w. j av a2 s .c om
    aboutContent.addComponent(new Label(
            FontAwesome.INFO_CIRCLE.getHtml() + " This application is using Vaadin " + Version.getFullVersion(),
            ContentMode.HTML), "info");

    setSizeFull();
    setStyleName("about-view");
    addComponent(aboutContent);
    setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER);
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private void buildUI() {
    addStyleName("login-screen");

    // login form, centered in the available part of the screen
    Component loginForm = buildLoginForm();

    // layout to center login form when there is sufficient screen space
    // - see the theme for how this is made responsive for various screen
    // sizes//from  www. j  a va2  s .c  om
    VerticalLayout centeringLayout = new VerticalLayout();
    centeringLayout.setStyleName("centering-layout");
    centeringLayout.addComponent(loginForm);
    centeringLayout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    // information text about logging in
    CssLayout loginInformation = buildLoginInformation();

    addComponent(centeringLayout);
    addComponent(loginInformation);
}