Search in sources :

Example 61 with ListItem

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

the class ProjectCasDoctorPanel method createMessagesView.

private ListView<LogMessage> createMessagesView(IModel<LogMessageSet> aModel) {
    return new ListView<LogMessage>("messages", PropertyModel.of(aModel, "messages")) {

        private static final long serialVersionUID = 8957632000765128508L;

        @Override
        protected void populateItem(ListItem<LogMessage> aItem) {
            IModel<LogMessage> msg = aItem.getModel();
            aItem.add(new Label("level", PropertyModel.of(msg, "level")));
            aItem.add(new Label("source", PropertyModel.of(msg, "source")));
            aItem.add(new Label("message", PropertyModel.of(msg, "message")));
        }
    };
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) LogMessage(de.tudarmstadt.ukp.clarin.webanno.support.logging.LogMessage) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 62 with ListItem

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

the class ProjectCasDoctorPanel method createMessageSetsView.

private ListView<LogMessageSet> createMessageSetsView() {
    return new ListView<LogMessageSet>("messageSets", PropertyModel.of(this, "formModel.messageSets")) {

        private static final long serialVersionUID = 8957632000765128508L;

        @Override
        protected void populateItem(ListItem<LogMessageSet> aItem) {
            IModel<LogMessageSet> set = aItem.getModel();
            aItem.add(new Label("name", PropertyModel.of(set, "name")));
            aItem.add(createMessagesView(set));
        }
    };
}
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 63 with ListItem

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

the class GenericMultiValueLabelEditPanel method initLayout.

private void initLayout(final IModel<String> label, final String labelSize, final String textSize) {
    Label l = new Label(ID_LABEL, label);
    l.setVisible(getLabelVisibility());
    if (StringUtils.isNotEmpty(labelSize)) {
        l.add(AttributeAppender.prepend("class", labelSize));
    }
    add(l);
    WebMarkupContainer addFirstContainer = new WebMarkupContainer(ID_ADD_FIRST_CONTAINER);
    addFirstContainer.setOutputMarkupId(true);
    addFirstContainer.setOutputMarkupPlaceholderTag(true);
    addFirstContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isEmpty();
        }
    });
    add(addFirstContainer);
    AjaxLink addFirst = new AjaxLink(ID_ADD_FIRST) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addFirstPerformed(target);
        }
    };
    addFirstContainer.add(addFirst);
    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

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

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    if (StringUtils.isNotEmpty(textSize)) {
                        sb.append(textSize).append(' ');
                    }
                    if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) {
                        sb.append(getOffsetClass()).append(' ');
                        sb.append(CLASS_MULTI_VALUE);
                    }
                    return sb.toString();
                }
            }));
            listItem.add(textWrapper);
            TextField text = new TextField<>(ID_TEXT, createTextModel(listItem.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                }
            });
            text.setEnabled(false);
            text.add(AttributeAppender.replace("placeholder", label));
            text.setLabel(label);
            textWrapper.add(text);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
            textWrapper.add(feedback);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            AjaxLink edit = new AjaxLink(ID_EDIT) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editValuePerformed(target, listItem.getModel());
                }
            };
            textWrapper.add(edit);
            listItem.add(buttonGroup);
            initButtons(buttonGroup, listItem);
        }
    };
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 64 with ListItem

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

the class ObjectPolicyConfigurationEditor method initLayout.

protected void initLayout() {
    final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label"));
    add(label);
    ListView<ObjectPolicyConfigurationTypeDto> repeater = new ListView<ObjectPolicyConfigurationTypeDto>(ID_REPEATER, getModel()) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(textWrapper);
            TextField<String> name = new TextField<>(ID_NAME, createNameModel(item.getModel()));
            name.setOutputMarkupId(true);
            name.add(new AjaxFormComponentUpdatingBehavior("blur") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            name.setEnabled(false);
            name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder")));
            textWrapper.add(name);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name));
            textWrapper.add(feedback);
            AjaxLink<String> edit = new AjaxLink<String>(ID_BUTTON_EDIT) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editPerformed(target, item);
                }
            };
            textWrapper.add(edit);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    //        initDialog();
    repeater.setOutputMarkupId(true);
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 65 with ListItem

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

the class ProgressPanel method initLayout.

