Example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable addTopToolbar

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable addTopToolbar

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable addTopToolbar.

Prototype

public void addTopToolbar(final AbstractToolbar toolbar) 

Source Link

Document

Adds a toolbar to the datatable that will be displayed before the data

Usage

From source file:nl.mpi.lamus.web.pages.management.ManageWorkspacesPage.java

License:Open Source License

public ManageWorkspacesPage() {

    List<IColumn<Workspace, String>> columns = createColumns();

    SortableWorkspaceDataProvider provider = new SortableWorkspaceDataProvider(workspaceService);

    DataTable<Workspace, String> dataTable = createDataTable(columns, provider);

    FilterForm<WorkspaceFilter> filterForm = createFilterForm(provider);
    FilterToolbar filterToolbar = new FilterToolbar(dataTable, filterForm, provider);

    dataTable.addTopToolbar(filterToolbar);

    filterForm.add(dataTable);//from   w  ww  . j a va  2  s.  com
}

From source file:org.cast.cwm.admin.EventLog.java

License:Open Source License

public EventLog(final PageParameters params) {
    super(params);
    setPageTitle("Event Log");

    addFilterForm();//from  w  w  w.j  a  v a2s  .  com

    OrderingCriteriaBuilder builder = makeCriteriaBuilder();
    SortableHibernateProvider<Event> eventsprovider = makeHibernateProvider(builder);
    List<IDataColumn<Event>> columns = makeColumns();
    DataTable<Event, String> table = new DataTable<Event, String>("eventtable", columns, eventsprovider, 30);
    table.addTopToolbar(new HeadersToolbar<String>(table, eventsprovider));
    table.addTopToolbar(new NavigationToolbar(table));
    table.addBottomToolbar(new NavigationToolbar(table));
    table.addBottomToolbar(new NoRecordsToolbar(table, new Model<String>("No events found")));
    add(table);

    CSVDownload<Event> download = new CSVDownload<Event>(columns, eventsprovider);
    add(new ResourceLink<Object>("downloadLink", download));
}

From source file:org.cast.cwm.admin.UserContentLogPage.java

License:Open Source License

public UserContentLogPage(PageParameters parameters) {
    super(parameters);

    addFilterForm();//from www . j a  va  2s  .  co  m

    AuditDataProvider<UserContent, DefaultRevisionEntity> provider = getDataProvider();

    List<IDataColumn<AuditTriple<UserContent, DefaultRevisionEntity>>> columns = makeColumns();
    // Annoying to have to make a new List here; DataTable should use <? extends IColumn>.
    ArrayList<IColumn<AuditTriple<UserContent, DefaultRevisionEntity>, String>> colList = new ArrayList<IColumn<AuditTriple<UserContent, DefaultRevisionEntity>, String>>(
            columns);
    DataTable<AuditTriple<UserContent, DefaultRevisionEntity>, String> table = new DataTable<AuditTriple<UserContent, DefaultRevisionEntity>, String>(
            "table", colList, provider, ITEMS_PER_PAGE);

    table.addTopToolbar(new HeadersToolbar<String>(table, provider));
    table.addBottomToolbar(new NavigationToolbar(table));
    table.addBottomToolbar(new NoRecordsToolbar(table, new Model<String>("No revisions found")));
    add(table);

    CSVDownload<AuditTriple<UserContent, DefaultRevisionEntity>> download = new CSVDownload<AuditTriple<UserContent, DefaultRevisionEntity>>(
            columns, provider);
    add(new ResourceLink<Object>("downloadLink", download));

    // Look for a configuration variable with site's URL, called either cwm.url or app.url.
    // If it is set, it is used to make URLs absolute in the downloaded file
    if (Application.get() instanceof CwmApplication) {
        IAppConfiguration config = CwmApplication.get().getConfiguration();
        urlPrefix = config.getString("cwm.url", config.getString("app.url", ""));
    }
}

From source file:org.dcache.webadmin.view.panels.alarms.DisplayPanel.java

License:Open Source License

