From: James Moger Date: Wed, 2 Nov 2011 23:25:49 +0000 (-0400) Subject: Populate author selector based on repository selector X-Git-Tag: v0.7.0~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6477ce2aa8540fedbec7ebba5656cd3968e78019;p=gitblit.git Populate author selector based on repository selector --- diff --git a/src/com/gitblit/client/FeedsPanel.java b/src/com/gitblit/client/FeedsPanel.java index 0492b95a..60d2d5f0 100644 --- a/src/com/gitblit/client/FeedsPanel.java +++ b/src/com/gitblit/client/FeedsPanel.java @@ -174,6 +174,18 @@ public abstract class FeedsPanel extends JPanel { repositorySelector.setForeground(nameRenderer.getForeground()); repositorySelector.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { + // repopulate the author list based on repository selection + // preserve author selection, if possible + String selectedAuthor = null; + if (authorSelector.getSelectedIndex() > -1) { + selectedAuthor = authorSelector.getSelectedItem().toString(); + } + updateAuthors(); + if (selectedAuthor != null) { + if (authorChoices.getIndexOf(selectedAuthor) > -1) { + authorChoices.setSelectedItem(selectedAuthor); + } + } filterFeeds(); } }); @@ -235,12 +247,10 @@ public abstract class FeedsPanel extends JPanel { if (pack) { Utils.packColumns(table, Utils.MARGIN); } - // determine unique repositories and authors + // determine unique repositories Set uniqueRepositories = new HashSet(); - Set uniqueAuthors = new HashSet(); for (SyndicatedEntryModel entry : tableModel.entries) { uniqueRepositories.add(entry.repository); - uniqueAuthors.add(entry.author); } // repositories @@ -251,7 +261,18 @@ public abstract class FeedsPanel extends JPanel { for (String repo : sortedRespositories) { repositoryChoices.addElement(repo); } + } + private void updateAuthors() { + String repository = repositorySelector.getSelectedItem().toString(); + + // determine unique repositories and authors + Set uniqueAuthors = new HashSet(); + for (SyndicatedEntryModel entry : tableModel.entries) { + if (repository.equals(ALL) || entry.repository.equalsIgnoreCase(repository)) { + uniqueAuthors.add(entry.author); + } + } // authors List sortedAuthors = new ArrayList(uniqueAuthors); Collections.sort(sortedAuthors);