Search in sources :

Example 51 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class MultipleAssignmentSelectorPanel method initLayout.

private void initLayout(Class<H> targetFocusClass, PageBase page) {
    IModel<List<AssignmentEditorDto>> availableAssignmentModel = createAvailableAssignmentModel();
    final MultipleAssignmentSelector availableAssignmentsPanel = new MultipleAssignmentSelector<F, H>(ID_AVAILABLE_ASSIGNMENTS, availableAssignmentModel, targetFocusClass, type, focus, getFilterModel(true), page);
    final MultipleAssignmentSelector currentAssignmentsPanel = new MultipleAssignmentSelector<F, H>(ID_CURRENT_ASSIGNMENTS, assignmentsModel, targetFocusClass, type, null, getFilterModel(true), page) {

        @Override
        protected List<AssignmentEditorDto> getListProviderDataList() {
            return assignmentsModel.getObject();
        }
    };
    currentAssignmentsPanel.setFilterButtonVisibility(false);
    AjaxButton add = new AjaxButton(ID_BUTTON_ADD) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) {
            addToAssignmentsModel(target, availableAssignmentsPanel, currentAssignmentsPanel);
        }
    };
    AjaxButton remove = new AjaxButton(ID_BUTTON_REMOVE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) {
            deleteFromAssignmentsModel(target, currentAssignmentsPanel, availableAssignmentsPanel);
        }
    };
    remove.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL);
        }
    });
    AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            reset(currentAssignmentsPanel);
            target.add(currentAssignmentsPanel);
        }
    };
    buttonReset.setBody(createStringResource("MultipleAssignmentSelector.reset"));
    Form<?> form = new Form<Void>(ID_FORM);
    form.add(createTenantContainer());
    form.add(createOrgContainer());
    form.add(availableAssignmentsPanel);
    form.add(currentAssignmentsPanel);
    form.add(buttonReset);
    form.add(add);
    form.add(remove);
    add(form);
}
Also used : Form(com.evolveum.midpoint.web.component.form.Form) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(org.apache.wicket.ajax.markup.html.form.AjaxButton) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 52 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class MultiButtonTable method populateCell.

protected void populateCell(WebMarkupContainer cellContainer, final AssignmentEditorDto assignment) {
    AjaxLink inner = new AjaxLink(ID_INNER) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            targetObjectDetailsPerformed(assignment, ajaxRequestTarget);
        }
    };
    inner.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    cellContainer.add(inner);
    Label nameLabel = new Label(ID_INNER_LABEL, assignment.getName());
    inner.add(nameLabel);
    Label descriptionLabel = new Label(ID_INNER_DESCRIPTION, assignment.getTargetRef() != null ? assignment.getTargetRef().getDescription() : "");
    descriptionLabel.setOutputMarkupId(true);
    inner.add(descriptionLabel);
    AjaxLink detailsLink = new AjaxLink(ID_DETAILS_LINK) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            assignmentDetailsPerformed(assignment, ajaxRequestTarget);
        }
    };
    detailsLink.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    cellContainer.add(detailsLink);
    Label detailsLinkLabel = new Label(ID_DETAILS_LINK_LABEL, pageBase.createStringResource("MultiButtonPanel.detailsLink"));
    detailsLinkLabel.setRenderBodyOnly(true);
    detailsLink.add(detailsLinkLabel);
    AjaxLink detailsLinkIcon = new AjaxLink(ID_DETAILS_LINK_ICON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    };
    detailsLinkIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    detailsLink.add(detailsLinkIcon);
    AjaxLink addToCartLink = new AjaxLink(ID_ADD_TO_CART_LINK) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            addAssignmentPerformed(assignment, ajaxRequestTarget);
        }
    };
    addToCartLink.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    cellContainer.add(addToCartLink);
    AjaxLink addToCartLinkIcon = new AjaxLink(ID_ADD_TO_CART_LINK_ICON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    };
    addToCartLinkIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return isMultiUserRequest() || canAssign(assignment);
        }
    });
    addToCartLink.add(addToCartLinkIcon);
    WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON);
    icon.add(new AttributeAppender("class", getIconClass(assignment.getType())));
    cellContainer.add(icon);
    WebMarkupContainer alreadyAssignedIcon = new WebMarkupContainer(ID_ALREADY_ASSIGNED_ICON);
    alreadyAssignedIcon.add(new AttributeAppender("title", getAlreadyAssignedIconTitleModel(assignment)));
    alreadyAssignedIcon.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isMultiUserRequest() && assignment.isAlreadyAssigned();
        }
    });
    cellContainer.add(alreadyAssignedIcon);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 53 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class NavigatorPanel method initFirst.

