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.vaadin.tori.component.AuthoringComponent.java

License:Apache License

private void updateAttachmentList() {
    attachmentsLayout.removeAllComponents();
    attachmentsLayout.setVisible(!attachments.isEmpty());
    for (final Entry<String, byte[]> entry : attachments.entrySet()) {
        final String fileName = entry.getKey();
        final int fileSize = entry.getValue().length;
        final String caption = String.format("%s (%s KB)", fileName, fileSize / 1024);

        final Label nameComponent = new Label();
        nameComponent.addStyleName("namelabel");
        nameComponent.setValue(caption);
        nameComponent.setWidth(300.0f, Unit.PIXELS);
        try {//from   w  w w  .  j  av a 2s .c o m
            nameComponent.addStyleName(fileName.substring(fileName.lastIndexOf(".") + 1));
        } catch (final IndexOutOfBoundsException e) {
            // NOP
        }

        final HorizontalLayout wrapperLayout = new HorizontalLayout();
        wrapperLayout.addStyleName("filerow");
        wrapperLayout.addComponent(nameComponent);

        final Label deleteLabel = new Label();
        deleteLabel.addStyleName("deleteattachment");

        wrapperLayout.addComponent(deleteLabel);
        wrapperLayout.addLayoutClickListener(new LayoutClickListener() {
            @Override
            public void layoutClick(final LayoutClickEvent event) {
                if (event.getChildComponent() == deleteLabel) {
                    attachments.remove(entry.getKey());
                    updateAttachmentList();
                }
            }
        });

        attachmentsLayout.addComponent(wrapperLayout);

    }
}

From source file:org.vaadin.tori.component.Breadcrumbs.java

License:Apache License

private Component getCategoryLink(final Category category) {
    HorizontalLayout result = new HorizontalLayout();
    result.setSpacing(true);/*from   w  w  w .jav  a  2  s . c  o  m*/
    result.setHeight(100.0f, Unit.PERCENTAGE);
    result.addStyleName("categorylink");
    final Link crumb = new Link(category.getName(), new ExternalResource(
            "#" + ToriNavigator.ApplicationView.CATEGORIES.getUrl() + "/" + category.getId()));
    crumb.setHeight(100.0f, Unit.PERCENTAGE);
    result.addComponent(crumb);
    result.setComponentAlignment(crumb, Alignment.MIDDLE_CENTER);
    Component siblingMenu = getSiblingMenuBar(category);
    siblingMenu.setHeight(100.0f, Unit.PERCENTAGE);
    result.addComponent(siblingMenu);
    result.setComponentAlignment(siblingMenu, Alignment.MIDDLE_CENTER);
    return result;
}

From source file:org.vaadin.tori.util.ComponentUtil.java

License:Apache License

public static HorizontalLayout getHeaderLayout(final String titleString) {
    final HorizontalLayout result = new HorizontalLayout();
    result.setWidth(100.0f, Unit.PERCENTAGE);
    result.setHeight(56.0f, Unit.PIXELS);
    result.setSpacing(true);/*from ww  w . ja  v  a  2  s  . co  m*/
    result.setMargin(true);
    result.addStyleName("headerlayout");
    Component title = getHeadingLabel(titleString, HeadingLevel.H2);
    result.addComponent(title);
    result.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    return result;
}

From source file:org.vaadin.tori.view.thread.PostEditor.java

License:Apache License

private Component buildButtons() {
    HorizontalLayout result = new HorizontalLayout();
    result.addStyleName("buttonslayout");
    result.setWidth(100.0f, Unit.PERCENTAGE);
    result.setSpacing(true);/*  w  ww . j a  v a  2 s. c o m*/
    result.setMargin(true);
    final Button cancelButton = ComponentUtil.getSecondaryButton("Discard Changes", new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            event.getButton().removeClickShortcut();
            listener.cancelEdit();
        }
    });
    result.addComponent(new Button("Confirm Edit", new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            cancelButton.removeClickShortcut();
            listener.submitEdit(editor.getValue());
        }
    }));

    cancelButton.setClickShortcut(KeyCode.ESCAPE);
    result.addComponent(cancelButton);
    result.setExpandRatio(cancelButton, 1.0f);
    return result;
}

