]> source.dussan.org Git - gitblit.git/commitdiff
Add version number and date to ServerStatus. Conditionally hide status.
authorJames Moger <james.moger@gitblit.com>
Thu, 27 Oct 2011 12:16:46 +0000 (08:16 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 27 Oct 2011 12:16:46 +0000 (08:16 -0400)
src/com/gitblit/client/GitblitPanel.java
src/com/gitblit/client/StatusPanel.java
src/com/gitblit/models/ServerStatus.java
src/com/gitblit/wicket/GitBlitWebApp.properties

index 9eb896bcd43e19632a46dd74ac3c5f661198cf53..23aadb863e57b086b5f9cf7894b80bdcc3d6edbc 100644 (file)
@@ -530,11 +530,13 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                        Utils.packColumns(settingsTable, 5);\r
                } else {\r
                        // remove the settings tab\r
-                       String settingsTitle = Translation.get("gb.settings");\r
-                       for (int i = 0; i < tabs.getTabCount(); i++) {\r
-                               if (tabs.getTitleAt(i).equals(settingsTitle)) {\r
-                                       tabs.removeTabAt(i);\r
-                                       break;\r
+                       String[] titles = { Translation.get("gb.settings"), Translation.get("gb.status") };\r
+                       for (String title : titles) {\r
+                               for (int i = 0; i < tabs.getTabCount(); i++) {\r
+                                       if (tabs.getTitleAt(i).equals(title)) {\r
+                                               tabs.removeTabAt(i);\r
+                                               break;\r
+                                       }\r
                                }\r
                        }\r
                }\r
index 551d865d856e8502e22a050dc4a7c5ab00bf6721..0cc530ef3d8607542c2c8800fcec7615e1ca1f55 100644 (file)
@@ -27,8 +27,10 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;\r
 import javax.swing.JTable;\r
 \r
+import com.gitblit.Constants;\r
 import com.gitblit.models.ServerStatus;\r
 import com.gitblit.utils.ByteFormat;\r
+import com.gitblit.utils.TimeUtils;\r
 \r
 /**\r
  * This panel displays the server status.\r
@@ -46,6 +48,8 @@ public class StatusPanel extends JPanel {
        private JLabel heapUsed;\r
        private PropertiesTableModel model;\r
        private HeaderPanel headerPanel;\r
+       private JLabel version;\r
+       private JLabel releaseDate;\r
 \r
        public StatusPanel() {\r
                super();\r
@@ -58,6 +62,8 @@ public class StatusPanel extends JPanel {
        }\r
 \r
        private void initialize() {\r
+               version = new JLabel();\r
+               releaseDate = new JLabel();\r
                bootDate = new JLabel();\r
                servletContainer = new JLabel();\r
 \r
@@ -65,7 +71,17 @@ public class StatusPanel extends JPanel {
                heapAllocated = new JLabel();\r
                heapUsed = new JLabel();\r
 \r
-               JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));\r
+               JPanel fieldsPanel = new JPanel(new GridLayout(0, 1, 0, 5)) {\r
+               \r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       @Override\r
+                       public Insets getInsets() {\r
+                               return insets;\r
+                       }\r
+               };\r
+               fieldsPanel.add(createFieldPanel("gb.version", version));\r
+               fieldsPanel.add(createFieldPanel("gb.releaseDate", releaseDate));\r
                fieldsPanel.add(createFieldPanel("gb.bootDate", bootDate));\r
                fieldsPanel.add(createFieldPanel("gb.servletContainer", servletContainer));\r
                fieldsPanel.add(createFieldPanel("gb.heapUsed", heapUsed));\r
@@ -90,10 +106,10 @@ public class StatusPanel extends JPanel {
        }\r
 \r
        private JPanel createFieldPanel(String key, JLabel valueLabel) {\r
-               JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));\r
+               JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));\r
                JLabel textLabel = new JLabel(Translation.get(key));\r
                textLabel.setFont(textLabel.getFont().deriveFont(Font.BOLD));\r
-               textLabel.setPreferredSize(new Dimension(120, valueLabel.getFont().getSize() + 4));\r
+               textLabel.setPreferredSize(new Dimension(120, 10));\r
                panel.add(textLabel);\r
                panel.add(valueLabel);\r
                return panel;\r
@@ -106,7 +122,10 @@ public class StatusPanel extends JPanel {
 \r
        public void setStatus(ServerStatus status) {\r
                headerPanel.setText(Translation.get("gb.status"));\r
-               bootDate.setText(status.bootDate.toString());\r
+               version.setText(Constants.NAME + (status.isGO ? " GO v" : " WAR v") + status.version);\r
+               releaseDate.setText(status.releaseDate);\r
+               bootDate.setText(status.bootDate.toString() + " (" + TimeUtils.timeAgo(status.bootDate)\r
+                               + ")");\r
                servletContainer.setText(status.servletContainer);\r
                ByteFormat byteFormat = new ByteFormat();\r
                heapMaximum.setText(byteFormat.format(status.heapMaximum));\r
index 1c40b5f448ec77cc87778d406909992dbd24579f..3e7e8d827e072fb62ce7e7fa76739943d2755dac 100644 (file)
@@ -20,6 +20,8 @@ import java.util.Date;
 import java.util.Map;\r
 import java.util.TreeMap;\r
 \r
+import com.gitblit.Constants;\r
+\r
 /**\r
  * ServerStatus encapsulates runtime status information about the server\r
  * including some information about the system environment.\r
@@ -32,26 +34,32 @@ public class ServerStatus implements Serializable {
        private static final long serialVersionUID = 1L;\r
 \r
        public final Date bootDate;\r
-       \r
+\r
+       public final String version;\r
+\r
+       public final String releaseDate;\r
+\r
        public final boolean isGO;\r
-       \r
+\r
        public final Map<String, String> systemProperties;\r
 \r
        public final long heapMaximum;\r
 \r
        public volatile long heapAllocated;\r
-       \r
+\r
        public volatile long heapFree;\r
-       \r
+\r
        public String servletContainer;\r
 \r
        public ServerStatus(boolean isGO) {\r
-               bootDate = new Date();\r
+               this.bootDate = new Date();\r
+               this.version = Constants.VERSION;\r
+               this.releaseDate = Constants.VERSION_DATE;\r
                this.isGO = isGO;\r
-               \r
-               heapMaximum = Runtime.getRuntime().maxMemory();\r
-               \r
-               systemProperties = new TreeMap<String, String>();\r
+\r
+               this.heapMaximum = Runtime.getRuntime().maxMemory();\r
+\r
+               this.systemProperties = new TreeMap<String, String>();\r
                put("file.encoding");\r
                put("java.home");\r
                put("java.io.tmpdir");\r
index 715cb1563d62b8ae4f644feaea2d2f33c19fcbba..267fb5642d40d3ac3250bed36b8721009159234b 100644 (file)
@@ -173,4 +173,6 @@ gb.servletContainer = servlet container
 gb.heapMaximum = maximum heap\r
 gb.heapAllocated = allocated heap\r
 gb.heapUsed = used heap\r
-gb.free = free
\ No newline at end of file
+gb.free = free\r
+gb.version = version\r
+gb.releaseDate = release date
\ No newline at end of file