summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-11-03 17:11:47 -0400
committerJames Moger <james.moger@gitblit.com>2011-11-03 17:11:47 -0400
commit609a16e10fb705e146e7fd4b0fe48c744d40a2e0 (patch)
treee064043dbc65dafff68661a116de4c927b0d65f2
parent9bdb91ea80119121791271819f2c1fbf07bf5591 (diff)
downloadgitblit-609a16e10fb705e146e7fd4b0fe48c744d40a2e0.tar.gz
gitblit-609a16e10fb705e146e7fd4b0fe48c744d40a2e0.zip
Revised branch rendering. Added ref rendering to message column.
-rw-r--r--docs/05_roadmap.mkd1
-rw-r--r--src/com/gitblit/client/BranchRenderer.java43
-rw-r--r--src/com/gitblit/client/FeedsPanel.java13
-rw-r--r--src/com/gitblit/client/GitblitManager.java6
-rw-r--r--src/com/gitblit/client/GitblitPanel.java2
-rw-r--r--src/com/gitblit/client/GitblitRegistration.java7
-rw-r--r--src/com/gitblit/client/MessageRenderer.java129
-rw-r--r--src/com/gitblit/client/SyndicatedEntryTableModel.java15
-rw-r--r--src/com/gitblit/models/SyndicatedEntryModel.java2
-rw-r--r--src/com/gitblit/wicket/GitBlitWebApp.properties2
10 files changed, 164 insertions, 56 deletions
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<SyndicatedEntryTableModel>(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<GitblitRegi
}
}
+ protected void cacheFeeds() {
+ }
+
@Override
public int compareTo(GitblitRegistration o) {
return name.toLowerCase().compareTo(o.name.toLowerCase());
}
- protected void cacheFeeds() {
+ @Override
+ public String toString() {
+ return name + " (" + url + ")";
}
}
diff --git a/src/com/gitblit/client/MessageRenderer.java b/src/com/gitblit/client/MessageRenderer.java
new file mode 100644
index 00000000..c848cefc
--- /dev/null
+++ b/src/com/gitblit/client/MessageRenderer.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.client;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.Font;
+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 com.gitblit.models.SyndicatedEntryModel;
+
+/**
+ * Message renderer displays the short log message and then any refs in a style
+ * like the site.
+ *
+ * @author James Moger
+ *
+ */
+public class MessageRenderer extends JPanel implements TableCellRenderer, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String R_TAGS = "refs/tags/";
+
+ private static final String R_HEADS = "refs/heads/";
+
+ private static final String R_REMOTES = "refs/remotes/";
+
+ private final GitblitClient gitblit;
+
+ private final JLabel messageLabel;
+
+ private final JLabel branchLabel;
+
+ public MessageRenderer(GitblitClient gitblit) {
+ super(new FlowLayout(FlowLayout.LEFT, 10, 1));
+ this.gitblit = gitblit;
+
+ messageLabel = new JLabel();
+ branchLabel = new JLabel();
+ branchLabel.setOpaque(true);
+ Font font = branchLabel.getFont();
+ branchLabel.setFont(font.deriveFont(font.getSize2D() - 1f));
+ add(messageLabel);
+ 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());
+ messageLabel.setForeground(isSelected ? table.getSelectionForeground() : table
+ .getForeground());
+ SyndicatedEntryModel entry = (SyndicatedEntryModel) value;
+
+ // show message in BOLD if its a new entry
+ if (entry.published.after(gitblit.getLastFeedRefresh(entry.repository, entry.branch))) {
+ messageLabel.setText("<html><body><b>" + 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<SyndicatedEntryModel> 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<SyndicatedEntryModel>();
}
@@ -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 "<html><body><b>" + 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<Syndicated
public String link;
public String content;
public String contentType;
+ public List<String> 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