Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r280 - 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 r280 - 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 r280 - trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client
  • Date: Fri, 17 Oct 2008 11:12:10 +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: Fri Oct 17 11:12:10 2008
New Revision: 280

Log:
Moved rendering of iDok search results in IdokSearchTwikiMashup to a separate
widget


Added:

trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashupWidget.java
(contents, props changed)
Modified:

trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashup.java
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchUtil.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
Fri Oct 17 11:12:10 2008
@@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -13,14 +12,9 @@
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
-import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.DisclosurePanel;
-import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;

/**
* Calls the iDok ReST interface using the JSONP method to obtain search
results
@@ -34,12 +28,6 @@
static final int MAX_HITS = 100;

/**
- * Date format for rendering search results
- */
- static final private DateTimeFormat dataFormatOut = DateTimeFormat
- .getFormat("dd.MM.yyy - HH:mm");
-
- /**
* Called after the HTML document has finished loading.
*
* @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
@@ -146,97 +134,10 @@
});
}

- // Render search results
- for (Entry<String, List<SearchResultItem>> entry :
map.entrySet()) {
- SearchResultItem hit = entry.getValue().get(0);
-
- 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=\"" + IdokSearchUtil.getDocumentURL(hit)
- + "\"><b>" + hit.getName() + "</b></a>");
- buf.append("</div>");
-
- // Format right column: author
- String author = hit.getAuthor();
- if (author != null) {
- buf.append("<div class=\"twikiRight twikiSRAuthor\">");
- buf.append(hit.getAuthor());
- buf.append("</div>");
- }
-
- // Format middle column: file size and date
- buf.append("<div class=\"twikiRight twikiSRRev\">");
- long size = hit.getSize();
- if (size != -1)
- buf.append(IdokSearchUtil.formatByteSize(size));
- else
- buf.append("unknown size");
-
- Date date = hit.getDate();
- if (date != null) {
- String dateString = dataFormatOut.format(date);
- buf.append(" - <i>" + dateString + "</i>");
- }
- buf.append("</div>");
- buf
- .append("<br
class=\"twikiClear\"/></div><!--/twikiTopRow-->");
-
- if (hit.getEnv() != null) {
- buf.append("<div class=\"twikiTopRow\">");
- buf.append("<div class=\"twikiSummary twikiGrayText\">");
- buf.append(hit.getEnv());
- buf.append("</div><!--/twikiSummary-->");
- buf.append("</div><!--/twikiTopRow-->");
- }
+ // Render list of search results
+ idokSearchResultPanel.add(new IdokSearchTwikiMashupWidget(map));

- HTML w = new HTML(buf.toString());
- w.addStyleName("patternSearchResult");
- idokSearchResultPanel.add(w);
-
- HorizontalPanel bottomPanel = new HorizontalPanel();
- bottomPanel.addStyleName("twikiBottomRow");
- 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;
- for (String key : hit.getMeta().keySet()) {
- t.setText(row, 0, key);
- t.setText(row, 1, hit.getMeta().get(key));
- row++;
- }
- 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)
- panel.add(new HTML("<p><a href=\""
- + IdokSearchUtil.getDocumentURL(hit1)
- + "\">r" + hit1.getRev() + "</a></p>"));
- }
- }
- if (title != null) {
- DisclosurePanel dp = new DisclosurePanel(title);
- dp.setContent(panel);
- bottomPanel.add(dp);
- }
- idokSearchResultPanel.add(bottomPanel);
- }
-
- // render iDok search result title
+ // Render iDok search result title
final StringBuffer buf = new StringBuffer(2048);
buf
.append("<h4 style=\"background-color: rgb(255, 239,
166);\" class=\"patternSearchResultsHeader\">");
@@ -278,5 +179,4 @@
}

}
-
}

Added:
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashupWidget.java
==============================================================================
--- (empty file)
+++
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchTwikiMashupWidget.java
Fri Oct 17 11:12:10 2008
@@ -0,0 +1,131 @@
+package ch.psi.idok.gwt.twiki.client;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.DisclosurePanel;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+/**
+ * Search result list used for the IdokSearchTwikiMashup class
+ *
+ * The rendered HTML uses the same CSS classes as the TWiki search results.
+ */
+public class IdokSearchTwikiMashupWidget extends Composite {
+
+ /**
+ * Date format for rendering search results
+ */
+ static final private DateTimeFormat dataFormatOut = DateTimeFormat
+ .getFormat("dd.MM.yyy - HH:mm");
+
+ /**
+ * Constructor
+ *
+ * @param map search results, key is the document id, value are revisions
+ */
+ public IdokSearchTwikiMashupWidget(Map<String, List<SearchResultItem>>
map) {
+ FlowPanel container = new FlowPanel();
+
+ // Render search results
+ for (Entry<String, List<SearchResultItem>> entry : map.entrySet()) {
+ SearchResultItem hit = entry.getValue().get(0);
+
+ 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=\"" + IdokSearchUtil.getDocumentURL(hit)
+ + "\"><b>" + hit.getName() + "</b></a>");
+ buf.append("</div>");
+
+ // Format right column: author
+ String author = hit.getAuthor();
+ if (author != null) {
+ buf.append("<div class=\"twikiRight twikiSRAuthor\">");
+ buf.append(hit.getAuthor());
+ buf.append("</div>");
+ }
+
+ // Format middle column: file size and date
+ buf.append("<div class=\"twikiRight twikiSRRev\">");
+ long size = hit.getSize();
+ if (size != -1)
+ buf.append(IdokSearchUtil.formatByteSize(size));
+ else
+ buf.append("unknown size");
+
+ Date date = hit.getDate();
+ if (date != null) {
+ String dateString = dataFormatOut.format(date);
+ buf.append(" - <i>" + dateString + "</i>");
+ }
+ buf.append("</div>");
+ buf
+ .append("<br
class=\"twikiClear\"/></div><!--/twikiTopRow-->");
+
+ if (hit.getEnv() != null) {
+ buf.append("<div class=\"twikiTopRow\">");
+ buf.append("<div class=\"twikiSummary twikiGrayText\">");
+ buf.append(hit.getEnv());
+ buf.append("</div><!--/twikiSummary-->");
+ buf.append("</div><!--/twikiTopRow-->");
+ }
+
+ HTML w = new HTML(buf.toString());
+ w.addStyleName("patternSearchResult");
+ container.add(w);
+
+ HorizontalPanel bottomPanel = new HorizontalPanel();
+ bottomPanel.addStyleName("twikiBottomRow");
+ 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;
+ for (String key : hit.getMeta().keySet()) {
+ t.setText(row, 0, key);
+ t.setText(row, 1, hit.getMeta().get(key));
+ row++;
+ }
+ 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)
+ panel.add(new HTML("<p><a href=\""
+ + IdokSearchUtil.getDocumentURL(hit1)
+ + "\">r" + hit1.getRev() + "</a></p>"));
+ }
+ }
+ if (title != null) {
+ DisclosurePanel dp = new DisclosurePanel(title);
+ dp.setContent(panel);
+ bottomPanel.add(dp);
+ }
+ container.add(bottomPanel);
+ }
+
+ initWidget(container);
+ }
+
+}

Modified:
trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchUtil.java
==============================================================================
--- trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchUtil.java
(original)
+++ trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client/IdokSearchUtil.java
Fri Oct 17 11:12:10 2008
@@ -19,6 +19,10 @@
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.Window;

+/**
+ * This class provides a set of utility methods for accessing the iDok ReST
+ * search service.
+ */
public class IdokSearchUtil {

/**



  • [idok-commit] idok commit r280 - trunk/sites/psi/java/ch/psi/idok/gwt/twiki/client, AFS account Roman Geus, 10/17/2008

Archive powered by MHonArc 2.6.19.

Top of Page