Search in sources :

Example 6 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class MultiButtonTable method populateCell.

protected void populateCell(WebMarkupContainer cellContainer, final AssignmentEditorDto assignment) {
    AjaxLink inner = new AjaxLink(ID_INNER) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            targetObjectDetailsPerformed(assignment, ajaxRequestTarget);
        }
    };
    inner.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    cellContainer.add(inner);
    Label nameLabel = new Label(ID_INNER_LABEL, assignment.getName());
    inner.add(nameLabel);
    Label descriptionLabel = new Label(ID_INNER_DESCRIPTION, assignment.getTargetRef() != null ? assignment.getTargetRef().getDescription() : "");
    descriptionLabel.setOutputMarkupId(true);
    inner.add(descriptionLabel);
    AjaxLink detailsLink = new AjaxLink(ID_DETAILS_LINK) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            assignmentDetailsPerformed(assignment, ajaxRequestTarget);
        }
    };
    detailsLink.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    cellContainer.add(detailsLink);
    Label detailsLinkLabel = new Label(ID_DETAILS_LINK_LABEL, pageBase.createStringResource("MultiButtonPanel.detailsLink"));
    detailsLinkLabel.setRenderBodyOnly(true);
    detailsLink.add(detailsLinkLabel);
    AjaxLink detailsLinkIcon = new AjaxLink(ID_DETAILS_LINK_ICON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    };
    detailsLinkIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    detailsLink.add(detailsLinkIcon);
    AjaxLink addToCartLink = new AjaxLink(ID_ADD_TO_CART_LINK) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            addAssignmentPerformed(assignment, ajaxRequestTarget);
        }
    };
    addToCartLink.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    cellContainer.add(addToCartLink);
    AjaxLink addToCartLinkIcon = new AjaxLink(ID_ADD_TO_CART_LINK_ICON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    };
    addToCartLinkIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    addToCartLink.add(addToCartLinkIcon);
    WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON);
    icon.add(new AttributeAppender("class", getIconClass(assignment.getType())));
    cellContainer.add(icon);
    WebMarkupContainer alreadyAssignedIcon = new WebMarkupContainer(ID_ALREADY_ASSIGNED_ICON);
    alreadyAssignedIcon.add(new AttributeAppender("title", getAlreadyAssignedIconTitleModel(assignment)));
    alreadyAssignedIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isMultiUserRequest() && assignment.isAlreadyAssigned();
        }
    });
    cellContainer.add(alreadyAssignedIcon);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 7 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class MultiButtonTable method initLayout.

private void initLayout() {
    itemsCount = getModel() != null ? (getModel().getObject() != null ? getModel().getObject().size() : 0) : 0;
    RepeatingView rows = new RepeatingView(ID_ROW);
    rows.setOutputMarkupId(true);
    if (itemsCount > 0 && itemsPerRow > 0) {
        int index = 0;
        List<AssignmentEditorDto> assignmentsList = getModelObject();
        long rowCount = itemsCount % itemsPerRow == 0 ? (itemsCount / itemsPerRow) : (itemsCount / itemsPerRow + 1);
        for (int rowNumber = 0; rowNumber < rowCount; rowNumber++) {
            WebMarkupContainer rowContainer = new WebMarkupContainer(rows.newChildId());
            rows.add(rowContainer);
            RepeatingView columns = new RepeatingView(ID_CELL);
            columns.setOutputMarkupId(true);
            rowContainer.add(columns);
            for (int colNumber = 0; colNumber < itemsPerRow; colNumber++) {
                WebMarkupContainer colContainer = new WebMarkupContainer(columns.newChildId());
                columns.add(colContainer);
                WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER);
                itemButtonContainer.setOutputMarkupId(true);
                itemButtonContainer.add(new AttributeAppender("class", getBackgroundClass(assignmentsList.get(index))));
                colContainer.add(itemButtonContainer);
                populateCell(itemButtonContainer, assignmentsList.get(index));
                index++;
                if (index >= assignmentsList.size()) {
                    break;
                }
            }
        }
    }
    add(rows);
}
Also used : RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 8 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class SingleButtonPanel method initLayout.

private void initLayout() {
    AjaxButton button = new AjaxButton(ID_BUTTON, createButtonStringResource(getCaption())) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            clickPerformed(target, SingleButtonPanel.this.getModel());
        }

        @Override
        public boolean isEnabled() {
            return SingleButtonPanel.this.isEnabled(SingleButtonPanel.this.getModel());
        }

        @Override
        public boolean isVisible() {
            return SingleButtonPanel.this.isVisible(SingleButtonPanel.this.getModel());
        }
    };
    button.add(new AttributeAppender("class", getButtonCssClass()));
    add(button);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 9 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class TablePanel method setTableCssClass.

public void setTableCssClass(String cssClass) {
    Validate.notEmpty(cssClass, "Css class must not be null or empty.");
    DataTable table = getDataTable();
    table.add(new AttributeAppender("class", new Model(cssClass), " "));
}
Also used : DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 10 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class BoxedTablePanel method initLayout.

private void initLayout(List<IColumn<T, String>> columns, ISortableDataProvider provider, int pageSize) {
    setOutputMarkupId(true);
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    box.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            String boxCssClasses = getAdditionalBoxCssClasses();
            if (boxCssClasses == null) {
                return "";
            } else {
                return " " + boxCssClasses;
            }
        }
    }));
    add(box);
    WebMarkupContainer tableContainer = new WebMarkupContainer(ID_TABLE_CONTAINER);
    tableContainer.setOutputMarkupId(true);
    DataTable<T, String> table = new SelectableDataTable<T>(ID_TABLE, columns, provider, pageSize) {

        @Override
        protected Item<T> newRowItem(String id, int index, IModel<T> rowModel) {
            Item<T> item = super.newRowItem(id, index, rowModel);
            return customizeNewRowItem(item, rowModel);
        }
    };
    table.setOutputMarkupId(true);
    tableContainer.add(table);
    box.add(tableContainer);
    TableHeadersToolbar headersTop = new TableHeadersToolbar(table, provider);
    headersTop.setOutputMarkupId(true);
    table.addTopToolbar(headersTop);
    box.add(createHeader(ID_HEADER));
    box.add(createFooter(ID_FOOTER));
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) IModel(org.apache.wicket.model.IModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

AttributeAppender (org.apache.wicket.behavior.AttributeAppender)51 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)29 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)25 Label (org.apache.wicket.markup.html.basic.Label)24 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)24 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)17 IModel (org.apache.wicket.model.IModel)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)8 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)7 ListItem (org.apache.wicket.markup.html.list.ListItem)7 ListView (org.apache.wicket.markup.html.list.ListView)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AttributeModifier (org.apache.wicket.AttributeModifier)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 TextField (org.apache.wicket.markup.html.form.TextField)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)4