Example usage for com.vaadin.ui HorizontalLayout setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:org.ow2.sirocco.cloudmanager.MyUI.java

License:Open Source License

@Override
protected void init(final VaadinRequest request) {
    this.userName = request.getUserPrincipal().getName();
    this.identityContext.setUserName(this.userName);

    this.getPage().setTitle("Sirocco Dashboard");
    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from w  ww .java2s  .  co  m
    this.setContent(layout);

    // Top header *********************
    HorizontalLayout header = new HorizontalLayout();
    header.setMargin(true);
    header.setWidth("100%");
    header.setHeight("70px");
    header.setStyleName("topHeader");

    // logo
    Image image = new Image(null, new ThemeResource("img/sirocco_small_logo.png"));
    header.addComponent(image);

    // spacer
    Label spacer = new Label();
    spacer.setWidth("100%");
    header.addComponent(spacer);
    header.setExpandRatio(spacer, 1.0f);

    HorizontalLayout rightButtons = new HorizontalLayout();
    rightButtons.setStyleName("topHeader");
    rightButtons.setSpacing(true);

    this.userName = request.getUserPrincipal().getName();
    User user = null;
    try {
        user = this.userManager.getUserByUsername(this.userName);
    } catch (CloudProviderException e) {
        e.printStackTrace();
    }

    Label label = new Label("Tenant:");
    label.setStyleName("topHeaderLabel");
    rightButtons.addComponent(label);
    final ComboBox tenantSelect = new ComboBox();
    tenantSelect.setTextInputAllowed(false);
    tenantSelect.setNullSelectionAllowed(false);
    for (Tenant tenant : user.getTenants()) {
        tenantSelect.addItem(tenant.getName());
    }
    tenantSelect.setValue(user.getTenants().iterator().next().getName());
    tenantSelect.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(final ValueChangeEvent event) {
            Notification.show("Switching to tenant " + tenantSelect.getValue());

        }
    });
    tenantSelect.setImmediate(true);
    rightButtons.addComponent(tenantSelect);

    this.tenantId = user.getTenants().iterator().next().getUuid();
    this.identityContext.setTenantId(this.tenantId);

    // logged user name

    label = new Label("Logged in as: " + this.userName);
    label.setStyleName("topHeaderLabel");
    rightButtons.addComponent(label);

    // sign out button
    Button button = new Button("Sign Out");
    // button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            MyUI.this.logout();
        }
    });
    rightButtons.addComponent(button);

    header.addComponent(rightButtons);
    layout.addComponent(header);

    // Split view
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setFirstComponent(this.createLeftMenu());

    this.inventoryContainer = new VerticalLayout();
    this.inventoryContainer.setSizeFull();

    this.inventoryContainer.addComponent(this.machineView);

    splitPanel.setSecondComponent(this.inventoryContainer);
    splitPanel.setSplitPosition(15);

    layout.addComponent(splitPanel);
    layout.setExpandRatio(splitPanel, 1.0f);

    this.listenToNotifications();

}

From source file:org.ripla.web.controllers.RiplaBody.java

License:Open Source License

/**
 * Returns the default menu bar's layout component.<br />
 * Subclasses may override.//w  ww .  j  a  v  a2 s  . c  o  m
 * 
 * @return {@link HorizontalLayout} the default layout for the menu bar.
 */
protected HorizontalLayout getDftMenuBarLayout() {
    final HorizontalLayout outLayout = new HorizontalLayout();
    outLayout.setStyleName("ripla-menubar"); //$NON-NLS-1$
    outLayout.setMargin(new MarginInfo(false, false, false, true));
    outLayout.setWidth("100%"); //$NON-NLS-1$
    outLayout.setHeight(32, Unit.PIXELS);
    return outLayout;
}

From source file:org.ripla.web.controllers.RiplaBody.java

License:Open Source License

