Example usage for com.vaadin.ui HorizontalLayout addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:org.activiti.explorer.ui.profile.ProfilePanel.java

License:Apache License

protected void initAboutSection() {
    // Header/*from   w  ww .  ja  v  a 2 s. c  o  m*/
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, UNITS_PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);

    Label aboutLabel = createProfileHeader(infoPanelLayout, i18nManager.getMessage(Messages.PROFILE_ABOUT));
    header.addComponent(aboutLabel);
    header.setExpandRatio(aboutLabel, 1.0f);

    // only show edit/save buttons if current user matches
    if (isCurrentLoggedInUser) {
        Button actionButton = null;
        if (!editable) {
            actionButton = initEditProfileButton();
        } else {
            actionButton = initSaveProfileButton();
        }
        header.addComponent(actionButton);
        header.setComponentAlignment(actionButton, Alignment.MIDDLE_RIGHT);
    }

    // 'About' fields
    GridLayout aboutLayout = createInfoSectionLayout(2, 4);

    // Name
    if (!editable && (isDefined(user.getFirstName()) || isDefined(user.getLastName()))) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_NAME),
                user.getFirstName() + " " + user.getLastName());
    } else if (editable) {
        firstNameField = new TextField();
        firstNameField.focus();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_FIRST_NAME), firstNameField,
                user.getFirstName());
        lastNameField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LAST_NAME), lastNameField,
                user.getLastName());
    }

    // Job title
    if (!editable && isDefined(jobTitle)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitle);
    } else if (editable) {
        jobTitleField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitleField,
                jobTitle);
    }

    // Birthdate
    if (!editable && isDefined(birthDate)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDate);
    } else if (editable) {
        birthDateField = new DateField();
        birthDateField.setDateFormat(Constants.DEFAULT_DATE_FORMAT);
        birthDateField.setResolution(DateField.RESOLUTION_DAY);
        try {
            birthDateField.setValue(new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT).parse(birthDate));
        } catch (Exception e) {
        } // do nothing
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDateField,
                null);
    }

    // Location
    if (!editable && isDefined(location)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), location);
    } else if (editable) {
        locationField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), locationField,
                location);
    }
}

From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescriptionAndClaimButton() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.setSpacing(true);/*from  w w w  .j a  va2  s. c  om*/
    centralLayout.addComponent(layout);

    initClaimButton(layout);
    initDescription(layout);
}

From source file:org.bubblecloud.ilves.site.view.valo.DefaultValoView.java

License:Apache License

private CssLayout buildMenu() {

    final HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    topLayout.addStyleName("valo-menu-title");
    menu.addComponent(topLayout);//from  ww w  . j ava 2  s.c o m

    final Button showMenu = new Button("Menu", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>" + Site.getCurrent().localize(getViewVersion().getTitle()) + "</h3>",
            ContentMode.HTML);
    title.setSizeUndefined();
    topLayout.addComponent(title);
    topLayout.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    final String user = Site.getCurrent().getSecurityProvider().getUser();
    final String userMenuCaption;
    final Resource userMenuIcon;
    if (user == null) {
        userMenuCaption = Site.getCurrent().localize("page-link-login");
        userMenuIcon = new ThemeResource("ilves_logo.png");
    } else {
        final URL gravatarUrl = GravatarUtil.getGravatarUrl(user, 64);
        userMenuIcon = new ExternalResource(gravatarUrl);
        userMenuCaption = ((SecurityProviderSessionImpl) Site.getCurrent().getSecurityProvider())
                .getUserFromSession().getFirstName();
    }

    final MenuBar.MenuItem settingsItem = settings.addItem(userMenuCaption, userMenuIcon, null);
    if (user != null) {
        settingsItem.addItem(Site.getCurrent().localize("page-link-account"), new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                UI.getCurrent().getNavigator().navigateTo("account");
            }
        });
        settingsItem.addSeparator();
        settingsItem.addItem(Site.getCurrent().localize("button-logout"), new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                LoginService.logout(Site.getCurrent().getSiteContext());
                final Company company = Site.getCurrent().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());
                getSession().getSession().invalidate();
                getSession().close();
            }
        });
    } else {
        settingsItem.addItem(Site.getCurrent().localize("page-link-login"), new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                UI.getCurrent().getNavigator().navigateTo("login");
            }
        });
    }
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    final Site site = Site.getCurrent();
    final NavigationVersion navigationVersion = site.getCurrentNavigationVersion();

    for (final String pageName : navigationVersion.getRootPages()) {
        final ViewVersion pageVersion = site.getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (site.getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        if (navigationVersion.hasChildPages(pageName)) {

            final String localizedPageName = pageVersion.isDynamic() ? pageName
                    : site.localize("page-link-" + pageName);

            final Label label = new Label(localizedPageName, ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);

            final List<String> childPages = navigationVersion.getChildPages(pageName);
            for (final String childPage : childPages) {
                addMenuLink(navigationVersion, childPage);
            }

            label.setValue(
                    label.getValue() + " <span class=\"valo-menu-badge\">" + childPages.size() + "</span>");
        } else {
            addMenuLink(navigationVersion, pageName);
        }
    }

    return menu;
}

From source file:org.eclipse.emf.ecp.controls.vaadin.AbstractVaadinSimpleControlRenderer.java

License:Open Source License

