From ac7f1753d3f742e0af8dd5e142b4eac9d9d2fbba Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 28 Oct 2011 21:41:31 -0400
Subject: [PATCH] Preserve feed selections when not saving passwords
---
src/com/gitblit/client/NameRenderer.java | 48 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/src/com/gitblit/client/NameRenderer.java b/src/com/gitblit/client/NameRenderer.java
index 41393fb..ce04255 100644
--- a/src/com/gitblit/client/NameRenderer.java
+++ b/src/com/gitblit/client/NameRenderer.java
@@ -18,8 +18,11 @@
import java.awt.Color;
import java.awt.Component;
+import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
+
+import com.gitblit.models.RepositoryModel;
/**
* Repository name cell renderer. This renderer shows the group name in a gray
@@ -34,7 +37,24 @@
final String groupSpan;
- public NameRenderer(Color group, Color repo) {
+ private final boolean displayIcon;
+
+ private final ImageIcon blankIcon;
+
+ private final ImageIcon subscribedIcon;
+
+ public NameRenderer() {
+ this(false);
+ }
+
+ public NameRenderer(boolean showIcon) {
+ this(Color.gray, new Color(0x00, 0x69, 0xD6), showIcon);
+ }
+
+ private NameRenderer(Color group, Color repo, boolean showIcon) {
+ blankIcon = new ImageIcon(getClass().getResource("/blank.png"));
+ subscribedIcon = new ImageIcon(getClass().getResource("/bullet_feed.png"));
+ displayIcon = showIcon;
groupSpan = "<span style='color:" + getHexColor(group) + "'>";
setForeground(repo);
}
@@ -51,14 +71,26 @@
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- String name = value.toString();
- int lastSlash = name.lastIndexOf('/');
- if (!isSelected && lastSlash > -1) {
- String group = name.substring(0, lastSlash + 1);
- String repo = name.substring(lastSlash + 1);
- setText("<html><body>" + groupSpan + group + "</span>" + repo);
+ if (value instanceof RepositoryModel) {
+ RepositoryModel model = (RepositoryModel) value;
+ String name = value.toString();
+ int lastSlash = name.lastIndexOf('/');
+ if (!isSelected && lastSlash > -1) {
+ String group = name.substring(0, lastSlash + 1);
+ String repo = name.substring(lastSlash + 1);
+ setText("<html><body>" + groupSpan + group + "</span>" + repo);
+ } else {
+ this.setText(name);
+ }
+ if (displayIcon) {
+ if (model.subscribed) {
+ setIcon(subscribedIcon);
+ } else {
+ setIcon(blankIcon);
+ }
+ }
} else {
- this.setText(name);
+ this.setText(value.toString());
}
return this;
}
--
Gitblit v1.9.1