Author: kono
Date: 2011-03-23 15:59:21 -0700 (Wed, 23 Mar 2011)
New Revision: 24569

Modified:
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderFactory.java
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderTask.java
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTablePanel.java
   
core3/table-import-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Fixed task iterator related problems.

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderFactory.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderFactory.java
       2011-03-23 22:56:06 UTC (rev 24568)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderFactory.java
       2011-03-23 22:59:21 UTC (rev 24569)
@@ -19,11 +19,8 @@
                AbstractTableReaderFactory {
        private final static long serialVersionUID = 12023139869460898L;
 
-       public static final String FILE_EXTENSION_TXT = ".txt";
-       public static final String FILE_EXTENSION_XSL = ".xls"; // or ".xslx"
+       private final String fileFormat;
 
-       private String fileFormat = "Unknow";
-
        /**
         * Creates a new ImportAttributeTableReaderFactory object.
         */
@@ -52,15 +49,7 @@
        }
 
        public TaskIterator getTaskIterator() {
-               if (fileFormat.equalsIgnoreCase("file_format_txt")) {
-                       return new TaskIterator(new 
ImportAttributeTableReaderTask(
-                                       this.inputStream, FILE_EXTENSION_TXT));
-               } else if (fileFormat.equalsIgnoreCase("file_format_xls")) {
-                       return new TaskIterator(new 
ImportAttributeTableReaderTask(
-                                       this.inputStream, FILE_EXTENSION_XSL));
-               }
-               
-               // This should not happen.
-               return null;
+               return new TaskIterator(new ImportAttributeTableReaderTask(
+                               this.inputStream, fileFormat));
        }
 }

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderTask.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderTask.java
  2011-03-23 22:56:06 UTC (rev 24568)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ImportAttributeTableReaderTask.java
  2011-03-23 22:59:21 UTC (rev 24569)
@@ -1,25 +1,27 @@
 package org.cytoscape.tableimport.internal;
 
-import java.io.IOException;
 import java.io.InputStream;
 
 import javax.swing.JPanel;
-import javax.xml.bind.JAXBException;
 
 import org.cytoscape.io.read.CyTableReader;
 import org.cytoscape.model.CyTable;
 import org.cytoscape.tableimport.internal.ui.ImportAttributeTableTask;
 import org.cytoscape.tableimport.internal.ui.ImportTablePanel;
+import org.cytoscape.work.AbstractTask;
 import org.cytoscape.work.ProvidesGUI;
 import org.cytoscape.work.TaskMonitor;
 
-public class ImportAttributeTableReaderTask implements CyTableReader {
+public class ImportAttributeTableReaderTask extends AbstractTask implements
+               CyTableReader {
 
-       private ImportTablePanel importDialog = null;
-       private InputStream is = null;
-       private String fileType = null;
+       private ImportTablePanel importTablePanel;
 
-       public ImportAttributeTableReaderTask(InputStream is, String fileType) {
+       private final InputStream is;
+       private final String fileType;
+
+       public ImportAttributeTableReaderTask(final InputStream is,
+                       final String fileType) {
                this.is = is;
                this.fileType = fileType;
        }
@@ -27,46 +29,45 @@
        @ProvidesGUI
        public JPanel getGUI() {
 
-               JPanel myPanel = new JPanel();
-
-               try {
-                       if (this.importDialog == null) {
-                               this.importDialog = new ImportTablePanel(
+               if (importTablePanel == null) {
+                       try {
+                               this.importTablePanel = new ImportTablePanel(
                                                
ImportTablePanel.SIMPLE_ATTRIBUTE_IMPORT, is,
                                                this.fileType);
+                       } catch (Exception e) {
+                               throw new IllegalStateException(
+                                               "Could not initialize 
ImportTablePanel.", e);
                        }
-               } catch (JAXBException e1) {
-                       e1.printStackTrace();
-               } catch (IOException e1) {
-                       e1.printStackTrace();
                }
 
-               if (importDialog != null) {
-                       myPanel.add(importDialog);
-               }
+               System.out.println("$$$$$$$$$GUI Created. ");
 
-               return myPanel;
+               return importTablePanel;
        }
 
-       public void run(TaskMonitor e) throws Exception {
-               e.setTitle("Loading attribute table data");
-               e.setProgress(0.0);
-               e.setStatusMessage("Loading table...");
-               this.importDialog.importTable();
-               
-               if (this.importDialog.getLoadTask() != null) {
-                       this.importDialog.getLoadTask().run(e);
-               }
-               e.setProgress(1.0);
-               
-       }
+       @Override
+       public void run(TaskMonitor monitor) throws Exception {
 
-       public void cancel() {
+               System.out.println("$$$$$$$$$Run called");
+
+               monitor.setTitle("Loading attribute table data");
+               monitor.setProgress(0.0);
+               monitor.setStatusMessage("Loading table...");
+
+               System.out.println("$$$$$$$$$Table import start ");
+               this.importTablePanel.importTable();
+               System.out.println("$$$$$$$$$Table import END ");
+
+               monitor.setStatusMessage("Mapping data table to local ones...");
+               
this.insertTasksAfterCurrentTask(importTablePanel.getLoadTask());
+
+               System.out.println("$$$$$$$$$Finished. ");
+               monitor.setProgress(1.0);
        }
 
        public CyTable[] getCyTables() {
-               if (this.importDialog.getLoadTask() instanceof 
ImportAttributeTableTask) {
-                       ImportAttributeTableTask importTask = 
(ImportAttributeTableTask) this.importDialog
+               if (this.importTablePanel.getLoadTask() instanceof 
ImportAttributeTableTask) {
+                       ImportAttributeTableTask importTask = 
(ImportAttributeTableTask) this.importTablePanel
                                        .getLoadTask();
                        return importTask.getCyTables();
                }

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTablePanel.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTablePanel.java
     2011-03-23 22:56:06 UTC (rev 24568)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTablePanel.java
     2011-03-23 22:59:21 UTC (rev 24569)
@@ -1686,10 +1686,7 @@
                repaint();
        }
 
-       //private void cancelButtonActionPerformed(java.awt.event.ActionEvent 
evt) {
-               //dispose();
-       //}
-
+       
        /**
         * Load from the data source.<br>
         *

Modified: 
core3/table-import-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/table-import-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
 2011-03-23 22:56:06 UTC (rev 24568)
+++ 
core3/table-import-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
 2011-03-23 22:59:21 UTC (rev 24569)
@@ -65,7 +65,7 @@
                <constructor-arg ref="fileUtilService" />
                <constructor-arg ref="openBrowserService" />
                <constructor-arg ref="cyDataTableFactoryServiceRef" />
-               <constructor-arg value="file_format_txt" />
+               <constructor-arg value=".txt" />
        </bean>
 
  
@@ -83,6 +83,6 @@
                <constructor-arg ref="fileUtilService" />
                <constructor-arg ref="openBrowserService" />
                <constructor-arg ref="cyDataTableFactoryServiceRef" />
-               <constructor-arg value="file_format_xls" />
+               <constructor-arg value=".xls" />
        </bean>
 </beans>

-- 
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