From: James Moger Date: Thu, 3 Nov 2011 21:11:47 +0000 (-0400) Subject: Revised branch rendering. Added ref rendering to message column. X-Git-Tag: v0.7.0~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=609a16e10fb705e146e7fd4b0fe48c744d40a2e0;p=gitblit.git Revised branch rendering. Added ref rendering to message column. --- diff --git a/docs/05_roadmap.mkd b/docs/05_roadmap.mkd index 511e9bb8..a7f21a3b 100644 --- a/docs/05_roadmap.mkd +++ b/docs/05_roadmap.mkd @@ -7,7 +7,6 @@ This list is volatile. * Eclipse: create plugin to enumerate repositories and delegate cloning to EGit * Manager: support federation RPCs -* Manager: RSS feed reader tab ### TODO (medium priority) diff --git a/src/com/gitblit/client/BranchRenderer.java b/src/com/gitblit/client/BranchRenderer.java index b8f55f09..532a432e 100644 --- a/src/com/gitblit/client/BranchRenderer.java +++ b/src/com/gitblit/client/BranchRenderer.java @@ -17,24 +17,18 @@ package com.gitblit.client; import java.awt.Color; import java.awt.Component; -import java.awt.FlowLayout; -import java.io.Serializable; -import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JTable; -import javax.swing.border.Border; -import javax.swing.border.LineBorder; -import javax.swing.table.TableCellRenderer; +import javax.swing.table.DefaultTableCellRenderer; /** - * Branch renderer displays refs/heads and refs/remotes in a style like the - * site. + * Branch renderer displays refs/heads and refs/remotes in a color similar to + * the site. * * @author James Moger * */ -public class BranchRenderer extends JPanel implements TableCellRenderer, Serializable { +public class BranchRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; @@ -42,37 +36,20 @@ public class BranchRenderer extends JPanel implements TableCellRenderer, Seriali private static final String R_REMOTES = "refs/remotes/"; - private JLabel branchLabel; - - public BranchRenderer() { - super(new FlowLayout(FlowLayout.CENTER, 0, 1)); - branchLabel = new JLabel(); - branchLabel.setOpaque(true); - add(branchLabel); - } - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - if (isSelected) - setBackground(table.getSelectionBackground()); - else - setBackground(table.getBackground()); - + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); String name = value.toString(); - Color bg = getBackground(); - Border border = null; + Color fg = getForeground(); if (name.startsWith(R_HEADS)) { - bg = Color.decode("#CCFFCC"); name = name.substring(R_HEADS.length()); - border = new LineBorder(Color.decode("#00CC33"), 1); + fg = new Color(0, 0x80, 0); } else if (name.startsWith(R_REMOTES)) { - bg = Color.decode("#CAC2F5"); name = name.substring(R_REMOTES.length()); - border = new LineBorder(Color.decode("#6C6CBF"), 1); + fg = Color.decode("#6C6CBF"); } - branchLabel.setText(" " + name + " "); - branchLabel.setBackground(bg); - branchLabel.setBorder(border); + setText(name); + setForeground(isSelected ? table.getSelectionForeground() : fg); return this; } } \ No newline at end of file diff --git a/src/com/gitblit/client/FeedsPanel.java b/src/com/gitblit/client/FeedsPanel.java index a9a24731..a8094f80 100644 --- a/src/com/gitblit/client/FeedsPanel.java +++ b/src/com/gitblit/client/FeedsPanel.java @@ -41,7 +41,6 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.TableRowSorter; -import com.gitblit.Constants.RpcRequest; import com.gitblit.models.FeedModel; import com.gitblit.models.SyndicatedEntryModel; import com.gitblit.utils.StringUtils; @@ -130,8 +129,8 @@ public abstract class FeedsPanel extends JPanel { controls.add(viewTree); NameRenderer nameRenderer = new NameRenderer(); - tableModel = new SyndicatedEntryTableModel(gitblit); - header = new HeaderPanel(Translation.get("gb.timeline"), "feed_16x16.png"); + tableModel = new SyndicatedEntryTableModel(); + header = new HeaderPanel(Translation.get("gb.activity"), "feed_16x16.png"); table = Utils.newTable(tableModel, Utils.DATE_FORMAT); defaultSorter = new TableRowSorter(tableModel); String name = table.getColumnName(SyndicatedEntryTableModel.Columns.Author.ordinal()); @@ -143,6 +142,9 @@ public abstract class FeedsPanel extends JPanel { name = table.getColumnName(SyndicatedEntryTableModel.Columns.Branch.ordinal()); table.getColumn(name).setCellRenderer(new BranchRenderer()); + name = table.getColumnName(SyndicatedEntryTableModel.Columns.Message.ordinal()); + table.getColumn(name).setCellRenderer(new MessageRenderer(gitblit)); + table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { @@ -220,8 +222,7 @@ public abstract class FeedsPanel extends JPanel { } protected void refreshFeeds() { - // TODO change request type here - GitblitWorker worker = new GitblitWorker(FeedsPanel.this, RpcRequest.LIST_USERS) { + GitblitWorker worker = new GitblitWorker(FeedsPanel.this, null) { @Override protected Boolean doRequest() throws IOException { gitblit.refreshSubscribedFeeds(); @@ -242,7 +243,7 @@ public abstract class FeedsPanel extends JPanel { tableModel.entries.clear(); tableModel.entries.addAll(gitblit.getSyndicatedEntries()); tableModel.fireTableDataChanged(); - header.setText(Translation.get("gb.timeline") + " (" + header.setText(Translation.get("gb.activity") + " (" + gitblit.getSyndicatedEntries().size() + ")"); if (pack) { Utils.packColumns(table, Utils.MARGIN); diff --git a/src/com/gitblit/client/GitblitManager.java b/src/com/gitblit/client/GitblitManager.java index a16cfe64..dd0315f2 100644 --- a/src/com/gitblit/client/GitblitManager.java +++ b/src/com/gitblit/client/GitblitManager.java @@ -400,7 +400,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist } private void loadFeedCache(GitblitRegistration reg) { - File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.url) + File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.toString()) + ".cache"); if (!feedCache.exists()) { // no cache for this registration @@ -429,8 +429,8 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist private void writeFeedCache(GitblitRegistration reg) { try { - File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.url) - + ".cache"); + File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg + .toString()) + ".cache"); FileWriter writer = new FileWriter(feedCache); for (FeedModel feed : reg.feeds) { writer.append(MessageFormat.format("{0}={1,date,yyyy-MM-dd'T'HH:mm:ss}\n", diff --git a/src/com/gitblit/client/GitblitPanel.java b/src/com/gitblit/client/GitblitPanel.java index f675b4a6..0e670ae3 100644 --- a/src/com/gitblit/client/GitblitPanel.java +++ b/src/com/gitblit/client/GitblitPanel.java @@ -61,7 +61,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener { tabs = new JTabbedPane(JTabbedPane.BOTTOM); tabs.addTab(Translation.get("gb.repositories"), createRepositoriesPanel()); - tabs.addTab(Translation.get("gb.timeline"), createFeedsPanel()); + tabs.addTab(Translation.get("gb.activity"), createFeedsPanel()); tabs.addTab(Translation.get("gb.users"), createUsersPanel()); tabs.addTab(Translation.get("gb.settings"), createSettingsPanel()); tabs.addTab(Translation.get("gb.status"), createStatusPanel()); diff --git a/src/com/gitblit/client/GitblitRegistration.java b/src/com/gitblit/client/GitblitRegistration.java index 33399b16..f9d07488 100644 --- a/src/com/gitblit/client/GitblitRegistration.java +++ b/src/com/gitblit/client/GitblitRegistration.java @@ -71,11 +71,16 @@ public class GitblitRegistration implements Serializable, Comparable" + entry.title); + } else { + messageLabel.setText(entry.title); + } + + // reset ref label + branchLabel.setText(""); + branchLabel.setBackground(messageLabel.getBackground()); + branchLabel.setBorder(null); + + if (entry.tags != null) { + for (String tag : entry.tags) { + if (tag.equals(entry.branch)) { + continue; + } + String name = tag; + Color bg = getBackground(); + Border border = null; + if (name.startsWith(R_HEADS)) { + // local branch + bg = Color.decode("#CCFFCC"); + name = name.substring(R_HEADS.length()); + border = new LineBorder(Color.decode("#00CC33"), 1); + } else if (name.startsWith(R_REMOTES)) { + // origin branch + bg = Color.decode("#CAC2F5"); + name = name.substring(R_REMOTES.length()); + border = new LineBorder(Color.decode("#6C6CBF"), 1); + } else if (name.startsWith(R_TAGS)) { + // tag + bg = Color.decode("#FFFFAA"); + name = name.substring(R_TAGS.length()); + border = new LineBorder(Color.decode("#FFCC00"), 1); + } else if (name.equals("HEAD")) { + // HEAD + bg = Color.decode("#FFAAFF"); + border = new LineBorder(Color.decode("#FF00EE"), 1); + } else { + + } + branchLabel.setText(" " + name + " "); + branchLabel.setBackground(bg); + branchLabel.setBorder(border); + } + } + + return this; + } +} \ No newline at end of file diff --git a/src/com/gitblit/client/SyndicatedEntryTableModel.java b/src/com/gitblit/client/SyndicatedEntryTableModel.java index 93177a8f..8fcdb47d 100644 --- a/src/com/gitblit/client/SyndicatedEntryTableModel.java +++ b/src/com/gitblit/client/SyndicatedEntryTableModel.java @@ -34,12 +34,10 @@ public class SyndicatedEntryTableModel extends AbstractTableModel { private static final long serialVersionUID = 1L; - private final GitblitClient gitblit; - List entries; enum Columns { - Date, Repository, Author, Message, Branch; + Date, Repository, Branch, Author, Message; @Override public String toString() { @@ -47,8 +45,7 @@ public class SyndicatedEntryTableModel extends AbstractTableModel { } } - public SyndicatedEntryTableModel(GitblitClient gitblit) { - this.gitblit = gitblit; + public SyndicatedEntryTableModel() { this.entries = new ArrayList(); } @@ -95,6 +92,8 @@ public class SyndicatedEntryTableModel extends AbstractTableModel { public Class getColumnClass(int columnIndex) { if (Columns.Date.ordinal() == columnIndex) { return Date.class; + } else if (Columns.Message.ordinal() == columnIndex) { + return SyndicatedEntryModel.class; } return String.class; } @@ -113,11 +112,7 @@ public class SyndicatedEntryTableModel extends AbstractTableModel { case Author: return entry.author; case Message: - Date lastRefresh = gitblit.getLastFeedRefresh(entry.repository, entry.branch); - if (entry.published.after(lastRefresh)) { - return "" + entry.title; - } - return entry.title; + return entry; } return null; } diff --git a/src/com/gitblit/models/SyndicatedEntryModel.java b/src/com/gitblit/models/SyndicatedEntryModel.java index a1c12211..f59418ed 100644 --- a/src/com/gitblit/models/SyndicatedEntryModel.java +++ b/src/com/gitblit/models/SyndicatedEntryModel.java @@ -17,6 +17,7 @@ package com.gitblit.models; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * SyndicationEntryModel represents an entry in a syndication (RSS) feed. @@ -33,6 +34,7 @@ public class SyndicatedEntryModel implements Serializable, Comparable tags; private static final long serialVersionUID = 1L; diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 96a5bc86..3ab1b7a4 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -177,6 +177,6 @@ gb.free = free gb.version = version gb.releaseDate = release date gb.date = date -gb.timeline = timeline +gb.activity = activity gb.subscribe = subscribe gb.branch = branch \ No newline at end of file