]> source.dussan.org Git - gitblit.git/commitdiff
Revised branch rendering. Added ref rendering to message column.
authorJames Moger <james.moger@gitblit.com>
Thu, 3 Nov 2011 21:11:47 +0000 (17:11 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 3 Nov 2011 21:11:47 +0000 (17:11 -0400)
docs/05_roadmap.mkd
src/com/gitblit/client/BranchRenderer.java
src/com/gitblit/client/FeedsPanel.java
src/com/gitblit/client/GitblitManager.java
src/com/gitblit/client/GitblitPanel.java
src/com/gitblit/client/GitblitRegistration.java
src/com/gitblit/client/MessageRenderer.java [new file with mode: 0644]
src/com/gitblit/client/SyndicatedEntryTableModel.java
src/com/gitblit/models/SyndicatedEntryModel.java
src/com/gitblit/wicket/GitBlitWebApp.properties

index 511e9bb847c6bd99c25a2f5bc31c0339257b55cd..a7f21a3b536e94156b4d88b3ded306cfaa47f497 100644 (file)
@@ -7,7 +7,6 @@ This list is volatile.
 \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
index b8f55f09706fdc8ccd75d99b026df60ac8098bee..532a432e6afeb47acb080c3389f7c1f455ca4ccd 100644 (file)
@@ -17,24 +17,18 @@ package com.gitblit.client;
 \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
@@ -42,37 +36,20 @@ public class BranchRenderer extends JPanel implements TableCellRenderer, Seriali
 \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
index a9a24731b62243908a9e5420a2af8881f4c2af9d..a8094f80dc4838759241af1859d372a1b2b2d90a 100644 (file)
@@ -41,7 +41,6 @@ import javax.swing.event.ListSelectionEvent;
 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
@@ -130,8 +129,8 @@ public abstract class FeedsPanel extends JPanel {
                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
@@ -143,6 +142,9 @@ public abstract class FeedsPanel extends JPanel {
                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
@@ -220,8 +222,7 @@ public abstract class FeedsPanel extends JPanel {
        }\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
@@ -242,7 +243,7 @@ public abstract class FeedsPanel extends JPanel {
                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
index a16cfe64bce229a8147a57884830ba20fd45b6cf..dd0315f22b2deec1f02e9a1af20ce4ca31da0c2f 100644 (file)
@@ -400,7 +400,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
        }\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
@@ -429,8 +429,8 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
 \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
index f675b4a60d8b2e85fea30fea5a5b4f7ed253515f..0e670ae3121d1f52972bfab734d0a31bc3a67122 100644 (file)
@@ -61,7 +61,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
 \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
index 33399b1636b6a6a735323dc1def0028f3b791f53..f9d07488d785f69a424e7c1c0a9ed631ec64c064 100644 (file)
@@ -71,11 +71,16 @@ public class GitblitRegistration implements Serializable, Comparable<GitblitRegi
                }\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
diff --git a/src/com/gitblit/client/MessageRenderer.java b/src/com/gitblit/client/MessageRenderer.java
new file mode 100644 (file)
index 0000000..c848cef
--- /dev/null
@@ -0,0 +1,129 @@
+/*\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
index 93177a8f14f3aa2b151592f416836edfb5d7d0b6..8fcdb47d531ec9850e91b69093f49751789ac2d7 100644 (file)
@@ -34,12 +34,10 @@ public class SyndicatedEntryTableModel extends AbstractTableModel {
 \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
@@ -47,8 +45,7 @@ public class SyndicatedEntryTableModel extends AbstractTableModel {
                }\r
        }\r
 \r
-       public SyndicatedEntryTableModel(GitblitClient gitblit) {\r
-               this.gitblit = gitblit;\r
+       public SyndicatedEntryTableModel() {\r
                this.entries = new ArrayList<SyndicatedEntryModel>();\r
        }\r
 \r
@@ -95,6 +92,8 @@ public class SyndicatedEntryTableModel extends AbstractTableModel {
        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
@@ -113,11 +112,7 @@ public class SyndicatedEntryTableModel extends AbstractTableModel {
                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
index a1c122111d5b154f6de2cbf605277b85181e3c6e..f59418edf90d88ea187677018cc2532454d6d44b 100644 (file)
@@ -17,6 +17,7 @@ package com.gitblit.models;
 \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
@@ -33,6 +34,7 @@ public class SyndicatedEntryModel implements Serializable, Comparable<Syndicated
        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
index 96a5bc865532fc0f1575bb6e7bededcd7961f2ed..3ab1b7a4f16886d18918149ca265d15247b7ed2c 100644 (file)
@@ -177,6 +177,6 @@ gb.free = free
 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