James Moger
2012-10-18 13417cf9c6eec555b51da49742e47939d2f5715b
src/com/gitblit/client/EditTeamDialog.java
@@ -33,6 +33,7 @@
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
@@ -64,6 +65,12 @@
   private boolean canceled = true;
   private JTextField teamnameField;
   private JCheckBox canAdminCheckbox;
   private JCheckBox canForkCheckbox;
   private JCheckBox canCreateCheckbox;
   private JTextField mailingListsField;
@@ -73,7 +80,11 @@
   private JPalette<String> preReceivePalette;
   private JLabel preReceiveInherited;
   private JPalette<String> postReceivePalette;
   private JLabel postReceiveInherited;
   private Set<String> teamnames;
@@ -111,17 +122,26 @@
   private void initialize(int protocolVersion, TeamModel aTeam) {
      teamnameField = new JTextField(aTeam.name == null ? "" : aTeam.name, 25);
      canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), aTeam.canAdmin);
      canForkCheckbox = new JCheckBox(Translation.get("gb.canForkDescription"), aTeam.canFork);
      canCreateCheckbox = new JCheckBox(Translation.get("gb.canCreateDescription"), aTeam.canCreate);
      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.canAdmin"), canAdminCheckbox));
      fieldsPanel.add(newFieldPanel(Translation.get("gb.canFork"), canForkCheckbox));
      fieldsPanel.add(newFieldPanel(Translation.get("gb.canCreate"), canCreateCheckbox));
      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>();
      userPalette.setEnabled(settings.supportsTeamMembershipChanges);
      JPanel fieldsPanelTop = new JPanel(new BorderLayout());
      fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
@@ -146,16 +166,16 @@
      usersPanel.add(userPalette, BorderLayout.CENTER);
      preReceivePalette = new JPalette<String>(true);
      preReceiveInherited = new JLabel();
      JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
      preReceivePanel.add(
            newFieldPanel(Translation.get("gb.preReceiveScripts"), preReceivePalette),
            BorderLayout.CENTER);
      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(
            newFieldPanel(Translation.get("gb.postReceiveScripts"), postReceivePalette),
            BorderLayout.CENTER);
      postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
      postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
      JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
      panel.addTab(Translation.get("gb.general"), fieldsPanelTop);
@@ -241,6 +261,10 @@
      }
      team.name = tname;
      team.canAdmin = canAdminCheckbox.isSelected();
      team.canFork = canForkCheckbox.isSelected();
      team.canCreate = canCreateCheckbox.isSelected();
      String ml = mailingListsField.getText();
      if (!StringUtils.isEmpty(ml)) {
         Set<String> list = new HashSet<String>();
@@ -303,20 +327,36 @@
      userPalette.setObjects(users, selected);
   }
   public void setPreReceiveScripts(List<String> unused, List<String> 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> selected) {
   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() {