| | |
| | | import java.awt.Insets;
|
| | | import java.awt.event.ActionEvent;
|
| | | import java.awt.event.ActionListener;
|
| | | import java.awt.event.KeyEvent;
|
| | | import java.text.MessageFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | |
| | | import javax.swing.JList;
|
| | | import javax.swing.JOptionPane;
|
| | | import javax.swing.JPanel;
|
| | | import javax.swing.JRootPane;
|
| | | import javax.swing.JTabbedPane;
|
| | | import javax.swing.JTextField;
|
| | | import javax.swing.KeyStroke;
|
| | | import javax.swing.ListCellRenderer;
|
| | |
|
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | |
| | | public class EditRepositoryDialog extends JDialog {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | private final String repositoryName;
|
| | |
|
| | | private final RepositoryModel repository;
|
| | |
|
| | |
| | | private JCheckBox showRemoteBranches;
|
| | |
|
| | | private JCheckBox showReadme;
|
| | |
|
| | | private JCheckBox skipSizeCalculation;
|
| | |
|
| | | private JCheckBox skipSummaryMetrics;
|
| | |
|
| | | private JCheckBox isFrozen;
|
| | |
|
| | |
| | |
|
| | | public EditRepositoryDialog(RepositoryModel aRepository) {
|
| | | super();
|
| | | this.repositoryName = aRepository.name;
|
| | | this.repository = new RepositoryModel();
|
| | | this.repositoryNames = new HashSet<String>();
|
| | | this.isCreate = false;
|
| | |
| | | setResizable(false);
|
| | | setTitle(Translation.get("gb.edit") + ": " + aRepository.name);
|
| | | setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected JRootPane createRootPane() {
|
| | | KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
|
| | | JRootPane rootPane = new JRootPane();
|
| | | rootPane.registerKeyboardAction(new ActionListener() {
|
| | | public void actionPerformed(ActionEvent actionEvent) {
|
| | | setVisible(false);
|
| | | }
|
| | | }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
| | | return rootPane;
|
| | | }
|
| | |
|
| | | private void initialize(RepositoryModel anRepository) {
|
| | |
| | | anRepository.showRemoteBranches);
|
| | | showReadme = new JCheckBox(Translation.get("gb.showReadmeDescription"),
|
| | | anRepository.showReadme);
|
| | | skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"),
|
| | | anRepository.skipSizeCalculation);
|
| | | skipSummaryMetrics = new JCheckBox(Translation.get("gb.skipSummaryMetricsDescription"),
|
| | | anRepository.skipSummaryMetrics);
|
| | | isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);
|
| | |
|
| | | accessRestriction = new JComboBox(AccessRestrictionType.values());
|
| | |
| | | fieldsPanel
|
| | | .add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches));
|
| | | fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"), showReadme));
|
| | | fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"),
|
| | | skipSizeCalculation));
|
| | | fieldsPanel
|
| | | .add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics));
|
| | | fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
|
| | |
|
| | | usersPalette = new JPalette<String>();
|
| | |
| | | getContentPane().setLayout(new BorderLayout(5, 5));
|
| | | getContentPane().add(centerPanel, BorderLayout.CENTER);
|
| | | pack();
|
| | | setLocationRelativeTo(null);
|
| | | }
|
| | |
|
| | | private JPanel newFieldPanel(String label, JComponent comp) {
|
| | |
| | | "Can not create repository ''{0}'' because it already exists.", rname));
|
| | | return false;
|
| | | }
|
| | | } else {
|
| | | // check rename collision
|
| | | if (!repositoryName.equalsIgnoreCase(rname)) {
|
| | | if (repositoryNames.contains(rname.toLowerCase())) {
|
| | | error(MessageFormat.format(
|
| | | "Failed to rename ''{0}'' because ''{1}'' already exists.",
|
| | | repositoryName, rname));
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (accessRestriction.getSelectedItem() == null) {
|
| | |
| | | repository.useDocs = useDocs.isSelected();
|
| | | repository.showRemoteBranches = showRemoteBranches.isSelected();
|
| | | repository.showReadme = showReadme.isSelected();
|
| | | repository.skipSizeCalculation = skipSizeCalculation.isSelected();
|
| | | repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();
|
| | | repository.isFrozen = isFrozen.isSelected();
|
| | |
|
| | | repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem();
|