\r
* Eclipse: create plugin to enumerate repositories and delegate cloning to EGit\r
* Manager: support federation RPCs\r
-* Manager: RSS feed reader tab \r
\r
### TODO (medium priority)\r
\r
\r
import java.awt.Color;\r
import java.awt.Component;\r
-import java.awt.FlowLayout;\r
-import java.io.Serializable;\r
\r
-import javax.swing.JLabel;\r
-import javax.swing.JPanel;\r
import javax.swing.JTable;\r
-import javax.swing.border.Border;\r
-import javax.swing.border.LineBorder;\r
-import javax.swing.table.TableCellRenderer;\r
+import javax.swing.table.DefaultTableCellRenderer;\r
\r
/**\r
- * Branch renderer displays refs/heads and refs/remotes in a style like the\r
- * site.\r
+ * Branch renderer displays refs/heads and refs/remotes in a color similar to\r
+ * the site.\r
* \r
* @author James Moger\r
* \r
*/\r
-public class BranchRenderer extends JPanel implements TableCellRenderer, Serializable {\r
+public class BranchRenderer extends DefaultTableCellRenderer {\r
\r
private static final long serialVersionUID = 1L;\r
\r
\r
private static final String R_REMOTES = "refs/remotes/";\r
\r
- private JLabel branchLabel;\r
-\r
- public BranchRenderer() {\r
- super(new FlowLayout(FlowLayout.CENTER, 0, 1));\r
- branchLabel = new JLabel();\r
- branchLabel.setOpaque(true);\r
- add(branchLabel);\r
- }\r
-\r
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,\r
boolean hasFocus, int row, int column) {\r
- if (isSelected)\r
- setBackground(table.getSelectionBackground());\r
- else\r
- setBackground(table.getBackground());\r
-\r
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);\r
String name = value.toString();\r
- Color bg = getBackground();\r
- Border border = null;\r
+ Color fg = getForeground();\r
if (name.startsWith(R_HEADS)) {\r
- bg = Color.decode("#CCFFCC");\r
name = name.substring(R_HEADS.length());\r
- border = new LineBorder(Color.decode("#00CC33"), 1);\r
+ fg = new Color(0, 0x80, 0);\r
} else if (name.startsWith(R_REMOTES)) {\r
- bg = Color.decode("#CAC2F5");\r
name = name.substring(R_REMOTES.length());\r
- border = new LineBorder(Color.decode("#6C6CBF"), 1);\r
+ fg = Color.decode("#6C6CBF");\r
}\r
- branchLabel.setText(" " + name + " ");\r
- branchLabel.setBackground(bg);\r
- branchLabel.setBorder(border);\r
+ setText(name);\r
+ setForeground(isSelected ? table.getSelectionForeground() : fg);\r
return this;\r
}\r
}
\ No newline at end of file
import javax.swing.event.ListSelectionListener;\r
import javax.swing.table.TableRowSorter;\r
\r
-import com.gitblit.Constants.RpcRequest;\r
import com.gitblit.models.FeedModel;\r
import com.gitblit.models.SyndicatedEntryModel;\r
import com.gitblit.utils.StringUtils;\r
controls.add(viewTree);\r
\r
NameRenderer nameRenderer = new NameRenderer();\r
- tableModel = new SyndicatedEntryTableModel(gitblit);\r
- header = new HeaderPanel(Translation.get("gb.timeline"), "feed_16x16.png");\r
+ tableModel = new SyndicatedEntryTableModel();\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
name = table.getColumnName(SyndicatedEntryTableModel.Columns.Branch.ordinal());\r
table.getColumn(name).setCellRenderer(new BranchRenderer());\r
\r
+ name = table.getColumnName(SyndicatedEntryTableModel.Columns.Message.ordinal());\r
+ table.getColumn(name).setCellRenderer(new MessageRenderer(gitblit));\r
+\r
table.addMouseListener(new MouseAdapter() {\r
public void mouseClicked(MouseEvent e) {\r
if (e.getClickCount() == 2) {\r
}\r
\r
protected void refreshFeeds() {\r
- // TODO change request type here\r
- GitblitWorker worker = new GitblitWorker(FeedsPanel.this, RpcRequest.LIST_USERS) {\r
+ GitblitWorker worker = new GitblitWorker(FeedsPanel.this, null) {\r
@Override\r
protected Boolean doRequest() throws IOException {\r
gitblit.refreshSubscribedFeeds();\r
tableModel.entries.clear();\r
tableModel.entries.addAll(gitblit.getSyndicatedEntries());\r
tableModel.fireTableDataChanged();\r
- header.setText(Translation.get("gb.timeline") + " ("\r
+ header.setText(Translation.get("gb.activity") + " ("\r
+ gitblit.getSyndicatedEntries().size() + ")");\r
if (pack) {\r
Utils.packColumns(table, Utils.MARGIN);\r
}\r
\r
private void loadFeedCache(GitblitRegistration reg) {\r
- File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.url)\r
+ File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.toString())\r
+ ".cache");\r
if (!feedCache.exists()) {\r
// no cache for this registration\r
\r
private void writeFeedCache(GitblitRegistration reg) {\r
try {\r
- File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.url)\r
- + ".cache");\r
+ File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg\r
+ .toString()) + ".cache");\r
FileWriter writer = new FileWriter(feedCache);\r
for (FeedModel feed : reg.feeds) {\r
writer.append(MessageFormat.format("{0}={1,date,yyyy-MM-dd'T'HH:mm:ss}\n",\r
\r
tabs = new JTabbedPane(JTabbedPane.BOTTOM);\r
tabs.addTab(Translation.get("gb.repositories"), createRepositoriesPanel());\r
- tabs.addTab(Translation.get("gb.timeline"), createFeedsPanel());\r
+ tabs.addTab(Translation.get("gb.activity"), createFeedsPanel());\r
tabs.addTab(Translation.get("gb.users"), createUsersPanel());\r
tabs.addTab(Translation.get("gb.settings"), createSettingsPanel());\r
tabs.addTab(Translation.get("gb.status"), createStatusPanel());\r
}\r
}\r
\r
+ protected void cacheFeeds() {\r
+ }\r
+\r
@Override\r
public int compareTo(GitblitRegistration o) {\r
return name.toLowerCase().compareTo(o.name.toLowerCase());\r
}\r
\r
- protected void cacheFeeds() {\r
+ @Override\r
+ public String toString() {\r
+ return name + " (" + url + ")";\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.awt.Color;\r
+import java.awt.Component;\r
+import java.awt.FlowLayout;\r
+import java.awt.Font;\r
+import java.io.Serializable;\r
+\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTable;\r
+import javax.swing.border.Border;\r
+import javax.swing.border.LineBorder;\r
+import javax.swing.table.TableCellRenderer;\r
+\r
+import com.gitblit.models.SyndicatedEntryModel;\r
+\r
+/**\r
+ * Message renderer displays the short log message and then any refs in a style\r
+ * like the site.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class MessageRenderer extends JPanel implements TableCellRenderer, Serializable {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ private static final String R_TAGS = "refs/tags/";\r
+\r
+ private static final String R_HEADS = "refs/heads/";\r
+\r
+ private static final String R_REMOTES = "refs/remotes/";\r
+\r
+ private final GitblitClient gitblit;\r
+\r
+ private final JLabel messageLabel;\r
+\r
+ private final JLabel branchLabel;\r
+\r
+ public MessageRenderer(GitblitClient gitblit) {\r
+ super(new FlowLayout(FlowLayout.LEFT, 10, 1));\r
+ this.gitblit = gitblit;\r
+\r
+ messageLabel = new JLabel();\r
+ branchLabel = new JLabel();\r
+ branchLabel.setOpaque(true);\r
+ Font font = branchLabel.getFont();\r
+ branchLabel.setFont(font.deriveFont(font.getSize2D() - 1f));\r
+ add(messageLabel);\r
+ add(branchLabel);\r
+ }\r
+\r
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,\r
+ boolean hasFocus, int row, int column) {\r
+ if (isSelected)\r
+ setBackground(table.getSelectionBackground());\r
+ else\r
+ setBackground(table.getBackground());\r
+ messageLabel.setForeground(isSelected ? table.getSelectionForeground() : table\r
+ .getForeground());\r
+ SyndicatedEntryModel entry = (SyndicatedEntryModel) value;\r
+ \r
+ // show message in BOLD if its a new entry\r
+ if (entry.published.after(gitblit.getLastFeedRefresh(entry.repository, entry.branch))) {\r
+ messageLabel.setText("<html><body><b>" + entry.title);\r
+ } else {\r
+ messageLabel.setText(entry.title);\r
+ }\r
+\r
+ // reset ref label\r
+ branchLabel.setText("");\r
+ branchLabel.setBackground(messageLabel.getBackground());\r
+ branchLabel.setBorder(null);\r
+\r
+ if (entry.tags != null) {\r
+ for (String tag : entry.tags) {\r
+ if (tag.equals(entry.branch)) {\r
+ continue;\r
+ }\r
+ String name = tag;\r
+ Color bg = getBackground();\r
+ Border border = null;\r
+ if (name.startsWith(R_HEADS)) {\r
+ // local branch\r
+ bg = Color.decode("#CCFFCC");\r
+ name = name.substring(R_HEADS.length());\r
+ border = new LineBorder(Color.decode("#00CC33"), 1);\r
+ } else if (name.startsWith(R_REMOTES)) {\r
+ // origin branch\r
+ bg = Color.decode("#CAC2F5");\r
+ name = name.substring(R_REMOTES.length());\r
+ border = new LineBorder(Color.decode("#6C6CBF"), 1);\r
+ } else if (name.startsWith(R_TAGS)) {\r
+ // tag\r
+ bg = Color.decode("#FFFFAA");\r
+ name = name.substring(R_TAGS.length());\r
+ border = new LineBorder(Color.decode("#FFCC00"), 1);\r
+ } else if (name.equals("HEAD")) {\r
+ // HEAD\r
+ bg = Color.decode("#FFAAFF");\r
+ border = new LineBorder(Color.decode("#FF00EE"), 1);\r
+ } else {\r
+\r
+ }\r
+ branchLabel.setText(" " + name + " ");\r
+ branchLabel.setBackground(bg);\r
+ branchLabel.setBorder(border);\r
+ }\r
+ }\r
+\r
+ return this;\r
+ }\r
+}
\ No newline at end of file
\r
private static final long serialVersionUID = 1L;\r
\r
- private final GitblitClient gitblit;\r
-\r
List<SyndicatedEntryModel> entries;\r
\r
enum Columns {\r
- Date, Repository, Author, Message, Branch;\r
+ Date, Repository, Branch, Author, Message;\r
\r
@Override\r
public String toString() {\r
}\r
}\r
\r
- public SyndicatedEntryTableModel(GitblitClient gitblit) {\r
- this.gitblit = gitblit;\r
+ public SyndicatedEntryTableModel() {\r
this.entries = new ArrayList<SyndicatedEntryModel>();\r
}\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
case Author:\r
return entry.author;\r
case Message:\r
- Date lastRefresh = gitblit.getLastFeedRefresh(entry.repository, entry.branch);\r
- if (entry.published.after(lastRefresh)) {\r
- return "<html><body><b>" + entry.title;\r
- }\r
- return entry.title;\r
+ return entry;\r
}\r
return null;\r
}\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
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
gb.version = version\r
gb.releaseDate = release date\r
gb.date = date\r
-gb.timeline = timeline\r
+gb.activity = activity\r
gb.subscribe = subscribe\r
gb.branch = branch
\ No newline at end of file