public DisplayPanel(String id, final AlarmsPage parent) {
    super(id);//  ww w.ja  v  a 2 s . com
    List<IColumn<LogEntry, String>> columns = new ArrayList<>();
    final AlarmTableProvider provider = parent.getWebadminApplication().getAlarmDisplayService()
            .getDataProvider();
    addDeleteColumn(columns, provider);
    addCloseColumn(columns, provider);
    addAttributeColumns(columns);
    addNotesColumn(columns, provider);

    add(new Label("tableTitle", new PropertyModel<String>(provider, "tableTitle")));
    DataTable<LogEntry, String> table = new DataTable<LogEntry, String>("alarms", columns, provider, 100) {
        private static final long serialVersionUID = -6574880701979145714L;

        protected Item<LogEntry> newRowItem(final String id, final int index, final IModel<LogEntry> model) {
            Item<LogEntry> item = super.newRowItem(id, index, model);
            if (provider.isAlarm() == null && model.getObject().isAlarm()) {
                item.add(AttributeModifier.replace("style", "color: #880000;"));
            }
            return item;
        }
    };
    table.addBottomToolbar(new NavigationToolbar(table));
    table.addTopToolbar(new HeadersToolbar(table, provider));

    add(table);
}

From source file:org.efaps.ui.wicket.components.search.ResultPanel.java

License:Apache License

/**
 * Gets the data table./*from   w w  w . j  av a  2s  .  co m*/
 *
 * @param _indexSearch the index search
 * @return the data table
 */
private DataTable<Element, Void> getDataTable(final IndexSearch _indexSearch) {
    final List<IColumn<Element, Void>> columns = new ArrayList<>();

    columns.add(new AbstractColumn<Element, Void>(new Model<String>("")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final Item<ICellPopulator<Element>> _cellItem, final String _componentId,
                final IModel<Element> _rowModel) {
            _cellItem.add(new Link(_componentId, _rowModel));
        }
    });

    if (_indexSearch.getSearch() == null || _indexSearch.getSearch().getResultFields().isEmpty()) {
        columns.add(new PropertyColumn<Element, Void>(new Model<String>(""), "text"));
    } else {
        for (final Entry<String, Collection<String>> entry : _indexSearch.getSearch().getResultFields()
                .entrySet()) {
            columns.add(new ResultColumn(_indexSearch.getSearch().getResultLabel().get(entry.getKey()),
                    entry.getValue()));
        }
    }
    final DataTable<Element, Void> ret = new DataTable<Element, Void>("table", columns,
            _indexSearch.getDataProvider(),
            _indexSearch.getSearch() == null ? 100 : _indexSearch.getSearch().getNumHits());

    ret.addTopToolbar(new HeadersToolbar<Void>(ret, null));
    return ret;
}

From source file:org.jaulp.wicket.data.provider.examples.datatable.DataTablePanel.java

License:Apache License

public DataTablePanel(String id) {
    super(id);/* w w w  . j ava 2 s .com*/

    final SortableFilterPersonDataProvider dataProvider = new SortableFilterPersonDataProvider(getPersons()) {
        private static final long serialVersionUID = 1L;

        @Override
        public List<Person> getData() {
            List<Person> persons = getPersons();
            setData(persons);
            return persons;
        }
    };
    dataProvider.setSort("firstname", SortOrder.ASCENDING);

    List<IColumn<Person, String>> columns = new ArrayList<>();

    columns.add(new PropertyColumn<Person, String>(Model.of("First name"), "firstname", "firstname"));
    columns.add(new PropertyColumn<Person, String>(Model.of("Last Name"), "lastname", "lastname") {
        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return "last-name";
        }
    });
    columns.add(new PropertyColumn<Person, String>(Model.of("Date of birth"), "dateOfBirth", "dateOfBirth"));

    DataTable<Person, String> tableWithFilterForm = new DataTable<Person, String>("tableWithFilterForm",
            columns, dataProvider, 10);
    tableWithFilterForm.setOutputMarkupId(true);

    FilterForm<PersonFilter> filterForm = new FilterForm<>("filterForm", dataProvider);
    filterForm.add(new TextField<>("dateFrom", PropertyModel.of(dataProvider, "filterState.dateFrom")));
    filterForm.add(new TextField<>("dateTo", PropertyModel.of(dataProvider, "filterState.dateTo")));
    add(filterForm);

    FilterToolbar filterToolbar = new FilterToolbar(tableWithFilterForm, filterForm, dataProvider);
    tableWithFilterForm.addTopToolbar(filterToolbar);
    tableWithFilterForm.addTopToolbar(new NavigationToolbar(tableWithFilterForm));
    tableWithFilterForm.addTopToolbar(new HeadersToolbar<>(tableWithFilterForm, dataProvider));
    filterForm.add(tableWithFilterForm);
}

