buttonPanel.add(lastPageImageButton);
return buttonPanel;
}
private Widget createButtonPanel(final FlexTable mainPanel, final boolean forceOpen) {
final IconButton reloadImageButton = new IconButton("Refresh", true, BaseImageBundle.images.refresh_16(), BaseImageBundle.images.refresh_16(),
BaseImageBundle.images.refresh_16(), BaseImageBundle.images.refresh_disabled_16());
reloadImageButton.setSTYLE("commentToolBarButton");
reloadImageButton.setTitle("Refresh comments");
reloadImageButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
BaseServiceCache.getService().getPageInfo(permissibleObject, Comment.class.getName(), pageSize, new AsyncCallback<PageInfo>() {
public void onFailure(Throwable caught) {
};
public void onSuccess(PageInfo pageInfo) {
numComments = pageInfo.getTotalRowCount();
lastPageNumber = pageInfo.getLastPageNumber();
pageCache.clear();
fetchPage();
};
});
}
});
final IconButton sortImageButton = new IconButton("Sort " + (sortDescending ? "Ascending" : "Descending"), true, BaseImageBundle.images.sort(),
BaseImageBundle.images.sort(), BaseImageBundle.images.sort(), BaseImageBundle.images.sort());
sortImageButton.setSTYLE("commentToolBarButton");
sortImageButton.setTitle(sortDescending ? "Show oldest comments first" : "Show most recent comments first");
sortImageButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
sortDescending = !sortDescending;
// this could be optimized if we have all the pages, then we have all the data
// we could do it all on the client
pageCache.clear();
fetchPage();
}
});
IconButton flattenImageButton = null;
if (flatten) {
flattenImageButton = new IconButton("Hierarchy", true, BaseImageBundle.images.hierarchy(), BaseImageBundle.images.hierarchy(),
BaseImageBundle.images.hierarchy(), BaseImageBundle.images.hierarchy());
flattenImageButton.setTitle("Build a comment hierarchy");
} else {
flattenImageButton = new IconButton("Flatten", true, BaseImageBundle.images.flatten(), BaseImageBundle.images.flatten(),
BaseImageBundle.images.flatten(), BaseImageBundle.images.flatten());
flattenImageButton.setTitle("Flatten the comment hierarchy");
}
flattenImageButton.setSTYLE("commentToolBarButton");
flattenImageButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
flatten = !flatten;
loadCommentWidget(forceOpen);
}
});