Search in sources :

Example 6 with AttributeModifier

use of org.apache.wicket.AttributeModifier 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 7 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class NavigatorPanel method initNavigation.

private void initNavigation() {
    IModel<Integer> model = new AbstractReadOnlyModel<Integer>() {

        @Override
        public Integer getObject() {
            int count = (int) pageable.getPageCount();
            if (count < PAGING_SIZE) {
                return count;
            }
            return PAGING_SIZE;
        }
    };
    Loop navigation = new Loop(ID_NAVIGATION, model) {

        @Override
        protected void populateItem(final LoopItem item) {
            final NavigatorPageLink pageLink = new NavigatorPageLink(ID_PAGE_LINK, computePageNumber(item.getIndex())) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    pageLinkPerformed(target, getPageNumber());
                }
            };
            item.add(pageLink);
            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return pageable.getCurrentPage() == pageLink.getPageNumber() ? "active" : "";
                }
            }));
        }
    };
    navigation.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return BooleanUtils.isTrue(showPageListingModel.getObject());
        }
    });
    add(navigation);
}
Also used : Loop(org.apache.wicket.markup.html.list.Loop) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) LoopItem(org.apache.wicket.markup.html.list.LoopItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier)

Example 8 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class NavigatorPanel method initPrevious.

private void initPrevious() {
    WebMarkupContainer previous = new WebMarkupContainer(ID_PREVIOUS);
    previous.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isPreviousEnabled() ? "" : "disabled";
        }
    }));
    add(previous);
    AjaxLink previousLink = new AjaxLink(ID_PREVIOUS_LINK) {

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

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

        @Override
        public boolean isEnabled() {
            return isPreviousEnabled();
        }
    });
    previous.add(previousLink);
}
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 9 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class NavigatorPanel method initNext.

private void initNext() {
    WebMarkupContainer next = new WebMarkupContainer(ID_NEXT);
    next.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isNextEnabled() ? "" : "disabled";
        }
    }));
    add(next);
    AjaxLink nextLink = new AjaxLink(ID_NEXT_LINK) {

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

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

        @Override
        public boolean isEnabled() {
            return isNextEnabled();
        }
    });
    next.add(nextLink);
}
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 10 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class MyAssignmentsPanel method initLayout.

private void initLayout() {
    List<IColumn<AssignmentItemDto, String>> columns = new ArrayList<IColumn<AssignmentItemDto, String>>();
    columns.add(new IconColumn<AssignmentItemDto>(null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createIconModel(final IModel<AssignmentItemDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    AssignmentItemDto item = rowModel.getObject();
                    if (item.getType() == null) {
                        return OperationResultStatusPresentationProperties.FATAL_ERROR.getIcon() + " fa-lg";
                    }
                    return item.getType().getIconCssClass();
                }
            };
        }

        @Override
        protected IModel<String> createTitleModel(final IModel<AssignmentItemDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    AssignmentItemDto item = rowModel.getObject();
                    if (item.getType() == null) {
                        return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
                    }
                    switch(item.getType()) {
                        case CONSTRUCTION:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.accountConstruction");
                        case ORG_UNIT:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.orgUnit");
                        case ROLE:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.role");
                        default:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
                    }
                }
            };
        }
    });
    columns.add(new AbstractColumn<AssignmentItemDto, String>(createStringResource("MyAssignmentsPanel.assignment.displayName")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AssignmentItemDto>> cellItem, String componentId, final IModel<AssignmentItemDto> rowModel) {
            AssignmentHeaderPanel panel = new AssignmentHeaderPanel(componentId, rowModel);
            panel.add(new AttributeModifier("class", "dash-assignment-header"));
            cellItem.add(panel);
        }
    });
    ISortableDataProvider provider = new ListDataProvider(this, getModel());
    TablePanel accountsTable = new TablePanel<AssignmentItemDto>(ID_ASSIGNMETNS_TABLE, provider, columns);
    accountsTable.setShowPaging(false);
    add(accountsTable);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) IModel(org.apache.wicket.model.IModel) AssignmentHeaderPanel(com.evolveum.midpoint.web.component.assignment.AssignmentHeaderPanel) ArrayList(java.util.ArrayList) ISortableDataProvider(org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider) AttributeModifier(org.apache.wicket.AttributeModifier) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Aggregations

AttributeModifier (org.apache.wicket.AttributeModifier)37 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)23 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)23 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)21 Label (org.apache.wicket.markup.html.basic.Label)19 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)18 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)12 IModel (org.apache.wicket.model.IModel)9 PropertyModel (org.apache.wicket.model.PropertyModel)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 ListView (org.apache.wicket.markup.html.list.ListView)8 Model (org.apache.wicket.model.Model)7 ArrayList (java.util.ArrayList)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)4 PasswordPanel (com.evolveum.midpoint.gui.api.component.password.PasswordPanel)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)3 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)3