\r
private JButton editRepository;\r
\r
+ private HeaderPanel repositoriesHeader;\r
+\r
+ private HeaderPanel usersHeader;\r
+\r
+ private HeaderPanel settingsHeader;\r
+\r
public GitblitPanel(GitblitRegistration reg) {\r
this(reg.url, reg.account, reg.password);\r
}\r
return insets;\r
}\r
};\r
- repositoriesPanel.add(new HeaderPanel(Translation.get("gb.repositories"),\r
- "gitweb-favicon.png"), BorderLayout.NORTH);\r
+ repositoriesHeader = new HeaderPanel(Translation.get("gb.repositories"),\r
+ "gitweb-favicon.png");\r
+ repositoriesPanel.add(repositoriesHeader, BorderLayout.NORTH);\r
repositoriesPanel.add(repositoryTablePanel, BorderLayout.CENTER);\r
repositoriesPanel.add(repositoryControls, BorderLayout.SOUTH);\r
\r
return insets;\r
}\r
};\r
- usersPanel.add(new HeaderPanel(Translation.get("gb.users"), "user_16x16.png"),\r
- BorderLayout.NORTH);\r
+ usersHeader = new HeaderPanel(Translation.get("gb.users"), "user_16x16.png");\r
+ usersPanel.add(usersHeader, BorderLayout.NORTH);\r
usersPanel.add(userTablePanel, BorderLayout.CENTER);\r
usersPanel.add(userControls, BorderLayout.SOUTH);\r
\r
}\r
\r
private JPanel createSettingsPanel() {\r
+ JButton refreshSettings = new JButton(Translation.get("gb.refresh"));\r
+ refreshSettings.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent e) {\r
+ refreshSettings();\r
+ }\r
+ });\r
+\r
final SettingPanel settingPanel = new SettingPanel();\r
settingsModel = new SettingsTableModel();\r
defaultSettingsSorter = new TableRowSorter<SettingsTableModel>(settingsModel);\r
settingsTablePanel.add(settingPanel, BorderLayout.SOUTH);\r
\r
JPanel settingsControls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));\r
+ settingsControls.add(refreshSettings);\r
// TODO update setting?\r
\r
JPanel settingsPanel = new JPanel(new BorderLayout(margin, margin)) {\r
return insets;\r
}\r
};\r
- settingsPanel.add(new HeaderPanel(Translation.get("gb.settings"), "settings_16x16.png"),\r
- BorderLayout.NORTH);\r
+ settingsHeader = new HeaderPanel(Translation.get("gb.settings"), "settings_16x16.png");\r
+ settingsPanel.add(settingsHeader, BorderLayout.NORTH);\r
settingsPanel.add(settingsTablePanel, BorderLayout.CENTER);\r
settingsPanel.add(settingsControls, BorderLayout.SOUTH);\r
\r
} else {\r
// remove the settings tab\r
String settingsTitle = Translation.get("gb.settings");\r
- for (int i= 0; i < tabs.getTabCount(); i++) {\r
+ for (int i = 0; i < tabs.getTabCount(); i++) {\r
if (tabs.getTitleAt(i).equals(settingsTitle)) {\r
tabs.removeTabAt(i);\r
break;\r
- } \r
+ }\r
}\r
}\r
}\r
repositoriesModel.list.clear();\r
repositoriesModel.list.addAll(gitblit.getRepositories());\r
repositoriesModel.fireTableDataChanged();\r
+ repositoriesHeader.setText(Translation.get("gb.repositories") + " ("\r
+ + gitblit.getRepositories().size() + ")");\r
}\r
\r
private void updateUsersTable() {\r
usersModel.list.clear();\r
usersModel.list.addAll(gitblit.getUsers());\r
usersModel.fireTableDataChanged();\r
+ usersHeader.setText(Translation.get("gb.users") + " (" + gitblit.getUsers().size() + ")");\r
}\r
\r
private void updateSettingsTable() {\r
settingsModel.setSettings(gitblit.getSettings());\r
settingsModel.fireTableDataChanged();\r
+ settingsHeader.setText(Translation.get("gb.settings"));\r
}\r
\r
private void filterRepositories(final String fragment) {\r
worker.execute();\r
}\r
}\r
+\r
+ protected void refreshSettings() {\r
+ GitblitWorker worker = new GitblitWorker(GitblitPanel.this, RpcRequest.LIST_SETTINGS) {\r
+ @Override\r
+ protected Boolean doRequest() throws IOException {\r
+ gitblit.refreshSettings();\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ protected void onSuccess() {\r
+ updateSettingsTable();\r
+ }\r
+ };\r
+ worker.execute();\r
+ }\r
}
\ No newline at end of file
\r
import java.awt.BasicStroke;\r
import java.awt.Color;\r
-import java.awt.FlowLayout;\r
import java.awt.GradientPaint;\r
import java.awt.Graphics;\r
import java.awt.Graphics2D;\r
+import java.awt.GridLayout;\r
+import java.awt.Insets;\r
import java.awt.Paint;\r
import java.awt.geom.Point2D;\r
import java.awt.geom.Rectangle2D;\r
+import java.text.SimpleDateFormat;\r
+import java.util.Date;\r
\r
import javax.swing.ImageIcon;\r
import javax.swing.JLabel;\r
\r
private static final long serialVersionUID = 1L;\r
\r
+ private final Insets insets = new Insets(5, 5, 5, 5);\r
+\r
private Color lightColor = new Color(0, 0, 0x60);\r
\r
+ private JLabel headerLabel;\r
+\r
+ private JLabel refreshLabel;\r
+\r
public HeaderPanel(String text, String icon) {\r
- super(new FlowLayout(FlowLayout.LEFT), true);\r
+ // super(new FlowLayout(FlowLayout.LEFT), true);\r
+ super(new GridLayout(1, 2, 5, 5), true);\r
setOpaque(true);\r
setBackground(new Color(0, 0, 0x20));\r
\r
- JLabel label = new JLabel(text);\r
+ headerLabel = new JLabel(text);\r
if (!StringUtils.isEmpty(icon)) {\r
- label.setIcon(new ImageIcon(getClass().getResource("/" + icon)));\r
+ headerLabel.setIcon(new ImageIcon(getClass().getResource("/" + icon)));\r
}\r
- label.setForeground(Color.white);\r
- label.setFont(label.getFont().deriveFont(14f));\r
- add(label);\r
+ headerLabel.setForeground(Color.white);\r
+ headerLabel.setFont(headerLabel.getFont().deriveFont(14f));\r
+ add(headerLabel);\r
+\r
+ refreshLabel = new JLabel("", JLabel.RIGHT);\r
+ refreshLabel.setForeground(Color.white);\r
+ add(refreshLabel);\r
+ }\r
+\r
+ public void setText(String text) {\r
+ headerLabel.setText(text);\r
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");\r
+ refreshLabel.setText("refreshed " + df.format(new Date()));\r
+ }\r
+\r
+ @Override\r
+ public Insets getInsets() {\r
+ return insets;\r
}\r
\r
@Override\r