Author: ruschein
Date: 2010-10-01 14:09:32 -0700 (Fri, 01 Oct 2010)
New Revision: 22125

Removed:
   
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/TaskExecutor.java
Modified:
   
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/CLTaskFactoryInterceptor.java
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
   core3/work-api/trunk/src/main/java/org/cytoscape/work/TaskManager.java
   
core3/work-headless-impl/trunk/src/main/java/org/cytoscape/work/internal/task/HeadlessTaskManager.java
   
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
Log:
Now we pass TaskFactorys to the TaskManager's execute method.

Modified: 
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/CLTaskFactoryInterceptor.java
===================================================================
--- 
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/CLTaskFactoryInterceptor.java
  2010-10-01 17:15:44 UTC (rev 22124)
+++ 
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/CLTaskFactoryInterceptor.java
  2010-10-01 21:09:32 UTC (rev 22125)
@@ -73,12 +73,7 @@
      */
     private TaskFactoryGrabber grabber;
     
-    /**
-     * executor that will create a <code>SuperTask</code> to execute 
asynchronously the <code>Tasks</code>
-     */
-    private TaskExecutor executor;
     
-    
     /**
      * Interceptor of <code>Task Factories</code> : see details
      * 
@@ -104,19 +99,12 @@
        taskMap = grabber.getTaskMap();
        arguments = clp.getCommandLineCompleteArgs();
        
-       //Executor collects all the tasks, create a SuperTask, to launch them 
asynchronously
-       executor = new TaskExecutor();
-       
        //execute the methods
        createTaskOptions();
         findTaskArguments();
         parseTaskArguments();
         executeCommandLineArguments();
-        //Execute the SuperTask that has been created
-        executor.execute();
     }
-    
-    
 
     /**
      * creates an Option for each <code>TaskFactory</code>
@@ -178,21 +166,7 @@
                 }
             }
         }
-
-        executor.setNumberOfTasks(choosenTasks.size());
         
-        
-        
-        //print the different parsed arguments
-/*     System.out.println("tasksWithTheirArgs :");
-        for(String st : tasksWithTheirArgs.keySet())System.out.println(st + " 
= " + tasksWithTheirArgs.get(st));
-        System.out.println("\n\n");
-        
-        System.out.println("listOfChoosenTasks :");
-        for(String st : choosenTasks)System.out.println(st);
-        System.out.println("\n\n\n");
-*/             
-        
         //add the general help for all task
         for (String arg : arguments) {
             if (arg.equals("-ListTasks")) {
@@ -231,37 +205,29 @@
         for (String st : choosenTasks) {
             for (TFWrapper tf : taskMap.values()) {
                 if (st.equals(tf.getName())) {
-
                        String TFactoryName = tf.getName();
                                List<String> lst = new ArrayList<String>();
                                
-                       if(tasksWithTheirArgs.get(TFactoryName).size()!=0){
-                               
-                               for(int 
i=0;i<tasksWithTheirArgs.get(TFactoryName).size();i++) {
+                       if (tasksWithTheirArgs.get(TFactoryName).size() != 0) {
+                               for(int i = 0; i < 
tasksWithTheirArgs.get(TFactoryName).size(); i++) {
                                        
if(tasksWithTheirArgs.get(TFactoryName).get(i).contains(" ")) {
                                                int val = 
tasksWithTheirArgs.get(TFactoryName).get(i).indexOf(" ");
                                                
lst.add(tasksWithTheirArgs.get(TFactoryName).get(i).substring(0, val));
                                                
lst.add(tasksWithTheirArgs.get(TFactoryName).get(i).substring(val+1));
-                                       }
-                                       else{
+                                       } else
                                                
lst.add(tasksWithTheirArgs.get(TFactoryName).get(i).toString());
-                                               //lst.add("-H");
-                                       }
                                }
-                       }
-                       else{
+                       } else
                                lst.add("-H");
-                       }
                                
-                               
                        //creation of arguments
                                String[] args = new String[lst.size()];
                                for(int i=0;i<lst.size();i++)args[i]=lst.get(i);
                                
                                clp.setSpecificArgs(args);
-                               
-                               //Executor intercepts each task and store it in 
a SuperTask
-                               
executor.intercept(tf.getT(),tf.getTI(),tf.getTM());
+
+                       final TaskFactory factory =  tf.getT();
+                               tf.getTM().execute(factory);
                        }
             }
         }

Deleted: 
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/TaskExecutor.java
===================================================================
--- 
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/TaskExecutor.java
      2010-10-01 17:15:44 UTC (rev 22124)
+++ 
core3/cmdline-parser-impl/trunk/src/main/java/org/cytoscape/cmdline/internal/TaskExecutor.java
      2010-10-01 21:09:32 UTC (rev 22125)
@@ -1,73 +0,0 @@
-package org.cytoscape.cmdline.internal;
-
-
-import org.cytoscape.work.SuperTask;
-import org.cytoscape.work.Task;
-import org.cytoscape.work.TaskFactory;
-import org.cytoscape.work.TaskIterator;
-import org.cytoscape.work.TaskManager;
-import org.cytoscape.work.TunableInterceptor;
-
-
-/**
- * To execute asynchronously the <code>Tasks</code>, we use a 
<code>SuperTask</code> made of <code>Tasks</code> that have been intercepted 
using a <code>TunableInterceptor</code>
- * 
- * @author pasteur
- *
- */
-public class TaskExecutor {
-       public  TaskExecutor() {
-       }
-       
-       /**
-        * <code>Tasks</code> that will be executed
-        */
-       private Task[] tasks;
-       
-       /**
-        * Manager to execute the <code>Tasks</code>
-        */
-       private TaskManager tm;
-       
-       /**
-        * Number of <code>Tasks</code>
-        */
-       private int numberTasks = 0;
-       
-       /**
-        * to initialize the Array of <code>Tasks</code>
-        * @param val number of <code>Tasks</code> that will be executed
-        */
-       public void setNumberOfTasks(int val) {
-               tasks = new Task[val];
-       }
-       
-       /**
-        * Apply the <code>TunableInterceptor</code> on the <code>Tasks</code> 
and create an Array that contains those
-        * 
-        * @param tf <code>TaskFactory</code> selected
-        * @param ti interceptor applied on the <code>Task</code>
-        * @param tm execute the <code>Task</code>
-        */
-       public void intercept(final TaskFactory tf, final TunableInterceptor 
ti, final TaskManager tm) {
-               this.tm = tm;
-
-               final TaskIterator taskIterator = tf.getTaskIterator();
-               while (taskIterator.hasNext()) {
-                       final Task task = taskIterator.next();
-                       ti.loadTunables(task);
-                       if (!ti.execUI(task))
-                               return;
-                       tasks[numberTasks] = task;
-                       numberTasks++;
-               }
-       }
-               
-       /**
-        * Create a <code>SuperTask</code> of the selected <code>Tasks</code>, 
and execute them asynchronously
-        */
-       public void execute() {
-               Task superTask = new SuperTask(tasks);
-               tm.execute(new TaskIterator(superTask));
-       }
-}
\ No newline at end of file

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
       2010-10-01 17:15:44 UTC (rev 22124)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/PopupMenuHelper.java
       2010-10-01 21:09:32 UTC (rev 22125)
@@ -239,7 +239,6 @@
         * A place to capture the common task execution behavior.
         */
        private void executeTask(TaskFactory tf) {
-               final TaskIterator taskIterator = tf.getTaskIterator();
-               m_view.manager.execute(taskIterator);
+               m_view.manager.execute(tf);
        }
 }

Modified: core3/work-api/trunk/src/main/java/org/cytoscape/work/TaskManager.java
===================================================================
--- core3/work-api/trunk/src/main/java/org/cytoscape/work/TaskManager.java      
2010-10-01 17:15:44 UTC (rev 22124)
+++ core3/work-api/trunk/src/main/java/org/cytoscape/work/TaskManager.java      
2010-10-01 21:09:32 UTC (rev 22125)
@@ -16,9 +16,9 @@
        /**
         * This method is called to execute a <code>Task</code>.
         *
-        * This method returns once the <code>Task</code> has
-        * started execution. It does not wait for the
-        * <code>Task</code> to finish.
+        * This method returns once the <code>Task</code>s derived from the 
<code>TaskIterator</code>
+        * returned by the <code>TaskFactory>'s <code>getTaskIterator()</code> 
method started execution.
+        * It does not wait for the <code>Task</code>s to finish.
         */
-       void execute(TaskIterator taskIterator);
+       void execute(TaskFactory factory);
 }

