Author: kono
Date: 2011-06-14 15:52:50 -0700 (Tue, 14 Jun 2011)
New Revision: 25757
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportAction.java
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportClient.java
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/AttributeImportPanel.java
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/CheckBoxJList.java
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGeneDialog.java
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
core3/webservice-ncbi-client-impl/trunk/src/main/resources/images/
core3/webservice-ncbi-client-impl/trunk/src/main/resources/images/entrez_page_title.gif
Modified:
core3/webservice-ncbi-client-impl/trunk/pom.xml
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBIWebServiceClient.java
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Start porting NCBI attribute (table) import client.
Modified: core3/webservice-ncbi-client-impl/trunk/pom.xml
===================================================================
--- core3/webservice-ncbi-client-impl/trunk/pom.xml 2011-06-14 22:36:26 UTC
(rev 25756)
+++ core3/webservice-ncbi-client-impl/trunk/pom.xml 2011-06-14 22:52:50 UTC
(rev 25757)
@@ -115,6 +115,12 @@
<version>3.0.0-alpha3-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>swing-application-api</artifactId>
+ <version>3.0.0-alpha3-SNAPSHOT</version>
+ </dependency>
+
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportAction.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportAction.java
(rev 0)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportAction.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -0,0 +1,33 @@
+package org.cytoscape.webservice.ncbi;
+
+import java.awt.event.ActionEvent;
+import java.util.Map;
+
+import org.cytoscape.application.swing.AbstractCyAction;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyTableManager;
+import org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.webservice.ncbi.ui.NCBIGeneDialog;
+
+public class NCBITableImportAction extends AbstractCyAction {
+
+ private static final long serialVersionUID = 3101400401346193602L;
+
+ final CyTableManager tblManager;
+ final CyNetworkManager netManager;
+
+ public NCBITableImportAction(final CyTableManager tblManager, final
CyNetworkManager netManager, CyApplicationManager applicationManager) {
+ super("Import Data Table from NCBI...", applicationManager);
+ setPreferredMenu("File.Import");
+ this.tblManager = tblManager;
+ this.netManager = netManager;
+ }
+
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ NCBIGeneDialog dialog = new NCBIGeneDialog(tblManager,
netManager);
+ dialog.setVisible(true);
+ }
+
+}
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportClient.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportClient.java
(rev 0)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBITableImportClient.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -0,0 +1,29 @@
+package org.cytoscape.webservice.ncbi;
+
+import java.util.Set;
+
+import org.cytoscape.io.webservice.TableImportWebServiceClient;
+import org.cytoscape.io.webservice.client.AbstractWebServiceClient;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.work.TaskIterator;
+
+public class NCBITableImportClient extends AbstractWebServiceClient implements
TableImportWebServiceClient {
+
+ public NCBITableImportClient(String uri, String displayName, String
description) {
+ super(uri, displayName, description);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public TaskIterator getTaskIterator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<CyTable> getTables() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBIWebServiceClient.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBIWebServiceClient.java
2011-06-14 22:36:26 UTC (rev 25756)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/NCBIWebServiceClient.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -4,26 +4,22 @@
import java.util.Set;
import org.cytoscape.io.webservice.NetworkImportWebServiceClient;
-import org.cytoscape.io.webservice.SearchWebServiceClient;
-import org.cytoscape.io.webservice.TableImportWebServiceClient;
import org.cytoscape.io.webservice.client.AbstractWebServiceClient;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.model.CyNetworkManager;
-import org.cytoscape.model.CyTable;
import org.cytoscape.webservice.ncbi.task.ImportNetworkFromGeneTask;
import org.cytoscape.work.TaskIterator;
-public class NCBIWebServiceClient extends AbstractWebServiceClient implements
- TableImportWebServiceClient, NetworkImportWebServiceClient,
- SearchWebServiceClient<Object> {
-
+public class NCBIWebServiceClient extends AbstractWebServiceClient implements
NetworkImportWebServiceClient {
+
private final CyNetworkFactory networkFactory;
private final CyNetworkManager manager;
-
+
private ImportNetworkFromGeneTask networkTask;
-
- public NCBIWebServiceClient(final String uri, String displayName,
String description, final CyNetworkFactory networkFactory, final
CyNetworkManager manager) {
+
+ public NCBIWebServiceClient(final String uri, String displayName,
String description,
+ final CyNetworkFactory networkFactory, final
CyNetworkManager manager) {
super(uri, displayName, description);
this.networkFactory = networkFactory;
this.manager = manager;
@@ -31,7 +27,7 @@
@Override
public TaskIterator getTaskIterator() {
- if(currentQuery == null)
+ if (currentQuery == null)
throw new NullPointerException("Query object is null.");
else {
networkTask = new
ImportNetworkFromGeneTask(this.currentQuery.toString(), networkFactory,
manager);
@@ -42,24 +38,11 @@
@Override
public Set<CyNetwork> getNetworks() {
final Set<CyNetwork> result = new HashSet<CyNetwork>();
- if(networkTask != null) {
+ if (networkTask != null) {
final CyNetwork network = networkTask.getNetwork();
- if(network != null)
+ if (network != null)
result.add(network);
}
return result;
}
-
- @Override
- public Set<CyTable> getTables() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Object getSearchResult() {
- // TODO Auto-generated method stub
- return null;
- }
-
}
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/AttributeImportPanel.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/AttributeImportPanel.java
(rev 0)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/AttributeImportPanel.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -0,0 +1,490 @@
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.webservice.ncbi.ui;
+
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.swing.DefaultListModel;
+import javax.swing.GroupLayout;
+import javax.swing.Icon;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.LayoutStyle;
+import javax.swing.SwingUtilities;
+
+import org.cytoscape.model.CyColumn;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.events.ColumnCreatedEvent;
+import org.cytoscape.model.events.ColumnCreatedListener;
+import org.cytoscape.model.events.ColumnDeletedEvent;
+import org.cytoscape.model.events.ColumnDeletedListener;
+
+/**
+ * General GUI component for importing attributes.<br>
+ * Maybe used by Web Service Clients to import attributes.
+ *
+ * This UI accepts title and icon. Usually, those are from source database.
+ *
+ * TODO: is this the right place for this class?
+ *
+ */
+public abstract class AttributeImportPanel extends JPanel implements
+ ColumnCreatedListener, ColumnDeletedListener {
+
+ private static final long serialVersionUID = 8665197023334496167L;
+
+ protected static final String TABLE_PREFIX = "BioMart Global Table ";
+
+ /**
+ * Will be caught by parent object (usually a dialog.)
+ */
+ public static final String CLOSE_EVENT = "CLOSE";
+
+ // Default title of this panel.
+ private static final String DEF_TITLE = "Attribute Import Utility";
+
+ // Labels for the sub-panels.
+ private static final String DATASOURCE = "Data Source";
+ private static final String KEY_ATTR = "Key Attribute in Cytoscape";
+ private static final String ATTR_PANEL_TITLE = "Available Annotations";
+
+ // Swing components. Maybe accessed from child classes.
+ protected javax.swing.JComboBox attributeComboBox;
+ protected javax.swing.JLabel attributeLabel;
+ protected javax.swing.JPanel attributePanel;
+ protected javax.swing.JComboBox attributeTypeComboBox;
+ protected javax.swing.JLabel attributeTypeLabel;
+ protected javax.swing.JButton cancelButton;
+ protected javax.swing.JComboBox databaseComboBox;
+ protected javax.swing.JPanel databasePanel;
+ protected javax.swing.JPanel attrListPanel;
+ protected javax.swing.JPanel availableAttrPanel;
+ protected javax.swing.JScrollPane availableAttrScrollPane;
+ protected javax.swing.JButton importButton;
+ protected javax.swing.JLabel titleLabel;
+ protected javax.swing.JButton resetButton;
+ protected CheckBoxJList attrCheckboxList;
+
+ protected DefaultListModel attrCheckboxListModel;
+
+ // Title of the panel.
+ protected String panelTitle;
+
+ // Icon for this panel title.
+ protected Icon logo;
+
+ // Attribute panel border title
+ protected String attributePanelTitle;
+
+ protected final CyTableManager tblManager;
+ private final CyNetworkManager netManager;
+
+
+ protected AttributeImportPanel(final CyTableManager tblManager, final
CyNetworkManager netManager,
+ Icon logo, String title,
+ String attrPanelTitle) {
+ this.logo = logo;
+ this.panelTitle = title;
+ this.attributePanelTitle = attrPanelTitle;
+ this.tblManager = tblManager;
+ this.netManager = netManager;
+
+ initComponents();
+
+ setAttributeComboBox();
+ }
+
+ private void initComponents() {
+ attrCheckboxList = new CheckBoxJList();
+ attrCheckboxListModel = new DefaultListModel();
+ attrCheckboxList.setModel(attrCheckboxListModel);
+
+ titleLabel = new javax.swing.JLabel();
+ databasePanel = new javax.swing.JPanel();
+ databaseComboBox = new javax.swing.JComboBox();
+ attributePanel = new javax.swing.JPanel();
+ attributeLabel = new javax.swing.JLabel();
+ attributeComboBox = new javax.swing.JComboBox();
+ attributeTypeLabel = new javax.swing.JLabel();
+ attributeTypeComboBox = new javax.swing.JComboBox();
+ availableAttrPanel = new javax.swing.JPanel();
+ availableAttrScrollPane = new javax.swing.JScrollPane();
+ attrListPanel = new javax.swing.JPanel();
+ importButton = new javax.swing.JButton();
+ cancelButton = new javax.swing.JButton();
+ resetButton = new javax.swing.JButton();
+
+ setBackground(new java.awt.Color(255, 255, 255));
+ titleLabel.setBackground(new java.awt.Color(255, 255, 255));
+ titleLabel.setIcon(logo);
+ titleLabel.setText(panelTitle);
+
+ databasePanel.setBackground(new java.awt.Color(255, 255, 255));
+ databasePanel.setBorder(javax.swing.BorderFactory
+ .createTitledBorder(DATASOURCE));
+
+ attributeComboBox.setBackground(Color.white);
+
+ databaseComboBox.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ databaseComboBoxActionPerformed(evt);
+ }
+ });
+ databaseComboBox.setBackground(Color.white);
+
+ GroupLayout databasePanelLayout = new
GroupLayout(databasePanel);
+ databasePanel.setLayout(databasePanelLayout);
+ databasePanelLayout.setHorizontalGroup(databasePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
+ databasePanelLayout
+
.createSequentialGroup()
+
.addContainerGap()
+
.addComponent(databaseComboBox, 0, 350,
+
Short.MAX_VALUE).addContainerGap()));
+ databasePanelLayout.setVerticalGroup(databasePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
+ databasePanelLayout
+
.createSequentialGroup()
+
.addComponent(databaseComboBox,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE)
+
.addContainerGap(14, Short.MAX_VALUE)));
+
+ attributePanel.setBackground(new java.awt.Color(255, 255, 255));
+ attributePanel.setBorder(javax.swing.BorderFactory
+ .createTitledBorder(KEY_ATTR));
+ attributeLabel.setText("Attribute:");
+
+ attributeTypeLabel.setText("Data Type:");
+
+ attributeTypeComboBox
+ .addActionListener(new
java.awt.event.ActionListener() {
+ public void
actionPerformed(java.awt.event.ActionEvent evt) {
+
attributeTypeComboBoxActionPerformed(evt);
+ }
+ });
+ attributeTypeComboBox.setBackground(Color.white);
+
+ GroupLayout attributePanelLayout = new
GroupLayout(attributePanel);
+ attributePanel.setLayout(attributePanelLayout);
+ attributePanelLayout
+ .setHorizontalGroup(attributePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(
+
attributePanelLayout
+
.createSequentialGroup()
+
.addContainerGap()
+
.addGroup(
+
attributePanelLayout
+
.createParallelGroup(
+
GroupLayout.Alignment.LEADING)
+
.addComponent(
+
attributeLabel)
+
.addComponent(
+
attributeTypeLabel))
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addGroup(
+
attributePanelLayout
+
.createParallelGroup(
+
GroupLayout.Alignment.LEADING)
+
.addComponent(
+
attributeTypeComboBox,
+
0, 350,
+
Short.MAX_VALUE)
+
.addComponent(
+
attributeComboBox,
+
0, 350,
+
Short.MAX_VALUE))
+
.addContainerGap()));
+ attributePanelLayout
+ .setVerticalGroup(attributePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(
+
attributePanelLayout
+
.createSequentialGroup()
+
.addGroup(
+
attributePanelLayout
+
.createParallelGroup(
+
GroupLayout.Alignment.BASELINE)
+
.addComponent(
+
attributeLabel)
+
.addComponent(
+
attributeComboBox,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE))
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addGroup(
+
attributePanelLayout
+
.createParallelGroup(
+
GroupLayout.Alignment.BASELINE)
+
.addComponent(
+
attributeTypeLabel)
+
.addComponent(
+
attributeTypeComboBox,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE))
+
.addContainerGap(13, Short.MAX_VALUE)));
+
+ availableAttrPanel.setBackground(new java.awt.Color(255, 255,
255));
+ availableAttrPanel.setBorder(javax.swing.BorderFactory
+ .createTitledBorder(attributePanelTitle));
+ availableAttrScrollPane
+
.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ availableAttrScrollPane.setViewportView(attrCheckboxList);
+
+ GroupLayout availableAttrPanelLayout = new GroupLayout(
+ availableAttrPanel);
+ availableAttrPanel.setLayout(availableAttrPanelLayout);
+
availableAttrPanelLayout.setHorizontalGroup(availableAttrPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
+ availableAttrPanelLayout
+
.createSequentialGroup()
+
.addContainerGap()
+
.addComponent(availableAttrScrollPane,
+
GroupLayout.DEFAULT_SIZE, 350,
+
Short.MAX_VALUE).addContainerGap()));
+
availableAttrPanelLayout.setVerticalGroup(availableAttrPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
+ GroupLayout.Alignment.TRAILING,
+ availableAttrPanelLayout
+
.createSequentialGroup()
+
.addComponent(availableAttrScrollPane,
+
GroupLayout.DEFAULT_SIZE, 362,
+
Short.MAX_VALUE).addContainerGap()));
+
+ importButton.setText("Import");
+ importButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ importButtonActionPerformed(evt);
+ }
+ });
+ importButton.setBackground(Color.white);
+
+ cancelButton.setText("Cancel");
+ cancelButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ cancelButtonActionPerformed(evt);
+ }
+ });
+ cancelButton.setBackground(Color.white);
+
+ resetButton.setText("Reset");
+ resetButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ resetButtonActionPerformed(evt);
+ }
+ });
+ resetButton.setBackground(Color.white);
+
+ GroupLayout layout = new GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(layout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(
+ GroupLayout.Alignment.TRAILING,
+ layout.createSequentialGroup()
+
.addContainerGap()
+ .addGroup(
+
layout.createParallelGroup(
+
GroupLayout.Alignment.TRAILING)
+
.addComponent(
+
availableAttrPanel,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)
+
.addComponent(
+
attributePanel,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)
+
.addComponent(
+
databasePanel,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)
+
.addComponent(titleLabel)
+
.addGroup(
+
layout.createSequentialGroup()
+
.addComponent(
+
resetButton)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED,
+
343,
+
Short.MAX_VALUE)
+
.addComponent(
+
cancelButton)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(
+
importButton)))
+
.addContainerGap()));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ GroupLayout.Alignment.LEADING)
+ .addGroup(
+ layout.createSequentialGroup()
+
.addContainerGap()
+
.addComponent(titleLabel)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(databasePanel,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(attributePanel,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(availableAttrPanel,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(
+
layout.createParallelGroup(
+
GroupLayout.Alignment.BASELINE)
+
.addComponent(importButton)
+
.addComponent(cancelButton)
+
.addComponent(resetButton))
+
.addContainerGap()));
+ } // </editor-fold>
+
+ protected abstract void resetButtonActionPerformed(ActionEvent evt);
+
+ protected void importButtonActionPerformed(ActionEvent evt) {
+ importAttributes();
+ }
+
+ protected void cancelButtonActionPerformed(java.awt.event.ActionEvent
evt) {
+ // Close parent
+ final JDialog container = (JDialog)
this.getRootPane().getParent();
+ // System.out.println("parent = " + container);
+ container.setVisible(false);
+ }
+
+ private void attributeTypeComboBoxActionPerformed(
+ java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ abstract protected void databaseComboBoxActionPerformed(
+ java.awt.event.ActionEvent evt);
+
+
+ protected abstract void importAttributes();
+
+
+ private void setAttributeComboBox() {
+ final Set<CyNetwork> networks = this.netManager.getNetworkSet();
+
+ for(CyNetwork network: networks) {
+ final Map<String, CyTable> tables =
this.tblManager.getTableMap(CyNode.class, network);
+ final CyTable nodeTable =
tables.get(CyNetwork.DEFAULT_ATTRS);
+ //final Map<String, Class<?>> columns =
nodeTable.getColumnTypeMap();
+ Collection<CyColumn> columns = nodeTable.getColumns();
+ for (CyColumn col : columns)
+ attributeComboBox.addItem(col.getName());
+ }
+ }
+
+ protected void addAttribute(final String attributeName) {
+ if (attributeName == null)
+ return;
+
+ final Object currentSelection =
attributeComboBox.getSelectedItem();
+
+ final SortedSet<String> attrNameSet = new TreeSet<String>();
+ attrNameSet.add(attributeName);
+ for (int i = 0; i < attributeComboBox.getItemCount(); i++)
+
attrNameSet.add(attributeComboBox.getItemAt(i).toString());
+
+ attributeComboBox.removeAllItems();
+
+ for (String name : attrNameSet)
+ attributeComboBox.addItem(name);
+
+ if(currentSelection != null)
+
attributeComboBox.setSelectedItem(currentSelection.toString());
+ }
+
+ protected void removeAttribute(final String attributeName) {
+ if (attributeName != null) {
+ attributeComboBox.removeItem(attributeName);
+ return;
+ }
+ }
+
+ @Override
+ public void handleEvent(ColumnCreatedEvent e) {
+ final String attrName = e.getColumnName();
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ addAttribute(attrName);
+ }
+ });
+ }
+
+ @Override
+ public void handleEvent(ColumnDeletedEvent e) {
+ final String attrName = e.getColumnName();
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ removeAttribute(attrName);
+ }
+ });
+ }
+
+}
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/CheckBoxJList.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/CheckBoxJList.java
(rev 0)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/CheckBoxJList.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -0,0 +1,206 @@
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.webservice.ncbi.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+/**
+ * <p>
+ * This class is based on CheckBoxJList: from SWING HACKS ISBN: 0-596-00907-0
By
+ * Joshua Marinacci, Chris Adamson
+ * </p>
+ *
+ * <p>
+ * Customized by Keiichiro Ono
+ * </p>
+ */
+public class CheckBoxJList extends JList implements ListSelectionListener {
+
+ private static final long serialVersionUID = 8204477191024405955L;
+
+ private static final Color SELECTED_COLOR = new Color(0, 100, 250, 250);
+ private static final Color NORMAL_COLOR = new Color(100, 100, 100, 170);
+
+ private static Color listBackground;
+ private static final Font NORMAL_FONT = new Font("SansSerif",
Font.PLAIN, 12);
+ private static final Font SELECTED_FONT = new Font("SansSerif",
Font.BOLD, 12);
+
+ public static final String LIST_UPDATED = "LIST_UPDATED";
+
+ static {
+ UIDefaults uid = UIManager.getLookAndFeel().getDefaults();
+ listBackground = uid.getColor("List.background");
+ }
+
+ private HashSet<Integer> selectionCache = new HashSet<Integer>();
+
+ /**
+ * Creates a new CheckBoxJList object.
+ */
+ public CheckBoxJList() {
+ super();
+ setCellRenderer(new CheckBoxListCellRenderer());
+ addListSelectionListener(this);
+ }
+
+ public void setSelectedItems(List<String> selected) {
+ ListSelectionListener[] listeners =
this.getListSelectionListeners();
+ for (ListSelectionListener l : listeners) {
+ removeListSelectionListener(l);
+ }
+ getSelectionModel().clearSelection();
+ selectionCache.clear();
+
+ for (int i = 0; i < this.getModel().getSize(); i++) {
+ if (selected.contains(getModel().getElementAt(i))) {
+ getSelectionModel().addSelectionInterval(i, i);
+ selectionCache.add(i);
+ }
+ }
+
+ for (ListSelectionListener l : listeners) {
+ addListSelectionListener(l);
+ }
+ }
+
+ // ListSelectionListener implementation
+ /**
+ * Update the list items.
+ *
+ * @param lse
+ * DOCUMENT ME!
+ */
+ public void valueChanged(ListSelectionEvent lse) {
+
+ if (!lse.getValueIsAdjusting()) {
+ removeListSelectionListener(this);
+
+ // remember everything selected as a result of this
action
+ final HashSet<Integer> newSelections = new
HashSet<Integer>();
+ final int size = getModel().getSize();
+
+ for (int i = 0; i < size; i++) {
+ if (getSelectionModel().isSelectedIndex(i)) {
+ newSelections.add(i);
+ }
+ }
+
+ // turn on everything that was previously selected
+ for (Integer index : selectionCache) {
+ getSelectionModel().addSelectionInterval(index,
index);
+ }
+
+ // add or remove the delta
+ for (Integer index : newSelections) {
+ if (selectionCache.contains(index))
+
getSelectionModel().removeSelectionInterval(index, index);
+ else
+
getSelectionModel().addSelectionInterval(index, index);
+ }
+
+ // save selections for next time
+ selectionCache.clear();
+
+ for (int i = 0; i < size; i++) {
+ if (getSelectionModel().isSelectedIndex(i)) {
+ selectionCache.add(i);
+ }
+ }
+
+ addListSelectionListener(this);
+ firePropertyChange(LIST_UPDATED, null, null);
+ }
+ }
+
+ private final class CheckBoxListCellRenderer extends JComponent
implements ListCellRenderer {
+
+ private static final long serialVersionUID =
3002151884598694214L;
+
+ private final DefaultListCellRenderer defaultComp;
+ private final JCheckBox checkbox;
+ private final BorderLayout layout = new BorderLayout();
+
+ public CheckBoxListCellRenderer() {
+ setLayout(layout);
+ defaultComp = new DefaultListCellRenderer();
+ checkbox = new JCheckBox();
+ add(checkbox, BorderLayout.WEST);
+ add(defaultComp, BorderLayout.CENTER);
+ }
+
+ public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected,
+ boolean cellHasFocus) {
+ defaultComp.getListCellRendererComponent(list, value,
index, isSelected, cellHasFocus);
+
+ checkbox.setSelected(isSelected);
+
+ if (isSelected) {
+ checkbox.setFont(SELECTED_FONT);
+ defaultComp.setFont(SELECTED_FONT);
+ checkbox.setForeground(SELECTED_COLOR);
+ defaultComp.setForeground(SELECTED_COLOR);
+ } else {
+ checkbox.setFont(NORMAL_FONT);
+ defaultComp.setFont(NORMAL_FONT);
+ checkbox.setForeground(NORMAL_COLOR);
+ defaultComp.setForeground(NORMAL_COLOR);
+ }
+
+ final Component[] comps = getComponents();
+ final int length = comps.length;
+
+ for (int i = 0; i < length; i++) {
+ comps[i].setBackground(listBackground);
+ }
+
+ return this;
+ }
+ }
+}
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGeneDialog.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGeneDialog.java
(rev 0)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGeneDialog.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -0,0 +1,43 @@
+package org.cytoscape.webservice.ncbi.ui;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyTableManager;
+
+public class NCBIGeneDialog extends JDialog implements PropertyChangeListener {
+
+ private static final long serialVersionUID = -2609215983943863094L;
+
+ private final CyTableManager tblManager;
+ private final CyNetworkManager netManager;
+
+ public NCBIGeneDialog(final CyTableManager tblManager, final
CyNetworkManager netManager) {
+ this.tblManager = tblManager;
+ this.netManager = netManager;
+
+ setTitle("NCBI Entrez Gene");
+
+ try {
+ final JPanel panel = new NCBIGenePanel(tblManager,
netManager, "NCBI table import");
+ panel.addPropertyChangeListener(this);
+ add(panel);
+ pack();
+ setLocationRelativeTo(null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if(evt.getPropertyName().equals("CLOSE")) {
+ dispose();
+ }
+
+ }
+
+}
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
(rev 0)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
2011-06-14 22:52:50 UTC (rev 25757)
@@ -0,0 +1,110 @@
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.webservice.ncbi.ui;
+
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+
+import javax.swing.DefaultListModel;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JComboBox;
+
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyTableManager;
+
+/**
+ * Simple attribute import GUI for Entrez Gene database
+ * This UI depends on
+ */
+public class NCBIGenePanel extends AttributeImportPanel {
+
+ private static final long serialVersionUID = -7433578094886775930L;
+
+ private static final Icon LOGO = new
ImageIcon(NCBIGenePanel.class.getResource("/images/entrez_page_title.gif"));
+
+ private DefaultListModel model;
+
+ private JComboBox attrList;
+
+
+ public NCBIGenePanel(final CyTableManager tblManager, final
CyNetworkManager netManager, String attrPanelName) throws IOException {
+ super(tblManager, netManager, LOGO, "NCBI Client",
attrPanelName);
+ initDataSources();
+ this.setPreferredSize(new Dimension(550, 480));
+ }
+
+ private void initDataSources() {
+ this.databaseComboBox.addItem("NCBI Entrez Gene");
+ databaseComboBox.setEnabled(false);
+ setDataType();
+ }
+
+ private void setDataType() {
+ this.attributeTypeComboBox.addItem("Entrez Gene ID");
+ attributeTypeComboBox.setEnabled(false);
+
+ buildList();
+ }
+
+ protected void importButtonActionPerformed(ActionEvent e) {
+ importAttributes();
+ }
+
+ protected void resetButtonActionPerformed(ActionEvent e) {
+ buildList();
+ }
+
+ private void buildList() {
+// model = new DefaultListModel();
+// this.attributeComboBox.setModel((ComboBoxModel) model);
+// for(AnnotationCategory dispAttrName :
AnnotationCategory.values()) {
+// model.addElement(dispAttrName.getName());
+// }
+ }
+
+
+ @Override
+ protected void databaseComboBoxActionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void importAttributes() {
+
+ }
+
+}
Modified:
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-06-14 22:36:26 UTC (rev 25756)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-06-14 22:52:50 UTC (rev 25757)
@@ -9,9 +9,19 @@
<osgi:service id="ncbiClientService" ref="ncbiClient"
auto-export="interfaces" />
+ <osgi:reference id="cyApplicationManagerRef"
+ interface="org.cytoscape.session.CyApplicationManager" />
+
+
<osgi:reference id="cyNetworkFactoryServiceRef"
interface="org.cytoscape.model.CyNetworkFactory" />
<osgi:reference id="cyNetworkManagerServiceRef"
interface="org.cytoscape.model.CyNetworkManager" />
+ <osgi:reference id="cyTableManagerServiceRef"
interface="org.cytoscape.model.CyTableManager" />
+
+
+ <osgi:service id="ncbiTableImportClientService"
ref="ncbiTableImportClient"
+ interface="org.cytoscape.application.swing.CyAction" />
+
</beans>
Modified:
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-06-14 22:36:26 UTC (rev 25756)
+++
core3/webservice-ncbi-client-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-06-14 22:52:50 UTC (rev 25757)
@@ -21,10 +21,20 @@
<!-- Wrapper for the REST client -->
<bean id="ncbiClient"
class="org.cytoscape.webservice.ncbi.NCBIWebServiceClient">
- <constructor-arg index="0"
value="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl" />
+ <constructor-arg index="0"
+
value="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl" />
<constructor-arg index="1" value="NCBI Client" />
- <constructor-arg index="2" value="SOAP version of NCBI Web
Service Client." />
- <constructor-arg index="3" ref="cyNetworkFactoryServiceRef"/>
+ <constructor-arg index="2"
+ value="SOAP version of NCBI Web Service Client." />
+ <constructor-arg index="3" ref="cyNetworkFactoryServiceRef" />
<constructor-arg index="4" ref="cyNetworkManagerServiceRef" />
</bean>
+
+ <bean id="ncbiTableImportClient"
class="org.cytoscape.webservice.ncbi.NCBITableImportAction">
+ <constructor-arg ref="cyTableManagerServiceRef" />
+ <constructor-arg ref="cyNetworkManagerServiceRef" />
+ <constructor-arg ref="cyApplicationManagerRef" />
+
+
+ </bean>
</beans>
Added:
core3/webservice-ncbi-client-impl/trunk/src/main/resources/images/entrez_page_title.gif
===================================================================
(Binary files differ)
Property changes on:
core3/webservice-ncbi-client-impl/trunk/src/main/resources/images/entrez_page_title.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
--
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.