Author: rodche
Date: 2012-05-28 15:35:17 -0700 (Mon, 28 May 2012)
New Revision: 29376

Added:
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/NameValuePairListItem.java
Removed:
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/FilterBoxItem.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/JListWithToolTips.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/RecordList.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SelectEntity.java
Modified:
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2Factory.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/DataSourceFilter.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/OrganismFilter.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/util/BioPaxUtil.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/ResultsModel.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchQueryPanel.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
   
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsPanel.java
Log:
Worked out filtering features and bugs... (code is also much cleaner now)

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2.java
      2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2.java
      2012-05-28 22:35:17 UTC (rev 29376)
@@ -77,7 +77,8 @@
                        return res;
     }
 
-    private static CPath2Client newClient() {
+    
+    public static CPath2Client newClient() {
         CPath2Client client = CPath2Client.newInstance();
 //        client.setEndPointURL("http://localhost:8080/cpath-web-service/";);
         client.setEndPointURL("http://awabi.cbio.mskcc.org/cpath2/";);
@@ -94,9 +95,9 @@
      */
     public static String getRecordsByIds(String[] ids, OutputFormat format) 
     {
-       //TODO client must return other formats, if requested
-       Model res = newClient().get(Arrays.asList(ids));
-               
+       //TODO client to return other formats as well
+       CPath2Client cli = newClient();
+       Model res = cli.get(Arrays.asList(ids));  
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
         BioPaxUtil.getBiopaxIO().convertToOWL(res, baos);
         

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2Factory.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2Factory.java
       2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2Factory.java
       2012-05-28 22:35:17 UTC (rev 29376)
@@ -2,6 +2,7 @@
 
 import java.util.List;
 
+import javax.swing.JList;
 import javax.swing.JPanel;
 
 import org.cytoscape.application.CyApplicationManager;
@@ -113,8 +114,8 @@
                return new DownloadDetails(passedRecordList);
        }
 
-       public static JPanel createSearchResultsFilterPanel(ResultsModel model) 
{
-               return new SearchResultsFilterPanel(model);
+       public static JPanel createSearchResultsFilterPanel(ResultsModel model, 
JList hits) {
+               return new SearchResultsFilterPanel(model, hits);
        }
        
        public static DetailsPanel createDetailsPanel(SearchResultsPanel 
searchHitsPanel) {

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/DataSourceFilter.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/DataSourceFilter.java
    2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/DataSourceFilter.java
    2012-05-28 22:35:17 UTC (rev 29376)
@@ -19,7 +19,7 @@
        public List<SearchHit> filter(List<SearchHit> recordList) {
                ArrayList<SearchHit> passedList = new ArrayList<SearchHit>();
                for (SearchHit record : recordList) {
-                       if (record.getDataSource() != null && 
!record.getDataSource().isEmpty()) 
+                       if (!record.getDataSource().isEmpty()) 
                        {
                                //copy datasources to a new set
                                Set<String> ds = new 
HashSet<String>(record.getDataSource());
@@ -27,6 +27,8 @@
                                if (!ds.isEmpty()) {
                                        passedList.add(record);
                                }
+                       } else {
+                               passedList.add(record);
                        }
                }
                return passedList;

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/OrganismFilter.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/OrganismFilter.java
      2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/filters/OrganismFilter.java
      2012-05-28 22:35:17 UTC (rev 29376)
@@ -19,7 +19,7 @@
        public List<SearchHit> filter(List<SearchHit> recordList) {
                ArrayList<SearchHit> passedList = new ArrayList<SearchHit>();
                for (SearchHit record : recordList) {
-                       if (record.getOrganism() != null && 
!record.getOrganism().isEmpty()) 
+                       if (!record.getOrganism().isEmpty()) 
                        {
                                //copy organisms to a new set
                                Set<String> o = new 
HashSet<String>(record.getOrganism());
@@ -27,6 +27,8 @@
                                if (!o.isEmpty()) {
                                        passedList.add(record);
                                }
+                       } else {
+                               passedList.add(record);
                        }
                }
                return passedList;

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/util/BioPaxUtil.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/util/BioPaxUtil.java
     2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/util/BioPaxUtil.java
     2012-05-28 22:35:17 UTC (rev 29376)
@@ -324,7 +324,7 @@
        }
 
        /**
-        * Gets the FilterBoxItem Name.
+        * Gets the NameValuePairListItem Name.
         *
         * @param bpe BioPAX element
         * @return organism field, or null if not available.

Deleted: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/FilterBoxItem.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/FilterBoxItem.java
  2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/FilterBoxItem.java
  2012-05-28 22:35:17 UTC (rev 29376)
@@ -1,33 +0,0 @@
-package org.cytoscape.cpathsquared.internal.view;
-
-
-public class FilterBoxItem implements Comparable<FilterBoxItem> {
-    private String name;
-    private String value;
-
-
-    public FilterBoxItem (String name, String value) {
-        this.name = name;
-        this.value = value;
-    }
-
-
-    public String getName() {
-        return name;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public String toString() {
-        return name;
-    }
-
-
-    //in order to order by name
-       @Override
-       public int compareTo(FilterBoxItem o) {
-               return this.name.compareTo(o.getName());
-       }
-}

Deleted: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/JListWithToolTips.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/JListWithToolTips.java
      2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/JListWithToolTips.java
      2012-05-28 22:35:17 UTC (rev 29376)
@@ -1,48 +0,0 @@
-package org.cytoscape.cpathsquared.internal.view;
-
-import java.awt.event.MouseEvent;
-
-import javax.swing.JList;
-import javax.swing.ListModel;
-
-import cpath.service.jaxb.SearchHit;
-
-
-/**
- * Extension to JList to Support Tool Tips.
- * <p/>
- * Based on sample code from:
- * http://www.roseindia.net/java/example/java/swing/TooltipTextOfList.shtml
- *
- */
-public class JListWithToolTips extends JList {
-
-    public JListWithToolTips(ListModel listModel) {
-        super(listModel);
-    }
-
-    /**
-     * Impelement Tool Tip Functionality.
-     *
-     * @param mouseEvent Mouse Event.
-     * @return Tool Tip.
-     */
-    @Override
-       public String getToolTipText(MouseEvent mouseEvent) {
-               int index = locationToIndex(mouseEvent.getPoint());
-               if (-1 < index) {
-                       SearchHit record = (SearchHit) 
getModel().getElementAt(index);
-                       StringBuilder html = new StringBuilder();
-                       html.append("<html><table cellpadding=10><tr><td>");
-                       html.append("<B>").append(record.getBiopaxClass());
-                       if(record.getName() != null)
-                               html.append("&nbsp;").append(record.getName());
-                       html.append("</B>&nbsp;");
-                       html.append("</td></tr></table></html>");
-                       return html.toString();
-               } else {
-                       return null;
-               }
-       }
-
-}

Copied: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/NameValuePairListItem.java
 (from rev 29345, 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/FilterBoxItem.java)
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/NameValuePairListItem.java
                          (rev 0)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/NameValuePairListItem.java
  2012-05-28 22:35:17 UTC (rev 29376)
@@ -0,0 +1,33 @@
+package org.cytoscape.cpathsquared.internal.view;
+
+
+public class NameValuePairListItem implements 
Comparable<NameValuePairListItem> {
+    private String name;
+    private String value;
+
+
+    public NameValuePairListItem (String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public String toString() {
+        return name;
+    }
+
+
+    //in order to order by name
+       @Override
+       public int compareTo(NameValuePairListItem o) {
+               return this.name.compareTo(o.getName());
+       }
+}

Deleted: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/RecordList.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/RecordList.java
     2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/RecordList.java
     2012-05-28 22:35:17 UTC (rev 29376)
@@ -1,101 +0,0 @@
-package org.cytoscape.cpathsquared.internal.view;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import cpath.service.jaxb.SearchHit;
-import cpath.service.jaxb.SearchResponse;
-
-
-final class RecordList {
-    private SearchResponse response;   
-    private Map<String, Integer> typeMap = new TreeMap<String, Integer>();
-    private Map<String, Integer> organismMap = new TreeMap<String, Integer>();
-    private Map<String, Integer> dataSourceMap = new TreeMap<String, 
Integer>();
-
-    /**
-     * Constructor.
-     * @param response 
-     */
-    public RecordList (SearchResponse response) {
-        this.response = response;
-        catalog();
-    }
-
-    /**
-     * Gets number of records.
-     * @return number of records.
-     */
-    public int getNumRecords() {
-        if (response != null && !response.isEmpty()) {
-            return response.getSearchHit().size();
-        } else {
-            return -1;
-        }
-    }
-
-    /**
-     * Gets hits
-     * @return 
-     */
-    public List<SearchHit> getHits() {
-        return response.getSearchHit();
-    }
-
-
-    /**
-     * Gets catalog of entity types.
-     * @return Map<Entity Type, # Records>
-     */
-    public Map<String, Integer> getTypeMap() {
-        return typeMap;
-    }
-
-    public Map<String, Integer> getOrganismMap() {
-        return organismMap;
-    }
-    
-    public Map<String, Integer> getDataSourceMap() {
-        return dataSourceMap;
-    }
-    
-    
-    private void catalog() {
-        List<SearchHit> recordList = response.getSearchHit();
-        if (recordList != null) {
-            for (SearchHit record:  recordList) {
-                catalog(record);
-            }
-        }
-    }
-
-    private void catalog(SearchHit record) {
-        String type = record.getBiopaxClass();
-        Integer count = typeMap.get(type);
-        if (count != null) {
-               typeMap.put(type, count + 1);
-        } else {
-               typeMap.put(type, 1);
-        }
-        
-        
-        for(String org : record.getOrganism()) {
-               Integer i = organismMap.get(org);
-            if (i != null) {
-                organismMap.put(org, i + 1);
-            } else {
-               organismMap.put(org, 1);
-            }
-        }
-        
-        for(String ds : record.getDataSource()) {
-               Integer i = dataSourceMap.get(ds);
-            if (i != null) {
-                dataSourceMap.put(ds, i + 1);
-            } else {
-               dataSourceMap.put(ds, 1);
-            }
-        }
-    }
-}
\ No newline at end of file

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/ResultsModel.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/ResultsModel.java
   2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/ResultsModel.java
   2012-05-28 22:35:17 UTC (rev 29376)
@@ -1,30 +1,100 @@
 package org.cytoscape.cpathsquared.internal.view;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Observable;
+import java.util.TreeMap;
 
+import cpath.service.jaxb.SearchHit;
+import cpath.service.jaxb.SearchResponse;
+
 /**
  * Contains information regarding the currently selected set of interaction 
bundles.
  *
  */
-public class ResultsModel extends Observable {
-    private RecordList recordList;
+public final class ResultsModel extends Observable {
 
+    private SearchResponse response;   
+    
+    Map<String, Integer> numHitsByTypeMap = new TreeMap<String, Integer>();
+    Map<String, Integer> numHitsByOrganismMap = new TreeMap<String, Integer>();
+    Map<String, Integer> numHitsByDatasourceMap = new TreeMap<String, 
Integer>();
+    
+    // URI-to-HTML summary text map
+    Map<String, String> summaryMap = new HashMap<String, String>();
+    Map<String, Collection<NameValuePairListItem>> pathwaysMap = new 
HashMap<String, Collection<NameValuePairListItem>>();    
+    Map<String, Collection<NameValuePairListItem>> moleculesMap = new 
HashMap<String, Collection<NameValuePairListItem>>();
+
+    public int getNumRecords() {
+        if (response != null && !response.isEmpty()) {
+            return response.getSearchHit().size();
+        } else {
+            return -1;
+        }
+    }
+  
+    
     /**
-     * Sets the SummaryResponse Object.
-     * @param recordList Record List.
+     * Re-builds hit-to-type, hit-to-organism, hit-to-datasource, 
+     * etc. internal maps.
      */
-    public void setRecordList (RecordList recordList) {
-        this.recordList = recordList;
+       private void init() {
+               if (response != null && !response.isEmpty()) {
+                       numHitsByTypeMap.clear();
+                       numHitsByOrganismMap.clear();
+                       numHitsByDatasourceMap.clear();
+                       pathwaysMap.clear();
+                       moleculesMap.clear();
+                       summaryMap.clear();
+
+                       for (SearchHit record : response.getSearchHit()) {
+                               catalog(record);
+                       }
+               }
+       }
+
+    
+    private void catalog(SearchHit record) {
+        String type = record.getBiopaxClass();
+        Integer count = numHitsByTypeMap.get(type);
+        if (count != null) {
+               numHitsByTypeMap.put(type, count + 1);
+        } else {
+               numHitsByTypeMap.put(type, 1);
+        }
+        
+        for(String org : record.getOrganism()) {
+               Integer i = numHitsByOrganismMap.get(org);
+            if (i != null) {
+                numHitsByOrganismMap.put(org, i + 1);
+            } else {
+               numHitsByOrganismMap.put(org, 1);
+            }
+        }
+        
+        for(String ds : record.getDataSource()) {
+               Integer i = numHitsByDatasourceMap.get(ds);
+            if (i != null) {
+                numHitsByDatasourceMap.put(ds, i + 1);
+            } else {
+               numHitsByDatasourceMap.put(ds, 1);
+            }
+        }
+    }
+    
+    
+    public void setSearchResponse (SearchResponse response) {
+        this.response = response;
+        init();
+        
         this.setChanged();
         this.notifyObservers();
     }
 
-    /**
-     * Gets the Record List.
-     * @return RecordList Object.
-     */
-    public RecordList getRecordList() {
-        return recordList;
+    
+    public SearchResponse getSearchResponse() {
+        return response;
     }
 
 }
\ No newline at end of file

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchQueryPanel.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchQueryPanel.java
       2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchQueryPanel.java
       2012-05-28 22:35:17 UTC (rev 29376)
@@ -40,12 +40,13 @@
  * Search Box Panel.
  *
  */
-public class SearchQueryPanel extends JPanel {
+public final class SearchQueryPanel extends JPanel {
     private static final String ENTER_TEXT = "Enter Gene Name or ID";
     private final CheckBoxJList organismList;
     private final CheckBoxJList dataSourceList;
     private final JTextField searchField;
-       
+    
+   
     /**
      * Constructor.
      */
@@ -120,10 +121,10 @@
 
 
     private final JComponent createOrganismFilterBox() {       
-       SortedJListModel<FilterBoxItem> model = new 
SortedJListModel<FilterBoxItem>();
+       SortedJListModel<NameValuePairListItem> model = new 
SortedJListModel<NameValuePairListItem>();
        Map<String,String> map = CPath2.getAvailableOrganisms();
        for(String o : map.keySet()) {
-               model.addElement(new FilterBoxItem(map.get(o), o));
+               model.addElement(new NameValuePairListItem(map.get(o), o));
        }
        organismList.setModel(model);
         organismList.setToolTipText("Select Organisms");
@@ -138,7 +139,7 @@
         
         Map<String,String> map = CPath2.getLoadedDataSources();
        for(String d : map.keySet()) {
-               dataSourceBoxModel.addElement(new FilterBoxItem(map.get(d), d));
+               dataSourceBoxModel.addElement(new 
NameValuePairListItem(map.get(d), d));
        }
         
         dataSourceList.setModel(dataSourceBoxModel);
@@ -185,11 +186,11 @@
         
         Set<String> organisms = new HashSet<String>();
         for(Object it : organism)
-               organisms.add(((FilterBoxItem)it).getValue());
+               organisms.add(((NameValuePairListItem)it).getValue());
         
        Set<String> datasources = new HashSet<String>();
         for(Object it : datasource)
-               datasources.add(((FilterBoxItem)it).getValue());
+               datasources.add(((NameValuePairListItem)it).getValue());
        
        Window window = CPath2Factory.getCySwingApplication().getJFrame();
         if (keyword == null || keyword.trim().length() == 0

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
       2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
       2012-05-28 22:35:17 UTC (rev 29376)
@@ -1,21 +1,20 @@
 package org.cytoscape.cpathsquared.internal.view;
 
-import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Observable;
 import java.util.Observer;
 import java.util.Set;
 
 import javax.swing.BoxLayout;
+import javax.swing.DefaultListModel;
 import javax.swing.JButton;
 import javax.swing.JLabel;
-import javax.swing.JOptionPane;
+import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.border.EmptyBorder;
@@ -24,7 +23,6 @@
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreePath;
 
-import org.cytoscape.cpathsquared.internal.CPath2Factory;
 import org.cytoscape.cpathsquared.internal.filters.ChainedFilter;
 import org.cytoscape.cpathsquared.internal.filters.DataSourceFilter;
 import org.cytoscape.cpathsquared.internal.filters.EntityTypeFilter;
@@ -33,18 +31,21 @@
 import cpath.service.jaxb.SearchHit;
 
 
-public class SearchResultsFilterPanel extends JPanel {
-    private JLabel matchingItemsLabel;
-    private ResultsModel model;
-    private CheckNode typeFilter;
-    private CheckNode dataSourceFilter;
-    private CheckNode organismFilter;
-    private JTreeWithCheckNodes tree;
-    private CollapsablePanel filterTreePanel;
-    private JButton applyButton;
+public class SearchResultsFilterPanel extends JPanel implements Observer {
+    private final JLabel matchingItemsLabel;
+    private final ResultsModel model;
+    private final JList hitsJList;
+    private final CheckNode rootNode;
+    private final CheckNode typeFilterNode;
+    private final CheckNode dataSourceFilterNode;
+    private final CheckNode organismFilterNode;
+    private final JTreeWithCheckNodes tree;
+    private final CollapsablePanel filterTreePanel;
+    private JButton downlodButton;
        
-       public SearchResultsFilterPanel(ResultsModel resultsModel) {
+       public SearchResultsFilterPanel(ResultsModel resultsModel, JList 
hitsJList) {
         this.model = resultsModel;
+        this.hitsJList = hitsJList;
         
         setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
         
@@ -56,10 +57,16 @@
         matchingItemsLabel.setBorder(new EmptyBorder(5, 10, 5, 5));
         add(matchingItemsLabel);
 
-        final CheckNode rootNode = new CheckNode("All Filters");
+        // create an empty filter tree (barebone)
+        rootNode = new CheckNode("All Filters");
+        typeFilterNode = new CheckNode("BioPAX Type");
+        rootNode.add(typeFilterNode);
+        organismFilterNode = new CheckNode("and Organism");
+        rootNode.add(organismFilterNode);
+        dataSourceFilterNode = new CheckNode("and Datasource");
+        rootNode.add(dataSourceFilterNode);
         tree = new JTreeWithCheckNodes(rootNode);
         tree.setOpaque(false);
-
         filterTreePanel = new CollapsablePanel("BioPAX Filters");
         filterTreePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
         filterTreePanel.getContentPane().add(tree);
@@ -67,217 +74,163 @@
         JScrollPane scrollPane = new JScrollPane(filterTreePanel);
         add(scrollPane);
         
-        addObserver(resultsModel, matchingItemsLabel, tree, rootNode);
+        model.addObserver(this);
         
-        createApplyFiltersButton();
+//        createDownloadButton();
     }
 
     /**
      * Expands all Nodes.
      */
     public void expandAllNodes() {
-        filterTreePanel.setCollapsed(false);
+       TreePath path;
+       filterTreePanel.setCollapsed(false);
         
-        typeFilter.setSelected(true);
-        TreePath path = new TreePath(typeFilter.getPath());
-        tree.expandPath(path);
+               typeFilterNode.setSelected(true);
+               path = new TreePath(typeFilterNode.getPath());
+               tree.expandPath(path);
         
-        dataSourceFilter.setSelected(true);
-        path = new TreePath(dataSourceFilter.getPath());
-        tree.expandPath(path);
+               dataSourceFilterNode.setSelected(true);
+               path = new TreePath(dataSourceFilterNode.getPath());
+               tree.expandPath(path);
         
-        organismFilter.setSelected(true);
-        path = new TreePath(organismFilter.getPath());
-        tree.expandPath(path);
+               organismFilterNode.setSelected(true);
+               path = new TreePath(organismFilterNode.getPath());
+               tree.expandPath(path);
     }
 
-    private void addObserver(final ResultsModel model,
-            final JLabel matchingHitsLabel, final JTreeWithCheckNodes tree,
-            final CheckNode rootNode) {
-        model.addObserver(new Observer() {
-            public void update(Observable observable, Object object) {
-                RecordList recordList = model.getRecordList();
-                matchingHitsLabel.setText("Matching entities:  "
-                        + recordList.getNumRecords());
-
-                if (recordList.getNumRecords() == 0) {
-                    filterTreePanel.setVisible(false);
-                    applyButton.setVisible(false);
-                } else {
-                    filterTreePanel.setVisible(true);
-                    applyButton.setVisible(true);
-                }
-                
-                
-                Map<String, Integer> typeMap = recordList.getTypeMap();
-                Map<String, Integer> organismMap = recordList.getOrganismMap();
-                Map<String, Integer> dataSourceMap = 
recordList.getDataSourceMap();
-
-                //  Store current expansion states
-                boolean typeFilterExpanded = false;
-                if (typeFilter != null) {
-                    TreePath path = new TreePath(typeFilter.getPath());
-                    typeFilterExpanded = tree.isExpanded(path);
-                }
-                boolean dataSourceFilterExpanded = false;
-                if (dataSourceFilter != null) {
-                    TreePath path = new TreePath(dataSourceFilter.getPath());
-                    dataSourceFilterExpanded = tree.isExpanded(path);
-                }
-                boolean organismFilterExpanded = false;
-                if (organismFilter != null) {
-                    TreePath path = new TreePath(organismFilter.getPath());
-                    organismFilterExpanded = tree.isExpanded(path);
-                }
-
-                //  Remove all children
-                rootNode.removeAllChildren();
-
-                // Create Filters
-                if (typeMap.size() > 0) {
-                    typeFilter = new CheckNode("by BioPAX Type");
-                    rootNode.add(typeFilter);
-                    for (String key : typeMap.keySet()) {
-                        CategoryCount categoryCount = new CategoryCount(key, 
typeMap.get(key));
-                        CheckNode typeNode = new CheckNode(categoryCount, 
false, true);
-                        typeFilter.add(typeNode);
-                    }
-                }
-                if (organismMap.size() > 0) {
-                    organismFilter = new CheckNode("by Organism");
-                    rootNode.add(organismFilter);
-                    for (String key : organismMap.keySet()) {
-                        CategoryCount categoryCount = new CategoryCount(key, 
organismMap.get(key));
-                        CheckNode organismNode = new CheckNode(categoryCount, 
false, true);
-                        organismFilter.add(organismNode);
-                    }
-                }
-                if (dataSourceMap.size() > 0) {
-                       dataSourceFilter = new CheckNode("by Datasource");
-                    rootNode.add(dataSourceFilter);
-                    for (String key : dataSourceMap.keySet()) {
-                        CategoryCount categoryCount = new CategoryCount(key, 
dataSourceMap.get(key));
-                        CheckNode dataSourceNode = new 
CheckNode(categoryCount, false, true);
-                        dataSourceFilter.add(dataSourceNode);
-                    }
-                }
-                
-                
-                DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
-                tree.setModel(treeModel);
-                treeModel.addTreeModelListener(new TreeModelListener() {
-
-                    /**
-                     * Respond to user check node selections.
-                     *
-                     * @param treeModelEvent Tree Model Event Object.
-                     */
-                    public void treeNodesChanged(TreeModelEvent 
treeModelEvent) {
-                        java.util.List<SearchHit> passedRecordList = 
executeFilter();
-                        if (passedRecordList != null) {
-                            matchingHitsLabel.setText("Matching entities:  "
-                                    + passedRecordList.size());
-                        }
-                    }
-
-                    public void treeNodesInserted(TreeModelEvent 
treeModelEvent) {
-                        //  no-op
-                    }
-
-                    public void treeNodesRemoved(TreeModelEvent 
treeModelEvent) {
-                        //  no-op
-                    }
-
-                    public void treeStructureChanged(TreeModelEvent 
treeModelEvent) {
-                        //  no-op
-                    }
-                });
-
-                //  Restore expansion state.
-                if (typeFilterExpanded) {
-                    TreePath path = new TreePath(typeFilter.getPath());
-                    tree.expandPath(path);
-                }
-                if (organismFilterExpanded) {
-                    TreePath path = new TreePath(organismFilter.getPath());
-                    tree.expandPath(path);
-                }
-                if (dataSourceFilterExpanded) {
-                    TreePath path = new TreePath(dataSourceFilter.getPath());
-                    tree.expandPath(path);
-                }
-            }
-        });
-    }
-
+    
     private List<SearchHit> executeFilter() {
-        Set<String> entityTypeSet = new HashSet<String>();
-        Set<String> entityOrganismSet = new HashSet<String>();
-        Set<String> entityDataSourceSet = new HashSet<String>();
+        ChainedFilter chainedFilter = new ChainedFilter();
         
-               if (typeFilter != null) {
-                       int childCount = typeFilter.getChildCount();
-                       for (int i = 0; i < childCount; i++) {
-                               CheckNode checkNode = (CheckNode) 
typeFilter.getChildAt(i);
-                               CategoryCount categoryCount = (CategoryCount) 
checkNode.getUserObject();
-                               String entityType = 
categoryCount.getCategoryName();
-                               if (checkNode.isSelected()) {
-                                       entityTypeSet.add(entityType);
-                               }
+               Set<String> entityTypeSet = new HashSet<String>();
+               for (int i = 0; i < typeFilterNode.getChildCount(); i++) {
+                       CheckNode checkNode = (CheckNode) 
typeFilterNode.getChildAt(i);
+                       CategoryCount categoryCount = (CategoryCount) 
checkNode.getUserObject();
+                       String entityType = categoryCount.getCategoryName();
+                       if (checkNode.isSelected()) {
+                               entityTypeSet.add(entityType);
                        }
                }
+               EntityTypeFilter entityTypeFilter = new 
EntityTypeFilter(entityTypeSet);
+               chainedFilter.addFilter(entityTypeFilter);
                
-               if (organismFilter != null) {
-                       int childCount = organismFilter.getChildCount();
-                       for (int i = 0; i < childCount; i++) {
-                               CheckNode checkNode = (CheckNode) 
organismFilter.getChildAt(i);
-                               CategoryCount categoryCount = (CategoryCount) 
checkNode.getUserObject();
-                               String entityType = 
categoryCount.getCategoryName();
-                               if (checkNode.isSelected()) {
-                                       entityOrganismSet.add(entityType);
-                               }
+               Set<String> entityOrganismSet = new HashSet<String>();
+               for (int i = 0; i < organismFilterNode.getChildCount(); i++) {
+                       CheckNode checkNode = (CheckNode) 
organismFilterNode.getChildAt(i);
+                       CategoryCount categoryCount = (CategoryCount) 
checkNode.getUserObject();
+                       String entityType = categoryCount.getCategoryName();
+                       if (checkNode.isSelected()) {
+                               entityOrganismSet.add(entityType);
                        }
                }
+               OrganismFilter organismFilter = new 
OrganismFilter(entityOrganismSet);
+               chainedFilter.addFilter(organismFilter);
                
-               if (dataSourceFilter != null) {
-                       int childCount = dataSourceFilter.getChildCount();
-                       for (int i = 0; i < childCount; i++) {
-                               CheckNode checkNode = (CheckNode) 
dataSourceFilter.getChildAt(i);
-                               CategoryCount categoryCount = (CategoryCount) 
checkNode.getUserObject();
-                               String entityType = 
categoryCount.getCategoryName();
-                               if (checkNode.isSelected()) {
-                                       entityDataSourceSet.add(entityType);
-                               }
+               Set<String> entityDataSourceSet = new HashSet<String>();
+               for (int i = 0; i < dataSourceFilterNode.getChildCount(); i++) {
+                       CheckNode checkNode = (CheckNode) 
dataSourceFilterNode.getChildAt(i);
+                       CategoryCount categoryCount = (CategoryCount) 
checkNode.getUserObject();
+                       String entityType = categoryCount.getCategoryName();
+                       if (checkNode.isSelected()) {
+                               entityDataSourceSet.add(entityType);
                        }
                }
+               DataSourceFilter dataSourceFilter = new 
DataSourceFilter(entityDataSourceSet);
+               chainedFilter.addFilter(dataSourceFilter);
                
+        return chainedFilter.filter(model.getSearchResponse().getSearchHit());
+    }
+
+    
+       private void applyFilter() {
+        List<SearchHit> passedRecordList = executeFilter();
+        matchingItemsLabel.setText("Matching entities:  "
+                       + passedRecordList.size());
                
-        ChainedFilter chainedFilter = new ChainedFilter();
-        EntityTypeFilter entityTypeFilter = new 
EntityTypeFilter(entityTypeSet);
-        chainedFilter.addFilter(entityTypeFilter);
-        DataSourceFilter dataSourceFilter = new 
DataSourceFilter(entityDataSourceSet);
-        chainedFilter.addFilter(dataSourceFilter);
-        OrganismFilter organismFilter = new OrganismFilter(entityOrganismSet);
-        chainedFilter.addFilter(organismFilter);
+               DefaultListModel listModel = (DefaultListModel) 
hitsJList.getModel();
+               listModel.clear();
+               listModel.setSize(passedRecordList.size());
+               int i = 0;
+               for (SearchHit searchHit : passedRecordList) {
+                       listModel.setElementAt(searchHit, i++);
+               }
+       }
+
+       
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public void update(Observable o, Object arg) {
+        matchingItemsLabel.setText("Matching entities:  "
+                + model.getNumRecords());
+
+        if (model.getNumRecords() == 0) {
+            filterTreePanel.setVisible(false);
+        } else {
+            filterTreePanel.setVisible(true);
+        }
         
-        List<SearchHit> passedRecordList;
-        passedRecordList = 
chainedFilter.filter(model.getRecordList().getHits());
+        //  Remove all children
+        typeFilterNode.removeAllChildren();
+        // Create Filter Nodes
+        for (String key : model.numHitsByTypeMap.keySet()) {
+            CategoryCount categoryCount = new CategoryCount(key, 
model.numHitsByTypeMap.get(key));
+            CheckNode typeNode = new CheckNode(categoryCount, false, true);
+            typeFilterNode.add(typeNode);
+        }
         
-        return passedRecordList;
-    }
+        organismFilterNode.removeAllChildren();
+        for (String key : model.numHitsByOrganismMap.keySet()) {
+            CategoryCount categoryCount = new CategoryCount(key, 
model.numHitsByOrganismMap.get(key));
+            CheckNode organismNode = new CheckNode(categoryCount, false, true);
+            organismFilterNode.add(organismNode);
+        }
+        
+        dataSourceFilterNode.removeAllChildren();
+        for (String key : model.numHitsByDatasourceMap.keySet()) {
+            CategoryCount categoryCount = new CategoryCount(key, 
model.numHitsByDatasourceMap.get(key));
+            CheckNode dataSourceNode = new CheckNode(categoryCount, false, 
true);
+            dataSourceFilterNode.add(dataSourceNode);
+        }
+            
+        DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
+        tree.setModel(treeModel);
+        treeModel.addTreeModelListener(new TreeModelListener() {
+            /**
+             * Respond to user check node selections.
+             *
+             * @param treeModelEvent Tree Model Event Object.
+             */
+            public void treeNodesChanged(TreeModelEvent treeModelEvent) {
+               applyFilter();
+               filterTreePanel.repaint();
+            }
+
+            public void treeNodesInserted(TreeModelEvent treeModelEvent) {
+                //  no-op
+            }
+
+            public void treeNodesRemoved(TreeModelEvent treeModelEvent) {
+                //  no-op
+            }
+
+            public void treeStructureChanged(TreeModelEvent treeModelEvent) {
+                //  no-op
+            }
+        });
+        
+        expandAllNodes();
+       }
+       
+       
     
-    //TODO must apply to the hits list!
-    private final void createApplyFiltersButton() {
-        applyButton = new JButton("Apply Filter");
-        applyButton.addActionListener(new ActionListener() {
-                       public void actionPerformed(ActionEvent actionEvent) {
-                List<SearchHit> passedRecordList = executeFilter();
-                if (passedRecordList.size() == 0) {
-                    
JOptionPane.showMessageDialog(CPath2Factory.getCySwingApplication().getJFrame(),
-                            "Your current filter settings result in 0 matching 
entities.  "
-                           + "\nPlease check your filter settings and try 
again.",
-                            "No matches.", JOptionPane.INFORMATION_MESSAGE);
-                } else {
+    //TODO 
+    private final void createDownloadButton() {
+        downlodButton = new JButton("Download");
+        downlodButton.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent actionEvent) {  
                
 //                    DownloadDetails detailsFrame = 
factory.createDownloadDetails(passedRecordList);
 //                    if (dialog != null) {
 //                            SwingUtilities.invokeLater(new Runnable() {
@@ -287,11 +240,9 @@
 //                            });
 //                    }
 //                    detailsFrame.setVisible(true);
-       
-                }
             }
         });
         
-        add(applyButton);
+        add(downlodButton);
     }
 }

Modified: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsPanel.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsPanel.java
     2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsPanel.java
     2012-05-28 22:35:17 UTC (rev 29376)
@@ -2,14 +2,13 @@
 
 import java.awt.BorderLayout;
 import java.awt.Component;
-import java.awt.Font;
 import java.awt.Window;
+import java.awt.event.MouseEvent;
 import java.util.List;
 import java.util.Set;
 
 import javax.swing.BoxLayout;
 import javax.swing.DefaultListModel;
-import javax.swing.JFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JList;
 import javax.swing.JOptionPane;
@@ -18,19 +17,15 @@
 import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 import javax.swing.JTextPane;
+import javax.swing.ListModel;
 import javax.swing.ListSelectionModel;
 import javax.swing.SwingUtilities;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 import javax.swing.table.DefaultTableModel;
-import javax.swing.text.Document;
 
+import org.apache.commons.lang.StringUtils;
 import org.cytoscape.application.swing.CySwingApplication;
-import org.cytoscape.application.swing.CytoPanel;
-import org.cytoscape.application.swing.CytoPanelName;
-import org.cytoscape.application.swing.CytoPanelState;
-import org.cytoscape.application.swing.events.CytoPanelStateChangedEvent;
-import org.cytoscape.application.swing.events.CytoPanelStateChangedListener;
 import org.cytoscape.cpathsquared.internal.CPath2Factory;
 import org.cytoscape.cpathsquared.internal.CPath2Properties;
 import org.cytoscape.cpathsquared.internal.CPath2;
@@ -43,22 +38,22 @@
 import cpath.service.jaxb.SearchResponse;
 
 
-public class SearchResultsPanel extends JPanel 
-implements CPath2Listener, CytoPanelStateChangedListener 
+public class SearchResultsPanel extends JPanel implements CPath2Listener 
 {
     private JList resList;
     private JList ppwList;
     private JList molList;
+    
 //    private HashMap <String, Map<String,String>> memberDetailsMap; //TODO 
map: search hits - participant/component names, xrefs, entity ref's ids, etc.
-    private Document summaryDocument;
     private String currentKeyword;
-    private ResultsModel resultsModel;
+    
+    private final ResultsModel resultsModel;
+    
     private JTextPane summaryTextPane;
     private DetailsPanel detailsPanel;
     private JScrollPane ppwListScrollPane;
     private JScrollPane molListScrollPane;
        private JLayeredPane appLayeredPane;
-//     private CytoPanelState cytoPanelState;
 
 
        public SearchResultsPanel() 
@@ -72,11 +67,10 @@
 
         //  Create Info Panel (the first tab)
         detailsPanel = CPath2Factory.createDetailsPanel(this);
-        summaryDocument = detailsPanel.getDocument();
         summaryTextPane = detailsPanel.getTextPane();
         
         //create parent pathways panel (the second tab)
-        ppwList = new JListWithToolTips(new DefaultListModel());
+        ppwList = new ToolTipsSearchHitsJList(new DefaultListModel());
         
ppwList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         ppwList.setPrototypeCellValue("12345678901234567890");
         JPanel ppwListPane = new JPanel();
@@ -86,7 +80,7 @@
         ppwListPane.add(ppwListScrollPane, BorderLayout.CENTER);
         
         //create participants (the third tab is about Entity References, 
Complexes, and Genes...)
-        molList = new JListWithToolTips(new DefaultListModel());
+        molList = new ToolTipsSearchHitsJList(new DefaultListModel());
         
molList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         molList.setPrototypeCellValue("12345678901234567890");
         JPanel molListPane = new JPanel();
@@ -102,7 +96,7 @@
         southPane.add("Molecules", molListPane);
   
         // search hits list
-        resList = new JListWithToolTips(new DefaultListModel());
+        resList = new ToolTipsSearchHitsJList(new DefaultListModel());
         
resList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         resList.setPrototypeCellValue("12345678901234567890");
         JPanel hitListPane = new JPanel();
@@ -118,7 +112,8 @@
         hitListPane.add(vSplit, BorderLayout.CENTER);
         
         //  Create search results extra filtering panel
-        JPanel filterPanel = 
CPath2Factory.createSearchResultsFilterPanel(resultsModel);
+        SearchResultsFilterPanel filterPanel = 
+               (SearchResultsFilterPanel) 
CPath2Factory.createSearchResultsFilterPanel(resultsModel, resList);
 
         //  Create the Split Pane
         JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 
filterPanel, hitListPane);
@@ -127,10 +122,6 @@
         add(hSplit);
         
         createSelectListener();
-                   
-//             // listener for cytopanel events
-//             CytoPanel cytoPanel = 
application.getCytoPanel(CytoPanelName.EAST);
-//             cytoPanelState = cytoPanel.getState();
     }
 
     /**
@@ -150,14 +141,9 @@
      * 
      */
     public void searchCompleted(final SearchResponse searchResponse) {
-
         if (!searchResponse.isEmpty()) {
-               
-            // set the all-results model - used for hits list filtering
-            resultsModel.setRecordList(new RecordList(searchResponse));
-
-            //  init/reset the hits list
-            updateHitsList(searchResponse);
+            resultsModel.setSearchResponse(searchResponse);
+            updateHitsList();
         } else {
             SwingUtilities.invokeLater(new Runnable(){
                 public void run() {
@@ -176,18 +162,16 @@
      * 
      * @param searchResponse
      */
-       public final void updateHitsList(final SearchResponse searchResponse) {
+       private final void updateHitsList() {
                // init/reset the hits list
                DefaultListModel listModel = (DefaultListModel) 
resList.getModel();
                listModel.clear();
-
-               List<SearchHit> searchHits = searchResponse.getSearchHit();
+               List<SearchHit> searchHits = 
resultsModel.getSearchResponse().getSearchHit();
                listModel.setSize(searchHits.size());
                int i = 0;
                for (SearchHit searchHit : searchHits) {
                        listModel.setElementAt(searchHit, i++);
                }
-
        }
     
 
@@ -199,9 +183,7 @@
                 //  Ignore the "unselect" event.
                 if (!listSelectionEvent.getValueIsAdjusting()) {
                     if (selectedIndex >=0) {
-                       (new SelectEntity()).selectItem(
-                                       
(SearchHit)resList.getModel().getElementAt(selectedIndex),
-                                summaryDocument, summaryTextPane, 
appLayeredPane);
+                       
selectHit((SearchHit)resList.getModel().getElementAt(selectedIndex));
                     }
                 }
             }
@@ -209,9 +191,66 @@
     }
 
     
-       @Override
-       public void handleEvent(CytoPanelStateChangedEvent e) {
-//             cytoPanelState = e.getNewState();
+       private void selectHit(SearchHit item) {
+               if (item == null) {
+                       return;
+               }
+
+               // get/create and show hit's summary
+               String summary = resultsModel.summaryMap.get(item.getUri());
+               if (summary == null) {
+                       StringBuilder html = new StringBuilder();
+                       html.append("<html>");
+
+                       if (item.getName() != null)
+                               html.append("<h2>" + item.getName() + "</h2>");
+                       html.append("<h3>Class: " + item.getBiopaxClass() + 
+                               "</h3><h3>URI: " + item.getUri() + "</h3>");
+
+                       List<String> items = item.getOrganism();
+                       if (items != null && !items.isEmpty()) {
+                               html.append("<H3>Organisms:<br/>"
+                                       + StringUtils.join(items, "<br/>") + 
"</H3>");
+                       }
+
+                       items = item.getPathway();
+                       if (items != null && !items.isEmpty()) {
+                               html.append("<H3>Pathway URIs:<br/>"
+                                               + StringUtils.join(items, 
"<br/>") + "</H3>");
+                       }
+
+                       items = item.getDataSource();
+                       if (items != null && !items.isEmpty()) {
+                               html.append("<H3>Data sources:<br/>"
+                                               + StringUtils.join(items, 
"<br/>") + "</H3>");
+                       }
+
+                       String primeExcerpt = item.getExcerpt();
+                       if (primeExcerpt != null) {
+                               html.append("<H4>Matched in</H4>");
+                               html.append("<span class='excerpt'>" + 
primeExcerpt
+                                               + "</span><BR>");
+                       }
+
+                       // TODO add more details here
+
+                       html.append("</html>");
+                       summary = html.toString();
+                       resultsModel.summaryMap.put(item.getUri(), summary);
+               }
+
+               summaryTextPane.setText(summary);
+               summaryTextPane.setCaretPosition(0);
+               appLayeredPane.repaint();
+
+               
+               
+               // TODO update pathways list
+               
+               
+
+               // TODO update mol. list
+
        }
        
        
@@ -246,4 +285,55 @@
         
CPath2Factory.getTaskManager().execute(taskFactory.createTaskIterator());
     }
     
+    
+    static class ToolTipsSearchHitsJList extends JList {
+
+        public ToolTipsSearchHitsJList(ListModel listModel) {
+            super(listModel);
+        }
+
+        @Override
+       public String getToolTipText(MouseEvent mouseEvent) {
+               int index = locationToIndex(mouseEvent.getPoint());
+               if (-1 < index) {
+                       SearchHit record = (SearchHit) 
getModel().getElementAt(index);
+                       StringBuilder html = new StringBuilder();
+                       html.append("<html><table cellpadding=10><tr><td>");
+                       html.append("<B>").append(record.getBiopaxClass());
+                       if(!record.getDataSource().isEmpty())
+                               
html.append("&nbsp;").append(record.getDataSource().toString());
+                       if(!record.getOrganism().isEmpty())
+                               
html.append("&nbsp;").append(record.getOrganism().toString());
+                       html.append("</B>&nbsp;");
+                       html.append("</td></tr></table></html>");
+                       return html.toString();
+               } else {
+                       return null;
+               }
+       }
+
+    }
+    
+    static class ToolTipsNameValuePairJList extends JList {
+
+        public ToolTipsNameValuePairJList(ListModel listModel) {
+            super(listModel);
+        }
+
+        @Override
+       public String getToolTipText(MouseEvent mouseEvent) {
+               int index = locationToIndex(mouseEvent.getPoint());
+               if (-1 < index) {
+                       StringBuilder html = new StringBuilder();
+                       html.append("<html><table cellpadding=10><tr><td>");
+                       html.append("<B>").append("TODO");
+                       html.append("</B>&nbsp;");
+                       html.append("</td></tr></table></html>");
+                       return html.toString();
+               } else {
+                       return null;
+               }
+       }
+
+    }
 }
\ No newline at end of file

Deleted: 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SelectEntity.java
===================================================================
--- 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SelectEntity.java
   2012-05-28 18:42:13 UTC (rev 29375)
+++ 
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SelectEntity.java
   2012-05-28 22:35:17 UTC (rev 29376)
@@ -1,65 +0,0 @@
-package org.cytoscape.cpathsquared.internal.view;
-
-import java.util.List;
-
-import javax.swing.JComponent;
-import javax.swing.JTextPane;
-import javax.swing.text.Document;
-
-import cpath.service.jaxb.*;
-
-import org.apache.commons.lang.StringUtils;
-
-
-public final class SelectEntity {
-
-    public final void selectItem(
-            SearchHit item, 
-            Document summaryDocumentModel, 
-            JTextPane textPane, 
-            JComponent textPaneOwner) 
-    {
-       
-        if (item != null) {
-            StringBuffer html = new StringBuffer();
-            html.append("<html>");
-
-            if(item.getName() != null)
-               html.append ("<h2>" + item.getName() + "</h2>");
-            html.append ("<h3>Class: " + item.getBiopaxClass() + "</h3>");
-            html.append ("<h3>URI: " + item.getUri() + "</h3>");
-
-            List<String> items = item.getOrganism();
-            if (items != null && !items.isEmpty()) {
-                html.append ("<H3>Organisms:<br/>" + StringUtils.join(items, 
"<br/>") + "</H3>");
-            }
-
-            items = item.getPathway();
-            if (items != null && !items.isEmpty()) {
-                html.append ("<H3>Pathway URIs:<br/>" + 
StringUtils.join(items, "<br/>") + "</H3>");
-            }
-            
-            items = item.getDataSource();
-            if (items != null && !items.isEmpty()) {
-                html.append ("<H3>Data sources:<br/>" + 
StringUtils.join(items, "<br/>") + "</H3>");
-            }
-            
-            String primeExcerpt = item.getExcerpt();
-            if (primeExcerpt != null) {
-                html.append("<H4>Matched in</H4>");
-                html.append("<span class='excerpt'>" + primeExcerpt + 
"</span><BR>") ;
-            }
-            
-            
-            //TODO add more details here
-
-            html.append ("</html>");
-            textPane.setText(html.toString());
-            textPane.setCaretPosition(0);
-
-                       textPaneOwner.repaint();
-        }
-    }
-
-
-}
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to