| | |
| | | import java.text.MessageFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.swing.BoxLayout;
|
| | | import javax.swing.DefaultComboBoxModel;
|
| | | import javax.swing.ImageIcon;
|
| | | import javax.swing.JButton;
|
| | |
| | | private Set<String> repositoryNames;
|
| | |
|
| | | private JPanel customFieldsPanel;
|
| | | |
| | | private List<JTextField> customTextfields;
|
| | |
|
| | | public EditRepositoryDialog(int protocolVersion) {
|
| | | this(protocolVersion, new RepositoryModel());
|
| | |
| | | postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
|
| | | postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
|
| | |
|
| | | customFieldsPanel = new JPanel(new VerticalFlowLayout());
|
| | | customFieldsPanel = new JPanel();
|
| | | customFieldsPanel.setLayout(new BoxLayout(customFieldsPanel, BoxLayout.Y_AXIS));
|
| | | JScrollPane customFieldsScrollPane = new JScrollPane(customFieldsPanel);
|
| | | customFieldsScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
| | | customFieldsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
| | |
| | | error("Relative folder references (../) are prohibited.");
|
| | | return false;
|
| | | }
|
| | | if (rname.endsWith("/")) {
|
| | | rname = rname.substring(0, rname.length() - 1);
|
| | | }
|
| | |
|
| | | // confirm valid characters in repository name
|
| | | Character c = StringUtils.findInvalidCharacter(rname);
|
| | |
| | | repository.postReceiveScripts = postReceivePalette.getSelections();
|
| | |
|
| | | // Custom Fields
|
| | | repository.customFields = new HashMap<String, String>();
|
| | | |
| | | for (Component aCustomFieldPanel : customFieldsPanel.getComponents()) {
|
| | | JTextField textField = (JTextField) ((JPanel)aCustomFieldPanel).getComponent(1);
|
| | | repository.customFields.put(textField.getName(), textField.getText());
|
| | | repository.customFields = new LinkedHashMap<String, String>();
|
| | | if (customTextfields != null) {
|
| | | for (JTextField field : customTextfields) {
|
| | | String key = field.getName();
|
| | | String value = field.getText();
|
| | | repository.customFields.put(key, value);
|
| | | }
|
| | | }
|
| | | |
| | | return true;
|
| | | }
|
| | |
|
| | | private void error(String message) {
|
| | | JOptionPane.showMessageDialog(EditRepositoryDialog.this, message,
|
| | | Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
|
| | | }
|
| | | |
| | | public void setAccessRestriction(AccessRestrictionType restriction) {
|
| | | this.accessRestriction.setSelectedItem(restriction);
|
| | | }
|
| | |
|
| | | public void setUsers(String owner, List<String> all, List<String> selected) {
|
| | |
| | | return teamsPalette.getSelections();
|
| | | }
|
| | |
|
| | | public void setCustomFields(RepositoryModel repository, List<String> customFields) {
|
| | | public void setCustomFields(RepositoryModel repository, Map<String, String> customFields) {
|
| | | customFieldsPanel.removeAll();
|
| | | customTextfields = new ArrayList<JTextField>();
|
| | |
|
| | | for (String customFieldDef : customFields) {
|
| | | String[] customFieldProperty = customFieldDef.split("=");
|
| | | String fieldName = customFieldProperty[0];
|
| | | String fieldLabel = customFieldProperty[1];
|
| | | final Insets insets = new Insets(5, 5, 5, 5);
|
| | | JPanel fields = new JPanel(new GridLayout(0, 1, 0, 5)) {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public Insets getInsets() {
|
| | | return insets;
|
| | | }
|
| | | }; |
| | | |
| | | for (Map.Entry<String, String> entry : customFields.entrySet()) {
|
| | | String field = entry.getKey();
|
| | | String value = "";
|
| | | if (repository.customFields != null && repository.customFields.containsKey(field)) {
|
| | | value = repository.customFields.get(field);
|
| | | }
|
| | | JTextField textField = new JTextField(value);
|
| | | textField.setName(field);
|
| | |
|
| | | JTextField textField = new JTextField(repository.customFields.get(fieldName), 50);
|
| | | textField.setName(fieldName);
|
| | | textField.setPreferredSize(new Dimension(450, 26));
|
| | |
|
| | | customFieldsPanel.add(newFieldPanel(fieldLabel, 250, textField));
|
| | | fields.add(newFieldPanel(entry.getValue(), 250, textField));
|
| | | |
| | | customTextfields.add(textField);
|
| | | }
|
| | | JScrollPane jsp = new JScrollPane(fields); |
| | | jsp.getVerticalScrollBar().setBlockIncrement(100);
|
| | | jsp.getVerticalScrollBar().setUnitIncrement(100);
|
| | | jsp.setViewportBorder(null);
|
| | | customFieldsPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
| | | customFieldsPanel.add(jsp);
|
| | | }
|
| | |
|
| | | /**
|