public FederationTokensPanel(String wicketId, final boolean showFederation) {
super(wicketId);
final String baseUrl = WicketUtils.getGitblitURL(getRequest());
add(new ExternalLink("federatedUsers", FederationUtils.asLink(baseUrl, app().federation()
.getFederationToken(FederationToken.USERS_AND_REPOSITORIES),
FederationRequest.PULL_USERS)));
add(new ExternalLink("federatedSettings", FederationUtils.asLink(baseUrl, app().federation()
.getFederationToken(FederationToken.ALL), FederationRequest.PULL_SETTINGS)));
final List<String[]> data = new ArrayList<String[]>();
for (FederationToken token : FederationToken.values()) {
data.add(new String[] { token.name(), app().federation().getFederationToken(token), null });
}
List<String> sets = app().settings().getStrings(Keys.federation.sets);
Collections.sort(sets);
for (String set : sets) {
data.add(new String[] { FederationToken.REPOSITORIES.name(),
app().federation().getFederationToken(set), set });
}
DataView<String[]> dataView = new DataView<String[]>("row", new ListDataProvider<String[]>(
data)) {
private static final long serialVersionUID = 1L;
private int counter;
@Override
protected void onBeforeRender() {
super.onBeforeRender();
counter = 0;
}
@Override
public void populateItem(final Item<String[]> item) {
final String[] entry = item.getModelObject();
final FederationToken token = FederationToken.fromName(entry[0]);
if (entry[2] == null) {
// standard federation token
item.add(new Label("description", describeToken(token)));
} else {
// federation set token
item.add(new Label("description", entry[2]));
}
item.add(new Label("value", entry[1]));
item.add(new ExternalLink("repositoryDefinitions", FederationUtils.asLink(
baseUrl, entry[1], FederationRequest.PULL_REPOSITORIES)));
item.add(new BookmarkablePageLink<Void>("send",
SendProposalPage.class, WicketUtils.newTokenParameter(entry[1])));