From source file:org.vaadin.tori.view.thread.ThreadUpdatesComponent.java

License:Apache License

public ThreadUpdatesComponent(final ThreadPresenter presenter) {
    setStyleName("threadupdates");

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();//from ww  w  .  ja  v a 2  s . c om
    layout.addStyleName("threadupdateslayout");
    setCompositionRoot(layout);

    setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);
    layout.setSpacing(true);
    setVisible(false);

    newPostsLabel.setSizeUndefined();
    newPostsLabel.addStyleName("newposts");
    layout.addComponent(newPostsLabel);

    showAllLabel.addStyleName("showall");
    layout.addComponent(showAllLabel);
    layout.setExpandRatio(showAllLabel, 1.0f);

    pendingRepliesLabel.setWidth(280.0f, Unit.PIXELS);
    layout.addComponent(pendingRepliesLabel);
    layout.setComponentAlignment(pendingRepliesLabel, Alignment.MIDDLE_RIGHT);

    layout.addLayoutClickListener(new LayoutClickListener() {
        @Override
        public void layoutClick(final LayoutClickEvent event) {
            if (event.getChildComponent() == showAllLabel) {
                presenter.showNewPostsRequested();
            }
        }
    });
}

From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityHandler.java

License:Apache License

@Override
public void handle(final ActionContext actionContext) throws Exception {
    final ComponentContainer container = actionContext.getTargetContainer();

    container.removeAllComponents();/*w  w w.j a  va  2  s.  com*/
    // container.setSizeFull();
    // container.setMargin(false);
    final OpenGroupsApplication app = actionContext.getApp();
    final Entity entity = actionContext.getEntity();

    EntityState entityState = entity.getState();
    boolean isOpened = entityState.isOpened();
    String complexEntityType = entity.getComplexType();
    ApplicationConfigManager appConfigManager = app.getAppConfigManager();
    List<String> subtyesList = appConfigManager.getSubtypesForComplexType(complexEntityType);

    // Panel currentContainer = (Panel) container;
    ComponentContainer currentContainer = container;
    entity.setEntityContainer(container);

    CssLayout headerContainer = new CssLayout();
    headerContainer.addStyleName("entity-header-container");
    currentContainer.addComponent(headerContainer);

    // CssLayout titleContainer = new CssLayout();
    // titleContainer.setWidth("80%");
    // titleContainer.addStyleName(OpenGroupsStyles.MIDDLE_LEFT);
    // headerContainer.addComponent(titleContainer);

    // titleContainer.setSizeFull();
    // /* show level */
    // String levelMsg = getMessage("level");
    // Label levelLabel = new Label(levelMsg+" "+entity.getDepth());
    // titleContainer.addComponent(levelLabel);

    /* show entity type */
    if (entity.getState().isEntityTypeVisible()) {
        String entityTypeCaption = getMessage(entity.getComplexType());

        String size = OpenGroupsIconsSet.MEDIUM;
        if (entity.getContent() != null) {
            size = OpenGroupsIconsSet.LARGE;
        }
        // Label typeIcon = new Label();
        // typeIcon.setDescription(entityTypeCaption);
        // typeIcon.setIcon(OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(),
        // size));
        // typeIcon.setSizeUndefined();
        // typeIcon.addStyleName("top-left right-margin-20");
        // headerContainer.addComponent(typeIcon);
        Embedded eicon = new Embedded(null,
                OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), size));
        eicon.setDescription(entityTypeCaption);
        eicon.addStyleName("top-left right-margin-20");

        headerContainer.addComponent(eicon);

        // Embedded eicon2 = new Embedded("",
        // OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(),
        // size));
        // eicon2.setDescription(entityTypeCaption);
        // eicon2.addStyleName("top-left right-margin-20");
        // headerContainer.addComponent(eicon2);

    }

    // Label test = new Label("test");
    // test.setSizeUndefined();
    // test.addStyleName("top-left");
    // headerContainer.addComponent(test);

    /* add last action for this entity */
    if (entity.getLastActionType() != null) {
        String actionType = entity.getLastActionType();
        String msg = getMessage(actionType);
        // Label actionLabel = new Label();
        // actionLabel.setDescription(msg);
        // actionLabel.setIcon(OpenGroupsResources.getIcon(actionType,
        // OpenGroupsIconsSet.MEDIUM));
        // actionLabel.setSizeUndefined();
        // actionLabel.addStyleName(OpenGroupsStyles.MIDDLE_LEFT);
        // titleContainer.addComponent(actionLabel);
        Embedded actionIcon = new Embedded(null,
                OpenGroupsResources.getIcon(actionType, OpenGroupsIconsSet.MEDIUM));
        actionIcon.setDescription(msg);
        actionIcon.addStyleName("top-left right-margin-20");
        headerContainer.addComponent(actionIcon);

    }

    EntityLink selectedCause = entity.getSelectedCause();
    /* display title */
    /* if the entity is open */
    /* treat leafs like all posts 21.08.2012 */
    if (isOpened /*
                 * || (subtyesList == null && entity.getLastActionType() ==
                 * null)
                 */) {
        Label title = new Label(entity.getTitle());
        if (isOpened) {
            title.addStyleName(OpenGroupsStyles.TITLE_LINK);
        } else {
            title.addStyleName("list-issue-title");
        }
        // title.addStyleName("top-left");
        // title.setSizeFull();
        title.setWidth("80%");
        // title.setHeight("100%");

        headerContainer.addComponent(title);

    } else {
        // Button titleLink = new Button(entity.getTitle());
        // titleLink.setWidth("100%");
        // titleLink.addStyleName(BaseTheme.BUTTON_LINK);
        // titleLink.addStyleName("issue-title");
        // titleLink.setDescription(entity.getContentPreview());
        Label titleLink = null;
        /* treat leafs like all posts 21.08.2012 */
        // if (subtyesList != null) {
        titleLink = OpenGroupsUtil.getLinkForEntity(entity, app);
        titleLink.setDescription(entity.getContentPreview());
        titleLink.addStyleName("list-issue-title");
        // }
        // /* is a leaf entity in the recent activity list */
        // else {
        // String parentTitle = selectedCause.getParentTitle();
        // Entity parentEntity = new Entity(selectedCause.getParentId());
        // parentEntity.setTitle(parentTitle);
        //
        // parentEntity.getState().setDesiredActionsPath(
        // complexEntityType +
        // Defaults.getDefaultActionForEntityType(complexEntityType));
        // titleLink = OpenGroupsUtil.getLinkForEntity(parentEntity, app,
        // entity.getTitle());
        // titleLink.setDescription(entity.getContentPreview());
        // titleLink.addStyleName("list-issue-title");
        //
        // }

        // titleLink.setWidth("75%");
        titleLink.addStyleName("top-left");
        headerContainer.addComponent(titleLink);
        // titleContainer.setExpandRatio(titleLink, 10f);
        // currentContainer.addStyleName("list-item");
    }

    /* add parent link */
    if (selectedCause != null && !isOpened && entity.getContent() == null) {
        // CssLayout parentInfoContainer = new CssLayout();
        // parentInfoContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
        // headerContainer.addComponent(parentInfoContainer);
        // headerContainer.setColumnExpandRatio(1, 1f);
        // headerContainer.setComponentAlignment(parentInfoContainer,
        // Alignment.TOP_RIGHT);
        /* if parent entity is the current selected entity, say it */
        Entity mainEntity = actionContext.getMainEntity();
        if (selectedCause.getParentId() == mainEntity.getId()) {
            // String currentMsg = getMessage(mainEntity.getComplexType() +
            // ".current");
            // Label currentEntityLabel = new Label(currentMsg);
            // currentEntityLabel.setSizeUndefined();
            // currentEntityLabel.addStyleName("top-right");
            // headerContainer.addComponent(currentEntityLabel);
            // titleContainer.setExpandRatio(currentEntityLabel, 2f);
        } else {/* add link to the parent entity */
            String parentTitle = selectedCause.getParentTitle();
            final Entity parentEntity = new Entity(selectedCause.getParentId());
            parentEntity.setTitle(parentTitle);

            Label parentLink = OpenGroupsUtil.getLinkForEntityWithImage(parentEntity, app,
                    OpenGroupsResources.getIconPath(OpenGroupsIconsSet.PARENT, OpenGroupsIconsSet.MEDIUM));
            parentLink.setDescription(parentTitle);
            parentLink.setSizeUndefined();
            parentLink.addStyleName(OpenGroupsStyles.TOP_RIGHT);
            // CssLayout imgContainer = new CssLayout();
            // imgContainer.setWidth("24px");
            // imgContainer.setHeight("24px");
            // imgContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
            // imgContainer.addComponent(parentLink);
            // parentInfoContainer.addComponent(imgContainer);
            headerContainer.addComponent(parentLink);
        }
    }

    /* display header actions */
    if (isOpened) {
        UserActionList headerActions = getAvailableActions(entity, ActionLocations.HEADER);
        boolean allowRefresh = appConfigManager.getComplexEntityBooleanParam(entity.getComplexType(),
                ComplexEntityParam.ALLOW_REFRESH);
        boolean hasHeaderActions = headerActions != null && headerActions.getActions() != null;
        if (allowRefresh || hasHeaderActions) {
            HorizontalLayout actionsContainer = new HorizontalLayout();
            actionsContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
            actionsContainer.setSpacing(true);
            // /* add refresh button */
            // if (allowRefresh) {
            // actionsContainer.addComponent(getRefreshButton(entity, app));
            // }
            // if (hasHeaderActions) {
            // for (final UserAction ha :
            // headerActions.getActions().values()) {
            // Button actButton = getButtonForAction(ha, entity, app);
            // actionsContainer.addComponent(actButton);
            // }
            // }
            headerContainer.addComponent(actionsContainer);
            // headerContainer.setColumnExpandRatio(1, 1f);
            // headerContainer.setComponentAlignment(actionsContainer,
            // Alignment.TOP_RIGHT);
            entity.setHeaderActionLinksContainer(actionsContainer);
            refreshHeaderActionLinks(entity, app, actionContext);
        }

    }

    /* display tags */
    List<Tag> tags = entity.getTags();
    if (tags != null) {
        if (tags.size() > 0) {
            String tagsList = "";
            for (int i = 0; i < tags.size(); i++) {
                Tag tag = tags.get(i);
                tagsList += tag.getTagName();
                if ((tags.size() - i) > 1) {
                    tagsList += ", ";
                }
            }
            String tagsLabelString = app.getMessage("tags.label") + tagsList;
            currentContainer.addComponent(new Label(tagsLabelString));
        }
    }

    CssLayout statusPane = new CssLayout();
    statusPane.addStyleName("entity-status-pane");

    currentContainer.addComponent(statusPane);

    if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.SHOW_POST_INFO)) {
        String insertDateString = entity.getInsertDate().toString();
        Label insertDate = new Label(app.getMessage("posted") + DateUtil.removeNanos(insertDateString));
        statusPane.addComponent(insertDate);
        // statusPane.setColumnExpandRatio(0, 1f);
    }

    CssLayout statsSummaryPane = new CssLayout();
    statsSummaryPane.addStyleName("entity-stats-summary-pane");
    // statsSummaryPane.setSizeFull();
    // statsSummaryPane.setWidth("100%");

    currentContainer.addComponent(statsSummaryPane);

    /* add votes */
    if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.ALLOW_VOTING)) {
        // HorizontalLayout votesPane = new HorizontalLayout();
        // votesPane.setMargin(false);
        // votesPane.addStyleName("middle-left");
        // votesPane.addStyleName("margin-right");
        // statsSummaryPane.addComponent(votesPane);
        // statsSummaryPane.setExpandRatio(votesPane, 1f);
        // statsSummaryPane.setComponentAlignment(votesPane,
        // Alignment.MIDDLE_LEFT);

        Label votesLabel = new Label(app.getMessage("votes") + ":&nbsp;");
        votesLabel.setContentMode(Label.CONTENT_XHTML);
        votesLabel.setSizeUndefined();
        votesLabel.addStyleName("middle-left");
        // votesPane.addComponent(votesLabel);
        Label proVotes = FormatingUtils.coloredLabel(entity.getProVotes(), "336633");
        proVotes.addStyleName("middle-left");
        proVotes.setSizeUndefined();
        // votesPane.addComponent(proVotes);
        Label dash = new Label("-");
        dash.addStyleName("middle-left");
        dash.setSizeUndefined();
        // votesPane.addComponent(new Label("-"));
        Label opposedVotes = FormatingUtils.coloredLabel(entity.getOpposedVotes(), "660000");
        // votesPane.addComponent(opposedVotes);
        opposedVotes.addStyleName("middle-left");
        opposedVotes.addStyleName("right-margin-10");
        opposedVotes.setSizeUndefined();

        statsSummaryPane.addComponent(votesLabel);
        statsSummaryPane.addComponent(proVotes);
        statsSummaryPane.addComponent(dash);
        statsSummaryPane.addComponent(opposedVotes);

    }
    List<TypeRelationConfig> subtypes = appConfigManager.getSubtypesForType(entity.getComplexTypeId());
    // if (subtyesList != null) {
    if (subtypes != null) {
        Map<String, Long> firstLevelSubtypesCount = entity.getSubtypeEntitiesCount();
        Map<String, Long> allSubtypesCount = entity.getRecursiveSubtypeEntitiesCount();

        // for (String s : subtyesList) {
        // String subtype = s.toLowerCase();
        for (TypeRelationConfig trc : subtypes) {
            String targetComplexType = trc.getTargetComplexType();
            String subtype = targetComplexType.toLowerCase();
            String displayName = app.getMessage("subtype." + subtype);

            Entity refEntity = new Entity(entity.getId());

            refEntity.getState().setDesiredActionsPath(
                    targetComplexType + Defaults.getDefaultActionForEntityType(targetComplexType));
            Label subtypeLink = OpenGroupsUtil.getLinkForEntity(refEntity, app, displayName);

            String valueString = ": " + firstLevelSubtypesCount.get(subtype);

            // if (getAppConfigManager().getComplexEntityBooleanParam(s,
            // ComplexEntityParam.ALLOW_RECURSIVE_LIST)) {
            if (appConfigManager.getTypeRelationBooleanConfigParam(trc.getId(),
                    TypeRelationConfigParam.ALLOW_RECURSIVE_LIST)) {
                Long recCount = allSubtypesCount.get(subtype);
                if (recCount != null) {
                    valueString += " / " + recCount;
                }
            }
            Label sl = new Label(valueString);
            sl.setWidth(null);
            sl.addStyleName("middle-left");
            sl.addStyleName("right-margin-10");

            subtypeLink.setWidth(null);
            subtypeLink.addStyleName("middle-left");

            statsSummaryPane.addComponent(subtypeLink);
            statsSummaryPane.addComponent(sl);
            // statsSummaryPane.setExpandRatio(sl, 1f);
            // statsSummaryPane.setComponentAlignment(sl,
            // Alignment.MIDDLE_LEFT);
        }
    }

    displaySummaryActions(entity, app, statsSummaryPane, actionContext);

    // statusPane.addComponent(statsSummaryPane, 1, 0);
    // statusPane.setColumnExpandRatio(1, 1.8f);
    // statusPane.setComponentAlignment(statsSummaryPane,
    // Alignment.MIDDLE_RIGHT);

    // summaryLayout.setComponentAlignment(statsSummaryPane,
    // Alignment.MIDDLE_RIGHT);

    /* add the content */
    Object contentObj = entity.getContent();
    if (contentObj != null) {
        // content.setSizeFull();
        Panel contentContainer = new Panel();
        // CssLayout contentContainer = new CssLayout();
        contentContainer.addStyleName("text-content");
        currentContainer.addComponent(contentContainer);

        Label content = new Label(contentObj.toString());
        content.setContentMode(Label.CONTENT_XHTML);
        // content.addStyleName("text-label");
        contentContainer.addComponent(content);

        /* if the content is visible, display footer actions */
        displayFooterActions(entity, app, currentContainer, actionContext);
    }

}

