Search in sources :

Example 26 with ListItem

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

the class SynchronizationReactionEditor method initLayout.

protected void initLayout(PageResourceWizard parentPage) {
    Label label = new Label(ID_LABEL, new ResourceModel("SynchronizationReactionEditor.label.edit"));
    add(label);
    TextField name = new TextField<>(ID_NAME, new PropertyModel<String>(getModel(), "name"));
    name.add(new ReactionListUpdateBehavior());
    parentPage.addEditingEnabledBehavior(name);
    add(name);
    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
    parentPage.addEditingEnabledBehavior(description);
    add(description);
    DropDownChoice situation = new DropDownChoice<>(ID_SITUATION, new PropertyModel<>(getModel(), "situation"), WebComponentUtil.createReadonlyModelFromEnum(SynchronizationSituationType.class), new EnumChoiceRenderer<>(this));
    situation.setNullValid(true);
    situation.add(new ReactionListUpdateBehavior());
    parentPage.addEditingEnabledBehavior(situation);
    situation.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ((PageResourceWizard) getPageBase()).refreshIssues(target);
        }
    });
    add(situation);
    MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL, new PropertyModel<>(getModel(), "channel"), true, parentPage.getReadOnlyModel()) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new IModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebComponentUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return CHANNEL_RENDERER;
        }
    };
    add(channel);
    TriStateComboPanel synchronize = new TriStateComboPanel(ID_SYNCHRONIZE, new PropertyModel<>(getModel(), "synchronize"));
    synchronize.getBaseFormComponent().add(new ReactionListUpdateBehavior());
    parentPage.addEditingEnabledBehavior(synchronize);
    add(synchronize);
    CheckBox reconcile = new CheckBox(ID_RECONCILE, new PropertyModel<>(getModel(), "reconcile"));
    parentPage.addEditingEnabledBehavior(reconcile);
    add(reconcile);
    DropDownChoice objectTemplateRef = new DropDownChoice<>(ID_OBJECT_TEMPLATE_REF, new PropertyModel<>(getModel(), "objectTemplateRef"), new IModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ObjectTemplateType.class, getPageBase(), objectTemplateMap);
        }
    }, new ObjectReferenceChoiceRenderer(objectTemplateMap));
    objectTemplateRef.setNullValid(true);
    parentPage.addEditingEnabledBehavior(objectTemplateRef);
    add(objectTemplateRef);
    MultiValueTextEditPanel action = new MultiValueTextEditPanel<SynchronizationActionType>(ID_ACTION, new PropertyModel<>(getModel(), "action"), null, false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<SynchronizationActionType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    SynchronizationActionType action = model.getObject();
                    if (action == null) {
                        return null;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(action.getName() != null ? action.getName() : "-");
                    if (action.getHandlerUri() != null) {
                        sb.append(" (").append(StringUtils.substringAfter(action.getHandlerUri(), "#")).append(")");
                    }
                    return sb.toString();
                }
            };
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, SynchronizationActionType added) {
            target.add(parentStep.getReactionList());
            ((PageResourceWizard) getPageBase()).refreshIssues(target);
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<SynchronizationActionType> item) {
            target.add(parentStep.getReactionList());
            ((PageResourceWizard) getPageBase()).refreshIssues(target);
        }

        @Override
        protected SynchronizationActionType createNewEmptyItem() {
            return new SynchronizationActionType();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, SynchronizationActionType object) {
            actionEditPerformed(target, object);
        }
    };
    action.setOutputMarkupId(true);
    add(action);
    Label situationTooltip = new Label(ID_T_SITUATION);
    situationTooltip.add(new InfoTooltipBehavior());
    add(situationTooltip);
    Label channelTooltip = new Label(ID_T_CHANNEL);
    channelTooltip.add(new InfoTooltipBehavior());
    add(channelTooltip);
    Label synchronizeTooltip = new Label(ID_T_SYNCHRONIZE);
    synchronizeTooltip.add(new InfoTooltipBehavior());
    add(synchronizeTooltip);
    Label reconcileTooltip = new Label(ID_T_RECONCILE);
    reconcileTooltip.add(new InfoTooltipBehavior());
    add(reconcileTooltip);
    Label objTemplateTooltip = new Label(ID_T_OBJ_TEMPLATE);
    objTemplateTooltip.add(new InfoTooltipBehavior());
    add(objTemplateTooltip);
    Label actionTooltip = new Label(ID_T_ACTION);
    actionTooltip.add(new InfoTooltipBehavior());
    add(actionTooltip);
    initModals();
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) TriStateComboPanel(com.evolveum.midpoint.web.component.input.TriStateComboPanel) Label(org.apache.wicket.markup.html.basic.Label) MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) MultiValueDropDownPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueDropDownPanel) ArrayList(java.util.ArrayList) List(java.util.List) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 27 with ListItem

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

the class InformationPanel method initLayout.

