# HG changeset patch # User Ingo Weinzierl # Date 1308673359 0 # Node ID 53ad6dd2cb2bc6963f57303f78a7f2292eed5912 # Parent e3c8e045737b0af93dea09a46d726a52fdbfd08d The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project. flys-client/trunk@2181 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/ChangeLog --- a/flys-client/ChangeLog Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/ChangeLog Tue Jun 21 16:22:39 2011 +0000 @@ -1,3 +1,29 @@ +2011-06-21 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java, + src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java, + src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java: + Read the time-to-live from collection's describe document. + + * src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java, + src/main/java/de/intevation/flys/client/shared/model/Collection.java: + Adapted the constructor calls. They require a time-to-live attribute + now. This value is retrievable via getTTL(). + + * src/main/java/de/intevation/flys/client/client/ui/ProjectList.java: + The project list has now a column that displays an icon that shows the + favorite state of the project. A gold star means, the project is marked + as favorite, a silver one means that the project is no favorite project. + + * src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java: + The 'ttl' attribute returns the filename of the icon that should be + displayed in the project list. + + * src/main/webapp/images/star_silver.png, + src/main/webapp/images/star_gold.png: New. These icons - based on icons + copied from famfamfam - are used to mark a project as favorite or no + favorite. + 2011-06-21 Sascha L. Teichmann * src/main/java/de/intevation/flys/client/client/config.xml: diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Tue Jun 21 16:22:39 2011 +0000 @@ -105,8 +105,9 @@ ListGridField date = buildDateField(); ListGridField name = buildNameField(); + ListGridField fav = buildFavoriteField(); - grid.setFields(date, name); + grid.setFields(date, name, fav); grid.addCellDoubleClickHandler(new CellDoubleClickHandler() { public void onCellDoubleClick(CellDoubleClickEvent e) { @@ -303,7 +304,7 @@ } }); - date.setWidth(105); + date.setWidth(100); date.setAlign(Alignment.LEFT); return date; @@ -333,10 +334,23 @@ } }); - name.setWidth(195); + name.setWidth(165); name.setAlign(Alignment.LEFT); return name; } + + + protected ListGridField buildFavoriteField() { + ListGridField fav = new ListGridField("ttl", "ttl"); + fav.setType(ListGridFieldType.IMAGE); + String base = GWT.getHostPageBaseURL(); + fav.setImageURLPrefix(base + "images/"); + fav.setImageURLSuffix(".png"); + fav.setWidth(30); + fav.setAlign(Alignment.RIGHT); + + return fav; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java Tue Jun 21 16:22:39 2011 +0000 @@ -33,6 +33,10 @@ public static final String XPATH_COLLECTION_UUID = "/art:result/art:artifact-collection/@art:uuid"; + /** XPath to figure out the ttl of the created collection.*/ + public static final String XPATH_COLLECTION_TTL = + "/art:result/art:artifact-collection/@art:ttl"; + /** Error message key that is thrown if an error occured while creating * a new collection.*/ public static final String ERROR_CREATE_COLLECTION = @@ -55,11 +59,14 @@ String uuid = XMLUtils.xpathString( doc, XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE); - if (uuid == null || uuid.trim().length() == 0) { + String ttlStr = XMLUtils.xpathString( + doc, XPATH_COLLECTION_TTL, ArtifactNamespaceContext.INSTANCE); + + if (uuid.trim().length() == 0 || ttlStr.length() == 0) { throw new ServerException(ERROR_CREATE_COLLECTION); } - return new DefaultCollection(uuid); + return new DefaultCollection(uuid, Long.valueOf(ttlStr)); } catch (ConnectionException ce) { System.err.println(ce.getLocalizedMessage()); diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Tue Jun 21 16:22:39 2011 +0000 @@ -112,16 +112,30 @@ "art:artifact-collection/@art:uuid", ArtifactNamespaceContext.INSTANCE); - if (uuid == null || uuid.length() == 0) { + String ttlStr = XMLUtils.xpathString( + description, + "art:artifact-collection/@art:ttl", + ArtifactNamespaceContext.INSTANCE); + + if (uuid.length() == 0 || ttlStr.length() == 0) { System.err.println("Found an invalid Collection!"); return null; } + + long ttl = -1; + try { + ttl = Long.valueOf(ttlStr); + } + catch (NumberFormatException nfe) { + // do nothing + } + Map themeList = parseThemeLists(description); Collection c = !themeList.isEmpty() - ? new DefaultCollection(uuid, themeList) - : new DefaultCollection(uuid); + ? new DefaultCollection(uuid, ttl, themeList) + : new DefaultCollection(uuid, ttl); NodeList items = (NodeList) XMLUtils.xpath( description, @@ -260,7 +274,7 @@ String uuid = node.getAttributeNS(uri, "uuid"); String hash = node.getAttributeNS(uri, "hash"); - if (uuid.length() == 0) { + if (uuid == null || uuid.length() == 0) { System.err.println("Found an invalid CollectionItem!"); return null; } diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java Tue Jun 21 16:22:39 2011 +0000 @@ -7,6 +7,7 @@ import javax.xml.xpath.XPathConstants; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -64,7 +65,7 @@ List all = new ArrayList(num); for (int i = 0; i < num; i++) { - Collection c = createCollection(list.item(i)); + Collection c = createCollection((Element) list.item(i)); if (c != null) { all.add(c); @@ -91,19 +92,24 @@ * * @return a list of Simplecollections. */ - protected Collection createCollection(Node node) { - String creationStr = XMLUtils.xpathString( - node, "@art:creation", ArtifactNamespaceContext.INSTANCE); + protected Collection createCollection(Element node) { + String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String name = XMLUtils.xpathString( - node, "@art:name", ArtifactNamespaceContext.INSTANCE); + String creationStr = node.getAttributeNS(uri, "creation"); + String name = node.getAttributeNS(uri, "name"); + String uuid = node.getAttributeNS(uri, "uuid"); + String ttlStr = node.getAttributeNS(uri, "ttl"); - String uuid = XMLUtils.xpathString( - node, "@art:uuid", ArtifactNamespaceContext.INSTANCE); - - if (uuid != null) { - long time = Long.parseLong(creationStr); - return new DefaultCollection(uuid, name, new Date(time)); + if (uuid != null && ttlStr != null) { + try { + long time = Long.parseLong(creationStr); + long ttl = Long.parseLong(ttlStr); + return new DefaultCollection(uuid, ttl, name, new Date(time)); + } + catch (NumberFormatException nfe) { + System.err.println("Error while parsing collection attributes."); + return null; + } } System.err.println("Found an invalid Collection."); diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java --- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java Tue Jun 21 16:22:39 2011 +0000 @@ -20,6 +20,8 @@ public Date getLastAccess(); + public long getTTL(); + public void addItem(CollectionItem item); public int getItemLength(); diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java --- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java Tue Jun 21 16:22:39 2011 +0000 @@ -30,6 +30,8 @@ setName(name != null && name.length() > 0 ? name : collection.identifier()); + + setTTL(collection.getTTL()); } @@ -73,6 +75,21 @@ } + public void setTTL(long ttl) { + if (ttl == 0) { + setAttribute("ttl", "star_gold"); + } + else { + setAttribute("ttl", "star_silver"); + } + } + + + public String getTTL() { + return getAttribute("ttl"); + } + + /** * Returns the collection objects itself. * diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java --- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Tue Jun 21 16:14:10 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Tue Jun 21 16:22:39 2011 +0000 @@ -23,6 +23,10 @@ /** The creation time of this collection.*/ protected Date creation; + /** The time to live of the collection. If this value is 0, it will never + * die.*/ + protected long ttl; + /** The list of artifacts that are managed by this Collection.*/ protected List items; @@ -41,16 +45,20 @@ * * @param uuid The UUID. */ - public DefaultCollection(String uuid) { + public DefaultCollection(String uuid, long ttl) { this.uuid = uuid; + this.ttl = ttl; this.items = new ArrayList(); this.themeLists = new HashMap(); } - public DefaultCollection(String uuid, Map themeLists) { - this(uuid); - + public DefaultCollection( + String uuid, + long ttl, + Map themeLists) + { + this(uuid, ttl); this.themeLists = themeLists; } @@ -61,8 +69,8 @@ * @param uuid The identifier of this collection. * @param name The name of this collection. */ - public DefaultCollection(String uuid, String name) { - this(uuid); + public DefaultCollection(String uuid, long ttl, String name) { + this(uuid, ttl); this.name = name; } @@ -75,8 +83,8 @@ * @param name The name of this collection. * @param creation The creation time. */ - public DefaultCollection(String uuid, String name, Date creation) { - this(uuid, name); + public DefaultCollection(String uuid, long ttl, String name, Date creation){ + this(uuid, ttl, name); this.creation = creation; } @@ -97,6 +105,11 @@ } + public long getTTL() { + return ttl; + } + + public String getName() { return name; } diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/webapp/images/star_gold.png Binary file flys-client/src/main/webapp/images/star_gold.png has changed diff -r e3c8e045737b -r 53ad6dd2cb2b flys-client/src/main/webapp/images/star_silver.png Binary file flys-client/src/main/webapp/images/star_silver.png has changed