James Moger
2011-12-19 4bd2037edddbf444ac9817e9d14710be45850a10
src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -33,6 +33,8 @@
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.util.CollectionModel;
import org.apache.wicket.model.util.ListModel;
@@ -52,6 +54,8 @@
   private final boolean isCreate;
   private boolean isAdmin;
   private IModel<String> mailRecipients;
   public EditRepositoryPage() {
      // create constructor
@@ -76,6 +80,9 @@
      List<String> federationSets = new ArrayList<String>();
      List<String> repositoryUsers = new ArrayList<String>();
      List<String> repositoryTeams = new ArrayList<String>();
      List<String> preReceiveScripts = new ArrayList<String>();
      List<String> postReceiveScripts = new ArrayList<String>();
      if (isCreate) {
         super.setupPage(getString("gb.newRepository"), "");
      } else {
@@ -86,8 +93,7 @@
            Collections.sort(repositoryUsers);
         }
         federationSets.addAll(repositoryModel.federationSets);
      }
      }
      final String oldName = repositoryModel.name;
      // users palette
@@ -98,13 +104,29 @@
      // teams palette
      final Palette<String> teamsPalette = new Palette<String>("teams", new ListModel<String>(
            repositoryTeams), new CollectionModel<String>(GitBlit.self().getAllTeamnames()),
            new ChoiceRenderer<String>("", ""), 10, false);
            new ChoiceRenderer<String>("", ""), 5, false);
      // federation sets palette
      List<String> sets = GitBlit.getStrings(Keys.federation.sets);
      final Palette<String> federationSetsPalette = new Palette<String>("federationSets",
            new ListModel<String>(federationSets), new CollectionModel<String>(sets),
            new ChoiceRenderer<String>("", ""), 10, false);
            new ChoiceRenderer<String>("", ""), 5, false);
      // pre-receive palette
      if (repositoryModel.preReceiveScripts != null) {
         preReceiveScripts.addAll(repositoryModel.preReceiveScripts);
      }
      final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
            new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
                  .self().getAvailableScripts()), new ChoiceRenderer<String>("", ""), 12, true);
      // post-receive palette
      if (repositoryModel.postReceiveScripts != null) {
         postReceiveScripts.addAll(repositoryModel.postReceiveScripts);
      }
      final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
            new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
                  .self().getAvailableScripts()), new ChoiceRenderer<String>("", ""), 12, true);
      CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(
            repositoryModel);
@@ -169,6 +191,29 @@
                  }
               }
               // set mail recipients
               String ml = mailRecipients.getObject();
               if (!StringUtils.isEmpty(ml)) {
                  List<String> list = StringUtils.getStringsFromValue(ml.trim(), " ");
                  repositoryModel.mailRecipients = list;
               }
               // pre-receive scripts
               List<String> preReceiveScripts = new ArrayList<String>();
               Iterator<String> pres = preReceivePalette.getSelectedChoices();
               while (pres.hasNext()) {
                  preReceiveScripts.add(pres.next());
               }
               repositoryModel.preReceiveScripts = preReceiveScripts;
               // post-receive scripts
               List<String> postReceiveScripts = new ArrayList<String>();
               Iterator<String> post = postReceivePalette.getSelectedChoices();
               while (post.hasNext()) {
                  postReceiveScripts.add(post.next());
               }
               repositoryModel.postReceiveScripts = postReceiveScripts;
               // save the repository
               GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);
@@ -186,7 +231,7 @@
                     repositoryUsers.add(repositoryModel.owner);
                  }
                  GitBlit.self().setRepositoryUsers(repositoryModel, repositoryUsers);
                  // save the team access list
                  Iterator<String> teams = teamsPalette.getSelectedChoices();
                  List<String> repositoryTeams = new ArrayList<String>();
@@ -230,9 +275,14 @@
      form.add(new CheckBox("showReadme"));
      form.add(new CheckBox("skipSizeCalculation"));
      form.add(new CheckBox("skipSummaryMetrics"));
      mailRecipients = new Model<String>(repositoryModel.mailRecipients == null ? ""
            : StringUtils.flattenStrings(repositoryModel.mailRecipients, " "));
      form.add(new TextField<String>("mailRecipients", mailRecipients));
      form.add(usersPalette);
      form.add(teamsPalette);
      form.add(federationSetsPalette);
      form.add(preReceivePalette);
      form.add(postReceivePalette);
      form.add(new Button("save"));
      Button cancel = new Button("cancel") {