private void initLayout(ProgressReportingAwarePage page) {
    progressForm = new Form<>(ID_PROGRESS_FORM, true);
    add(progressForm);
    contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
    contentsPanel.setOutputMarkupId(true);
    progressForm.add(contentsPanel);
    ListView statusItemsListView = new ListView<ProgressReportActivityDto>(ID_ACTIVITIES, new AbstractReadOnlyModel<List<ProgressReportActivityDto>>() {

        @Override
        public List<ProgressReportActivityDto> getObject() {
            ProgressDto progressDto = ProgressPanel.this.getModelObject();
            return progressDto.getProgressReportActivities();
        }
    }) {

        protected void populateItem(final ListItem<ProgressReportActivityDto> item) {
            item.add(new Label(ID_ACTIVITY_DESCRIPTION, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    ProgressReportActivityDto si = item.getModelObject();
                    if (si.getActivityType() == RESOURCE_OBJECT_OPERATION && si.getResourceShadowDiscriminator() != null) {
                        ResourceShadowDiscriminator rsd = si.getResourceShadowDiscriminator();
                        return createStringResource(rsd.getKind()).getString() + " (" + rsd.getIntent() + ") on " + // TODO correct i18n
                        si.getResourceName();
                    } else {
                        return createStringResource(si.getActivityType()).getString();
                    }
                }
            }));
            item.add(createImageLabel(ID_ACTIVITY_STATE, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    OperationResultStatusType statusType = item.getModelObject().getStatus();
                    if (statusType == null) {
                        return null;
                    } else {
                        return OperationResultStatusPresentationProperties.parseOperationalResultStatus(statusType).getIcon() + " fa-lg";
                    }
                }
            }, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    // TODO why this does not work???
                    // TODO i18n
                    OperationResultStatusType statusType = item.getModelObject().getStatus();
                    if (statusType == null) {
                        return null;
                    } else {
                        return statusType.toString();
                    }
                }
            }));
            item.add(new Label(ID_ACTIVITY_COMMENT, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    ProgressReportActivityDto si = item.getModelObject();
                    if (si.getResourceName() != null || si.getResourceOperationResultList() != null) {
                        StringBuilder sb = new StringBuilder();
                        boolean first = true;
                        if (si.getResourceOperationResultList() != null) {
                            for (ResourceOperationResult ror : si.getResourceOperationResultList()) {
                                if (!first) {
                                    sb.append(", ");
                                } else {
                                    first = false;
                                }
                                sb.append(createStringResource("ChangeType." + ror.getChangeType()).getString());
                                sb.append(":");
                                sb.append(createStringResource(ror.getResultStatus()).getString());
                            }
                        }
                        if (si.getResourceObjectName() != null) {
                            if (!first) {
                                sb.append(" -> ");
                            }
                            sb.append(si.getResourceObjectName());
                        }
                        return sb.toString();
                    } else {
                        return null;
                    }
                }
            }));
        }

        private Label createImageLabel(String id, IModel<String> cssClass, IModel<String> title) {
            Label label = new Label(id);
            label.add(AttributeModifier.replace("class", cssClass));
            // does not work, currently
            label.add(AttributeModifier.replace("title", title));
            return label;
        }
    };
    contentsPanel.add(statusItemsListView);
    statisticsPanel = new StatisticsPanel(ID_STATISTICS, new StatisticsDtoModel());
    contentsPanel.add(statisticsPanel);
    ListView logItemsListView = new ListView(ID_LOG_ITEMS, new AbstractReadOnlyModel<List>() {

        @Override
        public List getObject() {
            ProgressDto progressDto = ProgressPanel.this.getModelObject();
            return progressDto.getLogItems();
        }
    }) {

        protected void populateItem(ListItem item) {
            item.add(new Label(ID_LOG_ITEM, item.getModel()));
        }
    };
    contentsPanel.add(logItemsListView);
    Label executionTime = new Label(ID_EXECUTION_TIME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (operationDurationTime > 0) {
                return createStringResource("ProgressPanel.ExecutionTimeWhenFinished", operationDurationTime).getString();
            } else if (operationStartTime > 0) {
                return createStringResource("ProgressPanel.ExecutionTimeWhenRunning", (System.currentTimeMillis() - operationStartTime) / 1000).getString();
            } else {
                return null;
            }
        }
    });
    contentsPanel.add(executionTime);
    initButtons(progressForm, page);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) OperationResultStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) ListItem(org.apache.wicket.markup.html.list.ListItem) ResourceOperationResult(com.evolveum.midpoint.web.component.progress.ProgressReportActivityDto.ResourceOperationResult)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)131 ListView (org.apache.wicket.markup.html.list.ListView)107 Label (org.apache.wicket.markup.html.basic.Label)82 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)72 IModel (org.apache.wicket.model.IModel)44 List (java.util.List)42 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 ArrayList (java.util.ArrayList)38 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)17 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 Model (org.apache.wicket.model.Model)12 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11