Example usage for com.vaadin.ui Label setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentUploadField.java

License:Open Source License

public ProjectFormAttachmentUploadField() {
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    currentPollInterval = UI.getCurrent().getPollInterval();

    receiver = createReceiver();//from w  w w  .  j av  a 2s. c  om

    attachmentBtn = new MultiUpload();
    attachmentBtn.setButtonCaption("Select File(s)");
    attachmentBtn.setImmediate(true);

    MultiUploadHandler handler = new MultiUploadHandler() {
        private LinkedList<ProgressBar> indicators;

        @Override
        public void streamingStarted(StreamVariable.StreamingStartEvent event) {
        }

        @Override
        public void streamingFinished(StreamVariable.StreamingEndEvent event) {
            String tempName = event.getFileName();
            final String fileName;
            int index = tempName.lastIndexOf(".");
            if (index > 0) {
                String fileExt = tempName.substring(index + 1, tempName.length());
                fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "."
                        + fileExt;
            } else {
                fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis();
            }
            if (!indicators.isEmpty()) {
                rowWrap.replaceComponent(indicators.remove(0),
                        MobileAttachmentUtils.renderAttachmentFieldRow(
                                MobileAttachmentUtils.constructContent(fileName, attachmentPath),
                                new Button.ClickListener() {

                                    private static final long serialVersionUID = 581451358291203810L;

                                    @Override
                                    public void buttonClick(Button.ClickEvent event) {
                                        fileStores.remove(fileName);
                                    }
                                }));
            }

            if (indicators.size() == 0) {
                UI.getCurrent().setPollInterval(currentPollInterval);
            }

            File file = receiver.getFile();

            receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived());
            receiver.setValue(null);

        }

        @Override
        public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
            if (!indicators.isEmpty()) {
                Label uploadResult = new Label("Upload failed! File: " + event.getFileName());
                uploadResult.setStyleName("upload-status");
                rowWrap.replaceComponent(indicators.remove(0), uploadResult);
            }
        }

        @Override
        public void onProgress(StreamVariable.StreamingProgressEvent event) {
            long readBytes = event.getBytesReceived();
            long contentLength = event.getContentLength();
            float f = (float) readBytes / (float) contentLength;
            indicators.get(0).setValue(f);
        }

        @Override
        public OutputStream getOutputStream() {
            MultiUpload.FileDetail next = attachmentBtn.getPendingFileNames().iterator().next();
            return receiver.receiveUpload(next.getFileName(), next.getMimeType());
        }

        @Override
        public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) {
            UI.getCurrent().setPollInterval(500);
            if (indicators == null) {
                indicators = new LinkedList<ProgressBar>();
            }
            for (MultiUpload.FileDetail f : pendingFileNames) {
                ProgressBar pi = new ProgressBar();
                pi.setValue(0f);
                pi.setStyleName("upload-progress");
                pi.setWidth("100%");
                rowWrap.addComponentAsFirst(pi);
                pi.setEnabled(true);
                pi.setVisible(true);
                indicators.add(pi);
            }
        }

        @Override
        public boolean isInterrupted() {
            return false;
        }
    };
    attachmentBtn.setHandler(handler);

    fileStores = new HashMap<String, File>();

    constructUI();
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentUploadField.java

License:Open Source License

protected void constructUI() {
    content = new VerticalLayout();
    content.setStyleName("attachment-field");

    rowWrap = new VerticalLayout();
    rowWrap.setWidth("100%");
    rowWrap.setStyleName("attachment-row-wrap");

    Label compHeader = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT));
    compHeader.setStyleName("h2");

    content.addComponent(compHeader);/*from  w  ww . j a  v a2 s  .  c  om*/

    CssLayout btnWrap = new CssLayout();
    btnWrap.setWidth("100%");
    btnWrap.setStyleName("attachment-row");
    btnWrap.addComponent(attachmentBtn);

    content.addComponent(btnWrap);

    content.addComponent(rowWrap);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectAttachmentDisplayComp.java

License:Open Source License

