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