Object[] diffOutput = PasteItem.diffPastes(parentPaste.getContent(), pasteModel.getObject().getContent());
List<Integer> changedLines = (List<Integer>) diffOutput[0]; // TODO horrible horrible hackish thing, where do you get these things
String diffText = (String) diffOutput[1];
diffView.add(new HighlighterPanel("highlightedContent",
new Model<String>(diffText),
parentPaste.getType(),
false,
highlightLines,
changedLines));
}
add(diffView);
final List<PasteItem> pasteChildren = pasteService.hasChildren(pasteModel.getObject());
// final List<PasteItem> pasteChildren = new ArrayList<PasteItem>();
WebMarkupContainer hasChildPastes = new WebMarkupContainer("hasChildPastes") {
@Override
public boolean isVisible() {
return pasteChildren != null && pasteChildren.size() > 0;
}
};
add(hasChildPastes);
hasChildPastes.add(new ListView<PasteItem>("childPastes", pasteChildren) {
@Override
protected void populateItem(ListItem<PasteItem> item) {
PasteItem pasteItem = item.getModelObject();
PageParameters pp = new PageParameters();
pp.add("0", pasteItem.getItemId());
BookmarkablePageLink<Void> viewPaste = new BookmarkablePageLink<Void>("viewChildPaste", (pasteItem.isPrivate() ? ViewPrivatePage.class : ViewPublicPage.class), pp);
viewPaste.add(new Label("pasteId", new PropertyModel<String>(item.getModel(), "itemId")));
item.add(viewPaste);
item.add(new Label("posted", PasteItem.getElapsedTimeSincePost(pasteItem)));
}
});
String language = pasteModel.getObject().getType();
add(new HighlighterPanel("highlightedContent",
new PropertyModel<String>(pasteModel, "content"),
language, false,
highlightLines));
add(createRawLink("rawLink", params));