From source file:ro.zg.netcell.vaadin.action.application.VoteEntityHandler.java

License:Apache License

private void showAlreadyVotedFragment(final ComponentContainer container, final Entity selectedEntity,
        final OpenGroupsApplication app, final UserAction ua, final ActionContext ac) {
    String entityType = selectedEntity.getSimpleType().toLowerCase();
    String currentUserVote = selectedEntity.getUserData().getVote();
    String messageKey = entityType + ".already.voted." + currentUserVote;
    HorizontalLayout hl = new HorizontalLayout();
    hl.addStyleName(OpenGroupsStyles.TOP_RIGHT);
    hl.setSpacing(true);//  ww w .j  av a 2  s.c  o  m
    hl.addComponent(new Label(OpenGroupsResources.getMessage(messageKey)));

    final VoteType opposedVote = VoteType.opposteVoteForValue(currentUserVote, entityType);

    Button changeVoteButton = new Button(/*OpenGroupsResources.getMessage("change.vote")*/);
    changeVoteButton.setCaption(opposedVote.getCaption());
    changeVoteButton.setIcon(opposedVote.getIcon());
    changeVoteButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //      container.removeAllComponents();
            //      showVotesFragment(container, selectedEntity, app, ua, ac);
            Map<String, Object> params = ua.getActionParams();
            //      params.put("entityId", selectedEntity.getId());
            params.put("entityLinkId", selectedEntity.getSelectedCause().getLinkId());
            params.put("userId", app.getCurrentUserId());
            params.put("isRecordCreated", selectedEntity.getUserData().isEntityLinkUserRecordCreated());
            params.put("vote", opposedVote.getValue());
            CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params);
            /* refresh the entity only if the user was actually able to vote */
            if (response != null) {
                app.refreshEntity(selectedEntity, ac);
            }
        }
    });
    hl.addComponent(changeVoteButton);

    Button recallVoteButton = new Button(OpenGroupsResources.getMessage("recall.vote"));
    recallVoteButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.CANCEL, OpenGroupsIconsSet.SMALL));
    recallVoteButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            EntityLink selectedCause = selectedEntity.getSelectedCause();

            Map<String, Object> params = ua.getActionParams();

            params.put("entityLinkId", selectedCause.getLinkId());
            params.put("userId", app.getCurrentUserId());
            params.put("isRecordCreated", true);

            CommandResponse response = executeAction(new ActionContext(ua, app, selectedEntity), params);
            /* refresh the entity only if the user was actually able to vote */
            if (response != null) {
                app.refreshEntity(selectedEntity, ac);
            }
        }
    });
    hl.addComponent(recallVoteButton);
    container.addComponent(hl);
}

