Example usage for com.vaadin.ui Label setValue

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

Introduction

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

Prototype

public void setValue(String value) 

Source Link

Document

Sets the text to be shown in the label.

Usage

From source file:module.vaadin.ui.SystemInfoPage.java

License:Open Source License

public SystemInfoPage() {
    setSpacing(true);//  www  . j a  v  a 2  s . c  o  m

    final Label status = new Label((String) null, Label.CONTENT_PREFORMATTED);
    addComponent(status);

    Button serialize = new Button("serialize session", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                StringBuilder result = new StringBuilder();
                HttpSession session = ((WebApplicationContext) getApplication().getContext()).getHttpSession();
                for (Enumeration att = session.getAttributeNames(); att.hasMoreElements();) {
                    String key = (String) att.nextElement();
                    ByteArrayOutputStream array = new ByteArrayOutputStream();
                    ObjectOutputStream stream = new ObjectOutputStream(array);
                    stream.writeObject(session.getAttribute(key));
                    result.append(key + ":" + array.size() + " bytes\n");
                }
                status.setValue(result.toString());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    addComponent(serialize);
}

From source file:net.antoinecomte.regex.RegExTesterApplication.java

License:Apache License

private void showResult(String regexValue, String textValue) {
    Matcher matcher;/*w w w .ja  v  a  2 s  . co  m*/
    try {
        result.setVisible(!"".equals(regexValue));
        Label match = new Label("no match");
        match.addStyleName("h3 color");
        result.removeAllComponents();
        result.addComponent(match);
        matcher = Pattern.compile(regexValue).matcher(textValue);
        if (matcher.matches()) {
            if (matcher.groupCount() > 0)
                for (int i = 1; i <= matcher.groupCount(); i++) {
                    Label g = new Label("group " + i + " = " + matcher.group(i));
                    g.addStyleName("h3 color");
                    g.setSizeUndefined();
                    result.addComponent(g);
                }
            match.setValue("match");
        }
        matcher.reset();
        if (matcher.find()) {
            Label findresult = new Label("find=true, start = " + matcher.start() + " end = " + matcher.end());
            findresult.addStyleName("h3 color");
            result.addComponent(findresult);
        }
        Label javaString = new Label("java string : \"" + StringEscapeUtils.escapeJava(regexValue) + "\"");
        javaString.addStyleName("small color");
        result.addComponent(javaString);
    } catch (Exception e) {
        result.removeAllComponents();
        Label error = new Label(e.getMessage());
        error.addStyleName("error");
        result.addComponent(error);
    }
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.wizard.project.GAMPStep.java

License:Apache License

@Override
public Component getContent() {
    VerticalLayout vl = new VerticalLayout();
    Label text = new Label();
    text.setSizeFull();/*  w w  w  .j a  v a 2s  . com*/
    text.setEnabled(false);
    text.setValue(TRANSLATOR.translate("template.gamp5.disclaimer"));
    getCategory().removeAllItems();
    switch (wizard.getType()) {
    case "general.software":
        //Load SW options
        getCategory().addItem("template.gamp5.sw.cat1");
        getCategory().addItem("template.gamp5.sw.cat3");
        getCategory().addItem("template.gamp5.sw.cat4");
        getCategory().addItem("template.gamp5.sw.cat5");
        break;
    default:
        //Load HW options
        getCategory().addItem("template.gamp5.hw.cat1");
        getCategory().addItem("template.gamp5.hw.cat2");
    }
    wizard.translateSelect(getCategory());
    vl.addComponent(getCategory());
    vl.addComponent(text);
    vl.setSizeFull();
    return vl;
}

From source file:nz.co.senanque.vaadinsupport.I18n.I18nCaptionHelper.java

License:Apache License

private static void switchCaption(Label label, MessageSourceAccessor messageSourceAccessor) {
    String newCaption = getTranslatedCaption((String) label.getValue(), messageSourceAccessor);
    if (newCaption != null) {
        label.setValue(newCaption);
    }//w  w w .  j ava  2  s.co m
}

From source file:org.activiti.explorer.ui.custom.ToolBar.java

License:Apache License

public ToolBar() {
    entryMap = new HashMap<String, ToolbarEntry>();
    actionButtons = new ArrayList<Button>();
    additionalComponents = new ArrayList<Component>();

    setWidth("100%");
    setHeight(36, UNITS_PIXELS);/* ww  w  .j a v  a2  s .  c o m*/
    addStyleName(ExplorerLayout.STYLE_TOOLBAR);
    setSpacing(true);
    setMargin(false, true, false, true);

    // Add label to fill excess space
    Label spacer = new Label();
    spacer.setContentMode(Label.CONTENT_XHTML);
    spacer.setValue("&nbsp;");
    addComponent(spacer);
    setExpandRatio(spacer, 1.0f);
}

From source file:org.activiti.explorer.ui.flow.ProcessInstanceDetailPanel.java

License:Apache License

protected void addTasks() {
    Label header = new Label(i18nManager.getMessage(Messages.FLOW_INSTANCE_HEADER_TASKS));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    verticalLayout.addComponent(header);

    Label spacer = new Label();
    spacer.setValue("&nbsp");
    spacer.setContentMode(Label.CONTENT_XHTML);
    verticalLayout.addComponent(spacer);

    Table taskTable = new Table();
    taskTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
    taskTable.setWidth(100, UNITS_PERCENTAGE);

    // Fetch all tasks
    List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
            .processInstanceId(processInstance.getId()).orderByHistoricTaskInstanceEndTime().desc()
            .orderByHistoricActivityInstanceStartTime().desc().list();

    if (tasks.size() > 0) {

        // Finished icon
        taskTable.addContainerProperty("finished", Component.class, null, "", null, Table.ALIGN_CENTER);
        taskTable.setColumnWidth("finished", 22);

        taskTable.addContainerProperty("name", String.class, null, i18nManager.getMessage(Messages.TASK_NAME),
                null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("priority", Integer.class, null,
                i18nManager.getMessage(Messages.TASK_PRIORITY), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("assignee", Component.class, null,
                i18nManager.getMessage(Messages.TASK_ASSIGNEE), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("dueDate", Component.class, null,
                i18nManager.getMessage(Messages.TASK_DUEDATE), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("startDate", Component.class, null,
                i18nManager.getMessage(Messages.TASK_CREATE_TIME), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("endDate", Component.class, null,
                i18nManager.getMessage(Messages.TASK_COMPLETE_TIME), null, Table.ALIGN_LEFT);

        verticalLayout.addComponent(taskTable);
        verticalLayout.setExpandRatio(taskTable, 1.0f);

        for (HistoricTaskInstance task : tasks) {
            addTaskItem(task, taskTable);
        }/*from   w ww  .j  av  a2s. co m*/

        taskTable.setPageLength(taskTable.size());
    } else {
        // No tasks
        Label noTaskLabel = new Label(i18nManager.getMessage(Messages.FLOW_INSTANCE_NO_TASKS));
        verticalLayout.addComponent(noTaskLabel);
    }
}

From source file:org.activiti.explorer.ui.mainlayout.MainLayout.java

License:Apache License

protected void initFooter() {
    footer = new CssLayout();
    footer.setWidth(100, UNITS_PERCENTAGE);
    footer.addStyleName(ExplorerLayout.STYLE_MAIN_FOOTER);
    addComponent(footer);//from  w  ww.j  a v a 2 s.  c  o  m

    Label footerLabel = new Label();
    footerLabel.setContentMode(Label.CONTENT_XHTML);
    footerLabel.setValue(i18nManager.getMessage(Messages.FOOTER_MESSAGE));
    footerLabel.setWidth(100, UNITS_PERCENTAGE);
    footer.addComponent(footerLabel);
}

From source file:org.activiti.explorer.ui.management.deployment.DeploymentDetailPanel.java

License:Apache License

protected void addDeploymentName() {

    GridLayout taskDetails = new GridLayout(3, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);/*ww w.  j a va  2 s .  co m*/
    taskDetails.setMargin(false, false, true, false);

    // Add image
    Embedded image = new Embedded(null, Images.DEPLOYMENT_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add deployment name
    Label nameLabel = new Label();
    if (deployment.getName() != null) {
        nameLabel.setValue(deployment.getName());
    } else {
        nameLabel.setValue(i18nManager.getMessage(Messages.DEPLOYMENT_NO_NAME));
    }
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 2, 0);

    // Add deploy time
    PrettyTimeLabel deployTimeLabel = new PrettyTimeLabel(
            i18nManager.getMessage(Messages.DEPLOYMENT_DEPLOY_TIME), deployment.getDeploymentTime(), null,
            true);
    deployTimeLabel.addStyleName(ExplorerLayout.STYLE_DEPLOYMENT_HEADER_DEPLOY_TIME);
    taskDetails.addComponent(deployTimeLabel, 1, 1);

    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);

    addDetailComponent(taskDetails);
}

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

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(5, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);//from  w  w w.java2  s.c  om
    taskDetails.setMargin(false, false, true, false);

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(historicTask.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 4, 0);

    // Add due date
    PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT),
            historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false);
    dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE);
    taskDetails.addComponent(dueDateLabel, 1, 1);

    // Add priority
    Integer lowMedHighPriority = convertPriority(historicTask.getPriority());
    Label priorityLabel = new Label();
    switch (lowMedHighPriority) {
    case 1:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW);
        break;
    case 2:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM);
        break;
    case 3:
    default:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH);
    }
    taskDetails.addComponent(priorityLabel, 2, 1);

    // Add create date
    PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT),
            historicTask.getStartTime(), "", true);
    createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME);
    taskDetails.addComponent(createLabel, 3, 1);

    // Add label to fill excess space
    Label spacer = new Label();
    spacer.setContentMode(Label.CONTENT_XHTML);
    spacer.setValue("&nbsp;");
    spacer.setSizeUndefined();
    taskDetails.addComponent(spacer);

    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);
    taskDetails.setColumnExpandRatio(3, 1.0f);
    taskDetails.setColumnExpandRatio(4, 1.0f);
    centralLayout.addComponent(taskDetails);
}

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

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {//from  ww w.ja  v  a  2 s .  co m
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, UNITS_PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}