| | |
| | |
|
| | | import javax.swing.ImageIcon;
|
| | | import javax.swing.JButton;
|
| | | import javax.swing.JCheckBox;
|
| | | import javax.swing.JComponent;
|
| | | import javax.swing.JDialog;
|
| | | import javax.swing.JLabel;
|
| | |
| | | import javax.swing.KeyStroke;
|
| | |
|
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.Constants.AuthorizationControl;
|
| | | import com.gitblit.Constants.RegistrantType;
|
| | | import com.gitblit.models.RegistrantAccessPermission;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.ServerSettings;
|
| | | import com.gitblit.models.TeamModel;
|
| | |
| | | private boolean canceled = true;
|
| | |
|
| | | private JTextField teamnameField;
|
| | | |
| | | private JCheckBox canAdminCheckbox;
|
| | | |
| | | private JCheckBox canForkCheckbox;
|
| | | |
| | | private JCheckBox canCreateCheckbox;
|
| | |
|
| | | private JTextField mailingListsField;
|
| | |
|
| | | private JPalette<String> repositoryPalette;
|
| | | private RegistrantPermissionsPanel repositoryPalette;
|
| | |
|
| | | private JPalette<String> userPalette;
|
| | |
|
| | |
| | | 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>();
|
| | | repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);
|
| | | userPalette = new JPalette<String>();
|
| | |
|
| | | userPalette.setEnabled(settings.supportsTeamMembershipChanges);
|
| | | |
| | | JPanel fieldsPanelTop = new JPanel(new BorderLayout());
|
| | | fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
|
| | |
|
| | |
| | | }
|
| | | 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>();
|
| | |
| | | team.mailingLists.addAll(list);
|
| | | }
|
| | |
|
| | | team.repositories.clear();
|
| | | team.repositories.addAll(repositoryPalette.getSelections());
|
| | | for (RegistrantAccessPermission rp : repositoryPalette.getPermissions()) {
|
| | | team.setRepositoryPermission(rp.registrant, rp.permission);
|
| | | }
|
| | |
|
| | | team.users.clear();
|
| | | team.users.addAll(userPalette.getSelections());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void setRepositories(List<RepositoryModel> repositories, List<String> selected) {
|
| | | public void setRepositories(List<RepositoryModel> repositories, List<RegistrantAccessPermission> permissions) {
|
| | | List<String> restricted = new ArrayList<String>();
|
| | | for (RepositoryModel repo : repositories) {
|
| | | if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)) {
|
| | | if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)
|
| | | && repo.authorizationControl.equals(AuthorizationControl.NAMED)) {
|
| | | restricted.add(repo.name);
|
| | | }
|
| | | } |
| | | }
|
| | | StringUtils.sortRepositorynames(restricted);
|
| | | if (selected != null) {
|
| | | StringUtils.sortRepositorynames(selected);
|
| | | |
| | | List<String> list = new ArrayList<String>();
|
| | | // repositories
|
| | | list.add(".*");
|
| | | // all repositories excluding personal repositories
|
| | | list.add("[^~].*");
|
| | | String lastProject = null;
|
| | | for (String repo : restricted) {
|
| | | String projectPath = StringUtils.getFirstPathElement(repo);
|
| | | if (lastProject == null || !lastProject.equalsIgnoreCase(projectPath)) {
|
| | | lastProject = projectPath;
|
| | | if (!StringUtils.isEmpty(projectPath)) {
|
| | | // regex for all repositories within a project
|
| | | list.add(projectPath + "/.*");
|
| | | }
|
| | | list.add(repo);
|
| | | }
|
| | | }
|
| | | repositoryPalette.setObjects(restricted, selected);
|
| | |
|
| | | // remove repositories for which user already has a permission
|
| | | if (permissions == null) {
|
| | | permissions = new ArrayList<RegistrantAccessPermission>();
|
| | | } else {
|
| | | for (RegistrantAccessPermission rp : permissions) {
|
| | | list.remove(rp.registrant);
|
| | | }
|
| | | }
|
| | | repositoryPalette.setObjects(list, permissions);
|
| | | }
|
| | |
|
| | | public void setUsers(List<String> users, List<String> selected) {
|