]> source.dussan.org Git - gitblit.git/commitdiff
Populate author selector based on repository selector
authorJames Moger <james.moger@gitblit.com>
Wed, 2 Nov 2011 23:25:49 +0000 (19:25 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 2 Nov 2011 23:25:49 +0000 (19:25 -0400)
src/com/gitblit/client/FeedsPanel.java

index 0492b95ac4ef14420ed74dd5e584971e51390c94..60d2d5f0f7969c8dcececb882f73a9ecbf9d9031 100644 (file)
@@ -174,6 +174,18 @@ public abstract class FeedsPanel extends JPanel {
                repositorySelector.setForeground(nameRenderer.getForeground());\r
                repositorySelector.addActionListener(new ActionListener() {\r
                        public void actionPerformed(ActionEvent event) {\r
+                               // repopulate the author list based on repository selection\r
+                               // preserve author selection, if possible\r
+                               String selectedAuthor = null;\r
+                               if (authorSelector.getSelectedIndex() > -1) {\r
+                                       selectedAuthor = authorSelector.getSelectedItem().toString();\r
+                               }\r
+                               updateAuthors();\r
+                               if (selectedAuthor != null) {\r
+                                       if (authorChoices.getIndexOf(selectedAuthor) > -1) {\r
+                                               authorChoices.setSelectedItem(selectedAuthor);\r
+                                       }\r
+                               }\r
                                filterFeeds();\r
                        }\r
                });\r
@@ -235,12 +247,10 @@ public abstract class FeedsPanel extends JPanel {
                if (pack) {\r
                        Utils.packColumns(table, Utils.MARGIN);\r
                }\r
-               // determine unique repositories and authors\r
+               // determine unique repositories\r
                Set<String> uniqueRepositories = new HashSet<String>();\r
-               Set<String> uniqueAuthors = new HashSet<String>();\r
                for (SyndicatedEntryModel entry : tableModel.entries) {\r
                        uniqueRepositories.add(entry.repository);\r
-                       uniqueAuthors.add(entry.author);\r
                }\r
 \r
                // repositories\r
@@ -251,7 +261,18 @@ public abstract class FeedsPanel extends JPanel {
                for (String repo : sortedRespositories) {\r
                        repositoryChoices.addElement(repo);\r
                }\r
+       }\r
 \r
+       private void updateAuthors() {\r
+               String repository = repositorySelector.getSelectedItem().toString();\r
+\r
+               // determine unique repositories and authors\r
+               Set<String> uniqueAuthors = new HashSet<String>();\r
+               for (SyndicatedEntryModel entry : tableModel.entries) {\r
+                       if (repository.equals(ALL) || entry.repository.equalsIgnoreCase(repository)) {\r
+                               uniqueAuthors.add(entry.author);\r
+                       }\r
+               }\r
                // authors\r
                List<String> sortedAuthors = new ArrayList<String>(uniqueAuthors);\r
                Collections.sort(sortedAuthors);\r