From source file:ro.zg.netcell.vaadin.action.application.VoteEntityHandler.java

License:Apache License

private void showVotesFragment(ComponentContainer container, Entity selectedEntity,
        final OpenGroupsApplication app, final UserAction ua, final ActionContext ac) {
    String entityType = selectedEntity.getSimpleType().toLowerCase();
    List<VoteType> voteTypes = VoteType.valuesList(entityType);
    HorizontalLayout votesContainer = new HorizontalLayout();
    votesContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
    votesContainer.setSpacing(true);/*from  w  w  w  .j a  v a2 s  .c  o  m*/
    for (VoteType vt : voteTypes) {
        votesContainer.addComponent(getButtonForVoteType(vt, container, selectedEntity, app, ua, ac));
    }
    container.addComponent(votesContainer);
}

From source file:tad.grupo7.ccamistadeslargas.LoginView.java

/**
 * Crea los campos del formulario.// ww w.j  a  va  2 s . co m
 *
 * @return Component Devuelve el layout que contiene todos los campos del
 * formulario.
 */
private Component buildFields() {
    //LAYOUT CON LOS CAMPOS DEL FORMULARIO
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    final TextField email = new TextField("Email");
    email.setRequired(true);
    email.setIcon(FontAwesome.USER);
    email.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    email.focus();

    final PasswordField password = new PasswordField("Password");
    password.setRequired(true);
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(KeyCode.ENTER);

    final Button registrar = new Button("Sign Up");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);

    fields.addComponents(email, password, signin, registrar);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);
    fields.setComponentAlignment(registrar, Alignment.BOTTOM_LEFT);

    //LOGARSE
    signin.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                email.validate();
                password.validate();
                Usuario u = UsuarioDAO.read(email.getValue(), password.getValue());
                if (u != null) {
                    if (u.getEmail().equals("admin") && u.getPassword().equals("admin")) {
                        Session.setAttribute("usuario", u);
                        UI.getCurrent().getNavigator().navigateTo("AdminIndex");
                    } else {
                        Session.setAttribute("usuario", u);
                        UI.getCurrent().getNavigator().navigateTo("index");
                    }
                } else {
                    Notification n = new Notification("Usuario incorrecto", Notification.Type.WARNING_MESSAGE);
                    n.setPosition(Position.TOP_CENTER);
                    n.show(Page.getCurrent());
                }
            } catch (Validator.InvalidValueException ex) {
                Notification n = new Notification("Rellena todos los campos",
                        Notification.Type.WARNING_MESSAGE);
                n.setPosition(Position.TOP_CENTER);
                n.show(Page.getCurrent());
            }
        }
    });
    //IR AL FORMULARIO DE REGISTRARSE
    registrar.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo("registrar");
        }
    });
    return fields;
}

