Example usage for com.vaadin.ui Label Label

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

Introduction

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

Prototype

public Label(String text) 

Source Link

Document

Creates a new instance with text content mode and the given text.

Usage

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

License:Open Source License

@Override
protected Component initContent() {
    ResourceService resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = resourceService.getContents(
            AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(), projectid, type, typeid));
    if (CollectionUtils.isNotEmpty(attachments)) {
        VerticalLayout comp = new VerticalLayout();
        comp.setStyleName("attachment-view-panel");

        for (final Content attachment : attachments) {
            String docName = attachment.getPath();
            int lastIndex = docName.lastIndexOf("/");
            if (lastIndex != -1) {
                docName = docName.substring(lastIndex + 1, docName.length());
            }//from w  ww  .j av  a2s .com

            if (MimeTypesUtil.isImageType(docName)) {
                Button b = new Button(attachment.getTitle(), new Button.ClickListener() {

                    private static final long serialVersionUID = 293396615972447886L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        AttachmentPreviewView previewView = new AttachmentPreviewView(
                                VaadinResourceManager.getResourceManager()
                                        .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE));
                        EventBusFactory.getInstance().post(new ShellEvent.PushView(this, previewView));
                    }
                });
                b.setWidth("100%");
                comp.addComponent(b);
            } else {
                Label l = new Label(attachment.getTitle());
                l.setWidth("100%");
                comp.addComponent(l);
            }
        }

        return comp;
    }
    return new Label("&nbsp;", ContentMode.HTML);
}

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();/*ww  w  .j a va  2 s. c o  m*/

    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 w  w.  j  a  va2 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);
    }/*www  .j  a va2  s . com*/
    this.addComponent(comp);
}

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

License:Open Source License

private void prepareUploadField() {
    receiver = createReceiver();//  w w w .  ja v a  2  s.  c  om

    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.ProjectCommentInput.java

License:Open Source License

private Component createAttachmentRow(String fileName) {
    final HorizontalLayout uploadSucceedLayout = new HorizontalLayout();
    uploadSucceedLayout.setWidth("100%");
    Label uploadResult = new Label(fileName);
    uploadResult.setWidth("100%");
    uploadSucceedLayout.addComponent(uploadResult);
    uploadSucceedLayout.setExpandRatio(uploadResult, 1.0f);

    Button removeAttachment = new Button(
            "<span aria-hidden=\"true\" data-icon=\"" + IconConstants.DELETE + "\"></span>",
            new Button.ClickListener() {

                private static final long serialVersionUID = 1L;

                @Override/*from www . ja  v  a  2s  .  com*/
                public void buttonClick(ClickEvent event) {
                    statusWrapper.removeComponent(uploadSucceedLayout);
                }

            });
    removeAttachment.setHtmlContentAllowed(true);
    removeAttachment.setStyleName("link");
    uploadSucceedLayout.addComponent(removeAttachment);
    uploadSucceedLayout.setStyleName("upload-succeed-layout");
    uploadSucceedLayout.setSpacing(true);
    return uploadSucceedLayout;
}

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

License:Open Source License

private Component createAttachmentRow(String fileName) {
    final MHorizontalLayout uploadSucceedLayout = new MHorizontalLayout().withFullWidth();
    Label uploadResult = new Label(fileName);
    uploadSucceedLayout.with(uploadResult).expand(uploadResult);

    Button removeAttachment = new Button("", new Button.ClickListener() {
        @Override/*w w  w.  j  a  va 2 s.  co m*/
        public void buttonClick(ClickEvent event) {
            statusWrapper.removeComponent(uploadSucceedLayout);
        }
    });
    removeAttachment.setIcon(FontAwesome.TRASH);
    removeAttachment.setHtmlContentAllowed(true);
    removeAttachment.setStyleName("link");
    uploadSucceedLayout.addComponent(removeAttachment);
    return uploadSucceedLayout;
}

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

License:Open Source License

public void displayTime(final V bean) {
    this.removeAllComponents();

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);/*  w  w  w.  j a  v a  2  s.c o  m*/
    header.setStyleName("info-hdr");
    header.addStyleName("timelog-comp-hdr");
    header.setWidth("100%");
    Label dateInfoHeader = new Label(AppContext.getMessage(TimeTrackingI18nEnum.SUB_INFO_TIME));
    dateInfoHeader.setWidthUndefined();
    header.addComponent(dateInfoHeader);
    header.setExpandRatio(dateInfoHeader, 1.0f);

    if (hasEditPermission()) {
        Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        showEditTimeView(bean);

                    }
                });
        editBtn.setStyleName("link");
        editBtn.setHtmlContentAllowed(true);
        header.addComponent(editBtn);
        header.setComponentAlignment(editBtn, Alignment.BOTTOM_LEFT);
    }

    this.addComponent(header);

    GridFormLayoutHelper layout = new GridFormLayoutHelper(1, 3, "100%", "150px", Alignment.TOP_RIGHT);
    layout.getLayout().setWidth("100%");
    layout.getLayout().setMargin(false);

    double billableHours = getTotalBillableHours(bean);
    double nonBillableHours = getTotalNonBillableHours(bean);
    double remainHours = getRemainedHours(bean);
    layout.addComponent(new Label(billableHours + ""),
            AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_BILLABLE_HOURS), 0, 0);
    layout.addComponent(new Label(nonBillableHours + ""),
            AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_NON_BILLABLE_HOURS), 0, 1);
    layout.addComponent(new Label(remainHours + ""),
            AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_REMAIN_HOURS), 0, 2);
    this.addComponent(layout.getLayout());
}

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();//  w w  w.  j  a  v a  2 s  .  com
    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);
}