Author: kono
Date: 2011-01-20 16:51:55 -0800 (Thu, 20 Jan 2011)
New Revision: 23534
Added:
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/task/ShowNetworkImportDialogAction.java
Modified:
core3/webservice-impl/trunk/pom.xml
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/ui/UnifiedNetworkImportDialog.java
Log:
Modified: core3/webservice-impl/trunk/pom.xml
===================================================================
--- core3/webservice-impl/trunk/pom.xml 2011-01-21 00:44:58 UTC (rev 23533)
+++ core3/webservice-impl/trunk/pom.xml 2011-01-21 00:51:55 UTC (rev 23534)
@@ -132,7 +132,13 @@
<version>3.0.0-alpha2-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>swing-application-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
Added:
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/task/ShowNetworkImportDialogAction.java
===================================================================
---
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/task/ShowNetworkImportDialogAction.java
(rev 0)
+++
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/task/ShowNetworkImportDialogAction.java
2011-01-21 00:51:55 UTC (rev 23534)
@@ -0,0 +1,22 @@
+package org.cytoscape.webservice.internal.task;
+
+import java.awt.event.ActionEvent;
+
+import org.cytoscape.application.swing.AbstractCyAction;
+import org.cytoscape.session.CyApplicationManager;
+
+public class ShowNetworkImportDialogAction extends AbstractCyAction {
+
+ private static final long serialVersionUID = -36712860667900147L;
+
+ public ShowNetworkImportDialogAction(CyApplicationManager
applicationManager) {
+ super("Import Network from Public Databases...",
applicationManager);
+ setPreferredMenu("File.Import");
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ }
+
+}
Modified:
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/ui/UnifiedNetworkImportDialog.java
===================================================================
---
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/ui/UnifiedNetworkImportDialog.java
2011-01-21 00:44:58 UTC (rev 23533)
+++
core3/webservice-impl/trunk/src/main/java/org/cytoscape/webservice/internal/ui/UnifiedNetworkImportDialog.java
2011-01-21 00:51:55 UTC (rev 23534)
@@ -41,22 +41,29 @@
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
+import java.awt.Window;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.swing.BoxLayout;
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.GroupLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;
+import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import javax.swing.LayoutStyle;
import javax.swing.border.EmptyBorder;
import org.cytoscape.io.webservice.NetworkImportWebServiceClient;
@@ -66,419 +73,396 @@
import org.cytoscape.work.TaskManager;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.sun.java.swing.plaf.gtk.GTKConstants.IconSize;
/**
* Default GUI component for network import web service clients.
*
- * @author kono
*/
public class UnifiedNetworkImportDialog extends JDialog {
-
+
private static final long serialVersionUID = 3333726113970459078L;
+ private static final Logger logger = LoggerFactory
+ .getLogger(UnifiedNetworkImportDialog.class);
-// // This is a singleton.
-// private static final UnifiedNetworkImportDialog dialog;
-//
-// // Selected web service client ID
-// private String selectedClientID = null;
-//
-// // Task to run in the separate thread.
-// private WSNetworkImportTask task;
-//
-// // Key is display name, value is actual service name.
-// private Map<String, String> clientNames;
-//
-// // Client-Dependent GUI panels
-// private Map<String, Container> serviceUIPanels = new HashMap<String,
Container>();
-//
-// // Default icon for about dialog
-// private static final Icon DEF_ICON = new javax.swing.ImageIcon(
-//
Cytoscape.class.getResource("images/ximian/stock_internet-32.png"));
-//
-// private static CyLogger logger = CyLogger
-// .getLogger(UnifiedNetworkImportDialog.class);
-//
-// private int numDataSources = 0;
-// private int numClients = 0;
-//
-// private boolean cancelFlag = false;
-//
-// static {
-// dialog = new UnifiedNetworkImportDialog(Cytoscape.getDesktop(),
false);
-// }
-//
-// /**
-// * Display this standard GUI.
-// */
-// public static void showDialog() {
-// dialog.setLocationRelativeTo(Cytoscape.getDesktop());
-// dialog.setVisible(true);
-// }
-//
-// /**
-// * Creates new form NetworkImportDialog
-// */
-// public UnifiedNetworkImportDialog(Frame parent, boolean modal) {
-// super(parent, modal);
-//
-// // Register as listener.
-//
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(this);
-//
-// initGUI();
-// }
-//
-// /**
-// * Resets the GUI w/ all new info.
-// */
-// public void resetGUI() {
-// this.getContentPane().removeAll();
-// initGUI();
-// }
-//
-// private void initGUI() {
-// clientNames = new HashMap<String, String>();
-//
-// List<WebServiceClient<?>> clients = WebServiceClientManager
-// .getAllClients();
-// for (WebServiceClient<?> client : clients) {
-// if (client instanceof NetworkImportWebServiceClient) {
-// numClients++;
-// }
-// }
-//
-// initComponents();
-// setDatasource();
-//
-// // If we have no data sources, show the install panel
-// getContentPane().setLayout(new BorderLayout());
-// if (numClients <= 1) {
-// this.getContentPane().add(installPanel,
BorderLayout.SOUTH);
-// }
-// if (numClients > 0) {
-// this.getContentPane().add(queryPanel,
BorderLayout.CENTER);
-// }
-//
-// this.pack();
-//
setProperty(clientNames.get(datasourceComboBox.getSelectedItem()));
+ // Selected web service client ID
+ private String selectedClientID = null;
+
+ private Set<NetworkImportWebServiceClient> clients;
+
+ // Key is display name, value is URI of service.
+ private Map<String, String> clientNames;
+
+ // Client-Dependent GUI panels
+ private Map<String, Container> serviceUIPanels = new HashMap<String,
Container>();
+
+ // Default icon for about dialog
+ private static final Icon DEF_ICON = new ImageIcon(
+ UnifiedNetworkImportDialog.class
+
.getResource("images/ximian/stock_internet-32.png"));
+
+ private static final Icon NETWORK_IMPORT_ICON = new ImageIcon(
+ UnifiedNetworkImportDialog.class
+
.getResource("images/networkImportIcon.png"));
+
+ private int numDataSources = 0;
+ private int numClients = 0;
+
+ private boolean cancelFlag = false;
+
+ /**
+ * Display this standard GUI.
+ */
+ public void showDialog(final Window parent) {
+ setLocationRelativeTo(parent);
+ setVisible(true);
+ }
+
+ /**
+ * Creates new form NetworkImportDialog
+ */
+ public UnifiedNetworkImportDialog(Window parent) {
+ super(parent);
+ setModal(false);
+ this.clients = new HashSet<NetworkImportWebServiceClient>();
+
+ initGUI();
+ }
+
+ public void addNetworkImportClient(
+ final NetworkImportWebServiceClient client, Map props) {
+ datasourceComboBox.addItem(client);
+ this.clients.add(client);
+ numClients++;
+ }
+
+ public void removeNetworkImportClient(
+ final NetworkImportWebServiceClient client, Map props) {
+
+ datasourceComboBox.removeItem(client);
+ this.clients.remove(client);
+ numClients--;
+ }
+
+ private void initGUI() {
+ clientNames = new HashMap<String, String>();
+
+ // List<WebServiceClient<?>> clients = WebServiceClientManager
+ // .getAllClients();
+ // for (WebServiceClient<?> client : clients) {
+ // if (client instanceof NetworkImportWebServiceClient) {
+ // numClients++;
+ // }
+ // }
+
+ initComponents();
+ setDatasource();
+
+ // If we have no data sources, show the install panel
+ getContentPane().setLayout(new BorderLayout());
+ if (numClients <= 1) {
+ this.getContentPane().add(installPanel,
BorderLayout.SOUTH);
+ }
+ if (numClients > 0) {
+ this.getContentPane().add(queryPanel,
BorderLayout.CENTER);
+ }
+
+ this.pack();
+
setProperty(clientNames.get(datasourceComboBox.getSelectedItem()));
+ selectedClientID = clientNames
+ .get(datasourceComboBox.getSelectedItem());
+
+ // Initialize GUI panel.
+ datasourceComboBoxActionPerformed(null);
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the
form.
+ * WARNING: Do NOT modify this code. The content of this method is
always
+ * regenerated by the Form Editor.
+ */
+ private void initComponents() {
+ mainTabbedPane = new javax.swing.JTabbedPane();
+ searchTermScrollPane = new javax.swing.JScrollPane();
+ queryTextPane = new javax.swing.JTextPane();
+ propertyPanel = new javax.swing.JPanel();
+
+ queryTextPane.setFont(new java.awt.Font("SansSerif", 0, 12));
+ queryTextPane.setText("Please enter search terms...");
+ searchTermScrollPane.setViewportView(queryTextPane);
+
+ mainTabbedPane.addTab("Query", searchTermScrollPane);
+
+ GroupLayout propertyPanelLayout = new
GroupLayout(propertyPanel);
+ propertyPanel.setLayout(propertyPanelLayout);
+ propertyPanelLayout.setHorizontalGroup(propertyPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0,
+ 408, Short.MAX_VALUE));
+ propertyPanelLayout.setVerticalGroup(propertyPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0,
+ 303, Short.MAX_VALUE));
+
+ propertyScrollPane = new JScrollPane();
+ propertyScrollPane.setViewportView(propertyPanel);
+ mainTabbedPane.addTab("Search Property", propertyScrollPane);
+
+ titlePanel = new javax.swing.JPanel();
+ titleIconLabel = new javax.swing.JLabel();
+ datasourcePanel = new javax.swing.JPanel();
+ datasourceLabel = new javax.swing.JLabel();
+ datasourceComboBox = new javax.swing.JComboBox();
+ datasourceComboBox.setRenderer(new
ClientComboBoxCellRenderer());
+ aboutButton = new javax.swing.JButton();
+ buttonPanel = new javax.swing.JPanel();
+ searchButton = new javax.swing.JButton();
+ cancelButton = new javax.swing.JButton();
+ clearButton = new javax.swing.JButton();
+ dataQueryPanel = new javax.swing.JPanel();
+
+ setTitle("Import Network from Database");
+
+
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ titlePanel.setBackground(new java.awt.Color(0, 0, 0));
+
+ titleIconLabel.setIcon(NETWORK_IMPORT_ICON); // NOI18N
+
+ GroupLayout titlePanelLayout = new GroupLayout(titlePanel);
+ titlePanel.setLayout(titlePanelLayout);
+ titlePanelLayout.setHorizontalGroup(titlePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(titleIconLabel,
GroupLayout.PREFERRED_SIZE, 461,
+ GroupLayout.PREFERRED_SIZE));
+
titlePanelLayout.setVerticalGroup(titlePanelLayout.createParallelGroup(
+
GroupLayout.Alignment.LEADING).addComponent(titleIconLabel));
+
+ datasourceLabel.setFont(new java.awt.Font("SansSerif", 0, 12));
+ datasourceLabel.setText("Data Source");
+
+ datasourceComboBox
+ .addActionListener(new
java.awt.event.ActionListener() {
+ public void
actionPerformed(java.awt.event.ActionEvent evt) {
+
datasourceComboBoxActionPerformed(evt);
+ }
+ });
+
+ aboutButton.setText("About");
+ aboutButton.setMargin(new java.awt.Insets(2, 5, 2, 5));
+ aboutButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ aboutButtonActionPerformed(evt);
+ }
+ });
+
+ GroupLayout datasourcePanelLayout = new
GroupLayout(datasourcePanel);
+ datasourcePanel.setLayout(datasourcePanelLayout);
+ datasourcePanelLayout.setHorizontalGroup(datasourcePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
+ datasourcePanelLayout
+
.createSequentialGroup()
+
.addContainerGap()
+
.addComponent(datasourceLabel)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(datasourceComboBox, 0, 301,
+
Short.MAX_VALUE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(aboutButton).addContainerGap()));
+ datasourcePanelLayout
+ .setVerticalGroup(datasourcePanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(
+
datasourcePanelLayout
+
.createSequentialGroup()
+
.addContainerGap()
+
.addGroup(
+
datasourcePanelLayout
+
.createParallelGroup(
+
GroupLayout.Alignment.BASELINE)
+
.addComponent(
+
datasourceLabel)
+
.addComponent(
+
aboutButton)
+
.addComponent(
+
datasourceComboBox,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE))
+
.addContainerGap(
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)));
+
+
buttonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+
+ searchButton.setText("Search");
+ searchButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ searchButtonActionPerformed(evt);
+ }
+ });
+
+ cancelButton.setText("Cancel");
+ cancelButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ cancelButtonActionPerformed(evt);
+ }
+ });
+
+ clearButton.setText("Clear");
+ clearButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ clearButtonActionPerformed(evt);
+ }
+ });
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+ buttonPanelLayout.setHorizontalGroup(buttonPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
+ GroupLayout.Alignment.TRAILING,
+ buttonPanelLayout
+
.createSequentialGroup()
+
.addContainerGap()
+
.addComponent(clearButton)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED,
+
225, Short.MAX_VALUE)
+
.addComponent(cancelButton)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(searchButton).addContainerGap()));
+ buttonPanelLayout
+ .setVerticalGroup(buttonPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(
+
GroupLayout.Alignment.TRAILING,
+
buttonPanelLayout
+
.createSequentialGroup()
+
.addContainerGap(
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)
+
.addGroup(
+
buttonPanelLayout
+
.createParallelGroup(
+
GroupLayout.Alignment.BASELINE)
+
.addComponent(
+
searchButton)
+
.addComponent(
+
cancelButton)
+
.addComponent(
+
clearButton))
+
.addContainerGap()));
+
+ GroupLayout dataQueryPanelLayout = new
GroupLayout(dataQueryPanel);
+ dataQueryPanel.setLayout(dataQueryPanelLayout);
+ dataQueryPanelLayout.setHorizontalGroup(dataQueryPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0,
+ 461, Short.MAX_VALUE));
+ dataQueryPanelLayout.setVerticalGroup(dataQueryPanelLayout
+
.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0,
+ 247, Short.MAX_VALUE));
+
+ queryPanel = new JPanel();
+ GroupLayout layout = new GroupLayout(queryPanel);
+ queryPanel.setLayout(layout);
+ layout.setHorizontalGroup(layout
+
.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(titlePanel,
GroupLayout.DEFAULT_SIZE,
+ GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(datasourcePanel,
GroupLayout.DEFAULT_SIZE,
+ GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(buttonPanel,
GroupLayout.DEFAULT_SIZE,
+ GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(dataQueryPanel,
GroupLayout.DEFAULT_SIZE,
+ GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ GroupLayout.Alignment.LEADING)
+ .addGroup(
+ layout.createSequentialGroup()
+
.addComponent(titlePanel,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(datasourcePanel,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(dataQueryPanel,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
Short.MAX_VALUE)
+
.addPreferredGap(
+
LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(buttonPanel,
+
GroupLayout.PREFERRED_SIZE,
+
GroupLayout.DEFAULT_SIZE,
+
GroupLayout.PREFERRED_SIZE)));
+
+ dataQueryPanel.setLayout(new BorderLayout());
+ createInstallPanel();
+ } // </editor-fold>
+
+ private void createInstallPanel() {
+ installPanel = new JPanel();
+ installPanel.setLayout(new BorderLayout());
+ JLabel titleIconLabel2 = new JLabel();
+ titleIconLabel2.setIcon(NETWORK_IMPORT_ICON);
+ JPanel titlePanel2 = new JPanel();
+ titlePanel2.add(titleIconLabel2);
+ titlePanel2.setBackground(new Color(0, 0, 0));
+ titlePanel2.setLayout(new FlowLayout(FlowLayout.LEFT));
+ if (numClients == 0) {
+ installPanel.add(titlePanel2, BorderLayout.NORTH);
+ }
+
+ JPanel internalPanel = new JPanel();
+ internalPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
+ internalPanel.setLayout(new BoxLayout(internalPanel,
+ BoxLayout.PAGE_AXIS));
+ JTextArea area = new JTextArea(1, 40);
+ area.setBorder(new EmptyBorder(0, 0, 0, 0));
+ if (numClients == 0) {
+ area.setText("There are no network import web service
clients installed.");
+ } else {
+ area.setText("To install additional web service
clients, click the install button below.");
+ }
+ area.setEditable(false);
+ area.setOpaque(false);
+ area.setAlignmentX(Component.LEFT_ALIGNMENT);
+ internalPanel.add(area);
+ }
+
+ /**
+ * Execute the search task.
+ *
+ * @param evt
+ */
+ private void searchButtonActionPerformed(final ActionEvent evt) {
// selectedClientID = clientNames
// .get(datasourceComboBox.getSelectedItem());
//
-// // Initialize GUI panel.
-// datasourceComboBoxActionPerformed(null);
-// }
-//
-// /**
-// * This method is called from within the constructor to initialize the
form.
-// * WARNING: Do NOT modify this code. The content of this method is
always
-// * regenerated by the Form Editor.
-// */
-// private void initComponents() {
-// mainTabbedPane = new javax.swing.JTabbedPane();
-// searchTermScrollPane = new javax.swing.JScrollPane();
-// queryTextPane = new javax.swing.JTextPane();
-// propertyPanel = new javax.swing.JPanel();
-//
-// queryTextPane.setFont(new java.awt.Font("SansSerif", 0, 12));
-// queryTextPane.setText("Please enter search terms...");
-// searchTermScrollPane.setViewportView(queryTextPane);
-//
-// mainTabbedPane.addTab("Query", searchTermScrollPane);
-//
-// org.jdesktop.layout.GroupLayout propertyPanelLayout = new
org.jdesktop.layout.GroupLayout(
-// propertyPanel);
-// propertyPanel.setLayout(propertyPanelLayout);
-// propertyPanelLayout.setHorizontalGroup(propertyPanelLayout
-//
.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(0, 408, Short.MAX_VALUE));
-// propertyPanelLayout.setVerticalGroup(propertyPanelLayout
-//
.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(0, 303, Short.MAX_VALUE));
-//
-// propertyScrollPane = new JScrollPane();
-// propertyScrollPane.setViewportView(propertyPanel);
-// mainTabbedPane.addTab("Search Property", propertyScrollPane);
-//
-// titlePanel = new javax.swing.JPanel();
-// titleIconLabel = new javax.swing.JLabel();
-// datasourcePanel = new javax.swing.JPanel();
-// datasourceLabel = new javax.swing.JLabel();
-// datasourceComboBox = new javax.swing.JComboBox();
-// aboutButton = new javax.swing.JButton();
-// buttonPanel = new javax.swing.JPanel();
-// searchButton = new javax.swing.JButton();
-// cancelButton = new javax.swing.JButton();
-// clearButton = new javax.swing.JButton();
-// dataQueryPanel = new javax.swing.JPanel();
-//
-// setTitle("Import Network from Database");
-//
-//
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-//
-// titlePanel.setBackground(new java.awt.Color(0, 0, 0));
-//
-// titleIconLabel.setIcon(new javax.swing.ImageIcon(Cytoscape.class
-// .getResource("images/networkImportIcon.png")));
// NOI18N
-//
-// org.jdesktop.layout.GroupLayout titlePanelLayout = new
org.jdesktop.layout.GroupLayout(
-// titlePanel);
-// titlePanel.setLayout(titlePanelLayout);
-// titlePanelLayout.setHorizontalGroup(titlePanelLayout
-//
.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(titleIconLabel,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 461,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE));
-//
titlePanelLayout.setVerticalGroup(titlePanelLayout.createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING).add(titleIconLabel));
-//
-// datasourceLabel.setFont(new java.awt.Font("SansSerif", 0, 12));
-// datasourceLabel.setText("Data Source");
-//
-// datasourceComboBox
-// .addActionListener(new
java.awt.event.ActionListener() {
-// public void
actionPerformed(java.awt.event.ActionEvent evt) {
-//
datasourceComboBoxActionPerformed(evt);
-// }
-// });
-//
-// aboutButton.setText("About");
-// aboutButton.setMargin(new java.awt.Insets(2, 5, 2, 5));
-// aboutButton.addActionListener(new
java.awt.event.ActionListener() {
-// public void actionPerformed(java.awt.event.ActionEvent
evt) {
-// aboutButtonActionPerformed(evt);
-// }
-// });
-//
-// org.jdesktop.layout.GroupLayout datasourcePanelLayout = new
org.jdesktop.layout.GroupLayout(
-// datasourcePanel);
-// datasourcePanel.setLayout(datasourcePanelLayout);
-// datasourcePanelLayout
-// .setHorizontalGroup(datasourcePanelLayout
-// .createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING)
-// .add(
-//
datasourcePanelLayout
-//
.createSequentialGroup()
-//
.addContainerGap()
-//
.add(datasourceLabel)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED)
-//
.add(datasourceComboBox, 0, 301,
-//
Short.MAX_VALUE)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED)
-//
.add(aboutButton).addContainerGap()));
-// datasourcePanelLayout
-// .setVerticalGroup(datasourcePanelLayout
-// .createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING)
-// .add(
-//
datasourcePanelLayout
-//
.createSequentialGroup()
-//
.addContainerGap()
-//
.add(
-//
datasourcePanelLayout
-//
.createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.BASELINE)
-//
.add(datasourceLabel)
-//
.add(aboutButton)
-//
.add(
-//
datasourceComboBox,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-//
.addContainerGap(
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
Short.MAX_VALUE)));
-//
-//
buttonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-//
-// searchButton.setText("Search");
-// searchButton.addActionListener(new
java.awt.event.ActionListener() {
-// public void actionPerformed(java.awt.event.ActionEvent
evt) {
-// searchButtonActionPerformed(evt);
-// }
-// });
-//
-// cancelButton.setText("Cancel");
-// cancelButton.addActionListener(new
java.awt.event.ActionListener() {
-// public void actionPerformed(java.awt.event.ActionEvent
evt) {
-// cancelButtonActionPerformed(evt);
-// }
-// });
-//
-// clearButton.setText("Clear");
-// clearButton.addActionListener(new
java.awt.event.ActionListener() {
-// public void actionPerformed(java.awt.event.ActionEvent
evt) {
-// clearButtonActionPerformed(evt);
-// }
-// });
-//
-// org.jdesktop.layout.GroupLayout buttonPanelLayout = new
org.jdesktop.layout.GroupLayout(
-// buttonPanel);
-// buttonPanel.setLayout(buttonPanelLayout);
-// buttonPanelLayout
-// .setHorizontalGroup(buttonPanelLayout
-// .createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING)
-// .add(
-//
org.jdesktop.layout.GroupLayout.TRAILING,
-//
buttonPanelLayout
-//
.createSequentialGroup()
-//
.addContainerGap()
-//
.add(clearButton)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED,
-//
225, Short.MAX_VALUE)
-//
.add(cancelButton)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED)
-//
.add(searchButton).addContainerGap()));
-// buttonPanelLayout
-// .setVerticalGroup(buttonPanelLayout
-// .createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING)
-// .add(
-//
org.jdesktop.layout.GroupLayout.TRAILING,
-//
buttonPanelLayout
-//
.createSequentialGroup()
-//
.addContainerGap(
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
Short.MAX_VALUE)
-//
.add(
-//
buttonPanelLayout
-//
.createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.BASELINE)
-//
.add(searchButton).add(
-//
cancelButton)
-//
.add(clearButton))
-//
.addContainerGap()));
-//
-// org.jdesktop.layout.GroupLayout dataQueryPanelLayout = new
org.jdesktop.layout.GroupLayout(
-// dataQueryPanel);
-// dataQueryPanel.setLayout(dataQueryPanelLayout);
-// dataQueryPanelLayout.setHorizontalGroup(dataQueryPanelLayout
-//
.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(0, 461, Short.MAX_VALUE));
-// dataQueryPanelLayout.setVerticalGroup(dataQueryPanelLayout
-//
.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(0, 247, Short.MAX_VALUE));
-//
-// queryPanel = new JPanel();
-// org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(
-// queryPanel);
-// queryPanel.setLayout(layout);
-// layout.setHorizontalGroup(layout.createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING).add(titlePanel,
-// org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-// org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
-// .add(datasourcePanel,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
Short.MAX_VALUE).add(buttonPanel,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
Short.MAX_VALUE).add(dataQueryPanel,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-// Short.MAX_VALUE));
-// layout
-// .setVerticalGroup(layout
-// .createParallelGroup(
-//
org.jdesktop.layout.GroupLayout.LEADING)
-// .add(
-// layout
-//
.createSequentialGroup()
-//
.add(
-//
titlePanel,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED)
-//
.add(
-//
datasourcePanel,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED)
-//
.add(
-//
dataQueryPanel,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
Short.MAX_VALUE)
-//
.addPreferredGap(
-//
org.jdesktop.layout.LayoutStyle.RELATED)
-//
.add(
-//
buttonPanel,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
-//
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
-//
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));
-//
-// dataQueryPanel.setLayout(new BorderLayout());
-// createInstallPanel();
-// } // </editor-fold>
-//
-// private void createInstallPanel() {
-// installPanel = new JPanel();
-// installPanel.setLayout(new BorderLayout());
-// JLabel titleIconLabel2 = new JLabel();
-// titleIconLabel2.setIcon(new ImageIcon(Cytoscape.class
-// .getResource("images/networkImportIcon.png")));
-// JPanel titlePanel2 = new JPanel();
-// titlePanel2.add(titleIconLabel2);
-// titlePanel2.setBackground(new Color(0, 0, 0));
-// titlePanel2.setLayout(new FlowLayout(FlowLayout.LEFT));
-// if (numClients == 0) {
-// installPanel.add(titlePanel2, BorderLayout.NORTH);
-// }
-//
-// JPanel internalPanel = new JPanel();
-// internalPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
-// internalPanel.setLayout(new BoxLayout(internalPanel,
-// BoxLayout.PAGE_AXIS));
-// JTextArea area = new JTextArea(1, 40);
-// area.setBorder(new EmptyBorder(0, 0, 0, 0));
-// if (numClients == 0) {
-// area
-// .setText("There are no network import
web service clients installed.");
-// } else {
-// area.setText("To install additional web service
clients, click the install button below.");
-// }
-// area.setEditable(false);
-// area.setOpaque(false);
-// area.setAlignmentX(Component.LEFT_ALIGNMENT);
-// internalPanel.add(area);
-// }
-//
-//
-// private void searchButtonActionPerformed(final ActionEvent evt) {
-// selectedClientID = clientNames
-// .get(datasourceComboBox.getSelectedItem());
-//
// final CyWebServiceEvent<String> event = buildEvent();
// logger.info("Start importing network: " +
evt.getActionCommand());
//
// task = new
WSNetworkImportTask(datasourceComboBox.getSelectedItem()
// .toString(), event);
//
-// // Configure JTask Dialog Pop-Up Box
-// final JTaskConfig tConfig = new JTaskConfig();
-// tConfig.setOwner(Cytoscape.getDesktop());
-// tConfig.displayCloseButton(true);
-// tConfig.displayCancelButton(true);
-// tConfig.displayStatus(false);
-// tConfig.setAutoDispose(true);
-//
// // Execute Task in New Thread; pops open JTask Dialog Box.
// TaskManager.executeTask(task, tConfig);
//
// logger.info("Network Import from WS Success!");
-// }
-//
-// private void aboutButtonActionPerformed(ActionEvent evt) {
+ }
+
+ private void aboutButtonActionPerformed(ActionEvent evt) {
+
// final WebServiceClient<?> wsc = WebServiceClientManager
// .getClient(selectedClientID);
// final String clientName = wsc.getDisplayName();
@@ -492,53 +476,54 @@
// icon = DEF_ICON;
// }
// AboutDialog.showDialog(clientName, icon, description);
-// }
+ }
+
+ /**
+ * Clear query text field.
+ */
+ private void clearButtonActionPerformed(java.awt.event.ActionEvent evt)
{
+ // Just set empty string for the field.
+ queryTextPane.setText("");
+ }
+
+ private void cancelButtonActionPerformed(java.awt.event.ActionEvent
evt) {
+ // Do nothing. Just hide this window.
+ queryTextPane.setText("");
+ dispose();
+ }
+
+ private void datasourceComboBoxActionPerformed(
+ java.awt.event.ActionEvent evt) {
+
+ queryTextPane.setText("");
+
setProperty(clientNames.get(datasourceComboBox.getSelectedItem()));
+ selectedClientID = clientNames
+ .get(datasourceComboBox.getSelectedItem());
+
+ // Update Panel
+ dataQueryPanel.removeAll();
+
+ final Container gui = serviceUIPanels.get(selectedClientID);
+ if (gui != null) {
+ // This service has custom panel.
+ dataQueryPanel.add(gui, BorderLayout.CENTER);
+ // Hide button panel.
+ buttonPanel.setVisible(false);
+ } else {
+ // Otherwise, use the default panel.
+ logger.info("No custom GUI. Use default panel.");
+ dataQueryPanel.add(mainTabbedPane, BorderLayout.CENTER);
+ buttonPanel.setVisible(true);
+ }
+
+ pack();
+ repaint();
+ }
+
+ private void setProperty(String clientID) {
+// final WebServiceClient<?> client = WebServiceClientManager
+// .getClient(clientID);
//
-// /**
-// * Clear query text field.
-// */
-// private void clearButtonActionPerformed(java.awt.event.ActionEvent evt)
{
-// // Just set empty string for the field.
-// queryTextPane.setText("");
-// }
-//
-// private void cancelButtonActionPerformed(java.awt.event.ActionEvent
evt) {
-// // Do nothing. Just hide this window.
-// queryTextPane.setText("");
-// dispose();
-// }
-//
-// private void datasourceComboBoxActionPerformed(
-// java.awt.event.ActionEvent evt) {
-//
-// queryTextPane.setText("");
-//
setProperty(clientNames.get(datasourceComboBox.getSelectedItem()));
-// selectedClientID = clientNames
-// .get(datasourceComboBox.getSelectedItem());
-//
-// // Update Panel
-// dataQueryPanel.removeAll();
-//
-// final Container gui = serviceUIPanels.get(selectedClientID);
-// if (gui != null) {
-// // This service has custom panel.
-// dataQueryPanel.add(gui, BorderLayout.CENTER);
-// // Hide button panel.
-// buttonPanel.setVisible(false);
-// } else {
-// // Otherwise, use the default panel.
-// logger.info("No custom GUI. Use default panel.");
-// dataQueryPanel.add(mainTabbedPane, BorderLayout.CENTER);
-// buttonPanel.setVisible(true);
-// }
-//
-// pack();
-// repaint();
-// }
-//
-// private void setProperty(String clientID) {
-// final WebServiceClient<?> client =
WebServiceClientManager.getClient(clientID);
-//
// if (client == null)
// return;
//
@@ -557,16 +542,16 @@
// propertyScrollPane.setViewportView(propertyPanel);
// pack();
// repaint();
-// }
-//
-// private void setDatasource() {
+ }
+
+ private void setDatasource() {
// List<WebServiceClient<?>> clients = WebServiceClientManager
// .getAllClients();
// for (WebServiceClient<?> client : clients) {
// if (client instanceof NetworkImportWebServiceClient) {
//
this.datasourceComboBox.addItem(client.getDisplayName());
-// this.clientNames.put(client.getDisplayName(),
client
-// .getClientID());
+// this.clientNames.put(client.getDisplayName(),
+// client.getClientID());
//
// if (client instanceof WebServiceClientGUI
// && (((WebServiceClientGUI)
client).getGUI() != null)) {
@@ -576,8 +561,8 @@
// numDataSources++;
// }
// }
-// }
-//
+ }
+
// private CyWebServiceEvent<String> buildEvent() {
// final String clientID = clientNames.get(datasourceComboBox
// .getSelectedItem());
@@ -589,33 +574,32 @@
// WSEventType.SEARCH_DATABASE,
queryTextPane.getText(),
// WSEventType.IMPORT_NETWORK);
// }
-//
-// // Variables declaration - do not modify
-// private javax.swing.JButton cancelButton;
-// private javax.swing.JComboBox datasourceComboBox;
-// private javax.swing.JLabel datasourceLabel;
-// private javax.swing.JTabbedPane mainTabbedPane;
-// private javax.swing.JPanel propertyPanel;
-// private JScrollPane propertyScrollPane;
-// private javax.swing.JButton searchButton;
-// private javax.swing.JScrollPane searchTermScrollPane;
-// private javax.swing.JTextPane queryTextPane;
-// private javax.swing.JButton aboutButton;
-// private javax.swing.JPanel buttonPanel;
-// private JPanel queryPanel;
-// private JPanel installPanel;
-// private javax.swing.JButton clearButton;
-// private javax.swing.JPanel dataQueryPanel;
-// private javax.swing.JPanel datasourcePanel;
-// private javax.swing.JLabel titleIconLabel;
-// private javax.swing.JPanel titlePanel;
-//
-//
+
+ // Variables declaration - do not modify
+ private javax.swing.JButton cancelButton;
+ private javax.swing.JComboBox datasourceComboBox;
+ private javax.swing.JLabel datasourceLabel;
+ private javax.swing.JTabbedPane mainTabbedPane;
+ private javax.swing.JPanel propertyPanel;
+ private JScrollPane propertyScrollPane;
+ private javax.swing.JButton searchButton;
+ private javax.swing.JScrollPane searchTermScrollPane;
+ private javax.swing.JTextPane queryTextPane;
+ private javax.swing.JButton aboutButton;
+ private javax.swing.JPanel buttonPanel;
+ private JPanel queryPanel;
+ private JPanel installPanel;
+ private javax.swing.JButton clearButton;
+ private javax.swing.JPanel dataQueryPanel;
+ private javax.swing.JPanel datasourcePanel;
+ private javax.swing.JLabel titleIconLabel;
+ private javax.swing.JPanel titlePanel;
+
// /**
// * Task to import network from web service.
// *
// * @author kono
-// *
+// *
// */
// private class WSNetworkImportTask implements Task {
// private String serviceName;
@@ -704,8 +688,8 @@
// result.getResultSize() + "
records found in "
// +
selectedClientID,
// "Do you want to create new
network from the search result?" };
-// int value =
JOptionPane.showConfirmDialog(Cytoscape
-// .getDesktop(), message, "Import
network",
+// int value = JOptionPane.showConfirmDialog(
+// Cytoscape.getDesktop(),
message, "Import network",
// JOptionPane.YES_NO_OPTION);
//
// if (value == JOptionPane.YES_OPTION) {
@@ -732,21 +716,23 @@
// if (evt.getNewValue() == null)
// return;
//
-//// VisualStyle style = ((NetworkImportWebServiceClient)
WebServiceClientManager
-////
.getClient(selectedClientID)).getDefaultVisualStyle();
-//// if (style == null) {
-//// style =
Cytoscape.getVisualMappingManager().getVisualStyle();
-//// }
-////
-//// if
(Cytoscape.getVisualMappingManager().getCalculatorCatalog()
-//// .getVisualStyle(style.getName()) ==
null)
-////
Cytoscape.getVisualMappingManager().getCalculatorCatalog()
-//// .addVisualStyle(style);
-////
-////
Cytoscape.getVisualMappingManager().setVisualStyle(style);
-//
+// // VisualStyle style = ((NetworkImportWebServiceClient)
+// // WebServiceClientManager
+// //
.getClient(selectedClientID)).getDefaultVisualStyle();
+// // if (style == null) {
+// // style =
Cytoscape.getVisualMappingManager().getVisualStyle();
+// // }
+// //
+// // if
(Cytoscape.getVisualMappingManager().getCalculatorCatalog()
+// // .getVisualStyle(style.getName()) == null)
+// //
Cytoscape.getVisualMappingManager().getCalculatorCatalog()
+// // .addVisualStyle(style);
+// //
+// //
Cytoscape.getVisualMappingManager().setVisualStyle(style);
+//
// // Name the network
-// final String[] message = { "Network Loaded from " +
selectedClientID,
+// final String[] message = {
+// "Network Loaded from " +
selectedClientID,
// "Please enter title for new network:" };
// String value =
JOptionPane.showInputDialog(Cytoscape.getDesktop(),
// message, "Name new network",
JOptionPane.QUESTION_MESSAGE);
@@ -758,4 +744,24 @@
//
Cytoscape.getDesktop().getNetworkPanel().updateTitle(cyNetwork);
// }
// }
+
+ private final class ClientComboBoxCellRenderer extends
+ DefaultListCellRenderer {
+
+ private static final long serialVersionUID =
-7944343422335332051L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
Object value,
+ int index, boolean isSelected, boolean
cellHasFocus) {
+ super.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
+
+ if(value instanceof WebServiceClient) {
+ String displayName = ((WebServiceClient)
value).getDisplayName();
+ this.setText(displayName);
+ }
+
+ return this;
+
+ }
+ }
}
--
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.