protected void createSetOrUnsetComponent(final Component component, final HorizontalLayout horizontalLayout,
        final Setting setting) {
    final Label unsetLabel = getUnsetComponent();
    final Button setButton = getUnsetButton(component, horizontalLayout, setting);
    setButton.setEnabled(getVElement().isEnabled());
    setButton.setVisible(getVElement().isVisible());
    setButton.setReadOnly(getVElement().isReadonly());
    horizontalLayout.addStyleName("textheight");
    horizontalLayout.removeAllComponents();
    Component addComponent = component;
    if (setting.isSet()) {
        setButton.setCaption(VaadinRendererMessages.AbstractVaadinSimpleControlRenderer_Set);
        unsetLabel.setCaption(getUnsetLabel());
        addComponent = unsetLabel;//www.jav  a2 s  .c om

    } else {
        setButton.setCaption(VaadinRendererMessages.AbstractVaadinSimpleControlRenderer_Unset);

    }
    horizontalLayout.setData(addComponent);
    horizontalLayout.addComponent(addComponent);
    horizontalLayout.setExpandRatio(addComponent, 1f);
    horizontalLayout.addComponent(setButton);
    horizontalLayout.setComponentAlignment(setButton, Alignment.BOTTOM_RIGHT);

}

From source file:org.eclipse.emf.ecp.controls.vaadin.internal.BooleanControlVaadinRenderer.java

License:Open Source License

@Override
protected Component render() {
    final Setting setting = getVElement().getDomainModelReference().getIterator().next();
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    final Component checkBox = createControl();
    horizontalLayout.setData(checkBox);//from   w w w  .  ja v  a2s.  c o  m
    createDatabinding(setting, checkBox);
    checkBox.setWidth(100, Unit.PERCENTAGE);
    horizontalLayout.setWidth(100, Unit.PERCENTAGE);
    horizontalLayout.addComponent(checkBox);
    horizontalLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_LEFT);
    // TODO: Fix Size
    horizontalLayout.addStyleName("textheight");
    if (setting.getEStructuralFeature().isUnsettable()) {
        createSetOrUnsetComponent(checkBox, horizontalLayout, setting);
    }
    return horizontalLayout;
}

From source file:org.eclipse.emf.ecp.controls.vaadin.internal.ReferenceListVaadinRenderer.java

License:Open Source License

@Override
protected HorizontalLayout createToolbar() {
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    if (hasCaption()) {
        horizontalLayout.addStyleName(TABLE_BUTTON_TOOLBAR_STYLE);
    }//from w  w w. j a va 2  s . co m

    final Button add = VaadinWidgetFactory.createTableAddButton(getSetting(), getTable());
    horizontalLayout.addComponent(add);
    return horizontalLayout;
}

From source file:org.eclipse.emf.ecp.view.table.vaadin.TableRendererVaadin.java

License:Open Source License

private void addTableToolbarStyle(HorizontalLayout horizontalLayout) {
    if (hasCaption()) {
        horizontalLayout.addStyleName(TABLE_BUTTON_TOOLBAR);
    }/*from   w w  w  . j  a v a  2  s.  c  o m*/
}

From source file:org.eclipse.hawkbit.ui.AbstractHawkbitUI.java

License:Open Source License

private HorizontalLayout buildViewTitle() {
    final HorizontalLayout viewHeadercontent = new HorizontalLayout();
    viewHeadercontent.setWidth("100%");
    viewHeadercontent.addStyleName("view-header-layout");

    viewTitle = new Label();
    viewTitle.setWidth("100%");
    viewTitle.setStyleName("header-content");
    viewHeadercontent.addComponent(viewTitle);

    viewHeadercontent.addComponent(notificationUnreadButton);
    viewHeadercontent.setComponentAlignment(notificationUnreadButton, Alignment.MIDDLE_RIGHT);
    return viewHeadercontent;
}

From source file:org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout.java

License:Open Source License

private void buildLayout() {
    final HorizontalLayout header = new HorizontalLayout();
    header.addStyleName("artifact-details-header");
    header.addStyleName("bordered-layout");
    header.addStyleName("no-border-bottom");
    header.setSpacing(false);//w ww . ja  v a2 s .  c  o m
    header.setMargin(false);
    header.setSizeFull();
    header.setHeightUndefined();
    header.setImmediate(true);
    header.addComponents(titleOfArtifactDetails, maxMinButton);
    header.setComponentAlignment(titleOfArtifactDetails, Alignment.TOP_LEFT);
    header.setComponentAlignment(maxMinButton, Alignment.TOP_RIGHT);
    header.setExpandRatio(titleOfArtifactDetails, 1.0F);

    setSizeFull();
    setImmediate(true);
    addStyleName("artifact-table");
    addStyleName("table-layout");
    addComponent(header);
    setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    addComponent(artifactDetailsTable);
    setComponentAlignment(artifactDetailsTable, Alignment.MIDDLE_CENTER);
    setExpandRatio(artifactDetailsTable, 1.0F);
}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

private HorizontalLayout getFooterLayout() {
    final HorizontalLayout footer = new HorizontalLayout();
    footer.setSizeUndefined();//from   www  .j a va 2  s  .com
    footer.addStyleName("confirmation-window-footer");
    footer.setSpacing(true);
    footer.setMargin(false);
    footer.addComponents(uploadBtn, cancelBtn);
    footer.setComponentAlignment(uploadBtn, Alignment.TOP_LEFT);
    footer.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT);
    return footer;
}