Search in sources :

Example 56 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class OrgTreeFolderContent method initLayout.

private void initLayout() {
    SelectableFolderContent folder = new SelectableFolderContent(ID_FOLDER, tree, getModel(), selected) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onClick(Optional<AjaxRequestTarget> target) {
            super.onClick(target);
            OrgTreeFolderContent.this.setSelectedItem(selected.getObject(), orgTreeStorage);
            selectTreeItemPerformed(selected.getObject(), target.get());
            Component component = get("table");
            if (component != null) {
                target.get().add(component);
            }
        }
    };
    folder.setOutputMarkupId(true);
    addOrReplace(folder);
    if (selected.getObject().equals(getModelObject())) {
        getParent().add(AttributeAppender.append("class", "success"));
    } else {
        getParent().add(new AttributeAppender("class", "success", " ") {

            @Override
            protected Serializable newValue(String currentValue, String removeValue) {
                currentValue = getSeparator() + currentValue + getSeparator();
                removeValue = getSeparator() + removeValue + getSeparator();
                return currentValue.replace(removeValue, getSeparator());
            }
        });
    }
    MenuMultiButtonPanel<OrgType> menuButtons = new MenuMultiButtonPanel<>(ID_MENU, new PropertyModel<>(getModel(), TreeSelectableBean.F_VALUE), 2, createInlineMenuItemsModel());
    menuButtons.setOutputMarkupId(true);
    addOrReplace(menuButtons);
    CheckBoxPanel checkBoxPanel = new CheckBoxPanel(ID_CHECK, getCheckboxModel(getModel())) {

        @Override
        public void onUpdate(AjaxRequestTarget target) {
            getModelObject().setSelected(!getModelObject().isSelected());
            OrgTreeFolderContent.this.onUpdateCheckbox(target);
        }
    };
    checkBoxPanel.add(new VisibleBehaviour(() -> selectable));
    addOrReplace(checkBoxPanel);
}
Also used : SelectableFolderContent(com.evolveum.midpoint.web.page.admin.users.component.SelectableFolderContent) Serializable(java.io.Serializable) MenuMultiButtonPanel(com.evolveum.midpoint.web.component.data.MenuMultiButtonPanel) Optional(java.util.Optional) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CheckBoxPanel(com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) Component(org.apache.wicket.Component) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 57 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class DashboardPanel method initLayout.

private void initLayout(IModel<String> titleModel, String icon, String boxCssClasses) {
    if (boxCssClasses == null) {
        boxCssClasses = GuiStyleConstants.CLASS_BOX_DEFAULT;
    }
    WebMarkupContainer dashboardParent = new WebMarkupContainer(ID_DASHBOARD_PARENT);
    dashboardParent.add(new AttributeAppender("class", " " + boxCssClasses));
    add(dashboardParent);
    WebMarkupContainer dashboardTitle = new WebMarkupContainer(ID_DASHBOARD_TITLE);
    dashboardParent.add(dashboardTitle);
    Label title = new Label(ID_TITLE);
    title.setRenderBodyOnly(true);
    title.setDefaultModel(titleModel);
    dashboardTitle.add(title);
    WebMarkupContainer dashboardContent = new WebMarkupContainer(ID_DASHBOARD_CONTENT);
    dashboardContent.add(getMainComponent(ID_CONTENT));
    dashboardParent.add(dashboardContent);
    WebMarkupContainer iconI = new WebMarkupContainer(ID_ICON);
    iconI.add(AttributeModifier.replace("class", icon));
    dashboardTitle.add(iconI);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 58 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class OperationResultPanel method initHeader.

private void initHeader(WebMarkupContainer box) {
    WebMarkupContainer iconType = new WebMarkupContainer(ID_ICON_TYPE);
    iconType.setOutputMarkupId(true);
    iconType.add(new AttributeAppender("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            OpResult message = getModelObject();
            switch(message.getStatus()) {
                case IN_PROGRESS:
                case NOT_APPLICABLE:
                    sb.append(" fa-info");
                    break;
                case SUCCESS:
                    sb.append(" fa-check");
                    break;
                case FATAL_ERROR:
                    sb.append(" fa-ban");
                    break;
                case PARTIAL_ERROR:
                case UNKNOWN:
                case WARNING:
                case HANDLED_ERROR:
                default:
                    sb.append(" fa-warning");
            }
            return sb.toString();
        }
    }));
    box.add(iconType);
    Label message = createMessage();
    AjaxLink<String> showMore = new AjaxLink<String>(ID_MESSAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowMore(!result.isShowMore());
            // hack to be able to expand/collapse OpResult after rendered.
            result.setAlreadyShown(false);
            target.add(OperationResultPanel.this);
        }
    };
    showMore.add(message);
    box.add(showMore);
    AjaxLink<String> backgroundTask = new AjaxLink<String>(ID_BACKGROUND_TASK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getBackgroundTaskOid();
            if (oid == null || !opResult.isBackgroundTaskVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.TASK);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    backgroundTask.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getBackgroundTaskOid() != null && getModelObject().isBackgroundTaskVisible();
        }
    });
    box.add(backgroundTask);
    AjaxLink<String> aCase = new AjaxLink<String>(ID_CASE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getCaseOid();
            if (oid == null || !opResult.isCaseVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.CASE);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    aCase.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getCaseOid() != null && getModelObject().isCaseVisible();
        }
    });
    box.add(aCase);
    AjaxLink<String> showAll = new AjaxLink<String>(ID_SHOW_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(true, target);
        }
    };
    showAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(showAll);
    AjaxLink<String> hideAll = new AjaxLink<String>(ID_HIDE_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(false, target);
        }
    };
    hideAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(hideAll);
    AjaxLink<String> close = new AjaxLink<String>("close") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            close(target);
        }
    };
    box.add(close);
    DownloadLink downloadXml = new DownloadLink("downloadXml", new IModel<File>() {

        private static final long serialVersionUID = 1L;

        @Override
        public File getObject() {
            String home = getPageBase().getMidpointConfiguration().getMidpointHome();
            File f = new File(home, "result");
            try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(f))) {
                dos.writeBytes(OperationResultPanel.this.getModel().getObject().getXml());
            } catch (IOException e) {
                LOGGER.error("Could not download result: {}", e.getMessage(), e);
            }
            return f;
        }
    });
    downloadXml.add(new VisibleBehaviour(() -> getModelObject().isParent()));
    downloadXml.setDeleteAfterDownload(true);
    box.add(downloadXml);
}
Also used : DownloadLink(org.apache.wicket.markup.html.link.DownloadLink) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) DataOutputStream(java.io.DataOutputStream) Label(org.apache.wicket.markup.html.basic.Label) IOException(java.io.IOException) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FileOutputStream(java.io.FileOutputStream) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) File(java.io.File) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 59 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class ValidationErrorPanel method initHeader.

