]> source.dussan.org Git - gitblit.git/commitdiff
Object counts and refresh labels on all header panels
authorJames Moger <james.moger@gitblit.com>
Mon, 24 Oct 2011 20:33:40 +0000 (16:33 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 24 Oct 2011 20:33:40 +0000 (16:33 -0400)
src/com/gitblit/client/GitblitClient.java
src/com/gitblit/client/GitblitPanel.java
src/com/gitblit/client/HeaderPanel.java
src/com/gitblit/client/UsersTableModel.java
src/com/gitblit/wicket/GitBlitWebApp.properties

index 66675b16ffdb8d117a4c1246f9155d3fa38b0ea3..79914232a296df54912dcfc1d66712e27809ebfb 100644 (file)
@@ -86,7 +86,7 @@ public class GitblitClient implements Serializable {
                }\r
 \r
                try {\r
-                       settings = RpcUtils.getSettings(url, account, password);\r
+                       refreshSettings();\r
                        status = RpcUtils.getStatus(url, account, password);\r
                        allowAdministration = true;\r
                } catch (UnauthorizedException e) {\r
@@ -136,6 +136,11 @@ public class GitblitClient implements Serializable {
                allUsers.addAll(users);\r
                return allUsers;\r
        }\r
+       \r
+       public ServerSettings refreshSettings() throws IOException {\r
+               settings = RpcUtils.getSettings(url, account, password);\r
+               return settings;\r
+       }\r
 \r
        public List<FederationModel> refreshFederationRegistrations() throws IOException {\r
                List<FederationModel> list = RpcUtils.getFederationRegistrations(url, account, password);\r
index 31de44ef45208062b62b5178b09bf2c4ee491542..a9d7b466bf29a99411d7303e5e1d6ab9d86c5b26 100644 (file)
@@ -107,6 +107,12 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
 \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
@@ -259,8 +265,9 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                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
@@ -372,8 +379,8 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                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
@@ -381,6 +388,13 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
        }\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
@@ -434,6 +448,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                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
@@ -444,8 +459,8 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                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
@@ -478,11 +493,11 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                } 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
@@ -491,17 +506,21 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                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
@@ -882,4 +901,20 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                        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
index 0df291401e343f09911c5afb8a2f197e31d8425a..3cd89a704913eb3c1eb519ae9aa2e59515b03fb8 100644 (file)
@@ -17,13 +17,16 @@ package com.gitblit.client;
 \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
@@ -35,20 +38,42 @@ public class HeaderPanel extends JPanel {
 \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
index 57536adc61860c57f79592e11bb984517e20a8b9..de282b8e0350131a65d8245fda00d1af3dee90b3 100644 (file)
@@ -36,7 +36,7 @@ public class UsersTableModel extends AbstractTableModel {
        List<UserModel> list;\r
 \r
        enum Columns {\r
-               Name;\r
+               Name, AccessLevel;\r
 \r
                @Override\r
                public String toString() {\r
@@ -69,6 +69,8 @@ public class UsersTableModel extends AbstractTableModel {
                switch (col) {\r
                case Name:\r
                        return Translation.get("gb.name");\r
+               case AccessLevel:\r
+                       return Translation.get("gb.accessLevel");\r
                }\r
                return "";\r
        }\r
@@ -91,6 +93,10 @@ public class UsersTableModel extends AbstractTableModel {
                switch (col) {\r
                case Name:\r
                        return model.username;\r
+               case AccessLevel:\r
+                       if (model.canAdmin) {\r
+                               return "administrator";\r
+                       }\r
                }\r
                return null;\r
        }\r
index ae6f6cfa40d7d27479ae3dc6b2b8f46e5fa38843..4314cf9e11ca5f0327f53b26b74902bbd30a660a 100644 (file)
@@ -162,4 +162,5 @@ gb.lastLogin = last login
 gb.skipSizeCalculation = skip size calculation\r
 gb.skipSizeCalculationDescription = do not calculate the repository size (reduces page load time)\r
 gb.skipSummaryMetrics = skip summary metrics\r
-gb.skipSummaryMetricsDescription = do not calculate metrics on the summary page (reduces page load time)
\ No newline at end of file
+gb.skipSummaryMetricsDescription = do not calculate metrics on the summary page (reduces page load time)\r
+gb.accessLevel = access level
\ No newline at end of file