private void initLayout() {
    Label titleLabel = new Label(ID_TITLE, new LocalizableMessageModel(new IModel<LocalizableMessageType>() {

        @Override
        public LocalizableMessageType getObject() {
            InformationType info = getModelObject();
            if (info == null || info.getTitle() == null && info.getLocalizableTitle() == null) {
                return new SingleLocalizableMessageType().fallbackMessage("ApprovalStageDefinitionType.additionalInformation");
            }
            return getLocalizableMessageOrDefault(info.getLocalizableTitle(), info.getTitle());
        }
    }, this));
    titleLabel.add(new VisibleBehaviour(() -> getModelObject() != null));
    add(titleLabel);
    ListView<InformationPartType> list = new ListView<InformationPartType>(ID_PARTS, new PropertyModel<>(getModel(), InformationType.F_PART.getLocalPart())) {

        @Override
        protected void populateItem(ListItem<InformationPartType> item) {
            InformationPartType part = item.getModelObject();
            Label label = new Label(ID_PART, part != null ? WebComponentUtil.resolveLocalizableMessage(getLocalizableMessageOrDefault(part.getLocalizableText(), part.getText()), InformationPanel.this) : "");
            if (Boolean.TRUE.equals(part.isHasMarkup())) {
                label.setEscapeModelStrings(false);
            }
            item.add(label);
        }
    };
    add(list);
}
Also used : IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) LocalizableMessageModel(com.evolveum.midpoint.web.component.util.LocalizableMessageModel) ListItem(org.apache.wicket.markup.html.list.ListItem) InformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.InformationType) InformationPartType(com.evolveum.midpoint.xml.ns._public.common.common_3.InformationPartType) SingleLocalizableMessageType(com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType)

Example 28 with ListItem

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

the class ExecuteChangeOptionsPanel method createTracingOptionsPanel.

private void createTracingOptionsPanel() {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new InlineMenuItem(createStringResource("Tracing")) {

        @Override
        public InlineMenuItemAction initAction() {
            return null;
        }
    });
    DropdownButtonDto model = new DropdownButtonDto(null, GuiStyleConstants.CLASS_TRACING_BUTTON_ICON, "Tracing", items);
    DropdownButtonPanel dropdownButtonPanel = new DropdownButtonPanel(ID_TRACING, model) {

        @Override
        protected void populateMenuItem(String componentId, ListItem<InlineMenuItem> menuItem) {
            menuItem.add(createTracingRadioChoicesFragment(componentId));
        }

        @Override
        protected String getSpecialButtonClass() {
            return "btn-sm btn-default btn-margin-right";
        }

        @Override
        protected String getSpecialDropdownMenuClass() {
            return "execute-options radio";
        }

        @Override
        protected String getSpecialLabelClass() {
            return "execute-options-label";
        }
    };
    add(dropdownButtonPanel);
    dropdownButtonPanel.setOutputMarkupId(true);
    dropdownButtonPanel.add(new VisibleBehaviour(this::isTracingEnabled));
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ArrayList(java.util.ArrayList) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ListItem(org.apache.wicket.markup.html.list.ListItem) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Example 29 with ListItem

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

the class CorrelationContextPanel method createColumnsForPropertyRow.

private ListView<CorrelationOptionDto> createColumnsForPropertyRow(IModel<CorrelationContextDto> contextModel, ListItem<CorrelationPropertyDefinition> rowItem) {
    return new ListView<>(ID_COLUMNS, new PropertyModel<>(contextModel, CorrelationContextDto.F_CORRELATION_OPTIONS)) {

        @Override
        protected void populateItem(ListItem<CorrelationOptionDto> columnItem) {
            CorrelationContextDto contextDto = contextModel.getObject();
            CorrelationOptionDto optionDto = columnItem.getModelObject();
            CorrelationPropertyDefinition propertyDefinition = rowItem.getModelObject();
            CorrelationPropertyValues valuesForOption = optionDto.getPropertyValues(propertyDefinition);
            Label label = new Label(ID_COLUMN, valuesForOption.format());
            CorrelationOptionDto referenceOption = contextDto.getNewOwnerOption();
            if (referenceOption != null && !optionDto.isNewOwner()) {
                CorrelationPropertyValues referenceValues = referenceOption.getPropertyValues(propertyDefinition);
                Match match = referenceValues.match(valuesForOption);
                label.add(AttributeAppender.append("class", match.getCss()));
            }
            columnItem.add(label);
        }
    };
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 30 with ListItem

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

the class AssignmentEditorPanel method initAttributesLayout.

private void initAttributesLayout(WebMarkupContainer constructionContainer) {
    WebMarkupContainer attributes = new WebMarkupContainer(ID_ATTRIBUTES);
    attributes.setOutputMarkupId(true);
    attributes.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
        }
    });
    attributes.setEnabled(getModel().getObject().isEditable());
    constructionContainer.add(attributes);
    ListView<ACAttributeDto> attribute = new ListView<>(ID_ATTRIBUTE, attributesModel) {

        @Override
        protected void populateItem(ListItem<ACAttributeDto> listItem) {
            final IModel<ACAttributeDto> attrModel = listItem.getModel();
            ACAttributePanel acAttribute = new ACAttributePanel(ID_AC_ATTRIBUTE, attrModel, ignoreMandatoryAttributes());
            acAttribute.setRenderBodyOnly(true);
            listItem.add(acAttribute);
            listItem.setOutputMarkupId(true);
            listItem.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
                    if (editorDto.isShowEmpty()) {
                        return true;
                    }
                    ACAttributeDto dto = attrModel.getObject();
                    return !dto.isEmpty();
                }
            });
        }
    };
    attributes.add(attribute);
// todo extension
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)127 ListView (org.apache.wicket.markup.html.list.ListView)103 Label (org.apache.wicket.markup.html.basic.Label)79 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)70 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)69 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 IModel (org.apache.wicket.model.IModel)40 List (java.util.List)38 ArrayList (java.util.ArrayList)37 PropertyModel (org.apache.wicket.model.PropertyModel)28 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)23 TextField (org.apache.wicket.markup.html.form.TextField)15 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)14 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)14 QName (javax.xml.namespace.QName)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10