use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class UserPage method addPreferences.
private void addPreferences(UserModel user) {
// add preferences
Form<Void> prefs = new Form<Void>("prefsForm");
Locale locale = user.getPreferences().getLocale();
if (locale == null) {
// user has not specified language preference
// try server default preference
String lc = app().settings().getString(Keys.web.forceDefaultLocale, null);
if (StringUtils.isEmpty(lc)) {
// server default language is not configured
// try browser preference
Locale sessionLocale = GitBlitWebSession.get().getLocale();
if (sessionLocale != null) {
locale = sessionLocale;
}
}
}
List<Language> languages = getLanguages();
Language preferredLanguage = getPreferredLanguage(locale, languages);
final IModel<String> displayName = Model.of(user.getDisplayName());
final IModel<String> emailAddress = Model.of(user.emailAddress == null ? "" : user.emailAddress);
final IModel<Language> language = Model.of(preferredLanguage);
final IModel<Boolean> emailMeOnMyTicketChanges = Model.of(user.getPreferences().isEmailMeOnMyTicketChanges());
final IModel<Transport> transport = Model.of(user.getPreferences().getTransport());
prefs.add(new TextOption("displayName", getString("gb.displayName"), getString("gb.displayNameDescription"), displayName).setVisible(app().authentication().supportsDisplayNameChanges(user)));
prefs.add(new TextOption("emailAddress", getString("gb.emailAddress"), getString("gb.emailAddressDescription"), emailAddress).setVisible(app().authentication().supportsEmailAddressChanges(user)));
prefs.add(new ChoiceOption<Language>("language", getString("gb.languagePreference"), getString("gb.languagePreferenceDescription"), language, languages));
prefs.add(new BooleanOption("emailMeOnMyTicketChanges", getString("gb.emailMeOnMyTicketChanges"), getString("gb.emailMeOnMyTicketChangesDescription"), emailMeOnMyTicketChanges).setVisible(app().notifier().isSendingMail()));
List<Transport> availableTransports = new ArrayList<>();
if (app().services().isServingSSH()) {
availableTransports.add(Transport.SSH);
}
if (app().services().isServingHTTP()) {
availableTransports.add(Transport.HTTP);
}
if (app().services().isServingHTTPS()) {
availableTransports.add(Transport.HTTPS);
}
if (app().services().isServingGIT()) {
availableTransports.add(Transport.GIT);
}
prefs.add(new ChoiceOption<Transport>("transport", getString("gb.transportPreference"), getString("gb.transportPreferenceDescription"), transport, availableTransports));
prefs.add(new AjaxButton("save") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
UserModel user = GitBlitWebSession.get().getUser();
user.displayName = displayName.getObject();
user.emailAddress = emailAddress.getObject();
Language lang = language.getObject();
if (lang != null) {
user.getPreferences().setLocale(lang.code);
}
user.getPreferences().setEmailMeOnMyTicketChanges(emailMeOnMyTicketChanges.getObject());
user.getPreferences().setTransport(transport.getObject());
try {
app().gitblit().reviseUser(user.username, user);
setRedirect(true);
setResponsePage(UserPage.class, WicketUtils.newUsernameParameter(user.username));
} catch (GitBlitException e) {
// logger.error("Failed to update user " + user.username, e);
// error(getString("gb.failedToUpdateUser"), false);
}
}
});
// add the preferences tab
add(new Fragment("preferencesLink", "preferencesLinkFragment", this).setRenderBodyOnly(true));
Fragment fragment = new Fragment("preferencesTab", "preferencesTabFragment", this);
fragment.add(prefs);
add(fragment.setRenderBodyOnly(true));
}
use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class UserPage method addSshKeys.
private void addSshKeys(final UserModel user) {
Fragment keysTab = new Fragment("sshKeysTab", "sshKeysTabFragment", this);
keysTab.add(new SshKeysPanel("sshKeysPanel", user));
// add the SSH keys tab
add(new Fragment("sshKeysLink", "sshKeysLinkFragment", this).setRenderBodyOnly(true));
add(keysTab.setRenderBodyOnly(true));
}
use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class TicketPage method getMergeInstructions.
protected Component getMergeInstructions(UserModel user, RepositoryModel repository, String markupId, String infoKey) {
Fragment cmd = new Fragment(markupId, "commandlineMergeFragment", this);
cmd.add(new Label("instructions", MessageFormat.format(getString(infoKey), ticket.mergeTo)));
// git instructions
cmd.add(new Label("mergeStep1", MessageFormat.format(getString("gb.stepN"), 1)));
cmd.add(new Label("mergeStep2", MessageFormat.format(getString("gb.stepN"), 2)));
cmd.add(new Label("mergeStep3", MessageFormat.format(getString("gb.stepN"), 3)));
String ticketBranch = Repository.shortenRefName(PatchsetCommand.getTicketBranch(ticket.number));
String reviewBranch = PatchsetCommand.getReviewBranch(ticket.number);
String step1 = MessageFormat.format("git checkout -b {0} {1}", reviewBranch, ticket.mergeTo);
String step2 = MessageFormat.format("git pull origin {0}", ticketBranch);
String step3 = MessageFormat.format("git checkout {0}\ngit merge {1}\ngit push origin {0}\ngit branch -d {1}", ticket.mergeTo, reviewBranch);
cmd.add(new Label("mergePreStep1", step1));
cmd.add(new Label("mergePreStep2", step2));
cmd.add(new Label("mergePreStep3", step3));
cmd.add(createCopyFragment("mergeCopyStep1", step1.replace("\n", " && ")));
cmd.add(createCopyFragment("mergeCopyStep2", step2.replace("\n", " && ")));
cmd.add(createCopyFragment("mergeCopyStep3", step3.replace("\n", " && ")));
// pt instructions
String ptStep = MessageFormat.format("pt pull {0,number,0}", ticket.number);
cmd.add(new Label("ptMergeStep", ptStep));
cmd.add(createCopyFragment("ptMergeCopyStep", step1.replace("\n", " && ")));
return cmd;
}
use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class RepositoryPage method createPersonPanel.
protected Component createPersonPanel(String wicketId, PersonIdent identity, Constants.SearchType searchType) {
String name = identity == null ? "" : identity.getName();
String address = identity == null ? "" : identity.getEmailAddress();
name = StringUtils.removeNewlines(name);
address = StringUtils.removeNewlines(address);
boolean showEmail = app().settings().getBoolean(Keys.web.showEmailAddresses, false);
if (!showEmail || StringUtils.isEmpty(name) || StringUtils.isEmpty(address)) {
String value = name;
if (StringUtils.isEmpty(value)) {
if (showEmail) {
value = address;
} else {
value = getString("gb.missingUsername");
}
}
Fragment partial = new Fragment(wicketId, "partialPersonIdent", this);
LinkPanel link = new LinkPanel("personName", "list", value, GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType));
setPersonSearchTooltip(link, value, searchType);
partial.add(link);
return partial;
} else {
Fragment fullPerson = new Fragment(wicketId, "fullPersonIdent", this);
LinkPanel nameLink = new LinkPanel("personName", "list", name, GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, name, searchType));
setPersonSearchTooltip(nameLink, name, searchType);
fullPerson.add(nameLink);
LinkPanel addressLink = new LinkPanel("personAddress", "hidden-phone list", "<" + address + ">", GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, address, searchType));
setPersonSearchTooltip(addressLink, address, searchType);
fullPerson.add(addressLink);
return fullPerson;
}
}
use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.
the class RepositoryPage method addToolbarButton.
protected void addToolbarButton(String wicketId, String iconClass, String label, String url) {
Fragment button = new Fragment(wicketId, "toolbarLinkFragment", this);
Label icon = new Label("icon");
WicketUtils.setCssClass(icon, iconClass);
button.add(icon);
button.add(new Label("label", label));
button.add(new SimpleAttributeModifier("href", url));
add(button);
}
Aggregations