return pasteModel.getObject().getParent() != null;
}
};
if (pasteModel.getObject().getParent() != null) {
PasteItem parentPaste = pasteService.getItem(pasteModel.getObject().getParent());
PageParameters pp = new PageParameters();
pp.add("0", parentPaste.getItemId());
diffView.add(new BookmarkablePageLink<Void>("originalPasteLink", (parentPaste.isPrivate() ? ViewPrivatePage.class : ViewPublicPage.class), pp));
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));
add(createDownloadLink("downloadLink", params));
PageParameters repasteParams = new PageParameters();
repasteParams.add("0", pasteModel.getObject().getItemId());
add(new BookmarkablePageLink<Void>("repasteLink", ReplyPastePage.class, repasteParams));
final Label markAbuseLabel = new Label("markAbuseLabel", "Report Abuse");
markAbuseLabel.setOutputMarkupId(true);
StatelessLink markAbuseLink = new StatelessLink("markAbuseLink") {
public void onClick() {
PasteItem pasteItem = pasteModel.getObject();
pasteService.increaseAbuseCount(pasteItem);
markAbuseLabel.setDefaultModel(new Model<String>("Marked As Spam"));
markAbuseLabel.add(new AttributeModifier("style", "color: red; font-weight: bold;"));