Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r264 - trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r264 - trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client


Chronological Thread 
  • From: "AFS account Roman Geus" <geus AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r264 - trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client
  • Date: Tue, 30 Sep 2008 16:10:53 +0200
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: geus
Date: Tue Sep 30 16:10:52 2008
New Revision: 264

Log:
Show file size instead of revision number in search results, improved title
of disclosure panel

Modified:

trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashup.java

Modified:
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashup.java
==============================================================================
---
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashup.java
(original)
+++
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashup.java
Tue Sep 30 16:10:52 2008
@@ -16,6 +16,7 @@
import com.google.gwt.dom.client.Element;
import com.google.gwt.http.client.URL;
import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DisclosurePanel;
@@ -194,13 +195,13 @@

final StringBuffer buf = new StringBuffer(2048);
buf.append("<div class=\"twikiTopRow\">");
-
+
// Format left column: document name
buf.append("<div class=\"twikiLeft\">");
buf.append("<a href=\"" + getDocumentURL(hit) + "\"><b>"
+ getDocumentNameFromId(hit.getId()) + "</b></a>");
buf.append("</div>");
-
+
// Format right column: author
if (hit.getMeta() != null
&&
hit.getMeta().containsKey("svn:entry:last-author")) {
@@ -208,10 +209,19 @@
buf.append(hit.getMeta().get("svn:entry:last-author"));
buf.append("</div>");
}
-
- // Format middle column: rev and date
+
+ // Format middle column: file size and date
buf.append("<div class=\"twikiRight twikiSRRev\">");
- buf.append("r" + hit.getRev());
+ String fileSizeString = hit.getMeta().get("auto:filesize");
+ if (hit.getMeta() != null && fileSizeString != null) {
+ try {
+ long fileSize = Long.parseLong(fileSizeString);
+ buf.append(formatByteSize(fileSize));
+ } catch (NumberFormatException e) {
+ buf.append("unknown size");
+ }
+ } else
+ buf.append("unknown size");
if (hit.getMeta() != null
&& hit.getMeta()
.containsKey("svn:entry:committed-date")) {
@@ -244,8 +254,10 @@
bottomPanel.addStyleName("bottomPanel");

// Build DisclosurePanel
+ String title = null;
VerticalPanel panel = new VerticalPanel();
if (hit.getMeta() != null) {
+ title = "Meta data";
panel.add(new HTML("<h5>Meta data</h5>"));
FlexTable t = new FlexTable();
int row = 0;
@@ -257,6 +269,10 @@
panel.add(t);
}
if (entry.getValue().size() > 1) {
+ if (title == null)
+ title = "Older Revisions";
+ else
+ title += " and older Revisions";
panel.add(new HTML("<h5>Older Revisions</h5>"));
for (SearchResultItem hit1 : entry.getValue()) {
if (hit1 != hit)
@@ -265,8 +281,8 @@
+ hit1.getRev() + "</a></p>"));
}
}
- if (panel.getWidgetCount() > 0) {
- DisclosurePanel dp = new DisclosurePanel("Details");
+ if (title != null) {
+ DisclosurePanel dp = new DisclosurePanel(title);
dp.setContent(panel);
bottomPanel.add(dp);
}
@@ -313,6 +329,22 @@
}

/**
+ * @return Pretty-printed byte size String
+ */
+ private String formatByteSize(long size) {
+ if (size < 10000)
+ return "" + size + "b";
+ double sizeD = ((double) size) / 1024;
+ if (sizeD < 1000)
+ return NumberFormat.getFormat("0.0").format(sizeD) + "k";
+ sizeD /= 1024;
+ if (sizeD < 1000)
+ return NumberFormat.getFormat("0.0").format(sizeD) + "m";
+ sizeD /= 1024;
+ return NumberFormat.getFormat("0.0").format(sizeD) + "g";
+ }
+
+ /**
* @return the file name of a iDok docucment given by id
*/
private String getDocumentNameFromId(String id) {



  • [idok-commit] idok commit r264 - trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client, AFS account Roman Geus, 09/30/2008

Archive powered by MHonArc 2.6.19.

Top of Page