private Component createToolbar(final Label inSeparator) {
    final HorizontalLayout outToolbar = new HorizontalLayout();
    outToolbar.setStyleName("ripla-toolbar"); //$NON-NLS-1$
    outToolbar.setWidth("100%"); //$NON-NLS-1$
    outToolbar.setSpacing(true);// ww  w .j a  v  a2s  . c o  m
    outToolbar.setMargin(new MarginInfo(false, true, false, true));
    outToolbar.setHeight(22, Unit.PIXELS);

    final Label lExpand = new Label("&#160;", ContentMode.HTML);
    lExpand.setWidth("100%");
    outToolbar.addComponent(lExpand);
    outToolbar.setExpandRatio(lExpand, 1);

    final Iterator<IToolbarItem> lItems = ToolbarItemRegistry.INSTANCE.getSortedItems().iterator();
    boolean lFirst = true;
    while (lItems.hasNext()) {
        final IToolbarItem lItem = lItems.next();
        final IToolbarItemCreator lFactory = lItem.getCreator();
        final Component lComponent = lFactory == null ? lItem.getComponent()
                : lFactory.createToolbarItem(application, getUser());
        if (lComponent == null) {
            continue;
        }

        if (!lFirst) {
            final Label lSeparator = getSeparator(inSeparator);
            outToolbar.addComponent(lSeparator);
            outToolbar.setComponentAlignment(lSeparator, Alignment.MIDDLE_CENTER);
        }
        lFirst = false;

        outToolbar.addComponent(lComponent);
        outToolbar.setComponentAlignment(lComponent, Alignment.MIDDLE_CENTER);
        lItem.registerToolbarActionListener(new IToolbarActionListener() { // NOPMD
            @Override
            public void processAction(final IToolbarAction inAction) {
                inAction.run();
            }
        });
    }

    return outToolbar;
}

From source file:org.ripla.web.demo.skin.modest.Skin.java

License:Open Source License

@Override
public Component getHeader(final String inAppName) {
    final HorizontalLayout out = new HorizontalLayout();
    out.setStyleName("demo-header"); //$NON-NLS-1$
    out.setWidth("100%"); //$NON-NLS-1$
    out.setHeight(65, Unit.PIXELS);/*from   ww  w  .j a v a 2  s.c  o  m*/

    final Label lTitle = LabelHelper.createLabel("Ripla Demo [with modest skin]", "demo-header-text");
    lTitle.setSizeUndefined();
    out.addComponent(lTitle);

    return out;
}

From source file:org.ripla.web.demo.skin.Skin.java

License:Open Source License

@Override
public Component getHeader(final String inAppName) {
    final HorizontalLayout out = new HorizontalLayout();
    out.setStyleName("demo-header"); //$NON-NLS-1$
    out.setMargin(true);//from w  w w .j  a  v a2  s.  co  m
    out.setWidth("100%"); //$NON-NLS-1$
    out.setHeight(90, Unit.PIXELS);

    final Label lTitle = LabelHelper.createLabel("Ripla Demo Application", "demo-header-text");
    lTitle.setSizeUndefined();
    out.addComponent(lTitle);
    out.setComponentAlignment(lTitle, Alignment.MIDDLE_CENTER);

    return out;
}

From source file:org.ripla.web.demo.skin.stylish.Skin.java

License:Open Source License

@Override
public Component getHeader(final String inAppName) {
    final HorizontalLayout out = new HorizontalLayout();
    out.setStyleName("demo-header"); //$NON-NLS-1$
    out.setWidth("100%"); //$NON-NLS-1$
    out.setHeight(50, Unit.PIXELS);//  ww  w .j a v a  2 s .c  o  m

    final Label lTitle = LabelHelper.createLabel("Ripla Demo [with stylish skin]", "demo-header-text");
    lTitle.setSizeUndefined();
    out.addComponent(lTitle);
    out.setComponentAlignment(lTitle, Alignment.MIDDLE_CENTER);

    return out;
}

From source file:org.ripla.web.util.Dialog.java

License:Open Source License

private static HorizontalLayout createButtons(final Button inButton1, final Button inButton2) {
    final HorizontalLayout outButtons = new HorizontalLayout();
    outButtons.setStyleName("ripla-buttons"); //$NON-NLS-1$
    outButtons.setSpacing(true);//from   w  w w. java  2  s  . c  o m
    outButtons.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PIXELS);
    outButtons.addComponent(inButton1);
    outButtons.addComponent(inButton2);
    outButtons.setExpandRatio(inButton2, 1);
    outButtons.setComponentAlignment(inButton2, Alignment.MIDDLE_LEFT);
    return outButtons;
}

