Search in sources :

Example 61 with AttributeAppender

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

the class MetadataPanel method initLayout.

private void initLayout() {
    WebMarkupContainer metadataBlock = new WebMarkupContainer(ID_METADATA_BLOCK);
    metadataBlock.setOutputMarkupId(true);
    add(metadataBlock);
    WebMarkupContainer headerContainer = new WebMarkupContainer(ID_HEADER_CONTAINER);
    headerContainer.setOutputMarkupId(true);
    headerContainer.add(new AttributeAppender("class", "prism-header " + additionalHeaderStyle));
    metadataBlock.add(headerContainer);
    Label metadataHeader = new Label(ID_METADATA_LABEL, createStringResource("AssignmentEditorPanel.metadataBlock", header != null ? header : ""));
    metadataHeader.setOutputMarkupId(true);
    headerContainer.add(metadataHeader);
    RepeatingView metadataRowRepeater = new RepeatingView(ID_METADATA_ROW);
    metadataBlock.add(metadataRowRepeater);
    for (QName qname : metadataFieldsList) {
        WebMarkupContainer metadataRow = new WebMarkupContainer(metadataRowRepeater.newChildId());
        metadataRow.setOutputMarkupId(true);
        if (metadataFieldsList.indexOf(qname) % 2 != 0) {
            metadataRow.add(new AttributeAppender("class", "stripe"));
        }
        metadataRowRepeater.add(metadataRow);
        metadataRow.add(new Label(ID_METADATA_PROPERTY_KEY, createStringResource(DOT_CLASS + qname.getLocalPart())));
        IModel<String> metadataFieldModel = new IModel<String>() {

            @Override
            public String getObject() {
                PropertyModel<Object> tempModel = new PropertyModel<>(getModel(), qname.getLocalPart());
                if (tempModel.getObject() instanceof XMLGregorianCalendar) {
                    return WebComponentUtil.getLongDateTimeFormattedValue((XMLGregorianCalendar) tempModel.getObject(), getPageBase());
                } else if (tempModel.getObject() instanceof ObjectReferenceType) {
                    ObjectReferenceType ref = (ObjectReferenceType) tempModel.getObject();
                    return WebComponentUtil.getName(ref, getPageBase(), OPERATION_LOAD_USER);
                } else if (tempModel.getObject() instanceof List) {
                    List list = (List) tempModel.getObject();
                    String result = "";
                    for (Object o : list) {
                        if (o instanceof ObjectReferenceType) {
                            if (result.length() > 0) {
                                result += ", ";
                            }
                            result += WebComponentUtil.getName((ObjectReferenceType) o, getPageBase(), OPERATION_LOAD_USER);
                        }
                    }
                    return result;
                }
                return "";
            }
        };
        metadataRow.add(new Label(ID_METADATA_FILED, metadataFieldModel));
        metadataRow.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isVisible() {
                return StringUtils.isNotEmpty(metadataFieldModel.getObject());
            }
        });
    }
}
Also used : IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 62 with AttributeAppender

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

