<resource file="${basedir}/resources/feed_16x16.png" />\r
<resource file="${basedir}/resources/bullet_feed.png" />\r
<resource file="${basedir}/resources/search-icon.png" />\r
+ <resource file="${basedir}/resources/commit_changes_16x16.png" />\r
<resource file="${basedir}/resources/blank.png" />\r
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp.properties" />\r
\r
\r
import com.gitblit.models.RefModel;\r
import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
import com.gitblit.utils.HttpUtils;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.StringUtils;\r
offset, length);\r
}\r
Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository);\r
- List<SyndicatedEntryModel> entries = new ArrayList<SyndicatedEntryModel>();\r
+ List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();\r
\r
boolean mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true);\r
String urlPattern;\r
String gitblitUrl = HttpUtils.getGitblitURL(request);\r
// convert RevCommit to SyndicatedEntryModel\r
for (RevCommit commit : commits) {\r
- SyndicatedEntryModel entry = new SyndicatedEntryModel();\r
+ FeedEntryModel entry = new FeedEntryModel();\r
entry.title = commit.getShortMessage();\r
entry.author = commit.getAuthorIdent().getName();\r
entry.link = MessageFormat.format(urlPattern, gitblitUrl,\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Date;\r
+import java.util.List;\r
+\r
+import javax.swing.table.AbstractTableModel;\r
+\r
+import com.gitblit.models.FeedEntryModel;\r
+\r
+/**\r
+ * Table model for a list of retrieved feed entries.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class FeedEntryTableModel extends AbstractTableModel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ List<FeedEntryModel> entries;\r
+\r
+ enum Columns {\r
+ Date, Repository, Branch, Author, Message;\r
+\r
+ @Override\r
+ public String toString() {\r
+ return name().replace('_', ' ');\r
+ }\r
+ }\r
+\r
+ public FeedEntryTableModel() {\r
+ this.entries = new ArrayList<FeedEntryModel>();\r
+ }\r
+\r
+ public void setEntries(List<FeedEntryModel> entries) {\r
+ this.entries = entries;\r
+ Collections.sort(entries);\r
+ }\r
+\r
+ @Override\r
+ public int getRowCount() {\r
+ return entries.size();\r
+ }\r
+\r
+ @Override\r
+ public int getColumnCount() {\r
+ return Columns.values().length;\r
+ }\r
+\r
+ @Override\r
+ public String getColumnName(int column) {\r
+ Columns col = Columns.values()[column];\r
+ switch (col) {\r
+ case Date:\r
+ return Translation.get("gb.date");\r
+ case Repository:\r
+ return Translation.get("gb.repository");\r
+ case Branch:\r
+ return Translation.get("gb.branch");\r
+ case Author:\r
+ return Translation.get("gb.author");\r
+ case Message:\r
+ return Translation.get("gb.message");\r
+ }\r
+ return "";\r
+ }\r
+\r
+ /**\r
+ * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
+ * \r
+ * @param columnIndex\r
+ * the column being queried\r
+ * @return the Object.class\r
+ */\r
+ public Class<?> getColumnClass(int columnIndex) {\r
+ if (Columns.Date.ordinal() == columnIndex) {\r
+ return Date.class;\r
+ } else if (Columns.Message.ordinal() == columnIndex) {\r
+ return FeedEntryModel.class;\r
+ }\r
+ return String.class;\r
+ }\r
+\r
+ @Override\r
+ public Object getValueAt(int rowIndex, int columnIndex) {\r
+ FeedEntryModel entry = entries.get(rowIndex);\r
+ Columns col = Columns.values()[columnIndex];\r
+ switch (col) {\r
+ case Date:\r
+ return entry.published;\r
+ case Repository:\r
+ return entry.repository;\r
+ case Branch:\r
+ return entry.branch;\r
+ case Author:\r
+ return entry.author;\r
+ case Message:\r
+ return entry;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public FeedEntryModel get(int modelRow) {\r
+ return entries.get(modelRow);\r
+ }\r
+}\r
import javax.swing.table.TableRowSorter;\r
\r
import com.gitblit.models.FeedModel;\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
\r
private final String ALL = "*";\r
\r
- private SyndicatedEntryTableModel tableModel;\r
+ private FeedEntryTableModel tableModel;\r
\r
- private TableRowSorter<SyndicatedEntryTableModel> defaultSorter;\r
+ private TableRowSorter<FeedEntryTableModel> defaultSorter;\r
\r
private HeaderPanel header;\r
\r
controls.add(viewTree);\r
\r
NameRenderer nameRenderer = new NameRenderer();\r
- tableModel = new SyndicatedEntryTableModel();\r
+ tableModel = new FeedEntryTableModel();\r
header = new HeaderPanel(Translation.get("gb.activity"), "feed_16x16.png");\r
table = Utils.newTable(tableModel, Utils.DATE_FORMAT);\r
- defaultSorter = new TableRowSorter<SyndicatedEntryTableModel>(tableModel);\r
- String name = table.getColumnName(SyndicatedEntryTableModel.Columns.Author.ordinal());\r
+ defaultSorter = new TableRowSorter<FeedEntryTableModel>(tableModel);\r
+ String name = table.getColumnName(FeedEntryTableModel.Columns.Author.ordinal());\r
table.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
table.getColumn(name).setCellRenderer(nameRenderer);\r
- name = table.getColumnName(SyndicatedEntryTableModel.Columns.Repository.ordinal());\r
+ name = table.getColumnName(FeedEntryTableModel.Columns.Repository.ordinal());\r
table.getColumn(name).setCellRenderer(nameRenderer);\r
\r
- name = table.getColumnName(SyndicatedEntryTableModel.Columns.Branch.ordinal());\r
+ name = table.getColumnName(FeedEntryTableModel.Columns.Branch.ordinal());\r
table.getColumn(name).setCellRenderer(new BranchRenderer());\r
\r
- name = table.getColumnName(SyndicatedEntryTableModel.Columns.Message.ordinal());\r
+ name = table.getColumnName(FeedEntryTableModel.Columns.Message.ordinal());\r
table.getColumn(name).setCellRenderer(new MessageRenderer(gitblit));\r
\r
table.addMouseListener(new MouseAdapter() {\r
if (page == 0) {\r
// determine unique repositories\r
Set<String> uniqueRepositories = new HashSet<String>();\r
- for (SyndicatedEntryModel entry : tableModel.entries) {\r
+ for (FeedEntryModel entry : tableModel.entries) {\r
uniqueRepositories.add(entry.repository);\r
}\r
\r
\r
// determine unique repositories and authors\r
Set<String> uniqueAuthors = new HashSet<String>();\r
- for (SyndicatedEntryModel entry : tableModel.entries) {\r
+ for (FeedEntryModel entry : tableModel.entries) {\r
if (repository.equals(ALL) || entry.repository.equalsIgnoreCase(repository)) {\r
uniqueAuthors.add(entry.author);\r
}\r
}\r
}\r
\r
- protected SyndicatedEntryModel getSelectedSyndicatedEntry() {\r
+ protected FeedEntryModel getSelectedSyndicatedEntry() {\r
int viewRow = table.getSelectedRow();\r
int modelRow = table.convertRowIndexToModel(viewRow);\r
- SyndicatedEntryModel entry = tableModel.get(modelRow);\r
+ FeedEntryModel entry = tableModel.get(modelRow);\r
return entry;\r
}\r
\r
protected void viewCommit() {\r
- SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+ FeedEntryModel entry = getSelectedSyndicatedEntry();\r
Utils.browse(entry.link);\r
}\r
\r
protected void viewCommitDiff() {\r
- SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+ FeedEntryModel entry = getSelectedSyndicatedEntry();\r
Utils.browse(entry.link.replace("/commit/", "/commitdiff/"));\r
}\r
\r
protected void viewTree() {\r
- SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+ FeedEntryModel entry = getSelectedSyndicatedEntry();\r
Utils.browse(entry.link.replace("/commit/", "/tree/"));\r
}\r
\r
table.setRowSorter(defaultSorter);\r
return;\r
}\r
- final int repositoryIndex = SyndicatedEntryTableModel.Columns.Repository.ordinal();\r
- final int authorIndex = SyndicatedEntryTableModel.Columns.Author.ordinal();\r
- RowFilter<SyndicatedEntryTableModel, Object> containsFilter;\r
+ final int repositoryIndex = FeedEntryTableModel.Columns.Repository.ordinal();\r
+ final int authorIndex = FeedEntryTableModel.Columns.Author.ordinal();\r
+ RowFilter<FeedEntryTableModel, Object> containsFilter;\r
if (repository.equals(ALL)) {\r
// author filter\r
- containsFilter = new RowFilter<SyndicatedEntryTableModel, Object>() {\r
+ containsFilter = new RowFilter<FeedEntryTableModel, Object>() {\r
public boolean include(\r
- Entry<? extends SyndicatedEntryTableModel, ? extends Object> entry) {\r
+ Entry<? extends FeedEntryTableModel, ? extends Object> entry) {\r
return entry.getStringValue(authorIndex).equalsIgnoreCase(author);\r
}\r
};\r
} else if (author.equals(ALL)) {\r
// repository filter\r
- containsFilter = new RowFilter<SyndicatedEntryTableModel, Object>() {\r
+ containsFilter = new RowFilter<FeedEntryTableModel, Object>() {\r
public boolean include(\r
- Entry<? extends SyndicatedEntryTableModel, ? extends Object> entry) {\r
+ Entry<? extends FeedEntryTableModel, ? extends Object> entry) {\r
return entry.getStringValue(repositoryIndex).equalsIgnoreCase(repository);\r
}\r
};\r
} else {\r
// repository-author filter\r
- containsFilter = new RowFilter<SyndicatedEntryTableModel, Object>() {\r
+ containsFilter = new RowFilter<FeedEntryTableModel, Object>() {\r
public boolean include(\r
- Entry<? extends SyndicatedEntryTableModel, ? extends Object> entry) {\r
+ Entry<? extends FeedEntryTableModel, ? extends Object> entry) {\r
boolean authorMatch = entry.getStringValue(authorIndex)\r
.equalsIgnoreCase(author);\r
boolean repositoryMatch = entry.getStringValue(repositoryIndex)\r
}\r
};\r
}\r
- TableRowSorter<SyndicatedEntryTableModel> sorter = new TableRowSorter<SyndicatedEntryTableModel>(\r
+ TableRowSorter<FeedEntryTableModel> sorter = new TableRowSorter<FeedEntryTableModel>(\r
tableModel);\r
sorter.setRowFilter(containsFilter);\r
table.setRowSorter(sorter);\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.ServerSettings;\r
import com.gitblit.models.ServerStatus;\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.RpcUtils;\r
import com.gitblit.utils.StringUtils;\r
\r
private final List<FeedModel> availableFeeds;\r
\r
- private final List<SyndicatedEntryModel> syndicatedEntries;\r
+ private final List<FeedEntryModel> syndicatedEntries;\r
\r
private final Set<String> subscribedRepositories;\r
\r
this.allRepositories = new ArrayList<RepositoryModel>();\r
this.federationRegistrations = new ArrayList<FederationModel>();\r
this.availableFeeds = new ArrayList<FeedModel>();\r
- this.syndicatedEntries = new ArrayList<SyndicatedEntryModel>();\r
+ this.syndicatedEntries = new ArrayList<FeedEntryModel>();\r
this.subscribedRepositories = new HashSet<String>();\r
}\r
\r
return availableFeeds;\r
}\r
\r
- public List<SyndicatedEntryModel> refreshSubscribedFeeds(int page) throws IOException {\r
- Set<SyndicatedEntryModel> allEntries = new HashSet<SyndicatedEntryModel>();\r
+ public List<FeedEntryModel> refreshSubscribedFeeds(int page) throws IOException {\r
+ Set<FeedEntryModel> allEntries = new HashSet<FeedEntryModel>();\r
if (reg.feeds.size() > 0) {\r
for (FeedModel feed : reg.feeds) {\r
feed.lastRefreshDate = feed.currentRefreshDate;\r
feed.currentRefreshDate = new Date();\r
- List<SyndicatedEntryModel> entries = SyndicationUtils.readFeed(url,\r
+ List<FeedEntryModel> entries = SyndicationUtils.readFeed(url,\r
feed.repository, feed.branch, -1, page, account, password);\r
allEntries.addAll(entries);\r
}\r
return subscribedRepositories.contains(repository.name.toLowerCase());\r
}\r
\r
- public List<SyndicatedEntryModel> getSyndicatedEntries() {\r
+ public List<FeedEntryModel> getSyndicatedEntries() {\r
return syndicatedEntries;\r
}\r
\r
- public List<SyndicatedEntryModel> search(String repository, String branch, String fragment,\r
+ public List<FeedEntryModel> log(String repository, String branch, int numberOfEntries,\r
+ int page) throws IOException {\r
+ return SyndicationUtils.readFeed(url, repository, branch, numberOfEntries, page, account,\r
+ password);\r
+ }\r
+\r
+ public List<FeedEntryModel> search(String repository, String branch, String fragment,\r
Constants.SearchType type, int numberOfEntries, int page) throws IOException {\r
return SyndicationUtils.readSearchFeed(url, repository, branch, fragment, type,\r
numberOfEntries, page, account, password);\r
import javax.swing.border.LineBorder;\r
import javax.swing.table.TableCellRenderer;\r
\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
\r
/**\r
* Message renderer displays the short log message and then any refs in a style\r
if (value == null) {\r
return this;\r
}\r
- SyndicatedEntryModel entry = (SyndicatedEntryModel) value;\r
+ FeedEntryModel entry = (FeedEntryModel) value;\r
\r
if (gitblit == null) {\r
// no gitblit client, just display message\r
}\r
});\r
\r
+ final JButton logRepository = new JButton(Translation.get("gb.log") + "...");\r
+ logRepository.setEnabled(false);\r
+ logRepository.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent e) {\r
+ RepositoryModel model = getSelectedRepositories().get(0);\r
+ showSearchDialog(false, model);\r
+ }\r
+ });\r
+\r
final JButton searchRepository = new JButton(Translation.get("gb.search") + "...");\r
searchRepository.setEnabled(false);\r
searchRepository.addActionListener(new ActionListener() {\r
public void actionPerformed(ActionEvent e) {\r
RepositoryModel model = getSelectedRepositories().get(0);\r
- searchRepository(model);\r
+ showSearchDialog(true, model);\r
}\r
});\r
\r
return;\r
}\r
boolean singleSelection = table.getSelectedRowCount() == 1;\r
- boolean selected = table.getSelectedRow() > -1; \r
+ boolean selected = table.getSelectedRow() > -1;\r
if (singleSelection) {\r
RepositoryModel repository = getSelectedRepositories().get(0);\r
browseRepository.setEnabled(repository.hasCommits);\r
+ logRepository.setEnabled(repository.hasCommits);\r
searchRepository.setEnabled(repository.hasCommits);\r
subscribeRepository.setEnabled(repository.hasCommits);\r
} else {\r
browseRepository.setEnabled(false);\r
+ logRepository.setEnabled(false);\r
searchRepository.setEnabled(false);\r
subscribeRepository.setEnabled(false);\r
}\r
- delRepository.setEnabled(selected); \r
+ delRepository.setEnabled(selected);\r
if (selected) {\r
int viewRow = table.getSelectedRow();\r
int modelRow = table.convertRowIndexToModel(viewRow);\r
repositoryControls.add(editRepository);\r
repositoryControls.add(delRepository);\r
repositoryControls.add(subscribeRepository);\r
+ repositoryControls.add(logRepository);\r
repositoryControls.add(searchRepository);\r
\r
setLayout(new BorderLayout(Utils.MARGIN, Utils.MARGIN));\r
}\r
}\r
\r
- protected void searchRepository(final RepositoryModel repository) {\r
- SearchDialog searchDialog = new SearchDialog(gitblit);\r
+ private void showSearchDialog(boolean isSearch, final RepositoryModel repository) {\r
+ final SearchDialog dialog = new SearchDialog(gitblit, isSearch);\r
if (repository != null) {\r
- searchDialog.selectRepository(repository);\r
+ dialog.selectRepository(repository);\r
}\r
- searchDialog.setLocationRelativeTo(this);\r
- searchDialog.setVisible(true);\r
+ dialog.setLocationRelativeTo(this);\r
+ dialog.setVisible(true);\r
}\r
}\r
\r
import com.gitblit.Constants;\r
import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
\r
private static final long serialVersionUID = 1L;\r
\r
+ private final boolean isSearch;\r
+\r
private final GitblitClient gitblit;\r
\r
- private SyndicatedEntryTableModel tableModel;\r
+ private FeedEntryTableModel tableModel;\r
\r
private HeaderPanel header;\r
\r
\r
private JButton next;\r
\r
- public SearchDialog(GitblitClient gitblit) {\r
+ public SearchDialog(GitblitClient gitblit, boolean isSearch) {\r
super();\r
this.gitblit = gitblit;\r
- setTitle(Translation.get("gb.search"));\r
- setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());\r
+ this.isSearch = isSearch;\r
+ setTitle(Translation.get(isSearch ? "gb.search" : "gb.log"));\r
+ setIconImage(new ImageIcon(getClass().getResource(\r
+ isSearch ? "/gitblt-favicon.png" : "/commit_changes_16x16.png")).getImage());\r
initialize();\r
- setSize(900, 400);\r
+ setSize(900, 550);\r
}\r
\r
private void initialize() {\r
}\r
});\r
\r
- final JButton search = new JButton(Translation.get("gb.search"));\r
+ final JButton search = new JButton(Translation.get(isSearch ? "gb.search" : "gb.refresh"));\r
search.addActionListener(new ActionListener() {\r
public void actionPerformed(ActionEvent e) {\r
search(0);\r
controls.add(viewTree);\r
\r
NameRenderer nameRenderer = new NameRenderer();\r
- tableModel = new SyndicatedEntryTableModel();\r
- header = new HeaderPanel(Translation.get("gb.search"), "search-icon.png");\r
+ tableModel = new FeedEntryTableModel();\r
+ header = new HeaderPanel(Translation.get(isSearch ? "gb.search" : "gb.log"),\r
+ isSearch ? "search-icon.png" : "commit_changes_16x16.png");\r
table = Utils.newTable(tableModel, Utils.DATE_FORMAT);\r
\r
- String name = table.getColumnName(SyndicatedEntryTableModel.Columns.Author.ordinal());\r
+ String name = table.getColumnName(FeedEntryTableModel.Columns.Author.ordinal());\r
table.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
table.getColumn(name).setCellRenderer(nameRenderer);\r
- name = table.getColumnName(SyndicatedEntryTableModel.Columns.Repository.ordinal());\r
+ name = table.getColumnName(FeedEntryTableModel.Columns.Repository.ordinal());\r
table.getColumn(name).setCellRenderer(nameRenderer);\r
\r
- name = table.getColumnName(SyndicatedEntryTableModel.Columns.Branch.ordinal());\r
+ name = table.getColumnName(FeedEntryTableModel.Columns.Branch.ordinal());\r
table.getColumn(name).setCellRenderer(new BranchRenderer());\r
\r
- name = table.getColumnName(SyndicatedEntryTableModel.Columns.Message.ordinal());\r
+ name = table.getColumnName(FeedEntryTableModel.Columns.Message.ordinal());\r
table.getColumn(name).setCellRenderer(new MessageRenderer());\r
\r
table.addMouseListener(new MouseAdapter() {\r
\r
branchChoices = new DefaultComboBoxModel();\r
branchSelector = new JComboBox(branchChoices);\r
- branchSelector.setRenderer(new BranchRenderer()); \r
+ branchSelector.setRenderer(new BranchRenderer());\r
\r
searchTypeSelector = new JComboBox(Constants.SearchType.values());\r
searchTypeSelector.setSelectedItem(Constants.SearchType.COMMIT);\r
queryPanel.add(repositorySelector);\r
queryPanel.add(new JLabel(Translation.get("gb.branch")));\r
queryPanel.add(branchSelector);\r
- queryPanel.add(new JLabel(Translation.get("gb.type")));\r
- queryPanel.add(searchTypeSelector);\r
+ if (isSearch) {\r
+ queryPanel.add(new JLabel(Translation.get("gb.type")));\r
+ queryPanel.add(searchTypeSelector);\r
+ }\r
queryPanel.add(new JLabel(Translation.get("gb.maxHits")));\r
queryPanel.add(maxHitsSelector);\r
\r
\r
JPanel northControls = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));\r
northControls.add(queryPanel, BorderLayout.WEST);\r
- northControls.add(searchFragment, BorderLayout.CENTER);\r
+ if (isSearch) {\r
+ northControls.add(searchFragment, BorderLayout.CENTER);\r
+ }\r
northControls.add(actionsPanel, BorderLayout.EAST);\r
- \r
\r
JPanel northPanel = new JPanel(new BorderLayout(0, Utils.MARGIN));\r
northPanel.add(header, BorderLayout.NORTH);\r
contentPanel.add(controls, BorderLayout.SOUTH);\r
setLayout(new BorderLayout());\r
add(contentPanel, BorderLayout.CENTER);\r
- addWindowListener(new WindowAdapter() {\r
- @Override\r
- public void windowOpened(WindowEvent event) {\r
- searchFragment.requestFocus();\r
- }\r
+ if (isSearch) {\r
+ addWindowListener(new WindowAdapter() {\r
+ @Override\r
+ public void windowOpened(WindowEvent event) {\r
+ searchFragment.requestFocus();\r
+ }\r
\r
- @Override\r
- public void windowActivated(WindowEvent event) {\r
- searchFragment.requestFocus();\r
- }\r
- });\r
+ @Override\r
+ public void windowActivated(WindowEvent event) {\r
+ searchFragment.requestFocus();\r
+ }\r
+ });\r
+ }\r
}\r
\r
public void selectRepository(RepositoryModel repository) {\r
.getSelectedItem().toString() : null;\r
final Constants.SearchType searchType = (Constants.SearchType) searchTypeSelector\r
.getSelectedItem();\r
- final String fragment = searchFragment.getText();\r
+ final String fragment = isSearch ? searchFragment.getText() : null;\r
final int maxEntryCount = maxHitsSelector.getSelectedIndex() > -1 ? ((Integer) maxHitsSelector\r
.getSelectedItem()) : -1;\r
\r
- if (StringUtils.isEmpty(fragment)) {\r
+ if (isSearch && StringUtils.isEmpty(fragment)) {\r
return;\r
}\r
- SwingWorker<List<SyndicatedEntryModel>, Void> worker = new SwingWorker<List<SyndicatedEntryModel>, Void>() {\r
+ SwingWorker<List<FeedEntryModel>, Void> worker = new SwingWorker<List<FeedEntryModel>, Void>() {\r
@Override\r
- protected List<SyndicatedEntryModel> doInBackground() throws IOException {\r
- return gitblit\r
- .search(repository, branch, fragment, searchType, maxEntryCount, page);\r
+ protected List<FeedEntryModel> doInBackground() throws IOException {\r
+ if (isSearch) {\r
+ return gitblit.search(repository, branch, fragment, searchType, maxEntryCount,\r
+ page);\r
+ } else {\r
+ return gitblit.log(repository, branch, maxEntryCount, page);\r
+ }\r
}\r
\r
@Override\r
protected void done() {\r
try {\r
- List<SyndicatedEntryModel> results = get();\r
- updateTable(true, fragment, results);\r
+ List<FeedEntryModel> results = get();\r
+ if (isSearch) {\r
+ updateTable(true, fragment, results);\r
+ } else {\r
+ updateTable(true, branch == null ? "" : branch, results);\r
+ }\r
} catch (Throwable t) {\r
Utils.showException(SearchDialog.this, t);\r
}\r
worker.execute();\r
}\r
\r
- protected void updateTable(boolean pack, String fragment, List<SyndicatedEntryModel> entries) {\r
+ protected void updateTable(boolean pack, String text, List<FeedEntryModel> entries) {\r
tableModel.entries.clear();\r
tableModel.entries.addAll(entries);\r
tableModel.fireTableDataChanged();\r
- setTitle(Translation.get("gb.search") + ": " + fragment + " (" + entries.size()\r
- + (page > 0 ? (", pg " + (page + 1)) : "") + ")");\r
+ setTitle(Translation.get(isSearch ? "gb.search" : "gb.log") + ": " + text + " ("\r
+ + entries.size() + (page > 0 ? (", pg " + (page + 1)) : "") + ")");\r
header.setText(getTitle());\r
if (pack) {\r
Utils.packColumns(table, Utils.MARGIN);\r
prev.setEnabled(page > 0);\r
}\r
\r
- protected SyndicatedEntryModel getSelectedSyndicatedEntry() {\r
+ protected FeedEntryModel getSelectedSyndicatedEntry() {\r
int viewRow = table.getSelectedRow();\r
int modelRow = table.convertRowIndexToModel(viewRow);\r
- SyndicatedEntryModel entry = tableModel.get(modelRow);\r
+ FeedEntryModel entry = tableModel.get(modelRow);\r
return entry;\r
}\r
\r
protected void viewCommit() {\r
- SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+ FeedEntryModel entry = getSelectedSyndicatedEntry();\r
Utils.browse(entry.link);\r
}\r
\r
protected void viewCommitDiff() {\r
- SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+ FeedEntryModel entry = getSelectedSyndicatedEntry();\r
Utils.browse(entry.link.replace("/commit/", "/commitdiff/"));\r
}\r
\r
protected void viewTree() {\r
- SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+ FeedEntryModel entry = getSelectedSyndicatedEntry();\r
Utils.browse(entry.link.replace("/commit/", "/tree/"));\r
}\r
}\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import javax.swing.table.AbstractTableModel;\r
-\r
-import com.gitblit.models.SyndicatedEntryModel;\r
-\r
-/**\r
- * Table model for a list of retrieved feed entries.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public class SyndicatedEntryTableModel extends AbstractTableModel {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- List<SyndicatedEntryModel> entries;\r
-\r
- enum Columns {\r
- Date, Repository, Branch, Author, Message;\r
-\r
- @Override\r
- public String toString() {\r
- return name().replace('_', ' ');\r
- }\r
- }\r
-\r
- public SyndicatedEntryTableModel() {\r
- this.entries = new ArrayList<SyndicatedEntryModel>();\r
- }\r
-\r
- public void setEntries(List<SyndicatedEntryModel> entries) {\r
- this.entries = entries;\r
- Collections.sort(entries);\r
- }\r
-\r
- @Override\r
- public int getRowCount() {\r
- return entries.size();\r
- }\r
-\r
- @Override\r
- public int getColumnCount() {\r
- return Columns.values().length;\r
- }\r
-\r
- @Override\r
- public String getColumnName(int column) {\r
- Columns col = Columns.values()[column];\r
- switch (col) {\r
- case Date:\r
- return Translation.get("gb.date");\r
- case Repository:\r
- return Translation.get("gb.repository");\r
- case Branch:\r
- return Translation.get("gb.branch");\r
- case Author:\r
- return Translation.get("gb.author");\r
- case Message:\r
- return Translation.get("gb.message");\r
- }\r
- return "";\r
- }\r
-\r
- /**\r
- * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
- * \r
- * @param columnIndex\r
- * the column being queried\r
- * @return the Object.class\r
- */\r
- public Class<?> getColumnClass(int columnIndex) {\r
- if (Columns.Date.ordinal() == columnIndex) {\r
- return Date.class;\r
- } else if (Columns.Message.ordinal() == columnIndex) {\r
- return SyndicatedEntryModel.class;\r
- }\r
- return String.class;\r
- }\r
-\r
- @Override\r
- public Object getValueAt(int rowIndex, int columnIndex) {\r
- SyndicatedEntryModel entry = entries.get(rowIndex);\r
- Columns col = Columns.values()[columnIndex];\r
- switch (col) {\r
- case Date:\r
- return entry.published;\r
- case Repository:\r
- return entry.repository;\r
- case Branch:\r
- return entry.branch;\r
- case Author:\r
- return entry.author;\r
- case Message:\r
- return entry;\r
- }\r
- return null;\r
- }\r
-\r
- public SyndicatedEntryModel get(int modelRow) {\r
- return entries.get(modelRow);\r
- }\r
-}\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.models;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+import java.util.List;\r
+\r
+/**\r
+ * FeedEntryModel represents an entry in a syndication (RSS) feed.\r
+ * \r
+ * @author James Moger\r
+ */\r
+public class FeedEntryModel implements Serializable, Comparable<FeedEntryModel> {\r
+\r
+ public String repository;\r
+ public String branch;\r
+ public String title;\r
+ public String author;\r
+ public Date published;\r
+ public String link;\r
+ public String content;\r
+ public String contentType;\r
+ public List<String> tags;\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ public FeedEntryModel() {\r
+ }\r
+\r
+ @Override\r
+ public int compareTo(FeedEntryModel o) {\r
+ return o.published.compareTo(published);\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return link.hashCode();\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object o) {\r
+ if (o instanceof FeedEntryModel) {\r
+ return hashCode() == o.hashCode();\r
+ }\r
+ return false;\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.models;\r
-\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-/**\r
- * SyndicationEntryModel represents an entry in a syndication (RSS) feed.\r
- * \r
- * @author James Moger\r
- */\r
-public class SyndicatedEntryModel implements Serializable, Comparable<SyndicatedEntryModel> {\r
-\r
- public String repository;\r
- public String branch;\r
- public String title;\r
- public String author;\r
- public Date published;\r
- public String link;\r
- public String content;\r
- public String contentType;\r
- public List<String> tags;\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- public SyndicatedEntryModel() {\r
- }\r
-\r
- @Override\r
- public int compareTo(SyndicatedEntryModel o) {\r
- return o.published.compareTo(published);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return link.hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object o) {\r
- if (o instanceof SyndicatedEntryModel) {\r
- return hashCode() == o.hashCode();\r
- }\r
- return false;\r
- }\r
-}\r
\r
import com.gitblit.Constants;\r
import com.gitblit.GitBlitException;\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
import com.sun.syndication.feed.synd.SyndCategory;\r
import com.sun.syndication.feed.synd.SyndCategoryImpl;\r
import com.sun.syndication.feed.synd.SyndContent;\r
* @throws FeedException\r
*/\r
public static void toRSS(String hostUrl, String feedLink, String title, String description,\r
- String repository, List<SyndicatedEntryModel> entryModels, OutputStream os)\r
+ String repository, List<FeedEntryModel> entryModels, OutputStream os)\r
throws IOException, FeedException {\r
\r
SyndFeed feed = new SyndFeedImpl();\r
feed.setImage(image);\r
\r
List<SyndEntry> entries = new ArrayList<SyndEntry>();\r
- for (SyndicatedEntryModel entryModel : entryModels) {\r
+ for (FeedEntryModel entryModel : entryModels) {\r
SyndEntry entry = new SyndEntryImpl();\r
entry.setTitle(entryModel.title);\r
entry.setAuthor(entryModel.author);\r
* @return a list of SyndicationModel entries\r
* @throws {@link IOException}\r
*/\r
- public static List<SyndicatedEntryModel> readFeed(String url, String repository, String branch,\r
+ public static List<FeedEntryModel> readFeed(String url, String repository, String branch,\r
int numberOfEntries, int page, String username, char[] password) throws IOException {\r
// build feed url\r
List<String> parameters = new ArrayList<String>();\r
* @return a list of SyndicationModel entries\r
* @throws {@link IOException}\r
*/\r
- public static List<SyndicatedEntryModel> readSearchFeed(String url, String repository,\r
+ public static List<FeedEntryModel> readSearchFeed(String url, String repository,\r
String branch, String fragment, Constants.SearchType searchType, int numberOfEntries,\r
int page, String username, char[] password) throws IOException {\r
// determine parameters\r
* @return a list of SyndicationModel entries\r
* @throws {@link IOException}\r
*/\r
- private static List<SyndicatedEntryModel> readFeed(String url, List<String> parameters,\r
+ private static List<FeedEntryModel> readFeed(String url, List<String> parameters,\r
String repository, String branch, String username, char[] password) throws IOException {\r
// build url\r
StringBuilder sb = new StringBuilder();\r
throw new GitBlitException(f);\r
}\r
is.close();\r
- List<SyndicatedEntryModel> entries = new ArrayList<SyndicatedEntryModel>();\r
+ List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();\r
for (Object o : feed.getEntries()) {\r
SyndEntryImpl entry = (SyndEntryImpl) o;\r
- SyndicatedEntryModel model = new SyndicatedEntryModel();\r
+ FeedEntryModel model = new FeedEntryModel();\r
model.repository = repository;\r
model.branch = branch;\r
model.title = entry.getTitle();\r
import junit.framework.TestCase;\r
\r
import com.gitblit.Constants.SearchType;\r
-import com.gitblit.models.SyndicatedEntryModel;\r
+import com.gitblit.models.FeedEntryModel;\r
import com.gitblit.utils.SyndicationUtils;\r
\r
public class SyndicationUtilsTest extends TestCase {\r
\r
public void testSyndication() throws Exception {\r
- List<SyndicatedEntryModel> entries = new ArrayList<SyndicatedEntryModel>();\r
+ List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();\r
for (int i = 0; i < 10; i++) {\r
- SyndicatedEntryModel entry = new SyndicatedEntryModel();\r
+ FeedEntryModel entry = new FeedEntryModel();\r
entry.title = "Title " + i;\r
entry.author = "Author " + i;\r
entry.link = "Link " + i;\r
public void testFeedRead() throws Exception {\r
Set<String> links = new HashSet<String>();\r
for (int i = 0; i < 2; i++) {\r
- List<SyndicatedEntryModel> feed = SyndicationUtils.readFeed(GitBlitSuite.url,\r
+ List<FeedEntryModel> feed = SyndicationUtils.readFeed(GitBlitSuite.url,\r
"ticgit.git", "master", 5, i, GitBlitSuite.account,\r
GitBlitSuite.password.toCharArray());\r
assertTrue(feed != null);\r
assertTrue(feed.size() > 0);\r
assertEquals(5, feed.size());\r
- for (SyndicatedEntryModel entry : feed) {\r
+ for (FeedEntryModel entry : feed) {\r
links.add(entry.link);\r
}\r
}\r
}\r
\r
public void testSearchFeedRead() throws Exception {\r
- List<SyndicatedEntryModel> feed = SyndicationUtils.readSearchFeed(GitBlitSuite.url,\r
+ List<FeedEntryModel> feed = SyndicationUtils.readSearchFeed(GitBlitSuite.url,\r
"ticgit.git", null, "test", null, 5, 0, GitBlitSuite.account,\r
GitBlitSuite.password.toCharArray());\r
assertTrue(feed != null);\r