Author: rodche
Date: 2012-05-25 13:33:42 -0700 (Fri, 25 May 2012)
New Revision: 29361
Added:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
Removed:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchHitsPanel.java
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/view/CPath2SearchPanel.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/DetailsPanel.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/SearchResultsPanel.java
Log:
cPathSquared prototype app UI was modified, some views - renamed (next step
will be to get/display all parent pathways and member molecules for a selected
Hit, and make after-search filters work...)
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-25 19:58:51 UTC (rev 29360)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/CPath2Factory.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -9,7 +9,7 @@
import org.cytoscape.cpathsquared.internal.view.BinarySifVisualStyleFactory;
import org.cytoscape.cpathsquared.internal.view.DownloadDetails;
import org.cytoscape.cpathsquared.internal.view.ResultsModel;
-import org.cytoscape.cpathsquared.internal.view.SearchHitsPanel;
+import org.cytoscape.cpathsquared.internal.view.SearchResultsFilterPanel;
import org.cytoscape.cpathsquared.internal.view.DetailsPanel;
import org.cytoscape.cpathsquared.internal.view.SearchQueryPanel;
import org.cytoscape.cpathsquared.internal.view.SearchResultsPanel;
@@ -113,12 +113,12 @@
return new DownloadDetails(passedRecordList);
}
- public static JPanel createFilterPanel(ResultsModel model) {
- return new SearchHitsPanel(model);
+ public static JPanel createSearchResultsFilterPanel(ResultsModel model)
{
+ return new SearchResultsFilterPanel(model);
}
public static DetailsPanel createDetailsPanel(SearchResultsPanel
searchHitsPanel) {
- return new DetailsPanel(searchHitsPanel);
+ return new DetailsPanel();
}
public static CyNetworkManager getNetworkManager() {
Modified:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/CPath2SearchPanel.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/CPath2SearchPanel.java
2012-05-25 19:58:51 UTC (rev 29360)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/CPath2SearchPanel.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -17,7 +17,8 @@
import cpath.service.jaxb.SearchResponse;
/**
- * Main GUI Panel for Searching a cPath Instance.
+ * Main GUI Panel for Searching a cPath2 Instance
+ * and Showing Results and Options.
*
*/
public class CPath2SearchPanel extends JPanel implements CPath2Listener {
@@ -40,7 +41,7 @@
cards = new JPanel(new CardLayout());
searchResultsPanel = new SearchResultsPanel();
- cards.add (createAboutPanel(), "ABOUT");
+// cards.add (createAboutPanel(), "ABOUT");
cards.add(searchResultsPanel, "HITS");
add(cards, BorderLayout.CENTER);
CPath2.addApiListener(this);
@@ -49,21 +50,22 @@
public void showAboutPanel() {
CardLayout cl = (CardLayout)(cards.getLayout());
- cl.show(cards, "ABOUT");
+// cl.show(cards, "ABOUT");
+ cl.show(cards, "HITS");
}
- private JPanel createAboutPanel() {
- JPanel aboutPanel = new JPanel();
- aboutPanel.setLayout(new BorderLayout());
- GradientHeader header = new GradientHeader("About");
+// private JPanel createAboutPanel() {
+// JPanel aboutPanel = new JPanel();
+// aboutPanel.setLayout(new BorderLayout());
+// GradientHeader header = new GradientHeader("About");
+//
+// aboutPanel.add(header, BorderLayout.NORTH);
+// JTextPane textPane =
DetailsPanel.createHtmlTextPane(CPath2Factory.getOpenBrowser());
+// textPane.setText(CPath2Properties.blurb);
+// aboutPanel.add(textPane, BorderLayout.CENTER);
+// return aboutPanel;
+// }
- aboutPanel.add(header, BorderLayout.NORTH);
- JTextPane textPane =
DetailsPanel.createHtmlTextPane(CPath2Factory.getOpenBrowser());
- textPane.setText(CPath2Properties.blurb);
- aboutPanel.add(textPane, BorderLayout.CENTER);
- return aboutPanel;
- }
-
public void searchInitiated(String keyword, Set<String> organism,
Set<String> datasource) {
}
Modified:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/DetailsPanel.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/DetailsPanel.java
2012-05-25 19:58:51 UTC (rev 29360)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/DetailsPanel.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -1,8 +1,6 @@
package org.cytoscape.cpathsquared.internal.view;
import java.awt.BorderLayout;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
@@ -22,37 +20,22 @@
* Summary Panel.
*
*/
-public class DetailsPanel extends JPanel implements MouseListener {
+public class DetailsPanel extends JPanel {
private Document doc;
private JTextPane textPane;
- private SearchResultsPanel searchHitsPanel; // ref to parent
/**
* Constructor.
* @param browser
*/
- public DetailsPanel(SearchResultsPanel searchHitsPanel) {
+ public DetailsPanel() {
this.setLayout(new BorderLayout());
- this.searchHitsPanel = searchHitsPanel;
textPane = createHtmlTextPane(CPath2Factory.getOpenBrowser());
doc = textPane.getDocument();
JScrollPane scrollPane = encloseInJScrollPane (textPane);
-
- GradientHeader header = new GradientHeader("Details");
- // we become gradient header mouse listener - see comment below
- header.addMouseListener(this);
- add (header, BorderLayout.NORTH);
add(scrollPane, BorderLayout.CENTER);
}
- // kill mouse events - fixes bug where user can
- // click on gradient header and select things underneath
- public void mouseClicked(MouseEvent e) {}
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
- public void mousePressed(MouseEvent e) {}
- public void mouseReleased(MouseEvent e) {}
-
/**
* Gets the summary document model.
* @return Document object.
Modified:
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-25 19:58:51 UTC (rev 29360)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/JListWithToolTips.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -1,7 +1,6 @@
package org.cytoscape.cpathsquared.internal.view;
import java.awt.event.MouseEvent;
-import java.util.List;
import javax.swing.JList;
import javax.swing.ListModel;
@@ -28,27 +27,22 @@
* @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);
- StringBuffer html = new StringBuffer();
- html.append("<html>");
- html.append("<table cellpadding=10><tr><td>");
- html.append("<B>" + record.getName() +
"</B> ");
-
- List<String> organisms = record.getOrganism();
- if (!organisms.isEmpty()) {
- html.append(organisms.toString());
- }
-
- html.append("</td></tr></table>");
- html.append("</html>");
+ StringBuilder html = new StringBuilder();
+ html.append("<html><table cellpadding=10><tr><td>");
+ html.append("<B>").append(record.getBiopaxClass());
+ if(record.getName() != null)
+ html.append(" ").append(record.getName());
+ html.append("</B> ");
+ html.append("</td></tr></table></html>");
return html.toString();
} else {
return null;
}
}
-
}
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchHitsPanel.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchHitsPanel.java
2012-05-25 19:58:51 UTC (rev 29360)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchHitsPanel.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -1,306 +0,0 @@
-package org.cytoscape.cpathsquared.internal.view;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.FlowLayout;
-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.JButton;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.border.EmptyBorder;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-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;
-import org.cytoscape.cpathsquared.internal.filters.OrganismFilter;
-
-import cpath.service.jaxb.SearchHit;
-
-
-public class SearchHitsPanel 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 SearchHitsPanel(ResultsModel resultsModel) {
- this.model = resultsModel;
- JPanel panel = new JPanel();
- panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-
- matchingItemsLabel = new JLabel("Matching entities: N/A");
- matchingItemsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
- Font font = matchingItemsLabel.getFont();
- Font newFont = new Font(font.getFamily(), Font.BOLD, font.getSize());
- matchingItemsLabel.setFont(newFont);
- matchingItemsLabel.setBorder(new EmptyBorder(5, 10, 5, 5));
- panel.add(matchingItemsLabel);
-
- final CheckNode rootNode = new CheckNode("All Filters");
- tree = new JTreeWithCheckNodes(rootNode);
- tree.setOpaque(false);
-
- filterTreePanel = new CollapsablePanel("Filters (Optional)");
- filterTreePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
- filterTreePanel.getContentPane().add(tree);
-
- panel.add(filterTreePanel);
- addObserver(resultsModel, matchingItemsLabel, tree, rootNode);
-
- JPanel footer = new JPanel();
- footer.setAlignmentX(Component.LEFT_ALIGNMENT);
- footer.setLayout(new FlowLayout(FlowLayout.LEFT));
- createDownloadButton(footer);
- panel.add(footer);
-
-
- JScrollPane scrollPane = new JScrollPane(panel);
- this.setLayout(new BorderLayout());
- this.add(scrollPane, BorderLayout.CENTER);
- }
-
- /**
- * Expands all Nodes.
- */
- public void expandAllNodes() {
- filterTreePanel.setCollapsed(false);
-
- typeFilter.setSelected(true);
- TreePath path = new TreePath(typeFilter.getPath());
- tree.expandPath(path);
-
- dataSourceFilter.setSelected(true);
- path = new TreePath(dataSourceFilter.getPath());
- tree.expandPath(path);
-
- organismFilter.setSelected(true);
- path = new TreePath(organismFilter.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("Filter 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("Filter 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("Filter 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>();
-
- 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);
- }
- }
- }
-
- 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);
- }
- }
- }
-
- 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);
- }
- }
- }
-
-
- 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);
-
- List<SearchHit> passedRecordList;
- passedRecordList =
chainedFilter.filter(model.getRecordList().getHits());
-
- return passedRecordList;
- }
-
- //TODO change this to reset the hits list in the left-top panel
- private final void createDownloadButton(JPanel footer) {
- 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 {
-// DownloadDetails detailsFrame =
factory.createDownloadDetails(passedRecordList);
-// if (dialog != null) {
-// SwingUtilities.invokeLater(new Runnable() {
-// public void run() {
-// dialog.dispose();
-// }
-// });
-// }
-// detailsFrame.setVisible(true);
-
-
-
- }
- }
- });
- footer.add(applyButton);
- }
-}
Copied:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
(from rev 29344,
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchHitsPanel.java)
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
(rev 0)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsFilterPanel.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -0,0 +1,297 @@
+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.JButton;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.EmptyBorder;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+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;
+import org.cytoscape.cpathsquared.internal.filters.OrganismFilter;
+
+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 SearchResultsFilterPanel(ResultsModel resultsModel) {
+ this.model = resultsModel;
+
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ matchingItemsLabel = new JLabel("Matching entities: N/A");
+ matchingItemsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
+ Font font = matchingItemsLabel.getFont();
+ Font newFont = new Font(font.getFamily(), Font.BOLD, font.getSize());
+ matchingItemsLabel.setFont(newFont);
+ matchingItemsLabel.setBorder(new EmptyBorder(5, 10, 5, 5));
+ add(matchingItemsLabel);
+
+ final CheckNode rootNode = new CheckNode("All Filters");
+ tree = new JTreeWithCheckNodes(rootNode);
+ tree.setOpaque(false);
+
+ filterTreePanel = new CollapsablePanel("BioPAX Filters");
+ filterTreePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+ filterTreePanel.getContentPane().add(tree);
+
+ JScrollPane scrollPane = new JScrollPane(filterTreePanel);
+ add(scrollPane);
+
+ addObserver(resultsModel, matchingItemsLabel, tree, rootNode);
+
+ createApplyFiltersButton();
+ }
+
+ /**
+ * Expands all Nodes.
+ */
+ public void expandAllNodes() {
+ filterTreePanel.setCollapsed(false);
+
+ typeFilter.setSelected(true);
+ TreePath path = new TreePath(typeFilter.getPath());
+ tree.expandPath(path);
+
+ dataSourceFilter.setSelected(true);
+ path = new TreePath(dataSourceFilter.getPath());
+ tree.expandPath(path);
+
+ organismFilter.setSelected(true);
+ path = new TreePath(organismFilter.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>();
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+
+ 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);
+
+ List<SearchHit> passedRecordList;
+ passedRecordList =
chainedFilter.filter(model.getRecordList().getHits());
+
+ return passedRecordList;
+ }
+
+ //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 {
+// DownloadDetails detailsFrame =
factory.createDownloadDetails(passedRecordList);
+// if (dialog != null) {
+// SwingUtilities.invokeLater(new Runnable() {
+// public void run() {
+// dialog.dispose();
+// }
+// });
+// }
+// detailsFrame.setVisible(true);
+
+ }
+ }
+ });
+
+ add(applyButton);
+ }
+}
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-25 19:58:51 UTC (rev 29360)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/view/SearchResultsPanel.java
2012-05-25 20:33:42 UTC (rev 29361)
@@ -47,33 +47,61 @@
implements CPath2Listener, CytoPanelStateChangedListener
{
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 ResultsModel topPathwaysModel;
private JTextPane summaryTextPane;
private DetailsPanel detailsPanel;
+ private JScrollPane ppwListScrollPane;
+ private JScrollPane molListScrollPane;
private JLayeredPane appLayeredPane;
- private CytoPanelState cytoPanelState;
- private JFrame detailsFrame;
+// private CytoPanelState cytoPanelState;
public SearchResultsPanel()
{
- this.resultsModel = new ResultsModel();
+ resultsModel = new ResultsModel();
CySwingApplication application = CPath2Factory.getCySwingApplication();
appLayeredPane =
application.getJFrame().getRootPane().getLayeredPane();
// add this search/get events listener to the api
CPath2.addApiListener(this);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- // Create the Details Panel
+ // Create Info Panel (the first tab)
detailsPanel = CPath2Factory.createDetailsPanel(this);
summaryDocument = detailsPanel.getDocument();
summaryTextPane = detailsPanel.getTextPane();
-
- // Create the hits list panel (to apply extra filters and choose from)
+
+ //create parent pathways panel (the second tab)
+ ppwList = new JListWithToolTips(new DefaultListModel());
+
ppwList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ ppwList.setPrototypeCellValue("12345678901234567890");
+ JPanel ppwListPane = new JPanel();
+ ppwListPane.setLayout(new BorderLayout());
+ ppwListScrollPane = new JScrollPane(ppwList);
+ ppwListScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
+ ppwListPane.add(ppwListScrollPane, BorderLayout.CENTER);
+
+ //create participants (the third tab is about Entity References,
Complexes, and Genes...)
+ molList = new JListWithToolTips(new DefaultListModel());
+
molList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ molList.setPrototypeCellValue("12345678901234567890");
+ JPanel molListPane = new JPanel();
+ molListPane.setLayout(new BorderLayout());
+ molListScrollPane = new JScrollPane(molList);
+ molListScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
+ molListPane.add(molListScrollPane, BorderLayout.CENTER);
+
+ // make tabs
+ JTabbedPane southPane = new JTabbedPane();
+ southPane.add("Summary", detailsPanel);
+ southPane.add("Parent Pathways", ppwListPane);
+ southPane.add("Molecules", molListPane);
+
+ // search hits list
resList = new JListWithToolTips(new DefaultListModel());
resList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
resList.setPrototypeCellValue("12345678901234567890");
@@ -81,38 +109,28 @@
hitListPane.setLayout(new BorderLayout());
JScrollPane hitListScrollPane = new JScrollPane(resList);
hitListScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
- GradientHeader header = new GradientHeader("Select from Search
Results");
+ GradientHeader header = new GradientHeader("Hits");
header.setAlignmentX(Component.LEFT_ALIGNMENT);
hitListPane.add(header, BorderLayout.NORTH);
- JSplitPane internalPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
hitListScrollPane, detailsPanel);
- internalPanel.setDividerLocation(200);
- hitListPane.add(internalPanel, BorderLayout.CENTER);
+ JSplitPane vSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
hitListScrollPane, southPane);
+ vSplit.setDividerLocation(200);
+ hitListPane.add(vSplit, BorderLayout.CENTER);
+
// Create search results extra filtering panel
- JPanel networksPanel = new JPanel();
- networksPanel.setLayout(new BorderLayout());
- networksPanel.add( new GradientHeader("Select"), BorderLayout.NORTH);
- JTabbedPane tabbedPane = new JTabbedPane();
- JPanel filterPanel = CPath2Factory.createFilterPanel(resultsModel);
-// JPanel pathwayPanel =
factory.createTopPathwaysPanel(CPath2Client.newInstance().getTopPathways(),
CPath2);
- Font font = tabbedPane.getFont();
- tabbedPane.setFont(new Font(font.getFamily(), Font.PLAIN,
font.getSize()-2));
- tabbedPane.add("Extra Filters", filterPanel);
- //TODO add more tabs: "networks by organism", "networks by datasource"
- networksPanel.add(tabbedPane, BorderLayout.CENTER);
+ JPanel filterPanel =
CPath2Factory.createSearchResultsFilterPanel(resultsModel);
// Create the Split Pane
- JSplitPane splitPane = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT,
- hitListPane, networksPanel);
- splitPane.setDividerLocation(400);
- splitPane.setAlignmentX(Component.LEFT_ALIGNMENT);
- this.add(splitPane);
-
+ JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
filterPanel, hitListPane);
+ hSplit.setDividerLocation(200);
+ hSplit.setAlignmentX(Component.LEFT_ALIGNMENT);
+ add(hSplit);
+
createSelectListener();
-
- // listener for cytopanel events
- CytoPanel cytoPanel =
application.getCytoPanel(CytoPanelName.EAST);
- cytoPanelState = cytoPanel.getState();
+
+// // listener for cytopanel events
+// CytoPanel cytoPanel =
application.getCytoPanel(CytoPanelName.EAST);
+// cytoPanelState = cytoPanel.getState();
}
/**
@@ -193,7 +211,7 @@
@Override
public void handleEvent(CytoPanelStateChangedEvent e) {
- cytoPanelState = e.getNewState();
+// cytoPanelState = e.getNewState();
}
--
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.