Search in sources :

Example 41 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class ObjectPolicyPanel method initLayout.

//	public void updateModel(AjaxRequestTarget target, ObjectPolicyConfigurationTypeDto config) {
//		model.setObject(new ObjectPolicyDialogDto(config, getPageBase()));
//		target.add(getContent());
//	}
public void initLayout() {
    Form form = new Form(ID_FORM);
    form.setOutputMarkupId(true);
    add(form);
    DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, new PropertyModel<QName>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), new QNameChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(type);
    type.getInput().setNullValid(false);
    type.getInput().setRequired(true);
    TextField<String> fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel<String>(model, ObjectPolicyDialogDto.F_SUBTYPE));
    form.add(fieldSubtype);
    form.add(fieldSubtype);
    DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, new PropertyModel<ObjectTemplateConfigTypeReferenceDto>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), createObjectTemplateList(), new ChoiceableChoiceRenderer<ObjectTemplateConfigTypeReferenceDto>(), createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(template);
    template.getInput().setNullValid(false);
    template.getInput().setRequired(true);
    ListView repeater = new ListView<PropertyConstraintTypeDto>(ID_REPEATER, new PropertyModel<List<PropertyConstraintTypeDto>>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) {

        @Override
        protected void populateItem(final ListItem item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(textWrapper);
            TextField property = new TextField<>(ID_PROPERTY, new PropertyModel<String>(item.getModel(), PropertyConstraintTypeDto.F_PROPERTY_PATH));
            property.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            property.add(AttributeAppender.replace("placeholder", createStringResource("ObjectPolicyDialog.property.placeholder")));
            textWrapper.add(property);
            CheckBox oidBound = new CheckBox(ID_OID_BOUND, new PropertyModel<Boolean>(item.getModel(), PropertyConstraintTypeDto.F_OID_BOUND));
            oidBound.add(AttributeModifier.replace("title", createStringResource("ObjectPolicyDialog.label.oidBound.help")));
            textWrapper.add(oidBound);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    form.add(repeater);
    AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, createStringResource("ObjectPolicyDialog.button.cancel")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("ObjectPolicyDialog.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }
    };
    form.add(save);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Form(org.apache.wicket.markup.html.form.Form) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 42 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class AssignmentTablePanel method initLayout.

private void initLayout(IModel<String> labelText) {
    final WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
    assignments.setOutputMarkupId(true);
    add(assignments);
    Label label = new Label(ID_HEADER, labelText);
    assignments.add(label);
    InlineMenu assignmentMenu = new InlineMenu(ID_MENU, new Model((Serializable) createAssignmentMenu()));
    assignmentMenu.setVisible(getAssignmentMenuVisibility());
    assignments.add(assignmentMenu);
    ListView<AssignmentEditorDto> list = new ListView<AssignmentEditorDto>(ID_LIST, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<AssignmentEditorDto> item) {
            AssignmentTablePanel.this.populateAssignmentDetailsPanel(item);
        }
    };
    list.setOutputMarkupId(true);
    assignments.add(list);
    AjaxCheckBox checkAll = new AjaxCheckBox(ID_CHECK_ALL, new Model()) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            List<AssignmentEditorDto> assignmentEditors = getAssignmentModel().getObject();
            for (AssignmentEditorDto dto : assignmentEditors) {
                dto.setSelected(this.getModelObject());
            }
            target.add(assignments);
        }
    };
    checkAll.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            int count = 0;
            for (AssignmentEditorDto dto : getModelObject()) {
                if (dto.isSimpleView()) {
                    count++;
                }
            }
            if (count == getModelObject().size()) {
                return false;
            } else {
                return true;
            }
        }
    });
    assignments.add(checkAll);
}
Also used : Serializable(java.io.Serializable) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 43 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class ACAttributePanel method initLayout.

protected void initLayout(boolean ignoreMandatoryAttributes) {
    Label attributeLabel = new Label(ID_ATTRIBUTE_LABEL, new PropertyModel(getModel(), ACAttributeDto.F_NAME));
    add(attributeLabel);
    WebMarkupContainer required = new WebMarkupContainer(ID_REQUIRED);
    required.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ACAttributeDto dto = getModel().getObject();
            PrismPropertyDefinition def = dto.getDefinition();
            return def.isMandatory();
        }
    });
    add(required);
    WebMarkupContainer hasOutbound = new WebMarkupContainer(ID_HAS_OUTBOUND);
    hasOutbound.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return hasOutbound();
        }
    });
    add(hasOutbound);
    ListView<ACValueConstructionDto> values = new ListView<ACValueConstructionDto>(ID_VALUES, new PropertyModel<List<ACValueConstructionDto>>(getModel(), ACAttributeDto.F_VALUES)) {

        @Override
        protected void populateItem(ListItem<ACValueConstructionDto> listItem) {
            Form form = findParent(Form.class);
            listItem.add(new ACAttributeValuePanel(ID_VALUE, listItem.getModel(), ignoreMandatoryAttributes, form));
        }
    };
    add(values);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 44 with ListView

use of org.apache.wicket.markup.html.list.ListView 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 45 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class ResourceConnectorPanel method initLayout.

private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
    setOutputMarkupId(true);
    IModel<List<ConnectorOperationalStatus>> statsModel = new AbstractReadOnlyModel<List<ConnectorOperationalStatus>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<ConnectorOperationalStatus> getObject() {
            PrismObject<ResourceType> resource = model.getObject();
            Task task = parentPage.createSimpleTask(OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS);
            OperationResult result = task.getResult();
            List<ConnectorOperationalStatus> status = null;
            try {
                status = parentPage.getModelInteractionService().getConnectorOperationalStatus(resource.getOid(), task, result);
            } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
                LOGGER.error("Error getting connector status for {}: {}", resource, e.getMessage(), e);
                parentPage.showResult(result);
            }
            return status;
        }
    };
    ListView<ConnectorOperationalStatus> listview = new ListView<ConnectorOperationalStatus>(ID_CONNECTOR_LIST, statsModel) {

        private static final long serialVersionUID = 1L;

        protected void populateItem(ListItem<ConnectorOperationalStatus> item) {
            item.add(new Label("label", item.getModel()));
            IModel<ConnectorOperationalStatus> statModel = item.getModel();
            item.add(createLabel(statModel, ID_CONNECTOR_NAME, ConnectorOperationalStatus.F_CONNECTOR_NAME));
            item.add(createLabel(statModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));
        }
    };
    add(listview);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) Label(org.apache.wicket.markup.html.basic.Label) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ListView(org.apache.wicket.markup.html.list.ListView) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Aggregations

ListView (org.apache.wicket.markup.html.list.ListView)54 ListItem (org.apache.wicket.markup.html.list.ListItem)51 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)39 Label (org.apache.wicket.markup.html.basic.Label)39 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)33 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)27 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)25 List (java.util.List)21 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)17 PropertyModel (org.apache.wicket.model.PropertyModel)15 ArrayList (java.util.ArrayList)14 TextField (org.apache.wicket.markup.html.form.TextField)13 Form (org.apache.wicket.markup.html.form.Form)10 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)9 AttributeModifier (org.apache.wicket.AttributeModifier)8 Model (org.apache.wicket.model.Model)8 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)7 IModel (org.apache.wicket.model.IModel)7 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5