private void constructUI() {
    this.setStyleName("attachment-display-comp");
    Label compHeader = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT));
    compHeader.setStyleName("h2");
    this.addComponent(compHeader);
    VerticalLayout comp = new VerticalLayout();
    comp.setStyleName("attachment-view-panel");
    comp.setWidth("100%");

    for (final Content attachment : attachments) {
        Component attachmentRow = MobileAttachmentUtils.renderAttachmentRow(attachment);
        comp.addComponent(attachmentRow);
    }//w  w  w  . j av  a2  s.  c o m
    this.addComponent(comp);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInput.java

License:Open Source License

private void prepareUploadField() {
    receiver = createReceiver();/*from ww  w.  ja va2s  . c o  m*/

    uploadField = new MultiUpload();
    uploadField.setButtonCaption("");
    uploadField.setImmediate(true);

    MultiUploadHandler handler = new MultiUploadHandler() {
        private LinkedList<ProgressBar> indicators;

        @Override
        public void streamingStarted(StreamVariable.StreamingStartEvent event) {
        }

        @Override
        public void streamingFinished(StreamVariable.StreamingEndEvent event) {
            String fileName = event.getFileName();
            int index = fileName.lastIndexOf(".");
            if (index > 0) {
                String fileExt = fileName.substring(index + 1, fileName.length());
                fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "."
                        + fileExt;
            }

            if (!indicators.isEmpty()) {
                statusWrapper.replaceComponent(indicators.remove(0), createAttachmentRow(fileName));
            }

            if (indicators.size() == 0) {
                UI.getCurrent().setPollInterval(currentPollInterval);
            }

            File file = receiver.getFile();

            receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived());
            receiver.setValue(null);
        }

        @Override
        public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
            if (!indicators.isEmpty()) {
                Label uploadResult = new Label("Upload failed! File: " + event.getFileName());
                uploadResult.setStyleName("upload-status");
                statusWrapper.replaceComponent(indicators.remove(0), uploadResult);
            }
        }

        @Override
        public void onProgress(StreamVariable.StreamingProgressEvent event) {
            long readBytes = event.getBytesReceived();
            long contentLength = event.getContentLength();
            float f = (float) readBytes / (float) contentLength;
            indicators.get(0).setValue(f);
        }

        @Override
        public OutputStream getOutputStream() {
            MultiUpload.FileDetail next = uploadField.getPendingFileNames().iterator().next();
            return receiver.receiveUpload(next.getFileName(), next.getMimeType());
        }

        @Override
        public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) {
            UI.getCurrent().setPollInterval(500);
            if (indicators == null) {
                indicators = new LinkedList<ProgressBar>();
            }
            for (MultiUpload.FileDetail f : pendingFileNames) {
                ProgressBar pi = new ProgressBar();
                pi.setValue(0f);
                pi.setStyleName("upload-progress");
                pi.setWidth("100%");
                statusWrapper.addComponent(pi);
                pi.setEnabled(true);
                pi.setVisible(true);
                indicators.add(pi);
            }
        }

        @Override
        public boolean isInterrupted() {
            return false;
        }
    };
    uploadField.setHandler(handler);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void initUI() {
    headerPanel = new HorizontalLayout();
    headerPanel.setWidth("100%");
    headerPanel.setStyleName("summary-info-panel");
    headerPanel.setMargin(new MarginInfo(true, false, true, false));
    headerPanel.setHeightUndefined();//from  w  w w  .  ja  v  a 2  s.co  m
    content.addComponent(headerPanel);
    constructSpentTimeEntryPanel();
    constructRemainTimeEntryPanel();

    this.tableItem = new DefaultPagedBeanList<ItemTimeLoggingService, ItemTimeLoggingSearchCriteria, SimpleItemTimeLogging>(
            ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), new TimeLogRowHandler()) {

        private static final long serialVersionUID = -4549910960891655297L;

        @Override
        protected void renderRows() {
            int i = 0;
            Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();
            for (final SimpleItemTimeLogging item : currentListData) {
                if (!DateUtils.isSameDay(item.getLogforday(), currentDate)) {
                    Label dateLbl = new Label(AppContext.formatDate(item.getLogforday()));
                    dateLbl.setStyleName("log-day");
                    listContainer.addComponent(dateLbl);
                    currentDate = item.getLogforday();
                }
                final Component row = getRowDisplayHandler().generateRow(item, i);
                listContainer.addComponent(row);
                i++;
            }
        }

    };

    this.tableItem.setWidth("100%");
    content.addComponent(tableItem);
    content.setExpandRatio(tableItem, 1.0f);

    VerticalLayout controlBtns = new VerticalLayout();
    controlBtns.setSpacing(true);
    controlBtns.setWidth("100%");
    controlBtns.setMargin(true);
    controlBtns.addStyleName("edit-btn-layout");
    controlBtns.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    Button addNewEntryBtn = new Button(AppContext.getMessage(TimeTrackingI18nEnum.M_DIALOG_ADD_TIME_LOG_ENTRY),
            new Button.ClickListener() {

                private static final long serialVersionUID = -2540265040691537699L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    UI.getCurrent().addWindow(new NewTimeLogEntryWindow());
                }
            });
    addNewEntryBtn.setWidth("100%");
    controlBtns.addComponent(addNewEntryBtn);

    Button updateRemainTimeBtn = new Button(
            AppContext.getMessage(TimeTrackingI18nEnum.M_DIALOG_UPDATE_REMAIN_HOURS),
            new Button.ClickListener() {

                private static final long serialVersionUID = 9215577509351959739L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    UI.getCurrent().addWindow(new UpdateRemainTimeWindow());
                }
            });
    updateRemainTimeBtn.setWidth("100%");
    controlBtns.addComponent(updateRemainTimeBtn);

    NavigationBarQuickMenu editBtn = new NavigationBarQuickMenu();
    editBtn.setButtonCaption(null);
    editBtn.setStyleName("edit-btn");
    editBtn.setContent(controlBtns);
    this.setRightComponent(editBtn);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void constructSpentTimeEntryPanel() {
    final VerticalLayout totalLayout = new VerticalLayout();
    totalLayout.setMargin(new MarginInfo(false, true, false, true));
    totalLayout.setStyleName("summary-block");
    totalLayout.addStyleName("total-time");
    totalLayout.setWidth("100%");
    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_TOTAL_SPENT_HOURS));
    lbTimeInstructTotal.setStyleName("block-label");
    totalLayout.addComponent(lbTimeInstructTotal);
    this.totalSpentTimeLbl = new Label("_");
    this.totalSpentTimeLbl.setStyleName("block-value");
    this.totalSpentTimeLbl.addStyleName("numberTotal");
    totalLayout.addComponent(this.totalSpentTimeLbl);

    headerPanel.addComponent(totalLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void constructRemainTimeEntryPanel() {
    final VerticalLayout updateLayout = new VerticalLayout();
    updateLayout.setMargin(new MarginInfo(false, true, false, true));
    updateLayout.setStyleName("summary-block");
    updateLayout.addStyleName("remain-time");
    updateLayout.setWidth("100%");

    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAINING_WORK_HOURS));
    lbTimeInstructTotal.setStyleName("block-label");
    updateLayout.addComponent(lbTimeInstructTotal);
    this.remainTimeLbl = new Label("_");
    this.remainTimeLbl.setStyleName("block-value");
    this.remainTimeLbl.addStyleName("numberTotal");
    updateLayout.addComponent(this.remainTimeLbl);

    this.headerPanel.addComponent(updateLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.view.bug.BugFormLayoutFactory.java

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);//  w  w  w.  j  a va 2  s.  com
    Label header = new Label(AppContext.getMessage(BugI18nEnum.M_FORM_READ_TITLE));
    header.setStyleName("h2");
    layout.addComponent(header);

    this.informationLayout = new GridFormLayoutHelper(1, 12, "100%", "150px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");
    this.informationLayout.getLayout().setMargin(false);
    this.informationLayout.getLayout().setWidth("100%");
    layout.addComponent(this.informationLayout.getLayout());
    layout.setComponentAlignment(this.informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

From source file:com.esofthead.mycollab.mobile.module.project.view.message.MessageAttachmentField.java

License:Open Source License

@Override
protected void constructUI() {
    content = new VerticalLayout();
    content.setStyleName("attachment-field");

    rowWrap = new VerticalLayout();
    rowWrap.setWidth("100%");
    rowWrap.setStyleName("attachment-row-wrap");

    HorizontalLayout compHeader = new HorizontalLayout();
    compHeader.setWidth("100%");
    compHeader.setStyleName("attachment-field-header");

    Label headerLbl = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT));
    headerLbl.setStyleName("field-caption");

    compHeader.addComponent(headerLbl);/*from  w ww.  ja  va 2 s .c  o m*/
    compHeader.setExpandRatio(headerLbl, 1.0f);

    compHeader.addComponent(attachmentBtn);

    content.addComponent(compHeader);

    content.addComponent(rowWrap);
}

