Search in sources :

Example 1 with OddEvenItem

use of org.apache.wicket.markup.repeater.OddEvenItem in project wicket by apache.

the class TableTreePage method createTree.

@Override
protected AbstractTree<Foo> createTree(FooProvider provider, IModel<Set<Foo>> state) {
    List<IColumn<Foo, String>> columns = createColumns();
    final TableTree<Foo, String> tree = new TableTree<Foo, String>("tree", columns, provider, Integer.MAX_VALUE, state) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Component newContentComponent(String id, IModel<Foo> model) {
            return TableTreePage.this.newContentComponent(id, model);
        }

        @Override
        protected Item<Foo> newRowItem(String id, int index, IModel<Foo> model) {
            return new OddEvenItem<>(id, index, model);
        }
    };
    tree.getTable().addTopToolbar(new HeadersToolbar<>(tree.getTable(), null));
    tree.getTable().addBottomToolbar(new NoRecordsToolbar(tree.getTable()));
    return tree;
}
Also used : IModel(org.apache.wicket.model.IModel) NoRecordsToolbar(org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) OddEvenItem(org.apache.wicket.markup.repeater.OddEvenItem) TableTree(org.apache.wicket.extensions.markup.html.repeater.tree.TableTree)

Example 2 with OddEvenItem

use of org.apache.wicket.markup.repeater.OddEvenItem in project wicket by apache.

the class EnhancedPageView method newTree.

private AbstractTree<TreeNode> newTree() {
    TreeProvider provider = new TreeProvider();
    IModel<Set<TreeNode>> expandStateModel = new LoadableDetachableModel<Set<TreeNode>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected Set<TreeNode> load() {
            return expandState;
        }
    };
    AbstractTree<TreeNode> tree = new DefaultTableTree<TreeNode, Void>("tree", visibleColumns, provider, Integer.MAX_VALUE, expandStateModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Item<TreeNode> newRowItem(String id, int index, IModel<TreeNode> model) {
            return new OddEvenItem<>(id, index, model);
        }
    };
    tree.setOutputMarkupId(true);
    return tree;
}
Also used : IModel(org.apache.wicket.model.IModel) HashSet(java.util.HashSet) Set(java.util.Set) OddEvenItem(org.apache.wicket.markup.repeater.OddEvenItem) SortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.util.SortableTreeProvider) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) DefaultTableTree(org.apache.wicket.extensions.markup.html.repeater.tree.DefaultTableTree)

Example 3 with OddEvenItem

use of org.apache.wicket.markup.repeater.OddEvenItem 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

OddEvenItem (org.apache.wicket.markup.repeater.OddEvenItem)3 IModel (org.apache.wicket.model.IModel)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 NoRecordsToolbar (org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar)2 Serializable (java.io.Serializable)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)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