private void initFirst() {
    WebMarkupContainer first = new WebMarkupContainer(ID_FIRST);
    first.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isFirstEnabled() ? "" : "disabled";
        }
    }));
    add(first);
    AjaxLink firstLink = new AjaxLink(ID_FIRST_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            firstPerformed(target);
        }
    };
    firstLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isFirstEnabled();
        }
    });
    first.add(firstLink);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 54 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class InfoBoxPanel method initLayout.

private void initLayout(final IModel<InfoBoxType> model, final Class<? extends IRequestablePage> linkPage) {
    WebMarkupContainer infoBox = new WebMarkupContainer(ID_INFO_BOX);
    add(infoBox);
    infoBox.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.BOX_BACKGROUND_COLOR)));
    WebMarkupContainer infoBoxIcon = new WebMarkupContainer(ID_INFO_BOX_ICON);
    infoBox.add(infoBoxIcon);
    infoBoxIcon.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.ICON_BACKGROUND_COLOR)));
    WebMarkupContainer image = new WebMarkupContainer(ID_IMAGE_ID);
    image.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.IMAGE_ID)));
    infoBoxIcon.add(image);
    Label message = new Label(ID_MESSAGE, new PropertyModel<String>(model, InfoBoxType.MESSAGE));
    infoBox.add(message);
    Label number = new Label(ID_NUMBER, new PropertyModel<String>(model, InfoBoxType.NUMBER));
    infoBox.add(number);
    WebMarkupContainer progress = new WebMarkupContainer(ID_PROGRESS);
    infoBox.add(progress);
    progress.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return model.getObject().getProgress() != null;
        }
    });
    ProgressbarPanel progressBar = new ProgressbarPanel(ID_PROGRESS_BAR, new PropertyModel<Integer>(model, InfoBoxType.PROGRESS));
    progress.add(progressBar);
    Label description = new Label(ID_DESCRIPTION, new PropertyModel<String>(model, InfoBoxType.DESCRIPTION));
    infoBox.add(description);
    if (linkPage != null) {
        add(new AjaxEventBehavior("click") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                setResponsePage(linkPage);
            }
        });
    }
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) 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) ProgressbarPanel(com.evolveum.midpoint.gui.api.component.progressbar.ProgressbarPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 55 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class MenuMultiButtonPanel method initLayout.

@Override
protected void initLayout() {
    super.initLayout();
    InlineMenu inlineMenu = new InlineMenu(ID_INLINE_MENU_PANEL, menuItemsModel) {

        @Override
        protected String getIconClass() {
            return "fa fa-ellipsis-h";
        }

        @Override
        protected String getAdditionalButtonClass() {
            return "btn btn-default btn-xs";
        }

        @Override
        protected String getMenuItemContainerClass() {
            return "none";
        }

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

        @Override
        protected String getMenuItemContainerStyle() {
            return "margin-left: -37px; margin-bottom: -3px; list-style: none;";
        }
    };
    inlineMenu.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !(numberOfButtons < 2);
        }
    });
    add(inlineMenu);
}
Also used : InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)183 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)116 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)101 Label (org.apache.wicket.markup.html.basic.Label)89 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)51 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)44 List (java.util.List)32 ListItem (org.apache.wicket.markup.html.list.ListItem)29 PropertyModel (org.apache.wicket.model.PropertyModel)29 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)26 ArrayList (java.util.ArrayList)25 Form (org.apache.wicket.markup.html.form.Form)25 ListView (org.apache.wicket.markup.html.list.ListView)25 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)23 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)19 AttributeModifier (org.apache.wicket.AttributeModifier)18 IModel (org.apache.wicket.model.IModel)17 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)16 TextField (org.apache.wicket.markup.html.form.TextField)16 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)15