Package org.apache.click.control

Examples of org.apache.click.control.Decorator


        column.setTitleProperty("job.description");
        table.addColumn(column);

        final Column statusColumn = new Column("triggerStateAsString", "Status");
        statusColumn.setEscapeHtml(false);
        statusColumn.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                JobAndSimpleTrigger jobAndTrigger = (JobAndSimpleTrigger) row;
                switch(jobAndTrigger.getTriggerState()){
                case Trigger.STATE_NONE:
                    return "<span style='color:red'>None</span>";
                case Trigger.STATE_NORMAL:
                    return "<span style='color:blue'>Normal</span>";
                case Trigger.STATE_PAUSED:
                    return "<span style='color:red'>Paused</span>";
                case Trigger.STATE_BLOCKED:
                    return "<span style='color:green'>Running</span>";
                case Trigger.STATE_COMPLETE:
                    return "<span style='color:black'>Complete</span>";
                case Trigger.STATE_ERROR:
                    return "<span style='color:red'>Error</span>";
                }
                return "Unknown";
            }
        });
        table.addColumn(statusColumn);

        table.addColumn(new Column("interval"));

        column = new Column("trigger.nextFireTime", "Next Run");
        column.setFormat(DATE_FORMAT);
        table.addColumn(column);

        column = new Column("trigger.startTime", "First Run");
        column.setFormat(DATE_FORMAT);
        table.addColumn(column);

        column = new Column("trigger.previousFireTime", "Last Run");
        column.setFormat(DATE_FORMAT);
        table.addColumn(column);

        // Initialized action column links

        editLink.setAttribute("class", "actionIcon");
        editLink.setTitle("Edit Job");
        addControl(editLink);

        pauseLink.setAttribute("class", "actionIcon");
        pauseLink.setTitle("Pause Job");
        pauseLink.setActionListener(new ActionListener(){
            public boolean onAction(Control source) {
                String name = pauseLink.getValue();
                getSchedulerService().pauseJob(name);
                setFlashMessage("Paused job '" + name + "'");
                return true;
            }
        });
        addControl(pauseLink);

        interruptLink.setAttribute("class", "actionIcon");
        interruptLink.setTitle("Interrupt Running Job");
        interruptLink.setActionListener(new ActionListener(){
            public boolean onAction(Control source) {
                String name = interruptLink.getValue();
                if (getSchedulerService().interuptJob(name)) {
                    setFlashMessage("Interrupted job '" + name + "'");
                } else {
                    setFlashMessage("Could not interrupt job '" + name + "'");
                }
                return true;
            }
        });
        addControl(interruptLink);

        triggerLink.setAttribute("class", "actionIcon");
        triggerLink.setTitle("Trigger Job");
        triggerLink.setActionListener(new ActionListener(){
            public boolean onAction(Control source) {
                String name = triggerLink.getValue();
                getSchedulerService().triggerJob(name);
                setFlashMessage("Triggered job '" + name +  "'");
                return true;
            }
        });
        addControl(triggerLink);

        resumeLink.setAttribute("class", "actionIcon");
        resumeLink.setTitle("Resume Job");
        resumeLink.setActionListener(new ActionListener(){
            public boolean onAction(Control source) {
                String name = resumeLink.getValue();
                getSchedulerService().resumeJob(name);
                setFlashMessage("Resumed job '" + name + "'");
                return true;
            }
        });
        addControl(resumeLink);

        deleteLink.setAttribute("class", "actionIcon");
        deleteLink.setTitle("Delete Job");
        String confirmMessage = getMessage("deleteConfirm", "Job");
        deleteLink.setAttribute("onclick", "return window.confirm('" + confirmMessage + "')");
        deleteLink.setActionListener(new ActionListener(){
            public boolean onAction(Control source) {
                String name = deleteLink.getValue();
                if (getSchedulerService().deleteJob(name)) {
                    setFlashMessage("Deleted job '" + name + "'");
                } else {
                    setFlashMessage("Could not delete " + name);
                }
                return true;
            }
        });
        addControl(deleteLink);

        // Add table action column if user has edit or delete permissions
        final Column actionColumn = new Column("action");

        // Render action controls based on users permission
        actionColumn.setDecorator(new Decorator() {
            public String render(Object object, Context context) {
                JobAndSimpleTrigger jobAndTrigger = (JobAndSimpleTrigger) object;

                HtmlStringBuffer buffer = new HtmlStringBuffer();
View Full Code Here


        // Setup customers table
        table.setClass(Table.CLASS_SIMPLE);

        Column column = new Column("name");
        column.setSortable(false);
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String email = customer.getEmail();
                String name = customer.getName();
                return "<a href='mailto:" + email + "'>" + name + "</a>";
            }
        });
        table.addColumn(column);

        column = new Column("investments");
        column.setAutolink(true);
        table.addColumn(column);

        column = new Column("holdings");
        column.setFormat("${0,number,#,##0.00}");
        column.setTextAlign("right");
        table.addColumn(column);

        viewLink.setTitle("View customer details");

        editLink.setListener(this, "onEditClick");
        editLink.setTitle("Edit customer details");
        editLink.setParameter("referrer", "/table/table-decorator.htm");

        deleteLink.setTitle("Delete customer record");
        deleteLink.setAttribute("onclick", "return window.confirm('Are you sure you want to delete this record?');");

        column = new Column("Action");
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String id = String.valueOf(customer.getId());

                viewLink.setValue(id);