the class RoleCatalogItemButton method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER);
    itemButtonContainer.setOutputMarkupId(true);
    itemButtonContainer.add(new AttributeAppender("class", getBackgroundClass(getModelObject())));
    add(itemButtonContainer);
    AjaxLink<Void> inner = new AjaxLink<Void>(ID_INNER) {

        private static final long serialVersionUID = 1L;

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

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isAuthorizedForTargetObjectDetailsPage(getModelObject()) && (isMultiUserRequest() || canAssign(RoleCatalogItemButton.this.getModelObject()));
        }
    });
    inner.add(new AttributeAppender("title", getModelObject().getName()));
    itemButtonContainer.add(inner);
    Label nameLabel = new Label(ID_INNER_LABEL, getModelObject().getName());
    inner.add(nameLabel);
    Label descriptionLabel = new Label(ID_INNER_DESCRIPTION, getModelObject().getTargetRef() != null ? getModelObject().getTargetRef().getDescription() : "");
    descriptionLabel.setOutputMarkupId(true);
    inner.add(descriptionLabel);
    AjaxLink<Void> detailsLink = new AjaxLink<Void>(ID_DETAILS_LINK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            assignmentDetailsPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget);
        }
    };
    detailsLink.add(getAssignmentDetailsLinkVisibleBehavior());
    detailsLink.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase())));
    detailsLink.add(AttributeAppender.append("class", new LoadableModel<String>() {

        @Override
        protected String load() {
            return detailsLink.isEnabled() ? "shopping-cart-item-button-details" : "shopping-cart-item-button-details-disabled";
        }
    }));
    itemButtonContainer.add(detailsLink);
    Label detailsLinkLabel = new Label(ID_DETAILS_LINK_LABEL, createStringResource("MultiButtonPanel.detailsLink"));
    detailsLinkLabel.setRenderBodyOnly(true);
    detailsLink.add(detailsLinkLabel);
    AjaxLink<Void> detailsLinkIcon = new AjaxLink<Void>(ID_DETAILS_LINK_ICON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    };
    detailsLinkIcon.add(getAssignmentDetailsLinkVisibleBehavior());
    detailsLink.add(detailsLinkIcon);
    AjaxLink<Void> addToCartLink = new AjaxLink<Void>(ID_ADD_TO_CART_LINK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            addAssignmentPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget);
        }
    };
    addToCartLink.add(getFooterLinksEnableBehaviour());
    addToCartLink.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase())));
    addToCartLink.add(AttributeAppender.append("class", new LoadableModel<String>() {

        @Override
        protected String load() {
            return addToCartLink.isEnabled() ? "shopping-cart-item-button-add" : "shopping-cart-item-button-add-disabled";
        }
    }));
    itemButtonContainer.add(addToCartLink);
    AjaxLink<Void> addToCartLinkIcon = new AjaxLink<Void>(ID_ADD_TO_CART_LINK_ICON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    };
    addToCartLinkIcon.add(getFooterLinksEnableBehaviour());
    addToCartLink.add(addToCartLinkIcon);
    WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON);
    icon.add(new AttributeAppender("class", WebComponentUtil.createDefaultBlackIcon(getModelObject().getType().getQname())));
    itemButtonContainer.add(icon);
    WebMarkupContainer alreadyAssignedIcon = new WebMarkupContainer(ID_ALREADY_ASSIGNED_ICON);
    alreadyAssignedIcon.add(new AttributeAppender("title", getAlreadyAssignedIconTitleModel(getModelObject())));
    alreadyAssignedIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isMultiUserRequest() && getModelObject().isAlreadyAssigned();
        }
    });
    itemButtonContainer.add(alreadyAssignedIcon);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) 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 63 with AttributeAppender

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

the class DoubleButtonPanel method initLayout.