From source file:org.onexus.website.api.widgets.tableviewer.DataTablePanel.java

License:Apache License

public DataTablePanel(String id, final List<? extends IColumn<IEntityTable, String>> columns,
        final EntitiesRowProvider dataProvider, final long defaultRowsPerPage) {
    super(id);/*from   ww  w . j av  a  2  s . c  o m*/

    this.dataProvider = dataProvider;

    indicator = new WebMarkupContainer("indicator");
    indicator.setOutputMarkupId(true);
    indicator.add(new Image("loading", OnDomReadyPanel.LOADING_IMAGE));
    add(indicator);

    DataTable<IEntityTable, String> resultTable = new DataTable<IEntityTable, String>("datatable", columns,
            dataProvider, defaultRowsPerPage);
    resultTable.setOutputMarkupId(true);
    resultTable.setVersioned(false);
    resultTable.addTopToolbar(new HeadersToolbar(resultTable, dataProvider));
    resultTable.addBottomToolbar(new NoRecordsToolbar(resultTable));
    resultTable.addBottomToolbar(new NavigationToolbar(resultTable));
    add(resultTable);
}

From source file:org.projectforge.web.timesheet.TimesheetEditSelectRecentDialogPanel.java

License:Open Source License

@SuppressWarnings({ "serial" })
private void addRecentSheetsTable() {
    final List<IColumn<TimesheetDO, String>> columns = new ArrayList<IColumn<TimesheetDO, String>>();
    final CellItemListener<TimesheetDO> cellItemListener = new CellItemListener<TimesheetDO>() {
        public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId,
                final IModel<TimesheetDO> rowModel) {
            final TimesheetDO timesheet = rowModel.getObject();
            final int rowIndex = ((Item<?>) item.findParent(Item.class)).getIndex();
            String cssClasses = null;
            if (timesheet.isDeleted() == true) {
                cssClasses = RowCssClass.MARKED_AS_DELETED.getCssClass();
            } else if (rowIndex < TimesheetEditPage.SIZE_OF_FIRST_RECENT_BLOCK) {
                cssClasses = RowCssClass.IMPORTANT_ROW.getCssClass();
            }//  w ww. j av  a2  s  .  c  o m
            if (cssClasses != null) {
                item.add(AttributeModifier.append("class", cssClasses));
            }
        }
    };
    if (showCost2Column == true) { // Is maybe invisible but does always exist if cost2 entries does exist in the system.
        columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(getString("fibu.kost2"), null,
                "kost2.shortDisplayName", cellItemListener) {
            @Override
            public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId,
                    final IModel<TimesheetDO> rowModel) {
                final TimesheetDO timesheet = rowModel.getObject();
                final ListSelectActionPanel actionPanel = new ListSelectActionPanel(componentId,
                        createRecentTimeSheetSelectionLink(timesheet), new Model<String>() {
                            @Override
                            public String getObject() {
                                final StringBuffer buf = new StringBuffer();
                                if (timesheet.getKost2() != null) {
                                    buf.append(timesheet.getKost2().getShortDisplayName());
                                }
                                if (timesheet.getUserId() != null
                                        && timesheet.getUserId().equals(PFUserContext.getUserId()) == false) {
                                    if (timesheet.getKost2() != null) {
                                        buf.append(", ");
                                    }
                                    buf.append(userFormatter.getFormattedUser(timesheet.getUserId()));
                                }
                                return buf.toString();
                            }
                        });
                item.add(actionPanel);
                item.add(AttributeModifier.append("style", new Model<String>("white-space: nowrap;")));
                final Item<?> row = item.findParent(Item.class);
                WicketUtils.addRowClick(row);
                cellItemListener.populateItem(item, componentId, rowModel);
            }
        });
        columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(new Model<String>(getString("fibu.kunde")),
                null, "kost2.projekt.kunde.name", cellItemListener));
        columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(
                new Model<String>(getString("fibu.projekt")), null, "kost2.projekt.name", cellItemListener));
        columns.add(new TaskPropertyColumn<TimesheetDO>(getString("task"), null, "task", cellItemListener)
                .withTaskTree(taskTree));
    } else {
        columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(new Model<String>(getString("task")), null,
                "task.title", cellItemListener) {
            @Override
            public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId,
                    final IModel<TimesheetDO> rowModel) {
                final TimesheetDO timesheet = rowModel.getObject();
                final TaskDO task = rowModel.getObject().getTask();
                final Label label = new Label("label", task != null ? task.getTitle() : "");
                final ListSelectActionPanel actionPanel = new ListSelectActionPanel(componentId,
                        createRecentTimeSheetSelectionLink(timesheet), label);
                WicketUtils.addTooltip(label,
                        TaskFormatter.instance().getTaskPath(task.getId(), false, OutputType.HTML));
                item.add(actionPanel);
                final Item<?> row = item.findParent(Item.class);
                WicketUtils.addRowClick(row);
                cellItemListener.populateItem(item, componentId, rowModel);
            }
        });
    }
    columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(getString("timesheet.location"), null,
            "location", cellItemListener) {

    });
    columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(getString("timesheet.description"), null,
            "shortDescription", cellItemListener));
    final DivPanel panel = gridBuilder.getPanel();
    final TablePanel table = new TablePanel(panel.newChildId());
    panel.add(table);
    final IDataProvider<TimesheetDO> dataProvider = new ListDataProvider<TimesheetDO>(
            parentPage.getRecentTimesheets());
    final DataTable<TimesheetDO, String> dataTable = new DataTable<TimesheetDO, String>(TablePanel.TABLE_ID,
            columns, dataProvider, 100) {
        @Override
        protected Item<TimesheetDO> newRowItem(final String id, final int index,
                final IModel<TimesheetDO> model) {
            return new OddEvenItem<TimesheetDO>(id, index, model);
        }
    };
    final HeadersToolbar headersToolbar = new HeadersToolbar(dataTable, null);
    dataTable.addTopToolbar(headersToolbar);
    table.add(dataTable);
}