View Full Code Here

     * for each tree node.
     *
     * @return a decorator that renders a Checkbox for each tree node
     */
    protected Decorator createDecorator() {
        return new Decorator() {

            public String render(Object object, Context context) {
                TreeNode treeNode = (TreeNode) object;
                HtmlStringBuffer buffer = new HtmlStringBuffer();

View Full Code Here

        form.add(select);

        // Table
        table.addColumn(new Column("id"));
        table.addColumn(new Column("name"));
        table.addColumn(new Column("studentHouse")).setDecorator(new Decorator() {

            public String render(Object object, Context context) {
                Student student = (Student) object;
                if (student.getStudentHouse() != null) {
                    return student.getStudentHouse().getName();
View Full Code Here

     * for each tree node.
     *
     * @return a decorator that renders a Checkbox for each tree node
     */
    protected Decorator createDecorator() {
        return new Decorator() {

            public String render(Object object, Context context) {
                TreeNode treeNode = (TreeNode) object;
                HtmlStringBuffer buffer = new HtmlStringBuffer();

View Full Code Here

        column.setTitleProperty("job.description");
        table.addColumn(column);

        final Column statusColumn = new Column("triggerStateAsString", "Status");
        statusColumn.setEscapeHtml(false);
        statusColumn.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                JobAndSimpleTrigger jobAndTrigger = (JobAndSimpleTrigger) row;
                switch(jobAndTrigger.getTriggerState()){
                case Trigger.STATE_NONE:
                    return "<span style='color:red'>None</span>";
                case Trigger.STATE_NORMAL:
                    return "<span style='color:blue'>Normal</span>";
                case Trigger.STATE_PAUSED:
                    return "<span style='color:red'>Paused</span>";
                case Trigger.STATE_BLOCKED:
                    return "<span style='color:green'>Running</span>";
                case Trigger.STATE_COMPLETE:
                    return "<span style='color:black'>Complete</span>";
                case Trigger.STATE_ERROR:
                    return "<span style='color:red'>Error</span>";
                }
                return "Unknown";
            }
        });
        table.addColumn(statusColumn);

        table.addColumn(new Column("interval"));

        column = new Column("trigger.nextFireTime", "Next Run");
        column.setFormat(DATE_FORMAT);
        table.addColumn(column);

        column = new Column("trigger.startTime", "First Run");
        column.setFormat(DATE_FORMAT);
        table.addColumn(column);

        column = new Column("trigger.previousFireTime", "Last Run");
        column.setFormat(DATE_FORMAT);
        table.addColumn(column);

        // Initialized action column links

        editLink.setAttribute("class", "actionIcon");
        editLink.setTitle("Edit Job");
        addControl(editLink);

        pauseLink.setAttribute("class", "actionIcon");
        pauseLink.setTitle("Pause Job");
        pauseLink.setActionListener(new ActionListener(){
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
                String name = pauseLink.getValue();
                getSchedulerService().pauseJob(name);
                setFlashMessage("Paused job '" + name + "'");
                return true;
            }
        });
        addControl(pauseLink);

        interruptLink.setAttribute("class", "actionIcon");
        interruptLink.setTitle("Interrupt Running Job");
        interruptLink.setActionListener(new ActionListener(){
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
                String name = interruptLink.getValue();
                if (getSchedulerService().interruptJob(name)) {
                    setFlashMessage("Interrupted job '" + name + "'");
                } else {
                    setFlashMessage("Could not interrupt job '" + name + "'");
                }
                return true;
            }
        });
        addControl(interruptLink);

        triggerLink.setAttribute("class", "actionIcon");
        triggerLink.setTitle("Trigger Job");
        triggerLink.setActionListener(new ActionListener(){
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
                String name = triggerLink.getValue();
                getSchedulerService().triggerJob(name);
                setFlashMessage("Triggered job '" + name +  "'");
                return true;
            }
        });
        addControl(triggerLink);

        resumeLink.setAttribute("class", "actionIcon");
        resumeLink.setTitle("Resume Job");
        resumeLink.setActionListener(new ActionListener(){
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
                String name = resumeLink.getValue();
                getSchedulerService().resumeJob(name);
                setFlashMessage("Resumed job '" + name + "'");
                return true;
            }
        });
        addControl(resumeLink);

        deleteLink.setAttribute("class", "actionIcon");
        deleteLink.setTitle("Delete Job");
        String confirmMessage = getMessage("deleteConfirm", "Job");
        deleteLink.setAttribute("onclick", "return window.confirm('" + confirmMessage + "')");
        deleteLink.setActionListener(new ActionListener(){
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
                String name = deleteLink.getValue();
                if (getSchedulerService().deleteJob(name)) {
                    setFlashMessage("Deleted job '" + name + "'");
                } else {
                    setFlashMessage("Could not delete " + name);
                }
                return true;
            }
        });
        addControl(deleteLink);

        // Add table action column if user has edit or delete permissions
        final Column actionColumn = new Column("action");

        // Render action controls based on users permission
        actionColumn.setDecorator(new Decorator() {
            public String render(Object object, Context context) {
                JobAndSimpleTrigger jobAndTrigger = (JobAndSimpleTrigger) object;

                HtmlStringBuffer buffer = new HtmlStringBuffer();
View Full Code Here

        // Setup customers table
        table.setClass(Table.CLASS_SIMPLE);

        Column column = new Column("name");
        column.setSortable(false);
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String email = customer.getEmail();
                String name = customer.getName();
                return "<a href='mailto:" + email + "'>" + name + "</a>";
            }
        });
        table.addColumn(column);

        column = new Column("investments");
        column.setAutolink(true);
        table.addColumn(column);

        column = new Column("holdings");
        column.setFormat("${0,number,#,##0.00}");
        column.setTextAlign("right");
        table.addColumn(column);

        viewLink.setTitle("View customer details");

        editLink.setListener(this, "onEditClick");
        editLink.setTitle("Edit customer details");
        editLink.setParameter("referrer", "/table/table-decorator.htm");

        deleteLink.setTitle("Delete customer record");
        deleteLink.setAttribute("onclick", "return window.confirm('Are you sure you want to delete this record?');");

        column = new Column("Action");
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String id = String.valueOf(customer.getId());

                viewLink.setValue(id);
View Full Code Here

     * for each tree node.
     *
     * @return a decorator that renders a Checkbox for each tree node
     */
    protected Decorator createDecorator() {
        return new Decorator() {

            public String render(Object object, Context context) {
                TreeNode treeNode = (TreeNode) object;
                HtmlStringBuffer buffer = new HtmlStringBuffer();

View Full Code Here

        // Setup customers table
        table.setClass(Table.CLASS_SIMPLE);

        Column column = new Column("name");
        column.setSortable(false);
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String email = customer.getEmail();
                String name = customer.getName();
                return "<a href='mailto:" + email + "'>" + name + "</a>";
            }
        });
        table.addColumn(column);

        column = new Column("investments");
        column.setAutolink(true);
        table.addColumn(column);

        column = new Column("holdings");
        column.setFormat("${0,number,#,##0.00}");
        column.setTextAlign("right");
        table.addColumn(column);

        viewLink.setTitle("View customer details");

        editLink.setListener(this, "onEditClick");
        editLink.setTitle("Edit customer details");
        editLink.setParameter("referrer", "/table/table-decorator.htm");

        deleteLink.setTitle("Delete customer record");
        deleteLink.setAttribute("onclick", "return window.confirm('Are you sure you want to delete this record?');");

        column = new Column("Action");
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String id = String.valueOf(customer.getId());

                viewLink.setValue(id);
View Full Code Here

     * for each tree node.
     *
     * @return a decorator that renders a Checkbox for each tree node
     */
    protected Decorator createDecorator() {
        return new Decorator() {

            public String render(Object object, Context context) {
                TreeNode treeNode = (TreeNode) object;
                HtmlStringBuffer buffer = new HtmlStringBuffer();

View Full Code Here

TOP

Related Classes of org.apache.click.control.Decorator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.