James Moger
2012-01-05 cb285cbfddfc0b633d6b8cdb4dc0d2bd2b8b51ef
src/com/gitblit/client/EditTeamDialog.java
@@ -65,9 +65,19 @@
   private JTextField teamnameField;
   private JTextField mailingListsField;
   private JPalette<String> repositoryPalette;
   private JPalette<String> userPalette;
   private JPalette<String> preReceivePalette;
   private JLabel preReceiveInherited;
   private JPalette<String> postReceivePalette;
   private JLabel postReceiveInherited;
   private Set<String> teamnames;
@@ -105,16 +115,20 @@
   private void initialize(int protocolVersion, TeamModel aTeam) {
      teamnameField = new JTextField(aTeam.name == null ? "" : aTeam.name, 25);
      mailingListsField = new JTextField(aTeam.mailingLists == null ? ""
            : StringUtils.flattenStrings(aTeam.mailingLists, " "), 50);
      JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
      fieldsPanel.add(newFieldPanel(Translation.get("gb.teamName"), teamnameField));
      fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField));
      final Insets _insets = new Insets(5, 5, 5, 5);
      repositoryPalette = new JPalette<String>();
      userPalette = new JPalette<String>();
      JPanel fieldsPanelTop = new JPanel(new BorderLayout());
      fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
      JPanel repositoriesPanel = new JPanel(new BorderLayout()) {
         private static final long serialVersionUID = 1L;
@@ -135,11 +149,24 @@
      };
      usersPanel.add(userPalette, BorderLayout.CENTER);
      preReceivePalette = new JPalette<String>(true);
      preReceiveInherited = new JLabel();
      JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
      preReceivePanel.add(preReceivePalette, BorderLayout.CENTER);
      preReceivePanel.add(preReceiveInherited, BorderLayout.WEST);
      postReceivePalette = new JPalette<String>(true);
      postReceiveInherited = new JLabel();
      JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
      postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
      postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
      JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
      panel.addTab(Translation.get("gb.general"), fieldsPanelTop);
      panel.addTab(Translation.get("gb.teamMembers"), usersPanel);
      panel.addTab(Translation.get("gb.restrictedRepositories"), repositoriesPanel);
      panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
      panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
      JButton createButton = new JButton(Translation.get("gb.save"));
      createButton.addActionListener(new ActionListener() {
@@ -162,7 +189,7 @@
      JPanel controls = new JPanel();
      controls.add(cancelButton);
      controls.add(createButton);
      JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {
         private static final long serialVersionUID = 1L;
@@ -218,11 +245,31 @@
      }
      team.name = tname;
      String ml = mailingListsField.getText();
      if (!StringUtils.isEmpty(ml)) {
         Set<String> list = new HashSet<String>();
         for (String address : ml.split("(,|\\s)")) {
            if (StringUtils.isEmpty(address)) {
               continue;
            }
            list.add(address.toLowerCase());
         }
         team.mailingLists.clear();
         team.mailingLists.addAll(list);
      }
      team.repositories.clear();
      team.repositories.addAll(repositoryPalette.getSelections());
      team.users.clear();
      team.users.addAll(userPalette.getSelections());
      team.preReceiveScripts.clear();
      team.preReceiveScripts.addAll(preReceivePalette.getSelections());
      team.postReceiveScripts.clear();
      team.postReceiveScripts.addAll(postReceivePalette.getSelections());
      return true;
   }
@@ -251,7 +298,7 @@
      }
      repositoryPalette.setObjects(restricted, selected);
   }
   public void setUsers(List<String> users, List<String> selected) {
      Collections.sort(users);
      if (selected != null) {
@@ -260,6 +307,38 @@
      userPalette.setObjects(users, selected);
   }
   public void setPreReceiveScripts(List<String> unused, List<String> inherited,
         List<String> selected) {
      Collections.sort(unused);
      if (selected != null) {
         Collections.sort(selected);
      }
      preReceivePalette.setObjects(unused, selected);
      showInherited(inherited, preReceiveInherited);
   }
   public void setPostReceiveScripts(List<String> unused, List<String> inherited,
         List<String> selected) {
      Collections.sort(unused);
      if (selected != null) {
         Collections.sort(selected);
      }
      postReceivePalette.setObjects(unused, selected);
      showInherited(inherited, postReceiveInherited);
   }
   private void showInherited(List<String> list, JLabel label) {
      StringBuilder sb = new StringBuilder();
      if (list != null && list.size() > 0) {
         sb.append("<html><body><b>INHERITED</b><ul style=\"margin-left:5px;list-style-type: none;\">");
         for (String script : list) {
            sb.append("<li>").append(script).append("</li>");
         }
         sb.append("</ul></body></html>");
      }
      label.setText(sb.toString());
   }
   public TeamModel getTeam() {
      if (canceled) {
         return null;