private void initHeader(WebMarkupContainer box) {
    WebMarkupContainer iconType = new WebMarkupContainer("iconType");
    iconType.setOutputMarkupId(true);
    iconType.add(new AttributeAppender("class", new IModel() {

        @Override
        public Object getObject() {
            FeedbackMessage result = getModelObject();
            if (result == null) {
                return " fa-info";
            }
            switch(result.getLevel()) {
                case FeedbackMessage.INFO:
                case FeedbackMessage.DEBUG:
                    return " fa-info";
                case FeedbackMessage.SUCCESS:
                    return " fa-check";
                case FeedbackMessage.ERROR:
                case FeedbackMessage.FATAL:
                    return " fa-ban";
                case FeedbackMessage.UNDEFINED:
                // TODO:
                case FeedbackMessage.WARNING:
                default:
                    return " fa-warning";
            }
        }
    }));
    box.add(iconType);
    Label message = new Label(ID_MESSAGE, new PropertyModel<Serializable>(getModel(), "message"));
    box.add(message);
    AjaxLink<Void> close = new AjaxLink<Void>("close") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            close(target);
        }
    };
    box.add(close);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) Serializable(java.io.Serializable) Label(org.apache.wicket.markup.html.basic.Label) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 60 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class UserSelectionButton method initLayout.

private void initLayout() {
    AjaxLink<String> userSelectionButton = new AjaxLink<String>(ID_USER_SELECTION_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (showUserSelectionPopup) {
                initUserSelectionPopup(target);
            }
            showUserSelectionPopup = true;
        }
    };
    userSelectionButton.add(AttributeModifier.append("class", getTargetUserButtonClass()));
    userSelectionButton.setOutputMarkupId(true);
    userSelectionButton.add(new AttributeAppender("title", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getUserSelectionButtonTitle();
        }
    }));
    add(userSelectionButton);
    Label label = new Label(ID_USER_SELECTION_BUTTON_LABEL, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getUserButtonLabel();
        }
    });
    label.setRenderBodyOnly(true);
    userSelectionButton.add(label);
    AjaxLink<Void> deleteButton = new AjaxLink<Void>(ID_DELETE_SELECTED_USER_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserSelectionButton.this.onDeleteSelectedUsersPerformed(target);
        }
    };
    deleteButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isDeleteButtonVisible();
        }
    });
    userSelectionButton.add(deleteButton);
}
Also used : IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

AttributeAppender (org.apache.wicket.behavior.AttributeAppender)69 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)34 Label (org.apache.wicket.markup.html.basic.Label)34 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 IModel (org.apache.wicket.model.IModel)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)28 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)19 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 ListItem (org.apache.wicket.markup.html.list.ListItem)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 AttributeModifier (org.apache.wicket.AttributeModifier)7 ListView (org.apache.wicket.markup.html.list.ListView)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)6 Component (org.apache.wicket.Component)6 Model (org.apache.wicket.model.Model)6 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5