Modified: 
core3/work-headless-impl/trunk/src/main/java/org/cytoscape/work/internal/task/HeadlessTaskManager.java
===================================================================
--- 
core3/work-headless-impl/trunk/src/main/java/org/cytoscape/work/internal/task/HeadlessTaskManager.java
      2010-10-01 17:15:44 UTC (rev 22124)
+++ 
core3/work-headless-impl/trunk/src/main/java/org/cytoscape/work/internal/task/HeadlessTaskManager.java
      2010-10-01 21:09:32 UTC (rev 22125)
@@ -7,6 +7,7 @@
 
 import org.cytoscape.work.AbstractTaskManager;
 import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskFactory;
 import org.cytoscape.work.TaskIterator;
 import org.cytoscape.work.TaskMonitor;
 import org.cytoscape.work.TunableInterceptor;
@@ -42,7 +43,8 @@
        }
 
        @Override
-       public void execute(final TaskIterator taskIterator) {
+       public void execute(final TaskFactory factory) {
+               final TaskIterator taskIterator = factory.getTaskIterator();
                final Timer timer = new Timer();
                final ConsoleTaskMonitor taskMonitor = new 
ConsoleTaskMonitor(timer);
 

Modified: 
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
===================================================================
--- 
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
    2010-10-01 17:15:44 UTC (rev 22124)
+++ 
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
    2010-10-01 21:09:32 UTC (rev 22125)
@@ -124,7 +124,8 @@
        }
 
        @Override
-       public void execute(final TaskIterator taskIterator) {
+       public void execute(final TaskFactory factory) {
+               final TaskIterator taskIterator = factory.getTaskIterator();
                taskMonitor = null;
                final Runnable executor = new Runnable() {
                        public void run() {

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