Package org.apache.click.control

Examples of org.apache.click.control.Column


        table.setSortable(true);
        table.setStyle("margin-left", "0.25em;");

        // Define columns

        Column column = new Column("job.name", "Job Name");
        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();

                editLink.setParameter("job.name", jobAndTrigger.getJob().getName());
                editLink.render(buffer);

                buffer.append(" | ");
                deleteLink.setValue(jobAndTrigger.getJob().getName());
                deleteLink.render(buffer);

                if (!getSchedulerService().isPaused()) {

                    if (jobAndTrigger.getTriggerState() == Trigger.STATE_PAUSED) {
                        buffer.append(" | ");
                        resumeLink.setValue(jobAndTrigger.getJob().getName());
                        resumeLink.render(buffer);

                    } else {
                        buffer.append(" | ");
                        pauseLink.setValue(jobAndTrigger.getJob().getName());
                        pauseLink.render(buffer);
                    }

                    buffer.append(" | ");
                    triggerLink.setValue(jobAndTrigger.getJob().getName());
                    triggerLink.render(buffer);

                    if (jobAndTrigger.getTriggerState() == Trigger.STATE_BLOCKED) {
                        buffer.append(" | ");
                        interruptLink.setValue(jobAndTrigger.getJob().getName());
                        interruptLink.render(buffer);
                    }
                }

                return buffer.toString();
            }

        });
        actionColumn.setSortable(false);
        table.addColumn(actionColumn);

        // Add Control Buttons.

        newJob.setActionListener(new ActionListener(){
View Full Code Here


        table.setClass(Table.CLASS_ITS);
        table.setPageSize(10);
        table.setShowBanner(true);
        table.setSortable(true);

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

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

        Column column = new Column("email");
        column.setAutolink(true);
        column.setTitleProperty("name");
        table.addColumn(column);

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

        editLink.setImageSrc("/assets/images/table-edit.png");
        editLink.setTitle("Edit customer details");
        editLink.setParameter("referrer", "/introduction/advanced-table.htm");

        deleteLink.setImageSrc("/assets/images/table-delete.png");
        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.setTextAlign("center");
        AbstractLink[] links = new AbstractLink[] { editLink, deleteLink };
        column.setDecorator(new LinkDecorator(table, links, "id"));
        column.setSortable(false);
        table.addColumn(column);

        table.setDataProvider(new DataProvider<Customer>() {

            private static final long serialVersionUID = 1L;
View Full Code Here

        table.setShowBanner(true);
        table.setSortable(true);
        table.setPaginator(new TableInlinePaginator(table));
        table.setPaginatorAttachment(Table.PAGINATOR_INLINE);

        Column column = new Column(Customer.NAME_PROPERTY);
        column.setWidth("140px;");
        table.addColumn(column);

        column = new Column(Customer.EMAIL_PROPERTY);
        column.setAutolink(true);
        column.setWidth("230px;");
        table.addColumn(column);

        column = new Column(Customer.AGE_PROPERTY);
        column.setTextAlign("center");
        column.setWidth("40px;");
        table.addColumn(column);

        column = new Column(Customer.HOLDINGS_PROPERTY);
        column.setFormat("${0,number,#,##0.00}");
        column.setTextAlign("right");
        column.setWidth("100px;");
        table.addColumn(column);

        editLink.setImageSrc("/assets/images/table-edit.png");
        editLink.setTitle("Edit customer details");
        editLink.setParameter("referrer", "/table/search-table.htm");

        deleteLink.setImageSrc("/assets/images/table-delete.png");
        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.setTextAlign("center");
        AbstractLink[] links = new AbstractLink[] { editLink, deleteLink };
        column.setDecorator(new LinkDecorator(table, links, "id"));
        column.setSortable(false);
        table.addColumn(column);

        table.setDataProvider(new DataProvider<Customer>() {
            public List<Customer> getData() {
                return getCustomerService().getCustomers(nameField.getValue(),
View Full Code Here

    public SimpleTablePage() {
        table = new Table("table");

        table.setClass(Table.CLASS_ITS);

        table.addColumn(new Column("id"));
        table.addColumn(new Column("name"));
        table.addColumn(new Column("email"));
        table.addColumn(new Column("investments"));

        addControl(table);
    }
View Full Code Here

        pickList = new PickList("courseList", "Courses");
        pickList.addAll(studentService.getCourses(), "id", "name");
        form.add(pickList);

        // Table
        table.addColumn(new Column("id"));
        table.addColumn(new Column("name"));

        super.onInit();
    }
View Full Code Here

        addControl(table);

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

        Column column = new Column("name");
        column.setWidth("140px;");
        table.addColumn(column);

        column = new Column("email");
        column.setAutolink(true);
        column.setWidth("230px;");
        table.addColumn(column);

        column = new Column("age");
        column.setTextAlign("center");
        column.setWidth("40px;");
        table.addColumn(column);

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

        table.setDataProvider(new DataProvider<Customer>() {
            public List<Customer> getData() {
                return customerService.getCustomersSortedByName(17);
View Full Code Here

        addControl(deleteLink);

        // 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

        // Setup customers table
        table.setClass("isi");
        table.setWidth("550px");
        table.setSortable(false);

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

        Column column = new Column("age");
        column.setTextAlign("center");
        table.addColumn(column);

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

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

        column = new Column("dateJoined");
        column.setTextAlign("right");
        column.setFormat("{0, date,dd MMM yyyy}");
        table.addColumn(column);

        table.setDataProvider(new DataProvider<Customer>() {
            public List<Customer> getData() {
                Date from = filterPanel.getStartDate();
View Full Code Here

        table.setClass(Table.CLASS_ISI);
        table.setPageSize(4);
        table.setShowBanner(true);
        table.setSortable(true);

        Column column = new Column("name");
        column.setWidth("140px;");
        table.addColumn(column);

        column = new Column("email");
        column.setAutolink(true);
        column.setWidth("230px;");
        table.addColumn(column);

        column = new Column("age");
        column.setTextAlign("center");
        column.setWidth("40px;");
        table.addColumn(column);

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

        table.setDataProvider(new DataProvider<Customer>() {
            public List<Customer> getData() {
                return customerService.getCustomers();
View Full Code Here

        // Complete form initialization
        form.add(new Submit("save", " Save ", this, "onSaveClick"));
        form.add(new Submit("cancel", "Cancel", this, "onCancelClick"));

        // Complete table initialization
        Column column = new Column("Action");
        column.setSortable(false);
        column.setAttribute("width", "100px;");
        ActionLink[] links = new ActionLink[]{editLink, removeLink};
        column.setDecorator(new LinkDecorator(table, links, "id"));
        table.addColumn(column);

        removeLink.setAttribute("onclick", "return window.confirm('Are you sure you want to delete this record?');");
    }
View Full Code Here

TOP

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

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.