Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Berry.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Berry.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Berry.java	(revision 2281)
@@ -20,22 +20,35 @@
 
 
-public class Berry extends Object
-{
-       private String berryTitle;
-       //private QueryID 
-	   //time stamp 
-	   // person added 
+import java.util.*;
 
+public class Berry extends Object {
+
+    private String berryTitle;
+    // private Person person;
+    private QueryHistoryItem queryHistoryItem;
+    private Date dateAdded;
+    private String collectionName; //unique collection ID across world?!?
+    private String documentID;
+      
 		 
-   public Berry( String newBerryTitle)
-         {	 
-         berryTitle = newBerryTitle;
-         }
-
-   public String toString ()
-         {
-         return( berryTitle);
-         }
+    public Berry(QueryHistoryItem newQueryHistoryItem, String newDocumentID, String newCollectionName, String newBerryTitle) {	
+	// need to add Person to argument list
+	queryHistoryItem = newQueryHistoryItem;
+	documentID = newDocumentID;
+	collectionName = newCollectionName;
+	berryTitle = newBerryTitle; // for the moment!
+	dateAdded = new Date();
+    }
 
 
-} //end Berry class
+    public Date getDateAdded() {
+	return dateAdded;
+    }
+
+
+    public String toString () {
+	return( berryTitle);
+    }
+
+
+} // Berry class
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/BerryBasketModel.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/BerryBasketModel.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/BerryBasketModel.java	(revision 2281)
@@ -27,38 +27,56 @@
 
 
-class BerryBasketModel extends AbstractTableModel
-{
+class BerryBasketModel extends AbstractTableModel {
 
- String[] content = {"Doc1", "Doc2", "Doc3"};
- String[] columnTitles = {"Document", "Person", "Date"};
+    private ArrayList columnTitles;
+    private ArrayList berryBasket;
+
+    private String DOCUMENT = "Document";
+    private String DATE = "Date";
  
  
-	public BerryBasketModel()
-	{
-		super();
-	}
+    public BerryBasketModel()
+    {
+	super();
+	berryBasket = new ArrayList();
+	columnTitles = new ArrayList();
+	columnTitles.add(DOCUMENT);
+	//columnTitles.add("User");
+	columnTitles.add(DATE);
+    }
 
-	public void add(Berry berry)
-	{
-		System.out.println("adding to BerryBasketModel: "  + berry.toString());	
-		//addElement(berry);
-	}
+    public void add(Berry berry) {
+	System.out.println("adding to BerryBasketModel: "  + berry.toString());
+	berryBasket.add(0, berry);
+	fireTableRowsInserted(0,0);
+    }
+	
+    public int getColumnCount() { 
+	return columnTitles.size();
+    }
 
+    public String getColumnName(int column) {
+	return (String) columnTitles.get(column);
+    }
+
+    public int getRowCount() {
+	return berryBasket.size();
+    }
 	
-	public int getColumnCount() { return columnTitles.length; }
-	
-    public int getRowCount() { return content.length;}
-	
-    public Object getValueAt(int row, int col) { 
-	     // get Berry object
-		 // extract document title (say), person, date info from Berry object
-		 // depending on column number
-		 // column reordering shouldn't matter, all
-		 // gets dealt with automatically
-	     return Color.black; 
-	}
-	
-    public String getColumnName(int col) {
-               return columnTitles[col];
+    public Object getValueAt(int row, int column) { 
+	// get Berry object
+	// extract document title (say), person, date info from Berry object
+	// depending on column number
+	// column reordering shouldn't matter, all
+	// gets dealt with automatically
+
+	Berry berry = (Berry) berryBasket.get(row);
+
+	if (column == columnTitles.indexOf(DOCUMENT)) return berry.toString();
+
+	if (column == columnTitles.indexOf(DATE)) return berry.getDateAdded();
+
+	// shouldn't get here but display something anyway
+	return "row" + row + "col" + column;
     }
 	
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/BerryBasketPanel.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/BerryBasketPanel.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/BerryBasketPanel.java	(revision 2281)
@@ -29,63 +29,43 @@
 
 
-public class BerryBasketPanel extends JPanel implements Constants
-{
+public class BerryBasketPanel extends JPanel implements Constants {
 
-BerryBasketModel berryModel;
-JTable berryTable;
-JList berryList;
-JScrollPane scrollBerryPane;
+    BerryBasketModel berryModel;
+    JTable berryTable;
+    JList berryList;
+    JScrollPane scrollBerryPane;
 
-  public BerryBasketPanel(CSModel csModel) 
-  {
-    super();
-    setLayout( new BorderLayout() );
+    public BerryBasketPanel(CSModel csModel)  {
+	super();
+	setLayout( new BorderLayout() );
 	setBorder(BorderFactory.createTitledBorder("BerryBasket"));
-	/* TableModel dataModel = new AbstractTableModel() {
-	     
-	
-          public int getColumnCount() { return columnTitles.length; }
-          public int getRowCount() { return 5;}
-          public Object getValueAt(int row, int col) { return new Integer(row*col); }
-		  public String getColumnName(int col) {
-               return columnTitles[col];
-          }
-
-      }; */
-	 berryModel = new BerryBasketModel();
-     berryTable = new JTable(berryModel);
+	berryModel = csModel.getBerryBasketModel();
+	berryTable = new JTable(berryModel);
  
-	//berryTable = new JTable(5,2);
-	
-	//berryList = new JList(csModel.getBerryModel()); //  must be vector or array
-	//berryList.setFont(berryFont);
-	//berryList.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
-	//scrollBerryPane = new JScrollPane(berryList);
-	
 	berryTable.setFont(berryFont);
 	berryTable.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
 	
-	berryTable.setDefaultRenderer(Color.class, new BerryCellRenderer());
+	//berryTable.setDefaultRenderer(Color.class, new BerryCellRenderer());
 	scrollBerryPane = new JScrollPane(berryTable);
 	berryTable.setPreferredScrollableViewportSize(new Dimension(100, 70));
 
-    add(scrollBerryPane, BorderLayout.CENTER);
-  } //end constructor
+	add(scrollBerryPane, BorderLayout.CENTER);
+    } //end constructor
 
 
-   class BerryCellRenderer extends JLabel implements TableCellRenderer {
+    class BerryCellRenderer extends JLabel implements TableCellRenderer {
   
-  public Component getTableCellRendererComponent(JTable table,
-                                               Object value,
-                                               boolean isSelected,
-                                               boolean hasFocus,
-                                               int row,
-                                               int column) {
-											   this.setText(value.toString());
-											   return this;
+	public Component getTableCellRendererComponent(JTable table,
+						       Object value,
+						       boolean isSelected,
+						       boolean hasFocus,
+						       int row,
+						       int column) {
+	    this.setText(value.toString());
+	    return this;
 	} // end getTableCellRendererComponent
   
   
-  } //  end BerryCellRenderer
+    } //  end BerryCellRenderer
 
 } // end BerryBasketPanel
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java	(revision 2281)
@@ -91,5 +91,11 @@
 	JPanel centerPanel = new JPanel();
 	QueryHistoryPanel queryHistoryPanel = new QueryHistoryPanel(csModel);
+	BerryBasketPanel berryBasketPanel = new BerryBasketPanel(csModel);
+
+
+	centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
+	centerPanel.add(berryBasketPanel);
 	centerPanel.add(queryHistoryPanel);
+
 
 	content.setLayout(new BoxLayout(content, BoxLayout.X_AXIS));	
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java	(revision 2281)
@@ -41,58 +41,62 @@
  */
 
-class CSModel extends Object
-{
+class CSModel extends Object {
 
-  Vector collectionList;
-  TreeMap collectionInfoMap;
+    Vector collectionList;
+    TreeMap collectionInfoMap;
     HashMap collectionNameMap;
-  String currentCollection;
-  ResultModel results;
-  NzdlService nzdl;
-  QueryHistoryModel queryHistoryModel;
+    String currentCollection;
+    ResultModel results;
+    NzdlService nzdl;
+    QueryHistoryModel queryHistoryModel;
+    BerryBasketModel berryBasketModel;
     
 
-  public CSModel(NzdlService newNzdl)
-  {
-    nzdl = newNzdl;
-    results = new ResultModel();
-    collectionList = new Vector();
-    collectionInfoMap = new TreeMap();
-    collectionNameMap = new HashMap();
-    queryHistoryModel = new QueryHistoryModel();
-    currentCollection = "";
-    initialiseCollection();
-  }
+    public CSModel(NzdlService newNzdl)
+    {
+	nzdl = newNzdl;
+	results = new ResultModel();
+	collectionList = new Vector();
+	collectionInfoMap = new TreeMap();
+	collectionNameMap = new HashMap();
+	queryHistoryModel = new QueryHistoryModel();
+	berryBasketModel = new BerryBasketModel();
+	currentCollection = "";
+	initialiseCollection();
+    }
   
   
-  public NzdlService getNzdlService()
-  {
-    return nzdl;
-  }
+    public NzdlService getNzdlService()
+    {
+	return nzdl;
+    }
 
     public QueryHistoryModel getQueryHistoryModel() {
 	return queryHistoryModel;
     }
+
+    public BerryBasketModel getBerryBasketModel() {
+	return berryBasketModel;
+    }
 	
+    /* Result methods */
 
-  /* Result methods */
+    public ResultModel getResultsModel()
+    {
+	return results;
+    }
+	
+    public void addResult(Result result)
+    {
+	results.add(result);
+    }
+	
+    public void clearResults()
+    {
+	//System.out.println("Clearing resultModel");
+	results.clear();
+    }
 
-  public ResultModel getResultsModel()
-  {
-    return results;
-  }
-	
-  public void addResult(Result result)
-  {
-    results.add(result);
-  }
-	
-  public void clearResults()
-  {
-    //System.out.println("Clearing resultModel");
-    results.clear();
-  }
-
-  /* collectionList methods */
+    /* collectionList methods */
 
     public Vector getCollectionList() {
@@ -127,60 +131,60 @@
 
 
-	public void setCurrentCollection(String collection )
-	    {
-		currentCollection = collection;
-	    }
+    public void setCurrentCollection(String collection )
+    {
+	currentCollection = collection;
+    }
 
-	public String getCurrentCollection()
-	    {
-		return currentCollection;
-	    }
+    public String getCurrentCollection()
+    {
+	return currentCollection;
+    }
 
-	public String getFirstCollection()
-	    {
-		if (getCollectionListSize() > 0)
-		    return (String)collectionInfoMap.firstKey();
-		else
-		    return "no collections";
-	    }
-	/**
-	 *
-	 */
-	public void initialiseCollection() 
-	    {
-		Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles
-		TreeSet orderedCollectionSet = new TreeSet(collectionSet);
-		// TreeSet automatically puts strings in alphabetical order
-		System.out.println("Number of collections on the server: " + 
-				   orderedCollectionSet.size());
-		Iterator collectionSetIterator = orderedCollectionSet.iterator();
-		while (collectionSetIterator.hasNext() ) {
-		  // object -> String
-		  String collectionName = (String)collectionSetIterator.next(); 
-		  NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName);
+    public String getFirstCollection()
+    {
+	if (getCollectionListSize() > 0)
+	    return (String)collectionInfoMap.firstKey();
+	else
+	    return "no collections";
+    }
+    /**
+     *
+     */
+    public void initialiseCollection() 
+    {
+	Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles
+	TreeSet orderedCollectionSet = new TreeSet(collectionSet);
+	// TreeSet automatically puts strings in alphabetical order
+	System.out.println("Number of collections on the server: " + 
+			   orderedCollectionSet.size());
+	Iterator collectionSetIterator = orderedCollectionSet.iterator();
+	while (collectionSetIterator.hasNext() ) {
+	    // object -> String
+	    String collectionName = (String)collectionSetIterator.next(); 
+	    NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName);
 
-		  if (info != null && 
-		      info.getBuildDate() != 0 &&
-		      nzdl.pingCollection(collectionName)) {
-		    collectionInfoMap.put(collectionName, info);
-		    String longCollectionName = "";
-		    Set n = nzdl.getMetaData(collectionName, "collection", "collectionname");
-		    if (n != null) {
-		      if (n.size() == 1) 
+	    if (info != null && 
+		info.getBuildDate() != 0 &&
+		nzdl.pingCollection(collectionName)) {
+		collectionInfoMap.put(collectionName, info);
+		String longCollectionName = "";
+		Set n = nzdl.getMetaData(collectionName, "collection", "collectionname");
+		if (n != null) {
+		    if (n.size() == 1) 
 			longCollectionName = (String) n.toArray()[0];
-		      else 
+		    else 
 			longCollectionName = collectionName + " has more than 1 collectionname";
-		      collectionNameMap.put(collectionName,longCollectionName );
-		      System.err.println("Adding " + collectionName + " to collection list...");
-		    }
-		  } // end if
-		  else {
-		    System.err.println("Collection " + collectionName + " getBuildDate() returned 0");
-		  } // end else
-		} // end while	
-		setCurrentCollection(getFirstCollection()); //assume at least one collection
+		    collectionNameMap.put(collectionName,longCollectionName );
+		    System.err.println("Adding " + collectionName + " to collection list...");
+		}
+	    } // end if
+	    else {
+		System.err.println("Collection " + collectionName + " getBuildDate() returned 0");
+	    } // end else
+	} // end while	
+	setCurrentCollection(getFirstCollection()); //assume at least one collection
     
-	    }
+    }
 	
 	
-    }
+}
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryItem.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryItem.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryItem.java	(revision 2281)
@@ -52,4 +52,8 @@
     }
 
+ public QueryHistoryItem() {
+     this(new Query(""), new Date(), "", "", 0, "", false, false);
+    }
+
     public String getCollectionName() {
 	return collectionName;
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryModel.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryModel.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryModel.java	(revision 2281)
@@ -32,10 +32,10 @@
 
     private String COLLECTION = "Collection";
-    private String DATE_TIME = "Date/Time";
+    private String DATE_TIME = "Time";
     private String TERMS = "Terms";
     private String HITS  = "Hits";
     private String QUERYTYPE = "Type";
-    private String STEMMED = "Stemmed?";
-    private String CASEMATCHED = "Case match?";
+    private String STEMMED = "Stem?";
+    private String CASEMATCHED = "Case?";
 
 
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Result.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Result.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Result.java	(revision 2281)
@@ -35,34 +35,35 @@
        private String docID;
        private String collectionName;
+       private QueryHistoryItem queryHistoryItem;
 
 
-    public final static Result FAKE_RESULT = new Result("No results returned", "", "");
-    public final static Result INITIAL_FAKE_RESULT = new Result("Search results will appear here", "", "");
+    public final static Result FAKE_RESULT = new Result("No results returned", "", "", new QueryHistoryItem() );
+    public final static Result INITIAL_FAKE_RESULT = new Result("Search results will appear here", "", "",  new QueryHistoryItem());
        // related query
 	   // time, person, collection etc
 
-		 public Result( String newResultTitle)
-         {	 
-         resultTitle = newResultTitle;
-         }
+    public Result( String newResultTitle) {	 
+	resultTitle = newResultTitle;
+    }
 		 
-   public Result( String newResultTitle, String newResultDocID,  String newResultCollectionName)
+   public Result( String newResultTitle, String newResultDocID,  String newResultCollectionName, QueryHistoryItem newQueryHistoryItem)
          {	 
          resultTitle = newResultTitle;
 	 docID = newResultDocID;
 	 collectionName = newResultCollectionName;
+	 queryHistoryItem = newQueryHistoryItem;
          }
 
-   public String toString ()
-         {
-         return resultTitle;
-         }
-    public String getDocID()
-	{
-	    return docID;
-	}
-    public String getCollectionName()
-    {
+    public String toString () {
+	return resultTitle;
+    }
+    public String getDocID() {
+	return docID;
+    }
+    public String getCollectionName() {
 	return collectionName;
+    }
+    public QueryHistoryItem getQueryHistoryItem() {
+	return queryHistoryItem;
     }
 
Index: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java	(revision 2278)
+++ trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java	(revision 2281)
@@ -68,4 +68,7 @@
     JPanel queryTypePanel, searchControlPanel;
   JPanel collectionListPanel, searchTextFieldPanel, searchButtonPanel;
+    JPopupMenu resultPopup;
+    Result selectedResult;
+    ResultModel resultListModel;
   JList   resultsList;   
     JCheckBox stemCheckBox, caseFoldCheckBox;
@@ -207,5 +210,5 @@
     resultsPanel.setLayout(new BorderLayout());
     resultsPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
-    ResultModel resultListModel = csModel.getResultsModel();
+    resultListModel = csModel.getResultsModel();
     resultsList = new JList(resultListModel); 
     resultsList.setFont(resultsFont);
@@ -215,4 +218,20 @@
     resultsPanel.add(scrollResultsPane, BorderLayout.CENTER);
     csModel.addResult(Result.INITIAL_FAKE_RESULT);
+
+    resultPopup = new JPopupMenu();
+    JMenuItem addBerryItem = new JMenuItem("Add to BerryBasket");
+    addBerryItem.addActionListener(new ActionListener() {
+	    public void actionPerformed(ActionEvent e) {
+		System.err.println("SelectedResult = " + selectedResult);
+		//System.err.println("add berry now...");
+		csModel.getBerryBasketModel().add( new Berry(selectedResult.getQueryHistoryItem(),selectedResult.getDocID(),selectedResult.getCollectionName(), selectedResult.toString()));
+	    } // actionPerformed
+    });
+    resultPopup.add(addBerryItem);
+    MouseListener popupListener = new PopupListener();
+    resultsList.addMouseListener(popupListener);
+
+
+
 
     dataPanel = new JPanel();
@@ -264,5 +283,4 @@
       NzdlQuery nzdlQuery = new NzdlQuery(queryString);
       nzdlQuery.setQueryType(buttonGroup.getSelection().getActionCommand());
-      System.err.println(buttonGroup.getSelection().getActionCommand());
       //nzdlQuery.setQueryType("boolean");
       nzdlQuery.setStemming(stemCheckBox.isSelected());
@@ -295,5 +313,8 @@
       // update the results list
       csModel.clearResults();
-      
+
+      QueryHistoryItem queryHistoryItem =  new QueryHistoryItem(new Query(queryString), new Date(), collectionName, "user",docIDs.size(),buttonGroup.getSelection().getActionCommand(),stemCheckBox.isSelected(), caseFoldCheckBox.isSelected());
+    csModel.getQueryHistoryModel().add(queryHistoryItem);
+
       if (docIDs.size() == 0 ) { // give some feedback for 0 results
 	csModel.addResult(Result.FAKE_RESULT);
@@ -304,5 +325,5 @@
 	while (docIDsIterator.hasNext()) {
 	  String resultDocID =  (String) docIDsIterator.next();
-	  csModel.addResult(new Result((String)titleMap.get(resultDocID), resultDocID, collectionName ));
+	  csModel.addResult(new Result((String)titleMap.get(resultDocID), resultDocID, collectionName, queryHistoryItem ));
 	} //end while
 	if (NzdlPreferences.getInstance().getBoolean(NzdlConstants.DISPLAY_FIRST_DOC))
@@ -310,7 +331,7 @@
       } // end else
 
-
+      /*
       csModel.getQueryHistoryModel().add( new QueryHistoryItem(new Query(queryString), new Date(), collectionName, "user",docIDs.size(),buttonGroup.getSelection().getActionCommand(),stemCheckBox.isSelected(), caseFoldCheckBox.isSelected() ));
-
+      */
       titleMap.clear();
       titleMetaData.clear();
@@ -443,3 +464,31 @@
 
 
+    class PopupListener extends MouseAdapter {
+	public void mousePressed(MouseEvent e) {
+	    maybeShowPopup(e);
+	}
+
+	public void mouseReleased(MouseEvent e) {
+	    maybeShowPopup(e);
+	}
+
+	private void maybeShowPopup(MouseEvent e) {
+	    if (e.isPopupTrigger()) {
+		int index = resultsList.locationToIndex(new Point(e.getX(), e.getY()));
+		if (index < resultListModel.getSize()) {
+		    Result result = (Result) resultListModel.getElementAt(index);
+		    if (result != Result.INITIAL_FAKE_RESULT) {
+			selectedResult = result;
+			resultPopup.show(e.getComponent(),
+					 e.getX(), e.getY());
+		    }
+		}
+		else
+		    System.err.println("popup not on item");
+	    }
+	}
+    } // PopupListener
+
+
+
 } //end SearchPanel
