if(!params.getParameterValue("itemsPerPage").isEmpty()) {
} else {
itemsPerPage = ITEMS_PER_PAGE;
}
*/
final HistoryDataProvider historyDataProvider = new HistoryDataProvider(pasteService);
final WebMarkupContainer historyDataViewContainer = new WebMarkupContainer("historyContainer");
historyDataView = new DataView<PasteItem>("history", historyDataProvider, itemsPerPage) {
protected void populateItem(Item<PasteItem> item) {
final PasteItem pasteItem = item.getModelObject();
PageParameters params = new PageParameters();
params.add("0", pasteItem.getItemId());
item.add(new BookmarkablePageLink<Void>("viewLink", ViewPublicPage.class, params));
item.add(new AjaxLink<Void>("increaseAbuseCount") {
@Override
public void onClick(AjaxRequestTarget target) {
pasteService.increaseAbuseCount(pasteItem);
target.add(historyDataViewContainer);
}
});
/*
item.add(new AjaxLink<Void>("decreaseAbuseCount") {
@Override
public void onClick(AjaxRequestTarget target) {
pasteService.decreaseAbuseCount(pasteItem);
target.add(historyDataView);
}
});
*/
final String[] contentLines = pasteItem.getContent().split("\n");
item.add(new Label("lineCount", "(" + contentLines.length + " Line" +
(contentLines.length > 1 ? "s" : "") + ")"));
item.add(new Label("posted", PasteItem.getElapsedTimeSincePost(pasteItem)));
item.add(new Label("clientIp", new PropertyModel<String>(item.getModel(), "clientIp")));
WebMarkupContainer hasImage = new WebMarkupContainer("hasImage") {
@Override
public boolean isVisible() {
return pasteItem.hasImage();
}
};
item.add(hasImage);
item.add(new Label("content",
new PropertyModel<String>(pasteItem, "previewContent")));
/*
item.add(new HighlighterPanel("content",
new PropertyModel<String>(pasteItem, "previewContent"), pasteItem.getType()));
*/
}
};
historyDataViewContainer.add(historyDataView);
historyDataViewContainer.setOutputMarkupId(true);
add(historyDataViewContainer);
PastePagingNavigator pageNav = new PastePagingNavigator("pageNav", historyDataView) {
@Override
public boolean isVisible() {
return historyDataProvider.isVisible();
}
};
PastePagingNavigator pageNav2 = new PastePagingNavigator("pageNav2", historyDataView) {
@Override
public boolean isVisible() {
return historyDataProvider.isVisible();
}
};
pageNav.setDependentNavigator(pageNav2);
pageNav2.setDependentNavigator(pageNav);
add(pageNav);
add(pageNav2);
add(new Label("noPastesFound", "No Pastes Found") {
@Override
public boolean isVisible() {
return !historyDataProvider.isVisible();
}
});
}