From f2dff4ea2ba10dca13b54d5968c5021f071b3ddd Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 28 Dec 2011 20:40:31 -0500 Subject: [PATCH] Show inherited push scripts in Manager --- .../gitblit/client/EditRepositoryDialog.java | 35 +++++++++++++---- src/com/gitblit/client/EditTeamDialog.java | 38 ++++++++++++++----- src/com/gitblit/client/RepositoriesPanel.java | 10 +++-- src/com/gitblit/client/TeamsPanel.java | 10 +++-- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java index b7278623..e4a332ab 100644 --- a/src/com/gitblit/client/EditRepositoryDialog.java +++ b/src/com/gitblit/client/EditRepositoryDialog.java @@ -104,8 +104,12 @@ public class EditRepositoryDialog extends JDialog { private JPalette teamsPalette; private JPalette preReceivePalette; + + private JLabel preReceiveInherited; private JPalette postReceivePalette; + + private JLabel postReceiveInherited; private Set repositoryNames; @@ -221,16 +225,16 @@ public class EditRepositoryDialog extends JDialog { BorderLayout.CENTER); preReceivePalette = new JPalette(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(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"), fieldsPanel); @@ -427,12 +431,27 @@ public class EditRepositoryDialog extends JDialog { setsPalette.setObjects(all, selected); } - public void setPreReceiveScripts(List all, List selected) { + public void setPreReceiveScripts(List all, List inherited, List selected) { preReceivePalette.setObjects(all, selected); + showInherited(inherited, preReceiveInherited); } - public void setPostReceiveScripts(List all, List selected) { + public void setPostReceiveScripts(List all, List inherited, + List selected) { postReceivePalette.setObjects(all, selected); + showInherited(inherited, postReceiveInherited); + } + + private void showInherited(List list, JLabel label) { + StringBuilder sb = new StringBuilder(); + if (list != null && list.size() > 0) { + sb.append("INHERITED
    "); + for (String script : list) { + sb.append("
  • ").append(script).append("
  • "); + } + sb.append("
"); + } + label.setText(sb.toString()); } public RepositoryModel getRepository() { diff --git a/src/com/gitblit/client/EditTeamDialog.java b/src/com/gitblit/client/EditTeamDialog.java index 49669e2c..80e41608 100644 --- a/src/com/gitblit/client/EditTeamDialog.java +++ b/src/com/gitblit/client/EditTeamDialog.java @@ -73,8 +73,12 @@ public class EditTeamDialog extends JDialog { private JPalette preReceivePalette; + private JLabel preReceiveInherited; + private JPalette postReceivePalette; + private JLabel postReceiveInherited; + private Set teamnames; public EditTeamDialog(int protocolVersion, ServerSettings settings) { @@ -146,16 +150,16 @@ public class EditTeamDialog extends JDialog { usersPanel.add(userPalette, BorderLayout.CENTER); preReceivePalette = new JPalette(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(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); @@ -303,20 +307,36 @@ public class EditTeamDialog extends JDialog { userPalette.setObjects(users, selected); } - public void setPreReceiveScripts(List unused, List selected) { + public void setPreReceiveScripts(List unused, List inherited, + List selected) { Collections.sort(unused); if (selected != null) { Collections.sort(selected); } preReceivePalette.setObjects(unused, selected); + showInherited(inherited, preReceiveInherited); } - public void setPostReceiveScripts(List unused, List selected) { + public void setPostReceiveScripts(List unused, List inherited, + List selected) { Collections.sort(unused); if (selected != null) { Collections.sort(selected); } postReceivePalette.setObjects(unused, selected); + showInherited(inherited, postReceiveInherited); + } + + private void showInherited(List list, JLabel label) { + StringBuilder sb = new StringBuilder(); + if (list != null && list.size() > 0) { + sb.append("INHERITED
    "); + for (String script : list) { + sb.append("
  • ").append(script).append("
  • "); + } + sb.append("
"); + } + label.setText(sb.toString()); } public TeamModel getTeam() { diff --git a/src/com/gitblit/client/RepositoriesPanel.java b/src/com/gitblit/client/RepositoriesPanel.java index 50284be1..104010d5 100644 --- a/src/com/gitblit/client/RepositoriesPanel.java +++ b/src/com/gitblit/client/RepositoriesPanel.java @@ -357,8 +357,10 @@ public abstract class RepositoriesPanel extends JPanel { dialog.setTeams(gitblit.getTeamnames(), null); dialog.setRepositories(gitblit.getRepositories()); dialog.setFederationSets(gitblit.getFederationSets(), null); - dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null), null); - dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null), null); + dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null), + gitblit.getPreReceiveScriptsInherited(null), null); + dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null), + gitblit.getPostReceiveScriptsInherited(null), null); dialog.setVisible(true); final RepositoryModel newRepository = dialog.getRepository(); final List permittedUsers = dialog.getPermittedUsers(); @@ -418,9 +420,9 @@ public abstract class RepositoriesPanel extends JPanel { dialog.setRepositories(gitblit.getRepositories()); dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets); dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(repository), - repository.preReceiveScripts); + gitblit.getPreReceiveScriptsInherited(repository), repository.preReceiveScripts); dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(repository), - repository.postReceiveScripts); + gitblit.getPostReceiveScriptsInherited(repository), repository.postReceiveScripts); dialog.setVisible(true); final RepositoryModel revisedRepository = dialog.getRepository(); final List permittedUsers = dialog.getPermittedUsers(); diff --git a/src/com/gitblit/client/TeamsPanel.java b/src/com/gitblit/client/TeamsPanel.java index b2a18731..71825665 100644 --- a/src/com/gitblit/client/TeamsPanel.java +++ b/src/com/gitblit/client/TeamsPanel.java @@ -257,8 +257,10 @@ public abstract class TeamsPanel extends JPanel { dialog.setTeams(gitblit.getTeams()); dialog.setRepositories(gitblit.getRepositories(), null); dialog.setUsers(gitblit.getUsernames(), null); - dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null), null); - dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null), null); + dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null), + gitblit.getPreReceiveScriptsInherited(null), null); + dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null), + gitblit.getPostReceiveScriptsInherited(null), null); dialog.setVisible(true); final TeamModel newTeam = dialog.getTeam(); if (newTeam == null) { @@ -307,9 +309,9 @@ public abstract class TeamsPanel extends JPanel { dialog.setUsers(gitblit.getUsernames(), team.users == null ? null : new ArrayList( team.users)); dialog.setPreReceiveScripts(gitblit.getPreReceiveScriptsUnused(null), - team.preReceiveScripts); + gitblit.getPreReceiveScriptsInherited(null), team.preReceiveScripts); dialog.setPostReceiveScripts(gitblit.getPostReceiveScriptsUnused(null), - team.postReceiveScripts); + gitblit.getPostReceiveScriptsInherited(null), team.postReceiveScripts); dialog.setVisible(true); final TeamModel revisedTeam = dialog.getTeam(); if (revisedTeam == null) { -- 2.39.5