From source file:com.esofthead.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java

License:Open Source License

@Override
public void previewItem(SimpleMessage message) {
    this.bean = message;
    mainLayout.removeAllComponents();/*from  ww w. j  a v  a 2s  . com*/

    HorizontalLayout messageBlock = new HorizontalLayout();
    messageBlock.setStyleName("message-block");
    Image userAvatarImg = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(message.getPostedUserAvatarId(), 32);
    userAvatarImg.setStyleName("user-avatar");
    messageBlock.addComponent(userAvatarImg);

    CssLayout rightCol = new CssLayout();
    rightCol.setWidth("100%");

    HorizontalLayout metadataRow = new HorizontalLayout();
    metadataRow.setWidth("100%");
    metadataRow.setStyleName("metadata-row");
    Label userNameLbl = new Label(message.getFullPostedUserName());
    userNameLbl.setStyleName("user-name");
    metadataRow.addComponent(userNameLbl);
    metadataRow.setExpandRatio(userNameLbl, 1.0f);

    Label messageTimePost = new Label(
            DateTimeUtils.getPrettyDateValue(message.getPosteddate(), AppContext.getUserLocale()));
    messageTimePost.setStyleName("time-post");
    messageTimePost.setWidthUndefined();
    metadataRow.addComponent(messageTimePost);
    rightCol.addComponent(metadataRow);

    HorizontalLayout titleRow = new HorizontalLayout();
    titleRow.setWidth("100%");
    titleRow.setStyleName("title-row");
    Label messageTitle = new Label(message.getTitle());
    messageTitle.setStyleName("message-title");
    titleRow.addComponent(messageTitle);
    titleRow.setExpandRatio(messageTitle, 1.0f);

    if (message.getCommentsCount() > 0) {
        Label msgCommentCount = new Label(String.valueOf(message.getCommentsCount()));
        msgCommentCount.setStyleName("comment-count");
        msgCommentCount.setWidthUndefined();
        titleRow.addComponent(msgCommentCount);
        titleRow.addStyleName("has-comment");
        titleRow.setComponentAlignment(messageTitle, Alignment.MIDDLE_LEFT);
    }
    rightCol.addComponent(titleRow);

    Label messageContent = new Label(
            StringUtils.trim(StringUtils.trimHtmlTags(message.getMessage()), 150, true));
    messageContent.setStyleName("message-content");
    rightCol.addComponent(messageContent);

    ResourceService attachmentService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService
            .getContents(AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(),
                    message.getProjectid(), AttachmentType.PROJECT_MESSAGE, message.getId()));
    if (attachments != null && !attachments.isEmpty()) {
        CssLayout attachmentPanel = new CssLayout();
        attachmentPanel.setStyleName("attachment-panel");
        attachmentPanel.setWidth("100%");

        for (Content attachment : attachments) {
            attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment));
        }
        rightCol.addComponent(attachmentPanel);
    }

    messageBlock.addComponent(rightCol);
    messageBlock.setExpandRatio(rightCol, 1.0f);
    messageBlock.setWidth("100%");

    mainLayout.addComponent(messageBlock);

    MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(CommentType.PRJ_MESSAGE,
            CurrentProjectVariables.getProjectId(), true, true, MessageRelayEmailNotificationAction.class);
    commentDisplay.loadComments("" + message.getId());

    this.setToolbar(commentDisplay.getCommentBox());
    mainLayout.addComponent(commentDisplay);
}