private void initLayout() {
    AjaxButton firstButton = new AjaxButton(ID_BUTTON_FIRST, createButtonStringResource(getFirstCaption())) {

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

        @Override
        public boolean isEnabled() {
            return isFirstEnabled(DoubleButtonPanel.this.getModel());
        }
    };
    firstButton.add(new AttributeAppender("class", getFirstCssClass()));
    AjaxButton secondButton = new AjaxButton(ID_BUTTON_SECOND, createButtonStringResource(getSecondCaption())) {

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

        @Override
        public boolean isEnabled() {
            return isSecondEnabled(DoubleButtonPanel.this.getModel());
        }
    };
    secondButton.add(new AttributeAppender("class", getSecondCssClass()));
    add(firstButton);
    add(secondButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 64 with AttributeAppender

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

the class AssignmentConflictPanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    Form container = new MidpointForm<>(ID_PANEL_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    Label statusIconLabel = new Label(ID_STATUS_ICON);
    statusIconLabel.add(new AttributeAppender("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null ? (getModelObject().isResolved() ? STATUS_FIXED : (getModelObject().isWarning() ? STATUS_WARNING : STATUS_ERROR)) : STATUS_ERROR;
        }
    }));
    container.add(statusIconLabel);
    Label existingAssignment = new Label(ID_EXISTING_ASSIGNMENT, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (getModelObject() != null) {
                String name = getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment1().getAssignmentTargetObject().getOid();
                return name + " " + getMessageLabel(getModelObject().getAssignment1().isOldAssignment());
            }
            return "";
        }
    });
    existingAssignment.add(new AttributeAppender("style", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null && getModelObject().getAssignment1().isResolved() ? "text-decoration: line-through;" : "";
        }
    }));
    container.add(existingAssignment);
    Label addedAssignment = new Label(ID_ADDED_ASSIGNMENT, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (getModelObject() != null) {
                String name = getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment2().getAssignmentTargetObject().getOid();
                return name + " " + getMessageLabel(getModelObject().getAssignment2().isOldAssignment());
            }
            return "";
        }
    });
    addedAssignment.add(new AttributeAppender("style", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null && getModelObject().getAssignment2().isResolved() ? "text-decoration: line-through;" : "";
        }
    }));
    container.add(addedAssignment);
    IModel<String> removeButtonTitleModel = new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject().getAssignment1().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
        }
    };
    AjaxSubmitButton removeButton = new AjaxSubmitButton(ID_REMOVE_BUTTON, removeButtonTitleModel) {

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment1(), target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }

        @Override
        public boolean isEnabled() {
            return !getModelObject().getAssignment2().isResolved();
        }
    });
    container.add(removeButton);
    IModel<String> unselectButtonTitleModel = new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject().getAssignment2().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
        }
    };
    AjaxSubmitButton unselectButton = new AjaxSubmitButton(ID_UNSELECT_BUTTON, unselectButtonTitleModel) {

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment2(), target);
        }
    };
    unselectButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }

        @Override
        public boolean isEnabled() {
            return !getModelObject().getAssignment1().isResolved();
        }
    });
    container.add(unselectButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) IModel(org.apache.wicket.model.IModel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Label(org.apache.wicket.markup.html.basic.Label) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 65 with AttributeAppender

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

the class CapabilityStep method initLayout.

protected void initLayout() {
    final ListDataProvider<CapabilityDto<CapabilityType>> capabilityProvider = new ListDataProvider<>(this, new PropertyModel<List<CapabilityDto<CapabilityType>>>(dtoModel, CapabilityStepDto.F_CAPABILITIES));
    WebMarkupContainer tableBody = new WebMarkupContainer(ID_CAPABILITY_TABLE);
    tableBody.setOutputMarkupId(true);
    add(tableBody);
    WebMarkupContainer configBody = new WebMarkupContainer(ID_CAPABILITY_CONFIG);
    configBody.setOutputMarkupId(true);
    add(configBody);
    DataView<CapabilityDto<CapabilityType>> capabilityDataView = new DataView<CapabilityDto<CapabilityType>>(ID_CAPABILITY_ROW, capabilityProvider) {

        @Override
        protected void populateItem(final Item<CapabilityDto<CapabilityType>> capabilityRow) {
            final CapabilityDto<CapabilityType> dto = capabilityRow.getModelObject();
            AjaxLink<Void> name = new AjaxLink<Void>(ID_CAPABILITY_LINK) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editCapabilityPerformed(target, dto);
                }
            };
            Label label = new Label(ID_CAPABILITY_NAME, new IModel<String>() {

                @Override
                public String getObject() {
                    String rv = dto.getDisplayName();
                    if (Boolean.FALSE.equals(dto.getCapability().isEnabled())) {
                        rv += " " + getString("CapabilityStep.disabled");
                    }
                    return rv;
                }
            });
            name.add(label);
            capabilityRow.add(name);
            Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
            if (dto.getTooltipKey() != null) {
                tooltipLabel.add(new AttributeAppender("data-original-title", getString(dto.getTooltipKey())));
                tooltipLabel.add(new InfoTooltipBehavior());
            } else {
                tooltipLabel.setVisible(false);
            }
            tooltipLabel.setOutputMarkupId(true);
            tooltipLabel.setOutputMarkupPlaceholderTag(true);
            name.add(tooltipLabel);
            AjaxLink<Void> deleteLink = new AjaxLink<Void>(ID_CAPABILITY_DELETE) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteCapabilityPerformed(target, dto);
                }
            };
            deleteLink.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return !dto.isAmongNativeCapabilities() && !parentPage.isReadOnly();
                }
            });
            name.add(deleteLink);
            capabilityRow.add(AttributeModifier.replace("class", new IModel<Object>() {

                @Override
                public Object getObject() {
                    return isSelected(capabilityRow.getModelObject()) ? "success" : null;
                }
            }));
        }
    };
    tableBody.add(capabilityDataView);
    AjaxLink<Void> addLink = new AjaxLink<Void>(ID_CAPABILITY_ADD) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addCapabilityPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(addLink);
    add(addLink);
    ModalWindow dialog = new AddCapabilityDialog(DIALOG_SELECT_CAPABILITY, dtoModel) {

        @Override
        protected void addPerformed(AjaxRequestTarget target) {
            addCapabilitiesPerformed(target, getSelectedData());
        }
    };
    add(dialog);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Item(org.apache.wicket.markup.repeater.Item) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) IModel(org.apache.wicket.model.IModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DataView(org.apache.wicket.markup.repeater.data.DataView) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto)

Aggregations

AttributeAppender (org.apache.wicket.behavior.AttributeAppender)69 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)34 Label (org.apache.wicket.markup.html.basic.Label)34 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 IModel (org.apache.wicket.model.IModel)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)28 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)19 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 ListItem (org.apache.wicket.markup.html.list.ListItem)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 AttributeModifier (org.apache.wicket.AttributeModifier)7 ListView (org.apache.wicket.markup.html.list.ListView)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)6 Component (org.apache.wicket.Component)6 Model (org.apache.wicket.model.Model)6 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5