Author: kono
Date: 2010-02-17 16:06:45 -0800 (Wed, 17 Feb 2010)
New Revision: 19356

Modified:
   
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartClientPlugin.java
   
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartStub.java
   
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartAttrMappingPanel.java
   
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartMainDialog.java
Log:
Made task monitor more informative.  It displays currently processed data 
sources and if it fails, display error massage to on the monitor.

Modified: 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartClientPlugin.java
===================================================================
--- 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartClientPlugin.java
        2010-02-17 23:50:53 UTC (rev 19355)
+++ 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartClientPlugin.java
        2010-02-18 00:06:45 UTC (rev 19356)
@@ -31,35 +31,46 @@
  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 edu.ucsd.bioeng.idekerlab.biomartclient;
 
 import java.awt.event.ActionEvent;
 
 import javax.swing.AbstractAction;
+import javax.swing.JMenu;
 
 import cytoscape.Cytoscape;
 import cytoscape.data.webservice.WebServiceClientManager;
 import cytoscape.plugin.CytoscapePlugin;
 import edu.ucsd.bioeng.idekerlab.biomartclient.ui.BiomartMainDialog;
 
-
 /**
- * Biomart web service client plugin.
+ * Biomart web service client plugin main class.
  */
 public class BiomartClientPlugin extends CytoscapePlugin {
        /**
         * Creates a new BiomartClientPlugin object.
+        * 
         * @throws Exception
         */
        public BiomartClientPlugin() throws Exception {
                // Register this client to the manager.
                
WebServiceClientManager.registerClient(BiomartClient.getClient());
 
-               
Cytoscape.getDesktop().getCyMenus().getMenuBar().getMenu("File.Import").add(new 
AbstractAction("Import attributes from Biomart...") {
+               final JMenu menu = 
Cytoscape.getDesktop().getCyMenus().getMenuBar()
+                               .getMenu("File.Import");
+
+               if (menu != null) {
+                       menu.add(new AbstractAction("Import attributes from 
Biomart...") {
+                               private static final long serialVersionUID = 
-1303677510967797368L;
+
                                public void actionPerformed(ActionEvent e) {
                                        BiomartMainDialog.showUI();
                                }
                        });
+               } else {
+                       throw new IllegalStateException(
+                                       "Could not register BioMart Client to 
Cytoscape menu.");
+               }
        }
 }

Modified: 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartStub.java
===================================================================
--- 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartStub.java
        2010-02-17 23:50:53 UTC (rev 19355)
+++ 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/BiomartStub.java
        2010-02-18 00:06:45 UTC (rev 19356)
@@ -194,7 +194,6 @@
                
                InputStream is = URLUtil.getBasicInputStream(targetURL);
                
-               
                final Document registry = builder.parse(is);
 
                // Extract each datasource

Modified: 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartAttrMappingPanel.java
===================================================================
--- 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartAttrMappingPanel.java
 2010-02-17 23:50:53 UTC (rev 19355)
+++ 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartAttrMappingPanel.java
 2010-02-18 00:06:45 UTC (rev 19356)
@@ -34,66 +34,64 @@
 */
 package edu.ucsd.bioeng.idekerlab.biomartclient.ui;
 
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.swing.DefaultListModel;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+
 import cytoscape.Cytoscape;
-
 import cytoscape.data.CyAttributes;
 import cytoscape.data.CyAttributesUtils;
-
 import cytoscape.data.webservice.AttributeImportQuery;
 import cytoscape.data.webservice.CyWebServiceEvent;
+import cytoscape.data.webservice.WebServiceClientManager;
 import cytoscape.data.webservice.CyWebServiceEvent.WSEventType;
-import cytoscape.data.webservice.WebServiceClientManager;
-
 import cytoscape.task.Task;
 import cytoscape.task.TaskMonitor;
-
 import cytoscape.task.ui.JTaskConfig;
-
 import cytoscape.task.util.TaskManager;
-
 import cytoscape.util.swing.AttributeImportPanel;
-
 import edu.ucsd.bioeng.idekerlab.biomartclient.BiomartClient;
 import edu.ucsd.bioeng.idekerlab.biomartclient.BiomartStub;
 import edu.ucsd.bioeng.idekerlab.biomartclient.utils.Attribute;
 import edu.ucsd.bioeng.idekerlab.biomartclient.utils.Dataset;
 import edu.ucsd.bioeng.idekerlab.biomartclient.utils.Filter;
 import edu.ucsd.bioeng.idekerlab.biomartclient.utils.XMLQueryBuilder;
-
 import giny.model.Node;
 
-import java.awt.event.ActionEvent;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.swing.DefaultListModel;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JOptionPane;
-
-
 /**
  *
  */
 public class BiomartAttrMappingPanel extends AttributeImportPanel implements 
PropertyChangeListener {
+
+       private static final long serialVersionUID = 3574198525811249639L;
+
        private static final Icon LOGO = new 
ImageIcon(BiomartAttrMappingPanel.class.getResource("/images/logo_biomart2.png"));
+       
        private Map<String, String> datasourceMap;
        private Map<String, Map<String, String[]>> attributeMap;
        private Map<String, List<String>> attributeListOrder;
        private Map<String, Map<String, String>> attrNameMap;
        private Map<String, Map<String, String>> filterMap;
+       
+       private final TaskMonitor monitor;
+       
        private enum SourceType {
                DATABASE,
                ATTRIBUTE,
@@ -102,9 +100,7 @@
 
        private boolean cancelFlag = false;
        private boolean initialized = false;
-       
-       private String statusMessage;
-       
+               
        private final BiomartStub stub = (BiomartStub) 
WebServiceClientManager.getClient("biomart")
                                                                              
.getClientStub();
 
@@ -119,8 +115,8 @@
                databaseFilter.add("Pancreatic_Expression");
        }
 
-       public BiomartAttrMappingPanel() throws Exception {
-               this(LOGO, "", "Available attributes");
+       public BiomartAttrMappingPanel(final TaskMonitor monitor) throws 
Exception {
+               this(LOGO, "", "Available attributes", monitor);
        }
 
        /**
@@ -130,14 +126,22 @@
         * @param title  DOCUMENT ME!
         * @throws Exception
         */
-       public BiomartAttrMappingPanel(Icon logo, String title, String 
attrPanelLabel)
+       public BiomartAttrMappingPanel(Icon logo, String title, String 
attrPanelLabel, final TaskMonitor monitor)
            throws Exception {
                super(logo, title, attrPanelLabel);
+               this.monitor = monitor;
+               
                
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(this);
                
BiomartMainDialog.getPropertyChangeSupport().addPropertyChangeListener(this);
                initDataSources();
        }
 
+       
+       /**
+        * Access data sources and build GUI.
+        * 
+        * @throws Exception
+        */
        private void initDataSources() throws Exception {
                datasourceMap = new HashMap<String, String>();
                attributeMap = new HashMap<String, Map<String, String[]>>();
@@ -145,7 +149,8 @@
                filterMap = new HashMap<String, Map<String, String>>();
                attrNameMap = new HashMap<String, Map<String, String>>();
 
-               loadDBList();
+               monitor.setPercentCompleted(0);
+               loadMartServiceList();
                loadFilter();
        }
 
@@ -153,20 +158,35 @@
                return initialized;
        }
 
-       private void loadDBList() throws Exception {
-               final Map<String, Map<String, String>> reg = stub.getRegistry();
+       private void loadMartServiceList() {
+               Map<String, Map<String, String>> reg = null;
+               monitor.setStatus("Accessing Mart service registry...");
+               try {
+                       reg = stub.getRegistry();
+               } catch (IOException e1) {
+                       monitor.setException(e1, "Could not retreve list of 
Mart Services from registry.");
+               } catch (ParserConfigurationException e1) {
+                       monitor.setException(e1, "Could not parse list of Mart 
Services.");
+               } catch (SAXException e1) {
+                       monitor.setException(e1, "Could not parse list of Mart 
Services.");
+               }
+               monitor.setPercentCompleted(10);
+               
+               final int registryCount = reg.size();
+               int increment = 90/registryCount;
+               int percentCompleted = 10;
 
                Map<String, String> datasources;
                List<String> dsList = new ArrayList<String>();
-
                for (String databaseName : reg.keySet()) {
+                       
                        Map<String, String> detail = reg.get(databaseName);
 
                        // Add the datasource if its visible
                        if (detail.get("visible").equals("1")
                            && (databaseFilter.contains(databaseName) == false) 
&& (cancelFlag == false)) {
                                String dispName = detail.get("displayName");
-
+                               monitor.setStatus("Connecting to " + dispName);
                                try {
                                        datasources = 
stub.getAvailableDatasets(databaseName);
                                } catch (IOException e) {
@@ -182,6 +202,9 @@
 
                                return;
                        }
+                       
+                       percentCompleted += increment;
+                       monitor.setPercentCompleted(percentCompleted);
                }
 
                Collections.sort(dsList);

Modified: 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartMainDialog.java
===================================================================
--- 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartMainDialog.java
       2010-02-17 23:50:53 UTC (rev 19355)
+++ 
coreplugins/trunk/BioMartClient/src/edu/ucsd/bioeng/idekerlab/biomartclient/ui/BiomartMainDialog.java
       2010-02-18 00:06:45 UTC (rev 19356)
@@ -34,45 +34,36 @@
 */
 package edu.ucsd.bioeng.idekerlab.biomartclient.ui;
 
-import cytoscape.Cytoscape;
-
-import cytoscape.data.webservice.WebServiceClientManager;
-
-import cytoscape.layout.Tunable;
-
-import cytoscape.task.Task;
-import cytoscape.task.TaskMonitor;
-
-import cytoscape.task.ui.JTaskConfig;
-
-import cytoscape.task.util.TaskManager;
-
-import cytoscape.util.ModuleProperties;
-import cytoscape.util.SwingWorker;
-
 import java.awt.Color;
-import java.awt.GridLayout;
-
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
-
 import java.util.List;
 
-import javax.swing.BoxLayout;
 import javax.swing.JDialog;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
-import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
-import javax.swing.SpringLayout;
 import javax.swing.event.SwingPropertyChangeSupport;
 
+import cytoscape.Cytoscape;
+import cytoscape.data.webservice.WebServiceClientManager;
+import cytoscape.layout.Tunable;
+import cytoscape.task.Task;
+import cytoscape.task.TaskMonitor;
+import cytoscape.task.ui.JTaskConfig;
+import cytoscape.task.util.TaskManager;
+import cytoscape.util.SwingWorker;
 
+
 /**
- *
+ * BioMart client main GUI.
  */
 public class BiomartMainDialog extends JDialog implements 
PropertyChangeListener {
+       
+       private static final long serialVersionUID = 8693726765795163080L;
+       
+       // Actual dialog.  This is a singleton.
        private static BiomartMainDialog mainDialog = null;
        protected static Object pcsO = new Object();
        protected static PropertyChangeSupport pcs = new 
SwingPropertyChangeSupport(pcsO);
@@ -91,7 +82,7 @@
        private static BiomartAttrMappingPanel panel;
 
        /**
-        *  DOCUMENT ME!
+        * Build and display Dialog 
         */
        public static void showUI() {
                if ((mainDialog == null) || (initialized == false)) {
@@ -108,18 +99,17 @@
 
                        // Execute Task in New Thread; pop open JTask Dialog 
Box.
                        TaskManager.executeTask(task, jTaskConfig);
-               } else {
+               } else
                        mainDialog.setVisible(true);
-               }
        }
 
-       private BiomartMainDialog() throws Exception {
+       private BiomartMainDialog(final TaskMonitor monitor) throws Exception {
                super(Cytoscape.getDesktop(), false);
-               setTitle("Biomart Web Service Client");
+               setTitle("BioMart Web Service Client");
 
                // Create a tabbed pane
-               JTabbedPane tabs = new JTabbedPane();
-               List<Tunable> tunables = 
WebServiceClientManager.getClient("biomart").getProps()
+               final JTabbedPane tabs = new JTabbedPane();
+               final List<Tunable> tunables = 
WebServiceClientManager.getClient("biomart").getProps()
                                                                .getTunables();
                final JPanel tPanel = new JPanel();
                
@@ -163,9 +153,9 @@
         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
         gridBagConstraints.weightx = 1.0;
         tPanel.add(jLabel4, gridBagConstraints);
-               //
+
         
-               panel = new BiomartAttrMappingPanel();
+               panel = new BiomartAttrMappingPanel(monitor);
                panel.addPropertyChangeListener(this);
                tabs.addTab("Query", panel);
                tabs.addTab("Property", tPanel);
@@ -177,9 +167,9 @@
 
        static class SetupUITask implements Task {
                private TaskMonitor taskMonitor;
-               SwingWorker worker;
 
                public SetupUITask() {
+                       super();
                }
 
                /**
@@ -188,8 +178,7 @@
                 * @return  DOCUMENT ME!
                 */
                public String getTitle() {
-                       // TODO Auto-generated method stub
-                       return "Accessing Biomart Web Service...";
+                       return "Checking accessible BioMart Services...";
                }
 
                /**
@@ -204,11 +193,11 @@
                 *  DOCUMENT ME!
                 */
                public void run() {
-                       taskMonitor.setStatus("Initializing Biomart Web Service 
Client.\n\nIt may take a while.\nPlease wait...");
+                       taskMonitor.setStatus("Checking available Mart 
services.\n\nThis process may take a while.\nPlease wait...");
                        taskMonitor.setPercentCompleted(-1);
 
                        try {
-                               mainDialog = new BiomartMainDialog();
+                               mainDialog = new BiomartMainDialog(taskMonitor);
                        } catch (InterruptedException ie) {
                                //System.out.println("============== GOT 
interaption");
                        } catch (Exception e) {

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

Reply via email to