Search in sources :

Example 51 with ListItem

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

the class RunReportPopupPanel method initLayout.

protected void initLayout() {
    Form<?> mainForm = new Form<>(ID_MAIN_FORM);
    add(mainForm);
    ListView<JasperReportParameterDto> paramListView = new ListView<JasperReportParameterDto>(ID_PARAMETERS, new PropertyModel<>(reportModel, "jasperReportDto.parameters")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<JasperReportParameterDto> paramItem) {
            paramItem.add(createParameterPanel(paramItem.getModel()));
        }
    };
    paramListView.setOutputMarkupId(true);
    mainForm.add(paramListView);
    AjaxSubmitButton addButton = new AjaxSubmitButton(ID_RUN, createStringResource("runReportPopupContent.button.run")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            runConfirmPerformed(target, reportModel);
        }
    };
    mainForm.add(addButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) ListView(org.apache.wicket.markup.html.list.ListView) Form(org.apache.wicket.markup.html.form.Form) ListItem(org.apache.wicket.markup.html.list.ListItem) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)

Example 52 with ListItem

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

the class RunReportPopupPanel method createParameterPanel.

private WebMarkupContainer createParameterPanel(final IModel<JasperReportParameterDto> parameterModel) {
    WebMarkupContainer paramPanel = new WebMarkupContainer("paramPanel");
    paramPanel.setOutputMarkupId(true);
    String paramValue = new PropertyModel<String>(parameterModel, "name").getObject();
    StringResourceModel paramDisplay = PageBase.createStringResourceStatic(RunReportPopupPanel.this, "runReportPopupContent.param.name." + paramValue, new Object[] {});
    // use display name rather than property name
    paramPanel.add(new Label("name", paramDisplay));
    String paramClass = new PropertyModel<String>(parameterModel, "nestedTypeAsString").getObject();
    if (StringUtils.isBlank(paramClass)) {
        paramClass = new PropertyModel<String>(parameterModel, "typeAsString").getObject();
    }
    paramClass = paramClass == null ? "" : paramClass.substring(paramClass.lastIndexOf(".") + 1);
    paramPanel.add(new Label("type", paramClass));
    ListView<JasperReportValueDto> listView = new ListView<JasperReportValueDto>(ID_VALUE_LIST, new PropertyModel<>(parameterModel, "value")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<JasperReportValueDto> item) {
            item.add(createInputMarkup(item.getModel(), parameterModel.getObject()));
        }
    };
    listView.setOutputMarkupId(true);
    paramPanel.add(listView);
    return paramPanel;
}
Also used : JasperReportValueDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) LookupPropertyModel(com.evolveum.midpoint.web.model.LookupPropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ListItem(org.apache.wicket.markup.html.list.ListItem) StringResourceModel(org.apache.wicket.model.StringResourceModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 53 with ListItem

use of org.apache.wicket.markup.html.list.ListItem 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)

Example 54 with ListItem

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

the class UserDelegationsTabPanel method initLayout.

private void initLayout() {
    WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
    delegations.setOutputMarkupId(true);
    add(delegations);
    AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, createStringResource("FocusType.delegations"), delegationsModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
            DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, privilegesListModel, pageBase);
            item.add(editor);
        }

        @Override
        public String getExcludeOid() {
            return getObjectWrapper().getOid();
        }

        @Override
        protected List<InlineMenuItem> createAssignmentMenu() {
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item;
            if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
                item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation"), new InlineMenuItemAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        List<QName> supportedTypes = new ArrayList<>();
                        supportedTypes.add(UserType.COMPLEX_TYPE);
                        ObjectFilter filter = InOidFilter.createInOid(getObjectWrapper().getOid());
                        ObjectFilter notFilter = NotFilter.createNot(filter);
                        ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(pageBase.getMainPopupBodyId(), UserType.class, supportedTypes, false, pageBase, notFilter) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
                                pageBase.hideMainPopup(target);
                                List<ObjectType> newAssignmentsList = new ArrayList<>();
                                newAssignmentsList.add(user);
                                addSelectedAssignablePerformed(target, newAssignmentsList, getPageBase().getMainPopup().getId());
                            }
                        };
                        panel.setOutputMarkupId(true);
                        pageBase.showMainPopup(panel, target);
                    }
                });
                items.add(item);
            }
            if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL)) {
                item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation"), new InlineMenuItemAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        deleteAssignmentPerformed(target);
                    }
                });
                items.add(item);
            }
            return items;
        }

        @Override
        protected String getNoAssignmentsSelectedMessage() {
            return getString("AssignmentTablePanel.message.noDelegationsSelected");
        }

        @Override
        protected String getAssignmentsDeleteMessage(int size) {
            return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", size).getString();
        }

        @Override
        protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, String popupId) {
            ModalWindow window = (ModalWindow) get(popupId);
            if (window != null) {
                window.close(target);
            }
            getPageBase().hideMainPopup(target);
            if (newAssignments.isEmpty()) {
                warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            for (ObjectType object : newAssignments) {
                try {
                    AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), SchemaConstants.ORG_DEPUTY, getPageBase(), (UserType) object);
                    dto.setPrivilegeLimitationList(privilegesListModel.getObject());
                    delegationsModel.getObject().add(dto);
                } catch (Exception e) {
                    error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
                }
            }
            reloadAssignmentsPanel(target);
            reloadMainFormButtons(target);
        }
    };
    delegations.add(panel);
}
Also used : DelegationEditorPanel(com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel) AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) AssignmentTablePanel(com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow)

Example 55 with ListItem

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

the class InlineMenu method initLayout.

@Override
protected void initLayout() {
    WebMarkupContainer menuItemContainer = new WebMarkupContainer(ID_MENU_ITEM_CONTAINER);
    menuItemContainer.setOutputMarkupId(true);
    menuItemContainer.add(new AttributeAppender("class", getMenuItemContainerClass()));
    menuItemContainer.add(new AttributeAppender("style", getMenuItemContainerStyle()));
    add(menuItemContainer);
    AjaxButton menuItemButton = new AjaxButton(ID_MENU_ITEM_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
        }
    };
    menuItemButton.setOutputMarkupId(true);
    menuItemButton.add(new AttributeAppender("class", "dropdown-toggle " + getAdditionalButtonClass()));
    menuItemButton.add(new AttributeAppender("style", getMenuItemButtonStyle()));
    menuItemContainer.add(menuItemButton);
    WebMarkupContainer icon = new WebMarkupContainer(ID_MENU_ITEM_ICON);
    icon.setOutputMarkupId(true);
    icon.add(new AttributeAppender("class", getIconClass()));
    menuItemButton.add(icon);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, getModel()) {

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            initMenuItem(item);
        }
    };
    li.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            List list = InlineMenu.this.getModel().getObject();
            return list != null && !list.isEmpty();
        }
    });
    menuItemContainer.add(li);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)59 ListView (org.apache.wicket.markup.html.list.ListView)51 Label (org.apache.wicket.markup.html.basic.Label)44 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)41 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)41 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)29 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)27 List (java.util.List)26 ArrayList (java.util.ArrayList)21 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)19 PropertyModel (org.apache.wicket.model.PropertyModel)17 TextField (org.apache.wicket.markup.html.form.TextField)13 IModel (org.apache.wicket.model.IModel)11 Form (org.apache.wicket.markup.html.form.Form)10 Model (org.apache.wicket.model.Model)10 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)9 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)8 AttributeModifier (org.apache.wicket.AttributeModifier)8 QName (javax.xml.namespace.QName)7 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)7