Search in sources :

Example 16 with Fragment

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));
}
Also used : Locale(java.util.Locale) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) TextOption(com.gitblit.wicket.panels.TextOption) GitBlitException(com.gitblit.GitBlitException) Fragment(org.apache.wicket.markup.html.panel.Fragment) UserModel(com.gitblit.models.UserModel) AjaxButton(org.apache.wicket.ajax.markup.html.form.AjaxButton) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Transport(com.gitblit.Constants.Transport) BooleanOption(com.gitblit.wicket.panels.BooleanOption)

Example 17 with Fragment

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));
}
Also used : SshKeysPanel(com.gitblit.wicket.panels.SshKeysPanel) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 18 with Fragment

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;
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) TicketLabel(com.gitblit.tickets.TicketLabel) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 19 with Fragment

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;
    }
}
Also used : Fragment(org.apache.wicket.markup.html.panel.Fragment) LinkPanel(com.gitblit.wicket.panels.LinkPanel)

Example 20 with Fragment

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);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) SimpleAttributeModifier(org.apache.wicket.behavior.SimpleAttributeModifier) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Aggregations

Fragment (org.apache.wicket.markup.html.panel.Fragment)51 Label (org.apache.wicket.markup.html.basic.Label)20 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 ArrayList (java.util.ArrayList)9 LinkPanel (com.gitblit.wicket.panels.LinkPanel)6 Component (org.apache.wicket.Component)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 RepositoryModel (com.gitblit.models.RepositoryModel)5 UserModel (com.gitblit.models.UserModel)5 Item (org.apache.wicket.markup.repeater.Item)5 DataView (org.apache.wicket.markup.repeater.data.DataView)5 ListDataProvider (org.apache.wicket.markup.repeater.data.ListDataProvider)5 ResourceModel (org.apache.wicket.model.ResourceModel)4 TicketLabel (com.gitblit.tickets.TicketLabel)3 List (java.util.List)3 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)3 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)3 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)3 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2