From 60da0dc453d55ce723483a3519d3df7568c106be Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 19 Sep 2010 17:38:40 +0200 Subject: [PATCH] show url and creationdate on gui --- .../java/sonia/scm/repository/Repository.java | 6 +++ .../main/java/sonia/scm/util/DateAdapter.java | 54 +++++++++++++++++++ .../src/main/webapp/resources/css/style.css | 13 +++++ .../webapp/resources/js/sonia.repository.js | 12 ++++- 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 scm-core/src/main/java/sonia/scm/util/DateAdapter.java diff --git a/scm-core/src/main/java/sonia/scm/repository/Repository.java b/scm-core/src/main/java/sonia/scm/repository/Repository.java index 4a27879e59..636910b92e 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Repository.java +++ b/scm-core/src/main/java/sonia/scm/repository/Repository.java @@ -9,6 +9,7 @@ package sonia.scm.repository; //~--- non-JDK imports -------------------------------------------------------- +import sonia.scm.util.DateAdapter; import sonia.scm.util.Util; //~--- JDK imports ------------------------------------------------------------ @@ -20,14 +21,18 @@ import java.util.Arrays; import java.util.Date; import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** * * @author Sebastian Sdorra */ @XmlRootElement(name = "repositories") +@XmlAccessorType(XmlAccessType.FIELD) @XmlType(propOrder = { "id", "type", "name", "contact", "description", "creationDate", "url", @@ -277,6 +282,7 @@ public class Repository implements Serializable private String contact; /** Field description */ + @XmlJavaTypeAdapter(DateAdapter.class) private Date creationDate; /** Field description */ diff --git a/scm-core/src/main/java/sonia/scm/util/DateAdapter.java b/scm-core/src/main/java/sonia/scm/util/DateAdapter.java new file mode 100644 index 0000000000..2318538f66 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/util/DateAdapter.java @@ -0,0 +1,54 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + + + +package sonia.scm.util; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * + * @author Sebastian Sdorra + */ +public class DateAdapter extends XmlAdapter +{ + + /** + * Method description + * + * + * @param data + * + * @return + * + * @throws Exception + */ + @Override + public String marshal(Date data) throws Exception + { + return Util.formatDate(data); + } + + /** + * Method description + * + * + * @param string + * + * @return + * + * @throws Exception + */ + @Override + public Date unmarshal(String string) throws Exception + { + return Util.parseDate(string); + } +} diff --git a/scm-webapp/src/main/webapp/resources/css/style.css b/scm-webapp/src/main/webapp/resources/css/style.css index 2b52b336ee..1ed36bd85a 100644 --- a/scm-webapp/src/main/webapp/resources/css/style.css +++ b/scm-webapp/src/main/webapp/resources/css/style.css @@ -11,6 +11,19 @@ Syntax recommendation http://www.w3.org/TR/REC-CSS2/ */ +a { + color: #004077; + text-decoration: none; +} + +a:hover { + color: #004077; +} + +a:visited { + color: #004077; +} + #header { margin: 5px; } diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js index e4cda289e5..559e4ae4cb 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js @@ -48,12 +48,14 @@ Ext.reg('repositoryEditForm', Sonia.repository.EditForm); Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { + urlTemplate: '{0}', + initComponent: function(){ var repositoryStore = new Sonia.rest.JsonStore({ url: restUrl + 'repositories.json', root: 'repositories', - fields: [ 'id', 'name', 'type', 'contact', 'description' ], + fields: [ 'id', 'name', 'type', 'contact', 'description', 'creationDate', 'url' ], sortInfo: { field: 'name' } @@ -64,7 +66,9 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { {header: 'Name', sortable: true, width: 100, dataIndex: 'name'}, {header: 'Type', sortable: true, width: 50, dataIndex: 'type'}, {header: 'Contact', sortable: true, width: 100, dataIndex: 'contact'}, - {header: 'Description', sortable: true, dataIndex: 'description'} + {header: 'Description', sortable: true, dataIndex: 'description'}, + {header: 'Creation date', sortable: true, dataIndex: 'creationDate'}, + {header: 'Url', sortable: true, dataIndex: 'url', scope: this, renderer: this.renderUrl } ] }); @@ -82,6 +86,10 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { Ext.apply(this, Ext.apply(this.initialConfig, config)); Sonia.repository.Grid.superclass.initComponent.apply(this, arguments); + }, + + renderUrl: function(url){ + return String.format( this.urlTemplate, url ); } });