use of org.apache.wicket.markup.html.link.BookmarkablePageLink in project wicket-dashboard by decebals.
the class DetachWidgetAction method getLink.
@Override
public AbstractLink getLink(String id) {
PageParameters parameters = new PageParameters();
parameters.add("id", widget.getId());
BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>(id, WidgetPage.class, parameters);
PopupSettings popupSettings = new PopupSettings(widget.getTitle()).setHeight(320).setWidth(550);
link.setPopupSettings(popupSettings);
return link;
}
use of org.apache.wicket.markup.html.link.BookmarkablePageLink in project gitblit by gitblit.
the class TicketPage method createPatchsetPanel.
protected Fragment createPatchsetPanel(String wicketId, RepositoryModel repository, UserModel user) {
final Patchset currentPatchset = ticket.getCurrentPatchset();
List<Patchset> patchsets = new ArrayList<Patchset>(ticket.getPatchsetRevisions(currentPatchset.number));
patchsets.remove(currentPatchset);
Collections.reverse(patchsets);
Fragment panel = new Fragment(wicketId, "collapsiblePatchsetFragment", this);
// patchset header
String ps = "<b>" + currentPatchset.number + "</b>";
if (currentPatchset.rev == 1) {
panel.add(new Label("uploadedWhat", MessageFormat.format(getString("gb.uploadedPatchsetN"), ps)).setEscapeModelStrings(false));
} else {
String rev = "<b>" + currentPatchset.rev + "</b>";
panel.add(new Label("uploadedWhat", MessageFormat.format(getString("gb.uploadedPatchsetNRevisionN"), ps, rev)).setEscapeModelStrings(false));
}
panel.add(new LinkPanel("patchId", null, "rev " + currentPatchset.rev, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, currentPatchset.tip), true));
// compare menu
panel.add(new LinkPanel("compareMergeBase", null, getString("gb.compareToMergeBase"), ComparePage.class, WicketUtils.newRangeParameter(repositoryName, currentPatchset.base, currentPatchset.tip), true));
ListDataProvider<Patchset> compareMenuDp = new ListDataProvider<Patchset>(patchsets);
DataView<Patchset> compareMenu = new DataView<Patchset>("comparePatch", compareMenuDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<Patchset> item) {
Patchset patchset = item.getModelObject();
LinkPanel link = new LinkPanel("compareLink", null, MessageFormat.format(getString("gb.compareToN"), patchset.number + "-" + patchset.rev), ComparePage.class, WicketUtils.newRangeParameter(getRepositoryModel().name, patchset.tip, currentPatchset.tip), true);
item.add(link);
}
};
panel.add(compareMenu);
// reviews
List<Change> reviews = ticket.getReviews(currentPatchset);
ListDataProvider<Change> reviewsDp = new ListDataProvider<Change>(reviews);
DataView<Change> reviewsView = new DataView<Change>("reviews", reviewsDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<Change> item) {
Change change = item.getModelObject();
final String username = change.author;
UserModel user = app().users().getUserModel(username);
if (user == null) {
item.add(new Label("reviewer", username));
} else {
item.add(new LinkPanel("reviewer", null, user.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(username)));
}
// indicate review score
Review review = change.review;
Label scoreLabel = new Label("score");
String scoreClass = getScoreClass(review.score);
String tooltip = getScoreDescription(review.score);
WicketUtils.setCssClass(scoreLabel, scoreClass);
if (!StringUtils.isEmpty(tooltip)) {
WicketUtils.setHtmlTooltip(scoreLabel, tooltip);
}
item.add(scoreLabel);
}
};
panel.add(reviewsView);
if (ticket.isOpen() && user.canReviewPatchset(repository) && app().tickets().isAcceptingTicketUpdates(repository)) {
// can only review open tickets
Review myReview = null;
for (Change change : ticket.getReviews(currentPatchset)) {
if (change.author.equals(user.username)) {
myReview = change.review;
}
}
// user can review, add review controls
Fragment reviewControls = new Fragment("reviewControls", "reviewControlsFragment", this);
// show "approve" button if no review OR not current score
if (user.canApprovePatchset(repository) && (myReview == null || Score.approved != myReview.score)) {
reviewControls.add(createReviewLink("approveLink", Score.approved));
} else {
reviewControls.add(new Label("approveLink").setVisible(false));
}
// show "looks good" button if no review OR not current score
if (myReview == null || Score.looks_good != myReview.score) {
reviewControls.add(createReviewLink("looksGoodLink", Score.looks_good));
} else {
reviewControls.add(new Label("looksGoodLink").setVisible(false));
}
// show "needs improvement" button if no review OR not current score
if (myReview == null || Score.needs_improvement != myReview.score) {
reviewControls.add(createReviewLink("needsImprovementLink", Score.needs_improvement));
} else {
reviewControls.add(new Label("needsImprovementLink").setVisible(false));
}
// show "veto" button if no review OR not current score
if (user.canVetoPatchset(repository) && (myReview == null || Score.vetoed != myReview.score)) {
reviewControls.add(createReviewLink("vetoLink", Score.vetoed));
} else {
reviewControls.add(new Label("vetoLink").setVisible(false));
}
panel.add(reviewControls);
} else {
// user can not review
panel.add(new Label("reviewControls").setVisible(false));
}
String insertions = MessageFormat.format("<span style=\"color:darkGreen;font-weight:bold;\">+{0}</span>", ticket.insertions);
String deletions = MessageFormat.format("<span style=\"color:darkRed;font-weight:bold;\">-{0}</span>", ticket.deletions);
panel.add(new Label("patchsetStat", MessageFormat.format(StringUtils.escapeForHtml(getString("gb.diffStat"), false), insertions, deletions)).setEscapeModelStrings(false));
// changed paths list
List<PathChangeModel> paths = JGitUtils.getFilesInRange(getRepository(), currentPatchset.base, currentPatchset.tip);
ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(paths);
DataView<PathChangeModel> pathsView = new DataView<PathChangeModel>("changedPath", pathsDp) {
private static final long serialVersionUID = 1L;
int counter;
@Override
public void populateItem(final Item<PathChangeModel> item) {
final PathChangeModel entry = item.getModelObject();
Label changeType = new Label("changeType", "");
WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
setChangeTypeTooltip(changeType, entry.changeType);
item.add(changeType);
boolean hasSubmodule = false;
String submodulePath = null;
if (entry.isTree()) {
// tree
item.add(new LinkPanel("pathName", null, entry.path, TreePage.class, WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, entry.path), true));
item.add(new Label("diffStat").setVisible(false));
} else if (entry.isSubmodule()) {
// submodule
String submoduleId = entry.objectId;
SubmoduleModel submodule = getSubmodule(entry.path);
submodulePath = submodule.gitblitPath;
hasSubmodule = submodule.hasSubmodule;
item.add(new LinkPanel("pathName", "list", entry.path + " @ " + getShortObjectId(submoduleId), TreePage.class, WicketUtils.newPathParameter(submodulePath, submoduleId, ""), true).setEnabled(hasSubmodule));
item.add(new Label("diffStat").setVisible(false));
} else {
// blob
String displayPath = entry.path;
String path = entry.path;
if (entry.isSymlink()) {
RevCommit commit = JGitUtils.getCommit(getRepository(), PatchsetCommand.getTicketBranch(ticket.number));
path = JGitUtils.getStringContent(getRepository(), commit.getTree(), path);
displayPath = entry.path + " -> " + path;
}
if (entry.changeType.equals(ChangeType.ADD)) {
// add show view
item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class, WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, path), true));
} else if (entry.changeType.equals(ChangeType.DELETE)) {
// delete, show label
item.add(new Label("pathName", displayPath));
} else {
// mod, show diff
item.add(new LinkPanel("pathName", "list", displayPath, BlobDiffPage.class, WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, path), true));
}
item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));
}
// quick links
if (entry.isSubmodule()) {
// submodule
item.add(setNewTarget(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path))).setEnabled(!entry.changeType.equals(ChangeType.ADD)));
item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils.newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule));
} else {
// tree or blob
item.add(setNewTarget(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils.newBlobDiffParameter(repositoryName, currentPatchset.base, currentPatchset.tip, entry.path))).setEnabled(!entry.changeType.equals(ChangeType.ADD) && !entry.changeType.equals(ChangeType.DELETE)));
item.add(setNewTarget(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, currentPatchset.tip, entry.path))).setEnabled(!entry.changeType.equals(ChangeType.DELETE)));
}
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
};
panel.add(pathsView);
addPtCheckoutInstructions(user, repository, panel);
addGitCheckoutInstructions(user, repository, panel);
return panel;
}
Aggregations