Search in sources :

Example 36 with WebMarkupContainer

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

the class FocusProjectionsTabPanel method initLayout.

private void initLayout(final PageBase page) {
    final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
    shadows.setOutputMarkupId(true);
    add(shadows);
    InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
    accountMenu.setVisible(!getObjectWrapper().isReadonly());
    shadows.add(accountMenu);
    final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
            PackageResourceReference packageRef;
            final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
            final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
            final Panel shadowPanel;
            if (dto.isLoadedOK()) {
                packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
                shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
            } else {
                shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onShowMorePerformed(AjaxRequestTarget target) {
                        OperationResult fetchResult = dto.getResult();
                        if (fetchResult != null) {
                            showResult(fetchResult);
                            target.add(page.getFeedbackPanel());
                        }
                    }
                };
            }
            shadowPanel.setOutputMarkupId(true);
            shadowPanel.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
                    ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
                    return !shadowWrapper.isMinimalized();
                }
            });
            item.add(shadowPanel);
            CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClickPerformed(AjaxRequestTarget target) {
                    super.onClickPerformed(target);
                    onExpandCollapse(target, item.getModel());
                    target.add(shadows);
                }
            };
            if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
                shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
            }
            item.add(shadowHeader);
        }
    };
    AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
                if (dto.isLoadedOK()) {
                    ObjectWrapper<ShadowType> accModel = dto.getObject();
                    accModel.setSelected(getModelObject());
                }
            }
            target.add(shadows);
        }
    };
    shadows.add(accountCheckAll);
    shadows.add(projectionList);
}
Also used : Serializable(java.io.Serializable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ImgResources(com.evolveum.midpoint.web.resource.img.ImgResources) ListView(org.apache.wicket.markup.html.list.ListView) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) Panel(org.apache.wicket.markup.html.panel.Panel) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 37 with WebMarkupContainer

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

the class MainMenuPanel method initLayout.

private void initLayout() {
    final MainMenuItem menu = getModelObject();
    WebMarkupContainer item = new WebMarkupContainer(ID_ITEM);
    item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (menu.isMenuActive((WebPage) getPage())) {
                return "active";
            }
            for (MenuItem item : menu.getItems()) {
                if (item.isMenuActive((WebPage) getPage())) {
                    return "active";
                }
            }
            return !menu.getItems().isEmpty() ? "treeview" : null;
        }
    }));
    add(item);
    WebMarkupContainer link;
    if (menu.getPageClass() != null) {
        link = new AjaxLink(ID_LINK) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                mainMenuPerformed(menu);
            }
        };
    } else if (menu instanceof AdditionalMenuItem) {
        link = new AjaxLink(ID_LINK) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                additionalMenuPerformed(menu);
            }
        };
    } else {
        link = new WebMarkupContainer(ID_LINK);
    }
    item.add(link);
    WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
    icon.add(AttributeModifier.replace("class", new PropertyModel<>(menu, MainMenuItem.F_ICON_CLASS)));
    link.add(icon);
    Label label = new Label(ID_LABEL, menu.getNameModel());
    link.add(label);
    final PropertyModel<String> bubbleModel = new PropertyModel<>(menu, MainMenuItem.F_BUBBLE_LABEL);
    Label bubble = new Label(ID_BUBBLE, bubbleModel);
    bubble.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return bubbleModel.getObject() != null;
        }
    });
    link.add(bubble);
    WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW);
    arrow.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !menu.getItems().isEmpty() && bubbleModel.getObject() == null;
        }
    });
    link.add(arrow);
    WebMarkupContainer submenu = new WebMarkupContainer(ID_SUBMENU);
    submenu.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !menu.getItems().isEmpty();
        }
    });
    item.add(submenu);
    ListView<MenuItem> subItem = new ListView<MenuItem>(ID_SUB_ITEM, new Model((Serializable) menu.getItems())) {

        @Override
        protected void populateItem(ListItem<MenuItem> listItem) {
            createSubmenu(listItem);
        }
    };
    submenu.add(subItem);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Serializable(java.io.Serializable) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) 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 38 with WebMarkupContainer

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

the class MultiValueTextEditPanel method initLayout.

private void initLayout(final boolean inputEnabled, final boolean showPlaceholder, final NonEmptyModel<Boolean> readOnlyModel) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return showPlaceholder && (getModel().getObject() == null || getModel().getObject().isEmpty());
        }
    });
    add(placeholderContainer);
    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }
            return "";
        }
    }));
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);
    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
            if (selectedModel != null && item.getModelObject() == selectedModel.getObject()) {
                // TODO color constant
                text.add(AttributeAppender.append("style", "background-color: #FFFFD0;"));
            }
            if (!inputEnabled) {
                text.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(text);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item, readOnlyModel);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModel().getObject() != null && !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ListView(org.apache.wicket.markup.html.list.ListView) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) 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) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 39 with WebMarkupContainer

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

the class MainPopupDialog method setBody.

private void setBody(Component component) {
    WebMarkupContainer content = (WebMarkupContainer) get(getContentId());
    content.addOrReplace(component);
}
Also used : WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 40 with WebMarkupContainer

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

the class AceEditorFormGroup method initLayout.

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize, boolean required, int rowNumber) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    add(labelContainer);
    Label l = new Label(ID_LABEL, label);
    if (StringUtils.isNotEmpty(labelSize)) {
        labelContainer.add(AttributeAppender.prepend("class", labelSize));
    }
    labelContainer.add(l);
    Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
    tooltipLabel.add(new AttributeAppender("data-original-title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(tooltipKey);
        }
    }));
    tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
    tooltipLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return tooltipKey != null;
        }
    });
    tooltipLabel.setOutputMarkupId(true);
    tooltipLabel.setOutputMarkupPlaceholderTag(true);
    labelContainer.add(tooltipLabel);
    WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        textWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(textWrapper);
    AceEditor text = new AceEditor(ID_TEXT, getModel());
    text.add(new AttributeModifier("rows", rowNumber));
    text.setOutputMarkupId(true);
    text.setRequired(required);
    text.setLabel(label);
    text.add(AttributeAppender.replace("placeholder", label));
    textWrapper.add(text);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AceEditor(com.evolveum.midpoint.web.component.AceEditor) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)227 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)106 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)101 Label (org.apache.wicket.markup.html.basic.Label)98 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)59 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)44 List (java.util.List)43 ListItem (org.apache.wicket.markup.html.list.ListItem)43 ArrayList (java.util.ArrayList)41 ListView (org.apache.wicket.markup.html.list.ListView)39 PropertyModel (org.apache.wicket.model.PropertyModel)34 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)26 TextField (org.apache.wicket.markup.html.form.TextField)25 IModel (org.apache.wicket.model.IModel)22 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)21 AttributeModifier (org.apache.wicket.AttributeModifier)21 Form (org.apache.wicket.markup.html.form.Form)21 Model (org.apache.wicket.model.Model)18 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)17 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)16