Search in sources :

Example 31 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class ShoppingCartEditorPanel method initHeaderRow.

@Override
protected void initHeaderRow() {
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    headerRow.add(box);
    box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
    box.add(new Label(ID_DISPLAY_NAME, new PropertyModel<AssignmentEditorDto>(getModel(), AssignmentEditorDto.F_NAME)));
    box.add(new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getModelObject().getTargetRef() != null && getModelObject().getTargetRef().getDescription() != null ? getModelObject().getTargetRef().getDescription() : "";
        }
    }));
    WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
    box.add(iconBox);
    if (getIconBoxAdditionalCssClass() != null) {
        iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
    }
    Label icon = new Label(ID_ICON, "");
    icon.add(new AttributeModifier("class", getIconCssClass()));
    iconBox.add(icon);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 32 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class LimitationsEditorDialog method initLayout.

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    content.add(form);
    ListView repeater = new ListView<PropertyLimitationsTypeDto>(ID_REPEATER, model) {

        @Override
        protected void populateItem(final ListItem<PropertyLimitationsTypeDto> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LIMITATIONS_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);
            Label linkLabel = new Label(ID_LIMITATIONS_LABEL, createLimitationsLabelModel(item));
            linkContainer.add(linkLabel);
            AjaxLink delete = new AjaxLink(ID_LIMITATION_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteLimitationPerformed(target, item);
                }
            };
            delete.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
            linkContainer.add(delete);
            WebMarkupContainer limitationBody = new WebMarkupContainer(ID_BODY);
            limitationBody.setOutputMarkupId(true);
            limitationBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                limitationBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            limitationBody.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
            item.add(limitationBody);
            initLimitationBody(limitationBody, item);
        }
    };
    repeater.setOutputMarkupId(true);
    form.add(repeater);
    initButtons(form);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ListView(org.apache.wicket.markup.html.list.ListView) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 33 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class AuditLogViewerPanel method initColumns.

protected List<IColumn<AuditEventRecordType, String>> initColumns() {
    List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<IColumn<AuditEventRecordType, String>>();
    IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("AuditEventRecordType.timestamp"), "timestamp") {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
                    return WebComponentUtil.formatDate(time);
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType record = rowModel.getObject();
            try {
                AuditEventRecord.adopt(record, pageBase.getPrismContext());
            } catch (SchemaException e) {
                throw new SystemException("Couldn't adopt event record: " + e, e);
            }
            pageBase.navigateToNext(new PageAuditLogDetails(record));
        }
    };
    columns.add(linkColumn);
    PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = rowModel.getObject();
            createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId);
        }
    };
    columns.add(initiatorRefColumn);
    if (visibilityMap == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY) == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY)) {
        IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage");
        columns.add(eventStageColumn);
    }
    IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType");
    columns.add(eventTypeColumn);
    if (visibilityMap == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId);
            }
        };
        columns.add(targetRefColumn);
    }
    if (visibilityMap == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId);
            }
        };
        columns.add(targetOwnerRefColumn);
    }
    IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.channel"), "channel") {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
            String channel = auditEventRecordType.getChannel();
            if (channel != null) {
                QName channelQName = QNameUtil.uriToQName(channel);
                String return_ = channelQName.getLocalPart();
                item.add(new Label(componentId, return_));
            } else {
                item.add(new Label(componentId, ""));
            }
            item.add(new AttributeModifier("style", new Model<String>("width: 10%;")));
        }
    };
    columns.add(channelColumn);
    IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome");
    columns.add(outcomeColumn);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) QName(javax.xml.namespace.QName) PageAuditLogDetails(com.evolveum.midpoint.web.page.admin.reports.PageAuditLogDetails) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Item(org.apache.wicket.markup.repeater.Item) SystemException(com.evolveum.midpoint.util.exception.SystemException) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 34 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class CapabilitiesPanel method createCapabilityButton.

private void createCapabilityButton(String id) {
    AjaxLink<Boolean> button = new AjaxLink<Boolean>(id, new PropertyModel<Boolean>(getModel(), id)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
        // TODO:
        }
    };
    button.add(new AttributeModifier("class", button.getModelObject() ? "btn btn-app btn-resource-capability bg-light-blue" : "btn btn-app btn-resource-capability bg-gray text-light-blue"));
    button.add(new Label("label", new ResourceModel("CapabilitiesType." + id)));
    add(button);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) ResourceModel(org.apache.wicket.model.ResourceModel) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeModifier(org.apache.wicket.AttributeModifier)

Example 35 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class PrismPropertyPanel method initLayout.

private void initLayout(final IModel<IW> model, final Form form) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    labelContainer.setOutputMarkupId(true);
    labelContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return labelContainerVisible;
        }
    });
    add(labelContainer);
    final IModel<String> label = createDisplayName(model);
    labelContainer.add(new Label(ID_LABEL, label));
    final IModel<String> helpText = new LoadableModel<String>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String load() {
            return loadHelpText(model);
        }
    };
    Label help = new Label(ID_HELP);
    help.add(AttributeModifier.replace("title", helpText));
    help.add(new InfoTooltipBehavior());
    help.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotEmpty(helpText.getObject());
        }
    });
    labelContainer.add(help);
    WebMarkupContainer required = new WebMarkupContainer("required");
    required.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            IW wrapper = model.getObject();
            ItemDefinition def = wrapper.getItemDefinition();
            if (ObjectType.F_NAME.equals(def.getName())) {
                //fix for "name as required" MID-789
                return true;
            }
            return def.isMandatory();
        }
    });
    labelContainer.add(required);
    WebMarkupContainer hasOutbound = new WebMarkupContainer("hasOutbound");
    hasOutbound.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasOutbound(model);
        }
    });
    labelContainer.add(hasOutbound);
    WebMarkupContainer hasPendingModification = new WebMarkupContainer(ID_HAS_PENDING_MODIFICATION);
    hasPendingModification.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasPendingModification(model);
        }
    });
    labelContainer.add(hasPendingModification);
    ListView<ValueWrapper> values = new ListView<ValueWrapper>("values", new PropertyModel<List<ValueWrapper>>(model, "values")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ValueWrapper> item) {
            PrismValuePanel panel = new PrismValuePanel("value", item.getModel(), label, form, getValueCssClass(), getInputCssClass(), pageBase);
            item.add(panel);
            item.add(AttributeModifier.append("class", createStyleClassModel(item.getModel())));
            item.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return isVisibleValue(item.getModel());
                }
            });
        }
    };
    values.add(new AttributeModifier("class", getValuesClass()));
    values.setReuseItems(true);
    add(values);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) ListView(org.apache.wicket.markup.html.list.ListView) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

AttributeModifier (org.apache.wicket.AttributeModifier)39 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)24 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)24 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)21 Label (org.apache.wicket.markup.html.basic.Label)19 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)18 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)12 IModel (org.apache.wicket.model.IModel)9 PropertyModel (org.apache.wicket.model.PropertyModel)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 ListView (org.apache.wicket.markup.html.list.ListView)8 Model (org.apache.wicket.model.Model)7 ArrayList (java.util.ArrayList)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)4 PasswordPanel (com.evolveum.midpoint.gui.api.component.password.PasswordPanel)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)3 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)3