}\r
} else if (RpcRequest.LIST_SETTINGS.equals(reqType)) {\r
// return the server's settings\r
- ServerSettings settings = GitBlit.self().getSettingsModel();\r
+ ServerSettings settings = GitBlit.self().getSettingsModel(); \r
if (allowAdmin) {\r
// return all settings\r
result = settings;\r
keys.add(Keys.federation.sets);\r
}\r
// build the settings\r
- ServerSettings managementSettings = new ServerSettings();\r
+ ServerSettings managementSettings = new ServerSettings(); \r
for (String key : keys) {\r
managementSettings.add(settings.get(key));\r
}\r
+ if (allowManagement) {\r
+ settings.pushScripts = settings.pushScripts;\r
+ }\r
result = managementSettings;\r
}\r
} else if (RpcRequest.EDIT_SETTINGS.equals(reqType)) {\r
private JCheckBox skipSummaryMetrics;\r
\r
private JCheckBox isFrozen;\r
- \r
+\r
private JTextField mailRecipientsField;\r
\r
private JComboBox accessRestriction;\r
private JComboBox ownerField;\r
\r
private JPalette<String> usersPalette;\r
- \r
+\r
private JPalette<String> setsPalette;\r
- \r
+\r
private JPalette<String> teamsPalette;\r
\r
+ private JPalette<String> preReceivePalette;\r
+\r
+ private JPalette<String> postReceivePalette;\r
+\r
private Set<String> repositoryNames;\r
\r
public EditRepositoryDialog(int protocolVersion) {\r
\r
mailRecipientsField = new JTextField(anRepository.mailRecipients == null ? ""\r
: StringUtils.flattenStrings(anRepository.mailRecipients, " "), 50);\r
- \r
+\r
accessRestriction = new JComboBox(AccessRestrictionType.values());\r
accessRestriction.setRenderer(new AccessRestrictionRenderer());\r
accessRestriction.setSelectedItem(anRepository.accessRestriction);\r
federationPanel.add(newFieldPanel(Translation.get("gb.federationSets"), setsPalette),\r
BorderLayout.CENTER);\r
\r
+ preReceivePalette = new JPalette<String>(true);\r
+ JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));\r
+ preReceivePanel.add(\r
+ newFieldPanel(Translation.get("gb.preReceiveScripts"), preReceivePalette),\r
+ BorderLayout.CENTER);\r
+\r
+ postReceivePalette = new JPalette<String>(true);\r
+ JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));\r
+ postReceivePanel.add(\r
+ newFieldPanel(Translation.get("gb.postReceiveScripts"), postReceivePalette),\r
+ BorderLayout.CENTER);\r
+\r
JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);\r
panel.addTab(Translation.get("gb.general"), fieldsPanel);\r
panel.addTab(Translation.get("gb.accessRestriction"), accessPanel);\r
panel.addTab(Translation.get("gb.teams"), teamsPanel);\r
}\r
panel.addTab(Translation.get("gb.federation"), federationPanel);\r
+ panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);\r
+ panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);\r
\r
JButton createButton = new JButton(Translation.get("gb.save"));\r
createButton.addActionListener(new ActionListener() {\r
repository.skipSizeCalculation = skipSizeCalculation.isSelected();\r
repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();\r
repository.isFrozen = isFrozen.isSelected();\r
- \r
- repository.mailRecipients = StringUtils.getStringsFromValue(mailRecipientsField.getText().trim(), " ");\r
+\r
+ repository.mailRecipients = StringUtils.getStringsFromValue(mailRecipientsField.getText()\r
+ .trim(), " ");\r
\r
repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem();\r
repository.federationStrategy = (FederationStrategy) federationStrategy.getSelectedItem();\r
if (repository.federationStrategy.exceeds(FederationStrategy.EXCLUDE)) {\r
repository.federationSets = setsPalette.getSelections();\r
}\r
+\r
+ repository.preReceiveScripts = preReceivePalette.getSelections();\r
+ repository.postReceiveScripts = postReceivePalette.getSelections();\r
return true;\r
}\r
\r
}\r
usersPalette.setObjects(all, selected);\r
}\r
- \r
+\r
public void setTeams(List<String> all, List<String> selected) {\r
teamsPalette.setObjects(all, selected);\r
}\r
setsPalette.setObjects(all, selected);\r
}\r
\r
+ public void setPreReceiveScripts(List<String> all, List<String> selected) {\r
+ preReceivePalette.setObjects(all, selected);\r
+ }\r
+\r
+ public void setPostReceiveScripts(List<String> all, List<String> selected) {\r
+ postReceivePalette.setObjects(all, selected);\r
+ }\r
+\r
public RepositoryModel getRepository() {\r
if (canceled) {\r
return null;\r
}\r
}\r
\r
+ public List<String> getAvailableScripts() {\r
+ if (settings.pushScripts == null) {\r
+ return new ArrayList<String>();\r
+ }\r
+ return settings.pushScripts;\r
+ }\r
+\r
public ServerSettings getSettings() {\r
return settings;\r
}\r
private PaletteModel<T> selectedModel;\r
\r
public JPalette() {\r
+ this(false);\r
+ }\r
+\r
+ public JPalette(boolean controlOrder) {\r
super(new BorderLayout(5, 5));\r
\r
availableModel = new PaletteModel<T>();\r
}\r
});\r
\r
+ JButton up = new JButton("\u2191");\r
+ up.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent event) {\r
+ int row = selected.getSelectedRow();\r
+ if (row > 0) {\r
+ T o = selectedModel.list.remove(row);\r
+ selectedModel.list.add(row - 1, o);\r
+ selectedModel.fireTableDataChanged();\r
+ }\r
+ }\r
+ });\r
+\r
+ JButton down = new JButton("\u2193");\r
+ down.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent event) {\r
+ int row = selected.getSelectedRow();\r
+ if (row < selected.getRowCount() - 1) {\r
+ T o = selectedModel.list.remove(row);\r
+ selectedModel.list.add(row + 1, o);\r
+ selectedModel.fireTableDataChanged();\r
+ }\r
+ }\r
+ });\r
+\r
JPanel controls = new JPanel(new GridLayout(0, 1, 0, 5));\r
controls.add(add);\r
controls.add(subtract);\r
+ if (controlOrder) {\r
+ controls.add(up);\r
+ controls.add(down);\r
+ }\r
\r
JPanel center = new JPanel(new GridBagLayout());\r
center.add(controls);\r
protected abstract void subscribeFeeds(List<FeedModel> feeds);\r
\r
protected abstract void updateUsersTable();\r
- \r
+\r
protected abstract void updateTeamsTable();\r
\r
protected void disableManagement() {\r
dialog.setTeams(gitblit.getTeamnames(), null);\r
dialog.setRepositories(gitblit.getRepositories());\r
dialog.setFederationSets(gitblit.getFederationSets(), null);\r
+ dialog.setPreReceiveScripts(gitblit.getAvailableScripts(), null);\r
+ dialog.setPostReceiveScripts(gitblit.getAvailableScripts(), null);\r
dialog.setVisible(true);\r
final RepositoryModel newRepository = dialog.getRepository();\r
final List<String> permittedUsers = dialog.getPermittedUsers();\r
\r
@Override\r
protected Boolean doRequest() throws IOException {\r
- boolean success = gitblit.createRepository(newRepository, permittedUsers, permittedTeams);\r
+ boolean success = gitblit.createRepository(newRepository, permittedUsers,\r
+ permittedTeams);\r
if (success) {\r
gitblit.refreshRepositories();\r
if (permittedUsers.size() > 0) {\r
* @param repository\r
*/\r
protected void editRepository(final RepositoryModel repository) {\r
- EditRepositoryDialog dialog = new EditRepositoryDialog(gitblit.getProtocolVersion(), repository);\r
+ EditRepositoryDialog dialog = new EditRepositoryDialog(gitblit.getProtocolVersion(),\r
+ repository);\r
dialog.setLocationRelativeTo(RepositoriesPanel.this);\r
List<String> usernames = gitblit.getUsernames();\r
List<String> members = gitblit.getPermittedUsernames(repository);\r
dialog.setTeams(gitblit.getTeamnames(), gitblit.getPermittedTeamnames(repository));\r
dialog.setRepositories(gitblit.getRepositories());\r
dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets);\r
+ dialog.setPreReceiveScripts(gitblit.getAvailableScripts(), repository.preReceiveScripts);\r
+ dialog.setPostReceiveScripts(gitblit.getAvailableScripts(), repository.postReceiveScripts);\r
dialog.setVisible(true);\r
final RepositoryModel revisedRepository = dialog.getRepository();\r
final List<String> permittedUsers = dialog.getPermittedUsers();\r
\r
private static final long serialVersionUID = 1L;\r
\r
+ public List<String> pushScripts;\r
+\r
public ServerSettings() {\r
settings = new TreeMap<String, SettingModel>();\r
}\r