From source file:org.projectforge.web.wicket.AbstractEditPage.java

License:Open Source License

@SuppressWarnings({ "serial", "unchecked" })
protected void init(O data) {
    final StringBuffer buf = new StringBuffer();
    buf.append("function showDeleteQuestionDialog() {\n").append("  return window.confirm('");
    if (getBaseDao().isHistorizable() == true) {
        buf.append(getString("question.markAsDeletedQuestion"));
    } else {//w  w  w. ja  va2  s . co  m
        buf.append(getString("question.deleteQuestion"));
    }
    buf.append("');\n}\n");
    body.add(new Label("showDeleteQuestionDialog", buf.toString()).setEscapeModelStrings(false));
    final Integer id = WicketUtils.getAsInteger(getPageParameters(), PARAMETER_KEY_ID);
    if (data == null) {
        if (id != null) {
            data = getBaseDao().getById(id);
        }
        if (data == null) {
            data = (O) WicketUtils.getAsObject(getPageParameters(), PARAMETER_KEY_DATA_PRESET,
                    getBaseDao().newInstance().getClass());
            if (data == null) {
                data = getBaseDao().newInstance();
            }
        }
    }
    form = newEditForm(this, data);

    body.add(form);
    form.init();
    if (form.isNew() == true) {
        showHistory = false;
        showModificationTimes = false;
    }
    body.add(new Label("tabTitle", getTitle()).setRenderBodyOnly(true));
    final List<IColumn<DisplayHistoryEntry, String>> columns = new ArrayList<IColumn<DisplayHistoryEntry, String>>();
    final CellItemListener<DisplayHistoryEntry> cellItemListener = new CellItemListener<DisplayHistoryEntry>() {
        public void populateItem(final Item<ICellPopulator<DisplayHistoryEntry>> item, final String componentId,
                final IModel<DisplayHistoryEntry> rowModel) {
            // Later a link should show the history entry as popup.
            item.add(AttributeModifier.append("class", new Model<String>("notrlink")));
        }
    };
    final DatePropertyColumn<DisplayHistoryEntry> timestampColumn = new DatePropertyColumn<DisplayHistoryEntry>(
            dateTimeFormatter, getString("timestamp"), null, "timestamp", cellItemListener);
    timestampColumn.setDatePattern(DateFormats.getFormatString(DateFormatType.TIMESTAMP_SHORT_MINUTES));
    columns.add(timestampColumn);
    columns.add(new UserPropertyColumn<DisplayHistoryEntry>(getString("user"), null, "user", cellItemListener)
            .withUserFormatter(userFormatter));
    columns.add(new CellItemListenerPropertyColumn<DisplayHistoryEntry>(getString("history.entryType"), null,
            "entryType", cellItemListener));
    columns.add(new CellItemListenerPropertyColumn<DisplayHistoryEntry>(getString("history.propertyName"), null,
            "propertyName", cellItemListener));
    columns.add(new CellItemListenerPropertyColumn<DisplayHistoryEntry>(getString("history.newValue"), null,
            "newValue", cellItemListener) {
        @Override
        public void populateItem(final Item<ICellPopulator<DisplayHistoryEntry>> item, final String componentId,
                final IModel<DisplayHistoryEntry> rowModel) {
            final DisplayHistoryEntry historyEntry = rowModel.getObject();
            item.add(new DiffTextPanel(componentId, Model.of(historyEntry.getNewValue()),
                    Model.of(historyEntry.getOldValue())));
            cellItemListener.populateItem(item, componentId, rowModel);
        }
    });
    final IDataProvider<DisplayHistoryEntry> dataProvider = new ListDataProvider<DisplayHistoryEntry>(
            getHistory());
    final DataTable<DisplayHistoryEntry, String> dataTable = new DataTable<DisplayHistoryEntry, String>(
            "historyTable", columns, dataProvider, 100) {
        @Override
        protected Item<DisplayHistoryEntry> newRowItem(final String id, final int index,
                final IModel<DisplayHistoryEntry> model) {
            return new OddEvenItem<DisplayHistoryEntry>(id, index, model);
        }

        @Override
        public boolean isVisible() {
            return showHistory;
        }
    };
    final HeadersToolbar<String> headersToolbar = new HeadersToolbar<String>(dataTable, null);
    dataTable.addTopToolbar(headersToolbar);
    body.add(dataTable);
    final Label timeOfCreationLabel = new Label("timeOfCreation",
            dateTimeFormatter.getFormattedDateTime(data.getCreated()));
    timeOfCreationLabel.setRenderBodyOnly(true);
    body.add(timeOfCreationLabel);
    final Label timeOfLastUpdateLabel = new Label("timeOfLastUpdate",
            dateTimeFormatter.getFormattedDateTime(data.getLastUpdate()));
    timeOfLastUpdateLabel.setRenderBodyOnly(true);
    body.add(timeOfLastUpdateLabel);
    onPreEdit();
    evaluateInitialPageParameters(getPageParameters());
    this.editPageSupport = new EditPageSupport<O, D>(this, getBaseDao());
}

From source file:org.ujorm.wicket.component.grid.UjoDataProvider.java

License:Apache License

/** Create AJAX-based DataTable */
public <S> DataTable<T, S> createDataTable(final String id, final int rowsPerPage) {
    final DataTable<T, S> result = new DataTable<T, S>(id, (List) columns, this, rowsPerPage) {
        @Override//from  w  ww.j av a  2  s. c o  m
        protected Item<T> newRowItem(final String id, final int index, final IModel<T> model) {
            return new OddEvenItem<T>(id, index, model);
        }
    };

    result.addTopToolbar(new AjaxNavigationToolbar(result));
    result.addTopToolbar(new HeadersToolbar(result, this));
    result.addBottomToolbar(new NoRecordsToolbar(result));
    result.setOutputMarkupId(true);
    return result;
}