Example usage for com.vaadin.ui Label setComponentError

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

Introduction

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

Prototype

public void setComponentError(ErrorMessage componentError) 

Source Link

Document

Sets the component's error message.

Usage

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel tooltips() {
    Panel p = new Panel("Tooltips");
    HorizontalLayout content = new HorizontalLayout() {
        {//from  www. ja  v a2s .  c  o m
            setSpacing(true);
            setMargin(true);
            addStyleName("wrapping");

            addComponent(new Label("Try out different tooltips/descriptions by hovering over the labels."));

            Label label = new Label("Simple");
            label.addStyleName("bold");
            label.setDescription("Simple tooltip message");
            addComponent(label);

            label = new Label("Long");
            label.addStyleName("bold");
            label.setDescription(
                    "Long tooltip message. Inmensae subtilitatis, obscuris et malesuada fames. Salutantibus vitae elit libero, a pharetra augue.");
            addComponent(label);

            label = new Label("HTML tooltip");
            label.addStyleName("bold");
            label.setDescription(
                    "<div><h1>Ut enim ad minim veniam, quis nostrud exercitation</h1><p><span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>Donec sed odio operae, eu vulputate felis rhoncus.</span> <span>At nos hinc posthac, sitientis piros Afros.</span> <span>Tu quoque, Brute, fili mi, nihil timor populi, nihil!</span></p><p><span>Gallia est omnis divisa in partes tres, quarum.</span> <span>Praeterea iter est quasdam res quas ex communi.</span> <span>Cum ceteris in veneratione tui montes, nascetur mus.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span> <span>Idque Caesaris facere voluntate liceret: sese habere.</span></p></div>");
            addComponent(label);

            label = new Label("With an error message");
            label.addStyleName("bold");
            label.setDescription("Simple tooltip message");
            label.setComponentError(new UserError("Something terrible has happened"));
            addComponent(label);

            label = new Label("With a long error message");
            label.addStyleName("bold");
            label.setDescription("Simple tooltip message");
            label.setComponentError(new UserError(
                    "<h2>Contra legem facit qui id facit quod lex prohibet <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span> <span>Prima luce, cum quibus mons aliud  consensu ab eo.</span> <span>Quid securi etiam tamquam eu fugiat nulla pariatur.</span> <span>Fabio vel iudice vincam, sunt in culpa qui officia.</span> <span>Nihil hic munitissimus habendi senatus locus, nihil horum?</span></p><p><span>Plura mihi bona sunt, inclinet, amari petere vellent.</span> <span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Nec dubitamus multa iter quae et nos invenerat.</span> <span>Quisque ut dolor gravida, placerat libero vel, euismod.</span> <span>Quae vero auctorem tractata ab fiducia dicuntur.</span></h2>",
                    AbstractErrorMessage.ContentMode.HTML, ErrorLevel.CRITICAL));
            addComponent(label);

            label = new Label("Error message only");
            label.addStyleName("bold");
            label.setComponentError(new UserError("Something terrible has happened"));
            addComponent(label);
        }
    };
    p.setContent(content);
    return p;

}

From source file:org.processbase.ui.bpm.worklist.CandidateTaskList.java

License:Open Source License

private void addTableRow(LightTaskInstance task, LightTaskInstance previousTask)
        throws InstanceNotFoundException, Exception {
    Item woItem = previousTask == null ? table.addItem(task) : table.addItemAfter(previousTask, task);
    try {/*from  w w  w  .j a  v a  2s  . c  o  m*/

        //        woItem.getItemProperty("accepted").setValue(task.isTaskAssigned() ? new ThemeResource("icons/accept.png") : new ThemeResource("icons/email.png"));
        ThemeResource icon = null;
        if (!task.isTaskAssigned()) {
            icon = new ThemeResource("icons/email.png");
        } else if (task.getState().equals(ActivityState.SUSPENDED) && task.getPriority() == 0) {
            icon = new ThemeResource("icons/pause_normal.png");
        } else if (task.getState().equals(ActivityState.SUSPENDED) && task.getPriority() == 1) {
            icon = new ThemeResource("icons/pause_high.png");
        } else if (task.getState().equals(ActivityState.SUSPENDED) && task.getPriority() == 2) {
            icon = new ThemeResource("icons/pause_urgent.png");
        } else if (task.getState().equals(ActivityState.EXECUTING) && task.getPriority() == 0) {
            icon = new ThemeResource("icons/arrow_right_normal.png");
        } else if (task.getState().equals(ActivityState.EXECUTING) && task.getPriority() == 1) {
            icon = new ThemeResource("icons/arrow_right_high.png");
        } else if (task.getState().equals(ActivityState.EXECUTING) && task.getPriority() == 2) {
            icon = new ThemeResource("icons/arrow_right_urgent.png");
        } else if (task.getState().equals(ActivityState.READY) && task.getPriority() == 0) {
            icon = new ThemeResource("icons/arrow_right_normal.png");
        } else if (task.getState().equals(ActivityState.READY) && task.getPriority() == 1) {
            icon = new ThemeResource("icons/arrow_right_high.png");
        } else if (task.getState().equals(ActivityState.READY) && task.getPriority() == 2) {
            icon = new ThemeResource("icons/arrow_right_urgent.png");
        } else {
            icon = new ThemeResource("icons/empty.png");
        }
        woItem.getItemProperty("accepted").setValue(icon);
        BPMModule bpmModule = ProcessbaseApplication.getCurrent().getBpmModule();
        LightProcessDefinition lpd = bpmModule.getLightProcessDefinition(task.getProcessDefinitionUUID());
        String processName = lpd.getLabel() != null ? lpd.getLabel() : lpd.getName();
        String processInstanceUUID = task.getProcessInstanceUUID().toString();
        TableLinkButton teb = new TableLinkButton(bpmModule.formatProcessName(lpd, task), lpd.getDescription(),
                null, task, this, Constants.ACTION_OPEN);
        woItem.getItemProperty("processName").setValue(teb);
        String taskTitle = task.getDynamicLabel() != null ? task.getDynamicLabel() : task.getActivityLabel();
        String taskDescription = task.getDynamicDescription() != null ? (" - " + task.getDynamicDescription())
                : "";
        woItem.getItemProperty("taskName").setValue(
                new Label("<b>" + taskTitle + "</b><i>" + taskDescription + "</i>", Label.CONTENT_XHTML));
        woItem.getItemProperty("lastUpdate").setValue(task.getLastUpdateDate());
        woItem.getItemProperty("expectedEndDate").setValue(task.getExpectedEndDate());
        woItem.getItemProperty("state").setValue(ProcessbaseApplication.getString(task.getState().toString()));

        ProcessInstanceUUID processUuid = task.getProcessInstanceUUID();
        if (task.getRootInstanceUUID() != null) {
            processUuid = task.getRootInstanceUUID();
        }
        try {
            LightProcessInstance process = bpmModule.getLightProcessInstance(processUuid);
            woItem.getItemProperty("initiator").setValue(process.getStartedBy());
        } catch (Exception e) {
            e.printStackTrace();
        }

    } catch (Exception e) {
        e.printStackTrace();
        Label label = new Label(task.getActivityName());
        label.setComponentError(new UserError(e.getMessage()));
        woItem.getItemProperty("taskName").setValue(label);

    }

}