use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class RpcUtils method getBranchFeeds.
/**
* Retrieves a list of available branch feeds in the Gitblit server.
*
* @param serverUrl
* @param account
* @param password
* @return
* @throws IOException
*/
public static List<FeedModel> getBranchFeeds(String serverUrl, String account, char[] password) throws IOException {
List<FeedModel> feeds = new ArrayList<FeedModel>();
Map<String, Collection<String>> allBranches = getBranches(serverUrl, account, password);
for (Map.Entry<String, Collection<String>> entry : allBranches.entrySet()) {
for (String branch : entry.getValue()) {
FeedModel feed = new FeedModel();
feed.repository = entry.getKey();
feed.branch = branch;
feeds.add(feed);
}
}
return feeds;
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class SubscriptionsDialog method initialize.
private void initialize() {
NameRenderer nameRenderer = new NameRenderer();
model = new FeedsTableModel(feeds);
feedsTable = Utils.newTable(model, Utils.DATE_FORMAT);
feedsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
int viewRow = feedsTable.getSelectedRow();
if (viewRow == -1) {
return;
}
int modelRow = feedsTable.convertRowIndexToModel(viewRow);
FeedModel feed = model.get(modelRow);
feed.subscribed = !feed.subscribed;
model.fireTableDataChanged();
}
});
String repository = feedsTable.getColumnName(FeedsTableModel.Columns.Repository.ordinal());
feedsTable.getColumn(repository).setCellRenderer(nameRenderer);
String branch = feedsTable.getColumnName(FeedsTableModel.Columns.Branch.ordinal());
feedsTable.getColumn(branch).setCellRenderer(new BranchRenderer());
String subscribed = feedsTable.getColumnName(FeedsTableModel.Columns.Subscribed.ordinal());
feedsTable.getColumn(subscribed).setCellRenderer(new BooleanCellRenderer());
feedsTable.getColumn(subscribed).setMinWidth(30);
feedsTable.getColumn(subscribed).setMaxWidth(30);
Utils.packColumns(feedsTable, 5);
final JButton cancel = new JButton(Translation.get("gb.cancel"));
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setVisible(false);
}
});
final JButton save = new JButton(Translation.get("gb.save"));
save.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
save();
}
});
feedsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
}
});
JPanel controls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
controls.add(cancel);
controls.add(save);
final Insets insets = new Insets(5, 5, 5, 5);
JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {
private static final long serialVersionUID = 1L;
@Override
public Insets getInsets() {
return insets;
}
};
centerPanel.add(new HeaderPanel(Translation.get("gb.subscribe") + "...", "feed_16x16.png"), BorderLayout.NORTH);
centerPanel.add(new JScrollPane(feedsTable), BorderLayout.CENTER);
centerPanel.add(controls, BorderLayout.SOUTH);
getContentPane().setLayout(new BorderLayout(5, 5));
getContentPane().add(centerPanel, BorderLayout.CENTER);
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class GitblitManager method loadFeedCache.
private void loadFeedCache(GitblitRegistration reg) {
File feedCache = new File(configFile.getParentFile(), StringUtils.getSHA1(reg.toString()) + ".cache");
if (!feedCache.exists()) {
// no cache for this registration
return;
}
try {
BufferedReader reader = new BufferedReader(new FileReader(feedCache));
Map<String, Date> cache = new HashMap<String, Date>();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
String line = null;
while ((line = reader.readLine()) != null) {
String[] kvp = line.split("=");
cache.put(kvp[0], df.parse(kvp[1]));
}
reader.close();
for (FeedModel feed : reg.feeds) {
String name = feed.toString();
if (cache.containsKey(name)) {
feed.currentRefreshDate = cache.get(name);
}
}
} catch (Exception e) {
Utils.showException(GitblitManager.this, e);
}
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class GitblitManager method writeFeedCache.
private void writeFeedCache(GitblitRegistration reg) {
try {
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", feed.toString(), feed.currentRefreshDate));
}
writer.close();
} catch (Exception e) {
Utils.showException(GitblitManager.this, e);
}
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class FeedsTableModel method getValueAt.
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
FeedModel model = list.get(rowIndex);
Columns col = Columns.values()[columnIndex];
switch(col) {
case Repository:
return model.repository;
case Branch:
return model.branch;
case Subscribed:
return model.subscribed;
}
return null;
}
Aggregations