commit | author | age
|
17820f
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package com.gitblit.client;
|
|
17 |
|
|
18 |
import java.awt.Component;
|
|
19 |
|
|
20 |
import javax.swing.ImageIcon;
|
|
21 |
import javax.swing.JTable;
|
|
22 |
|
|
23 |
import com.gitblit.models.RepositoryModel;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* Displays a subscribed icon on the left of the repository name, if there is at
|
|
27 |
* least one subscribed branch.
|
|
28 |
*
|
|
29 |
* @author James Moger
|
|
30 |
*
|
|
31 |
*/
|
|
32 |
public class SubscribedRepositoryRenderer extends NameRenderer {
|
|
33 |
|
|
34 |
private static final long serialVersionUID = 1L;
|
|
35 |
|
|
36 |
private final GitblitClient gitblit;
|
|
37 |
|
|
38 |
private final ImageIcon blankIcon;
|
|
39 |
|
|
40 |
private final ImageIcon subscribedIcon;
|
|
41 |
|
|
42 |
public SubscribedRepositoryRenderer(GitblitClient gitblit) {
|
|
43 |
super();
|
|
44 |
this.gitblit = gitblit;
|
|
45 |
blankIcon = new ImageIcon(getClass().getResource("/blank.png"));
|
|
46 |
subscribedIcon = new ImageIcon(getClass().getResource("/bullet_feed.png"));
|
|
47 |
}
|
|
48 |
|
|
49 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
|
50 |
boolean hasFocus, int row, int column) {
|
|
51 |
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
52 |
if (value instanceof RepositoryModel) {
|
|
53 |
RepositoryModel model = (RepositoryModel) value;
|
|
54 |
if (gitblit.isSubscribed(model)) {
|
|
55 |
setIcon(subscribedIcon);
|
|
56 |
} else {
|
|
57 |
setIcon(blankIcon);
|
|
58 |
}
|
|
59 |
}
|
|
60 |
return this;
|
|
61 |
}
|
|
62 |
}
|