From source file:uicomponents.BarcodePreviewComponent.java

License:Open Source License

public BarcodePreviewComponent(SampleToBarcodeFieldTranslator translator) {
    this.translator = translator;
    setSpacing(true);/* ww  w. ja va2s.c  o m*/
    setMargin(true);

    Resource res = new ThemeResource("img/qrtest.png");
    Image qr = new Image(null, res);
    qr.setHeight("140px");
    qr.setWidth("140px");
    Image qr2 = new Image(null, res);
    qr2.setHeight("140px");
    qr2.setWidth("140px");

    code = new TextField();
    info1 = new TextField();
    info2 = new TextField();

    codedName = new OptionGroup("Put ID on sticker:");
    codedName.addItems(Arrays.asList("QBiC ID", "Lab ID", "Secondary Name"));
    codedName.setImmediate(true);
    codedName.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    codedName.select("QBiC ID");

    code.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    code.setWidth("200px");
    code.addStyleName("barcode-large");

    styleInfoField(info1);
    styleInfoField(info2);
    styleInfoField(qbicInfo);

    VerticalLayout box = new VerticalLayout();
    box.setHeight("110px");
    box.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    box.addComponent(code);
    box.addComponent(info1);
    box.addComponent(info2);
    box.addComponent(qbicInfo);
    box.setWidth("190px");

    HorizontalLayout test = new HorizontalLayout();
    test.setSizeFull();
    test.addComponent(qr);
    test.addComponent(box);
    test.addComponent(qr2);

    setFieldsReadOnly(true);
    List<String> options = new ArrayList<String>(Arrays.asList("Tissue/Extr. Material", "Secondary Name",
            "QBiC ID", "Lab ID", "MHC Type", "Used Antibody"));
    select1 = new ComboBox("First Info", options);
    select1.setStyleName(Styles.boxTheme);
    select1.setImmediate(true);
    select1.select("Tissue/Extr. Material");
    select2 = new ComboBox("Second Info", options);
    select2.select("Secondary Name");
    select2.setImmediate(true);
    select2.setStyleName(Styles.boxTheme);

    ValueChangeListener vc = new ValueChangeListener() {

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

        @Override
        public void valueChange(ValueChangeEvent event) {
            refresh();
        }
    };
    codedName.addValueChangeListener(vc);
    select1.addValueChangeListener(vc);
    select2.addValueChangeListener(vc);

    HorizontalLayout designBox = new HorizontalLayout();
    designBox.addComponent(select1);
    designBox.addComponent(select2);
    designBox.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    designBox.setSpacing(true);

    VerticalLayout previewBox = new VerticalLayout();
    previewBox.setStyleName(ValoTheme.LAYOUT_CARD);
    previewBox.setCaption("Barcode Example");
    previewBox.addComponent(test);

    addComponent(previewBox);
    addComponent(codedName);
    addComponent(designBox);

    //    overwrite = new CheckBox("Overwrite existing Tube Barcode Files");
    //    addComponent(ProjectwizardUI.questionize(overwrite,
    //        "Overwrites existing files of barcode stickers. This is useful when "
    //            + "the design was changed after creating them.", "Overwrite Sticker Files"));
}