From source file:org.ripla.web.util.HelpButton.java

License:Open Source License

/**
 * HelpButton constructor./*from  w  w  w . j  a  v a2 s .  co m*/
 * 
 * @param inCaption
 *            String the link button's caption
 * @param inHelpContent
 *            URL the file's url containing the html formatted help text to
 *            display
 * @param inWidth
 *            int the popup windos's width
 * @param inHeight
 *            int the popup windos's height
 */
public HelpButton(final String inCaption, final URL inHelpContent, final int inWidth, final int inHeight) {
    super();

    final HorizontalLayout lLayout = new HorizontalLayout();
    lLayout.setStyleName("ripla-help"); //$NON-NLS-1$
    setCompositionRoot(lLayout);
    setWidth(SIZE_UNDEFINED, Unit.PIXELS);

    lLayout.setWidth(SIZE_UNDEFINED, Unit.PIXELS);
    Label lLabel = new Label("["); //$NON-NLS-1$
    RiplaViewHelper.makeUndefinedWidth(lLabel);
    lLayout.addComponent(lLabel);
    lLayout.addComponent(createLinkButton(inCaption, inHelpContent, inWidth, inHeight));
    lLabel = new Label("]"); //$NON-NLS-1$
    RiplaViewHelper.makeUndefinedWidth(lLabel);
    lLayout.addComponent(lLabel);
}

From source file:org.ripla.web.util.RiplaViewHelper.java

License:Open Source License

/**
 * Creates a layout component with the specified buttons aligned
 * horizontally./*from  w w w .  j  a va  2 s.co m*/
 * 
 * @param inButtons
 *            Button... the buttons to align
 * @return {@link HorizontalLayout}
 */
public static HorizontalLayout createButtons(final Button... inButtons) {
    final HorizontalLayout outButtons = new HorizontalLayout();
    outButtons.setStyleName("ripla-buttons"); //$NON-NLS-1$
    outButtons.setSpacing(true);
    outButtons.setWidth("100%"); //$NON-NLS-1$
    for (final Button lButton : inButtons) {
        outButtons.addComponent(lButton);
    }
    final Button lLast = inButtons[inButtons.length - 1];
    outButtons.setExpandRatio(lLast, 1);
    outButtons.setComponentAlignment(lLast, Alignment.MIDDLE_LEFT);
    return outButtons;
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.HorizontalNavigationViewlet.java

License:Apache License

public void refresh() {
    final CssLayout navigationLayout = new CssLayout();
    //navigationLayout.setSpacing(true);
    //navigationLayout.setMargin(true);

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    final String[] elements = navigationVersion.getTree().split(";");
    for (final String element : elements) {
        final int indentLastIndex = element.lastIndexOf('+');
        final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1);

        final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }/*from  ww  w.j  a va2 s. co m*/
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (getSite().getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        final String localizedPageName = getSite().localize("page-link-" + pageName);
        final Resource iconResource = getSite().getIcon("page-icon-" + pageName);

        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        itemLayout.setStyleName("horizontal-navigation-" + pageName);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = indentLastIndex + 1;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button link = new Button(localizedPageName);
        link.setStyleName(BaseTheme.BUTTON_LINK);
        link.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(pageName);
            }
        });
        /*if (page.getName().equals(pageName)) {
        link.setEnabled(false);
        }*/

        itemLayout.addComponent(link);
        itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setStyleName("horizontal-navigation-logout");
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = 0;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Resource iconResource = getSite().getIcon("page-icon-logout");
        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button logoutButton = new Button(getSite().localize("button-logout"));
        logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
        logoutButton.addClickListener(new ClickListener() {
            /** Serial version UID. */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());

                // Close the VaadinSession
                getSession().close();

            }
        });

        itemLayout.addComponent(logoutButton);
        itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT);
    }

    setCompositionRoot(navigationLayout);
}