Search in sources :

Example 1 with AjaxDataTablePanel

use of org.apache.syncope.client.console.panels.AjaxDataTablePanel in project syncope by apache.

the class AjaxFallbackDataTable method newRowItem.

@Override
protected Item<T> newRowItem(final String id, final int index, final IModel<T> model) {
    final OddEvenItem<T> item = new OddEvenItem<>(id, index, model);
    if (togglePanel != null) {
        final ActionsPanel<T> actions = getActions(model);
        if (actions != null && !actions.isEmpty()) {
            item.add(new AttributeModifier("style", "cursor: pointer;"));
            item.add(new AjaxEventBehavior(Constants.ON_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected String findIndicatorId() {
                    return StringUtils.EMPTY;
                }

                @Override
                protected void onEvent(final AjaxRequestTarget target) {
                    final String lastFocussedElementId = target.getLastFocusedElementId();
                    if (lastFocussedElementId == null) {
                        togglePanel.toggleWithContent(target, getActions(model), model.getObject());
                    } else {
                        final AjaxDataTablePanel<?, ?> parent = findParent(AjaxDataTablePanel.class);
                        final Model<Boolean> isCheck = Model.<Boolean>of(Boolean.FALSE);
                        parent.visitChildren(CheckGroupSelector.class, (selector, ivisit) -> {
                            if (selector.getMarkupId().equalsIgnoreCase(lastFocussedElementId)) {
                                isCheck.setObject(Boolean.TRUE);
                                ivisit.stop();
                            }
                        });
                        if (!isCheck.getObject()) {
                            parent.visitChildren(Check.class, (check, ivisit) -> {
                                if (check.getMarkupId().equalsIgnoreCase(lastFocussedElementId)) {
                                    isCheck.setObject(Boolean.TRUE);
                                    ivisit.stop();
                                }
                            });
                        }
                        if (!isCheck.getObject()) {
                            togglePanel.toggleWithContent(target, getActions(model), model.getObject());
                        }
                    }
                }
            });
        }
    }
    return item;
}
Also used : AjaxDataTablePanel(org.apache.syncope.client.console.panels.AjaxDataTablePanel) Constants(org.apache.syncope.client.console.commons.Constants) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AjaxFallbackOrderByBorder(org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder) OddEvenItem(org.apache.wicket.markup.repeater.OddEvenItem) StringUtils(org.apache.commons.lang3.StringUtils) NoRecordsToolbar(org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ActionsPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) IModel(org.apache.wicket.model.IModel) Check(org.apache.wicket.markup.html.form.Check) CheckGroupSelector(org.apache.wicket.markup.html.form.CheckGroupSelector) ISortStateLocator(org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator) DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) Model(org.apache.wicket.model.Model) AjaxDataNavigationToolbar(org.apache.syncope.client.console.wicket.ajax.markup.html.navigation.paging.AjaxDataNavigationToolbar) AttributeModifier(org.apache.wicket.AttributeModifier) Serializable(java.io.Serializable) List(java.util.List) ActionLinksTogglePanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksTogglePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Item(org.apache.wicket.markup.repeater.Item) AjaxFallbackHeadersToolbar(org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackHeadersToolbar) ISortableDataProvider(org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) OddEvenItem(org.apache.wicket.markup.repeater.OddEvenItem) Check(org.apache.wicket.markup.html.form.Check) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckGroupSelector(org.apache.wicket.markup.html.form.CheckGroupSelector) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) AjaxDataTablePanel(org.apache.syncope.client.console.panels.AjaxDataTablePanel)

Aggregations

Serializable (java.io.Serializable)1 List (java.util.List)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Constants (org.apache.syncope.client.console.commons.Constants)1 AjaxDataTablePanel (org.apache.syncope.client.console.panels.AjaxDataTablePanel)1 AjaxDataNavigationToolbar (org.apache.syncope.client.console.wicket.ajax.markup.html.navigation.paging.AjaxDataNavigationToolbar)1 ActionLinksTogglePanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksTogglePanel)1 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFallbackOrderByBorder (org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder)1 AjaxFallbackHeadersToolbar (org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackHeadersToolbar)1 ISortStateLocator (org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator)1 DataTable (org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable)1 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)1 ISortableDataProvider (org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider)1 NoRecordsToolbar (org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Check (org.apache.wicket.markup.html.form.Check)1