use of org.apache.wicket.PageParameters in project gitblit by gitblit.
the class TicketsPage method milestoneList.
protected DataView<TicketMilestone> milestoneList(String wicketId, List<TicketMilestone> milestones, final boolean acceptingUpdates) {
ListDataProvider<TicketMilestone> milestonesDp = new ListDataProvider<TicketMilestone>(milestones);
DataView<TicketMilestone> milestonesList = new DataView<TicketMilestone>(wicketId, milestonesDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<TicketMilestone> item) {
Fragment entryPanel = new Fragment("entryPanel", "milestoneListFragment", this);
item.add(entryPanel);
final TicketMilestone tm = item.getModelObject();
String[] states;
if (tm.isOpen()) {
states = TicketsUI.openStatii;
} else {
states = TicketsUI.closedStatii;
}
PageParameters params = queryParameters(null, tm.name, states, null, null, true, 1);
entryPanel.add(new LinkPanel("milestoneName", null, tm.name, TicketsPage.class, params).setRenderBodyOnly(true));
String css;
String status = tm.status.name();
switch(tm.status) {
case Open:
if (tm.isOverdue()) {
css = "aui-lozenge aui-lozenge-subtle aui-lozenge-error";
status = "overdue";
} else {
css = "aui-lozenge aui-lozenge-subtle";
}
break;
default:
css = "aui-lozenge";
break;
}
Label stateLabel = new Label("milestoneState", status);
WicketUtils.setCssClass(stateLabel, css);
entryPanel.add(stateLabel);
if (tm.due == null) {
entryPanel.add(new Label("milestoneDue", getString("gb.notSpecified")));
} else {
entryPanel.add(WicketUtils.createDatestampLabel("milestoneDue", tm.due, getTimeZone(), getTimeUtils()));
}
if (acceptingUpdates) {
entryPanel.add(new LinkPanel("editMilestone", null, getString("gb.edit"), EditMilestonePage.class, WicketUtils.newObjectParameter(repositoryName, tm.name)));
} else {
entryPanel.add(new Label("editMilestone").setVisible(false));
}
if (tm.isOpen()) {
// re-load milestone with query results
TicketMilestone m = app().tickets().getMilestone(getRepositoryModel(), tm.name);
Fragment milestonePanel = new Fragment("milestonePanel", "openMilestoneFragment", this);
Label label = new Label("progress");
WicketUtils.setCssStyle(label, "width:" + m.getProgress() + "%;");
milestonePanel.add(label);
milestonePanel.add(new LinkPanel("openTickets", null, MessageFormat.format(getString("gb.nOpenTickets"), m.getOpenTickets()), TicketsPage.class, queryParameters(null, tm.name, TicketsUI.openStatii, null, null, true, 1)));
milestonePanel.add(new LinkPanel("closedTickets", null, MessageFormat.format(getString("gb.nClosedTickets"), m.getClosedTickets()), TicketsPage.class, queryParameters(null, tm.name, TicketsUI.closedStatii, null, null, true, 1)));
milestonePanel.add(new Label("totalTickets", MessageFormat.format(getString("gb.nTotalTickets"), m.getTotalTickets())));
entryPanel.add(milestonePanel);
} else {
entryPanel.add(new Label("milestonePanel").setVisible(false));
}
}
};
return milestonesList;
}
use of org.apache.wicket.PageParameters in project gitblit by gitblit.
the class BranchesPanel method createDeleteBranchLink.
private Link<Void> createDeleteBranchLink(final RepositoryModel repositoryModel, final RefModel entry) {
Link<Void> deleteLink = new Link<Void>("deleteBranch") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
Repository r = app().repositories().getRepository(repositoryModel.name);
if (r == null) {
if (app().repositories().isCollectingGarbage(repositoryModel.name)) {
error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name));
} else {
error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name));
}
return;
}
final String branch = entry.getName();
Ref ref = null;
try {
ref = r.getRef(branch);
if (ref == null && !branch.startsWith(Constants.R_HEADS)) {
ref = r.getRef(Constants.R_HEADS + branch);
}
} catch (IOException e) {
}
if (ref != null) {
boolean success = JGitUtils.deleteBranchRef(r, ref.getName());
if (success) {
// clear commit cache
CommitCache.instance().clear(repositoryModel.name, branch);
// optionally update reflog
if (RefLogUtils.hasRefLogBranch(r)) {
UserModel user = GitBlitWebSession.get().getUser();
RefLogUtils.deleteRef(user, r, ref);
}
}
if (success) {
info(MessageFormat.format("Branch \"{0}\" deleted", branch));
} else {
error(MessageFormat.format("Failed to delete branch \"{0}\"", branch));
}
}
r.close();
// redirect to the owning page
PageParameters params = WicketUtils.newRepositoryParameter(repositoryModel.name);
String relativeUrl = urlFor(getPage().getClass(), params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format("Delete branch \"{0}\"?", entry.displayName)));
return deleteLink;
}
use of org.apache.wicket.PageParameters in project gitblit by gitblit.
the class DashboardPage method addDropDownMenus.
@Override
protected void addDropDownMenus(List<NavLink> navLinks) {
PageParameters params = getPageParameters();
DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", GitBlitWebApp.get().getHomePage());
// preserve repository filter option on time choices
menu.menuItems.addAll(getTimeFilterItems(params));
if (menu.menuItems.size() > 0) {
// Reset Filter
menu.menuItems.add(new ParameterMenuItem(getString("gb.reset")));
}
navLinks.add(menu);
}
use of org.apache.wicket.PageParameters in project gitblit by gitblit.
the class RootPage method getTimeFilterItems.
protected List<MenuItem> getTimeFilterItems(PageParameters params) {
// days back choices - additive parameters
int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
if (daysBack < 1) {
daysBack = 7;
}
if (daysBack > maxDaysBack) {
daysBack = maxDaysBack;
}
PageParameters clonedParams;
if (params == null) {
clonedParams = new PageParameters();
} else {
clonedParams = new PageParameters(params);
}
if (!clonedParams.containsKey("db")) {
clonedParams.put("db", daysBack);
}
List<MenuItem> items = new ArrayList<MenuItem>();
Set<Integer> choicesSet = new TreeSet<Integer>(app().settings().getIntegers(Keys.web.activityDurationChoices));
if (choicesSet.isEmpty()) {
choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));
}
List<Integer> choices = new ArrayList<Integer>(choicesSet);
Collections.sort(choices);
String lastDaysPattern = getString("gb.lastNDays");
for (Integer db : choices) {
if (db == 1) {
items.add(new ParameterMenuItem(getString("gb.time.today"), "db", db.toString(), clonedParams));
} else {
String txt = MessageFormat.format(lastDaysPattern, db);
items.add(new ParameterMenuItem(txt, "db", db.toString(), clonedParams));
}
}
items.add(new MenuDivider());
return items;
}
use of org.apache.wicket.PageParameters in project gitblit by gitblit.
the class RootPage method loginUser.
private void loginUser(UserModel user) {
if (user != null) {
HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest();
HttpServletResponse response = ((WebResponse) getResponse()).getHttpServletResponse();
// Set the user into the session
GitBlitWebSession session = GitBlitWebSession.get();
// issue 62: fix session fixation vulnerability
session.replaceSession();
session.setUser(user);
request = ((WebRequest) getRequest()).getHttpServletRequest();
response = ((WebResponse) getResponse()).getHttpServletResponse();
request.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CREDENTIALS);
// Set Cookie
app().authentication().setCookie(request, response, user);
if (!session.continueRequest()) {
PageParameters params = getPageParameters();
if (params == null) {
// redirect to this page
redirectTo(getClass());
} else {
// Strip username and password and redirect to this page
params.remove("username");
params.remove("password");
redirectTo(getClass(), params);
}
}
}
}
Aggregations