Author: mes
Date: 2011-11-02 13:42:20 -0700 (Wed, 02 Nov 2011)
New Revision: 27380

Added:
   
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/CyActivator.java
   
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultipleTaskFactory.java
   
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/SingleTask.java
   
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml-legacy
   
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml-legacy
Removed:
   
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml
Modified:
   core3/api/trunk/work-api/src/main/java/org/cytoscape/work/TaskIterator.java
   
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/TaskIteratorTest.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractCreationTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CloneNetworkTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTaskFactory.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewEmptyNetworkTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesEdgesTaskFactory.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesOnlyTaskFactory.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTaskFactoryImpl.java
   
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/JDialogTaskManager.java
   
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
   core3/support/trunk/task-testing-impl/osgi.bnd
   core3/support/trunk/task-testing-impl/pom.xml
Log:
The Swing TaskMonitor dialog is now fractionated based on the expected number 
of tasks found in the TaskIterator. Also, several tasks have been updated to 
better display their progress.

Modified: 
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/TaskIterator.java
===================================================================
--- core3/api/trunk/work-api/src/main/java/org/cytoscape/work/TaskIterator.java 
2011-11-02 19:11:50 UTC (rev 27379)
+++ core3/api/trunk/work-api/src/main/java/org/cytoscape/work/TaskIterator.java 
2011-11-02 20:42:20 UTC (rev 27380)
@@ -14,14 +14,18 @@
 public final class TaskIterator implements Iterator<Task> {
        private final List<Task> tasks;
        private int currentIndex;
+       private int numTasks;
 
-       /** Constructs an iterator that will yield Tasks in the order that they 
were passed into
-        *  this constructor.
+       /** 
+        * Constructs an iterator that will yield Tasks in the order that they 
were passed into
+        * this constructor. 
+        * @param expectedNumTasks The total number of tasks that the 
initialTasks are likely to spawn. 
         * @param initialTasks the Tasks to place into the iterator.
         */
-       public TaskIterator(final Task... initialTasks) {
+       public TaskIterator(int expectedNumTasks, final Task... initialTasks) {
                this.tasks = new ArrayList<Task>(initialTasks.length);
                this.currentIndex = 0;
+               this.numTasks = expectedNumTasks;
 
                for (final Task initialTask : initialTasks) {
                        tryToAddSelfReferenceToTask(initialTask);
@@ -29,6 +33,15 @@
                }
        }
 
+       /** 
+        * Constructs an iterator that will yield Tasks in the order that they 
were passed into
+        * this constructor.
+        * @param initialTasks the Tasks to place into the iterator.
+        */
+       public TaskIterator(final Task... initialTasks) {
+               this(initialTasks.length,initialTasks);
+       }
+
        /** Inserts "newTasks" immediately after "referenceTask".
         * @param referenceTask task to insert newTasks after.
         * @param newTasks tasks to insert after referenceTask.
@@ -38,6 +51,9 @@
                final int referenceIndex = tasks.indexOf(referenceTask);
                if (referenceIndex == -1)
                        throw new IllegalStateException("invalid reference task 
in call to insertTaskAfter()!");
+
+               numTasks += newTasks.length;
+
                int offset = 0;
                for (final Task newTask : newTasks) {
                        tryToAddSelfReferenceToTask(newTask);
@@ -55,6 +71,9 @@
                final int referenceIndex = tasks.indexOf(referenceTask);
                if (referenceIndex == -1)
                        throw new IllegalStateException("invalid reference task 
in call to insertTaskAfter()!");
+
+               numTasks += newTasks.getNumTasks();
+
                int offset = 0;
                while (newTasks.hasNext()) {
                        final Task newTask = newTasks.next();
@@ -101,6 +120,17 @@
                        }
                }
        }
+
+       /**
+        * Returns the current total number of tasks in the iterator. As tasks
+        * get added to the iterator, this number will change, so this should
+        * not be viewed as a fixed or final value!
+        * 
+        * @return the current total number of tasks in the iterator. 
+        */
+       public int getNumTasks() {
+               return numTasks;
+       }
 }
 
 

Modified: 
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/TaskIteratorTest.java
===================================================================
--- 
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/TaskIteratorTest.java 
    2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/TaskIteratorTest.java 
    2011-11-02 20:42:20 UTC (rev 27380)
@@ -80,6 +80,14 @@
                // This should blow up!
                iter.next();
        }
+
+       @Test
+       public final void testNumTasks() throws Exception {
+               final Task initialTask = new SimpleTask(1);
+               final Task initialTask2 = new SimpleTask(2);
+               final TaskIterator iter = new TaskIterator(initialTask, 
initialTask2);
+               assertEquals(2,iter.getNumTasks());
+       }
 }
 
 
@@ -105,4 +113,4 @@
        public boolean cancelled() {
                return false;
        }
-}
\ No newline at end of file
+}

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractCreationTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractCreationTask.java
        2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractCreationTask.java
        2011-11-02 20:42:20 UTC (rev 27380)
@@ -40,15 +40,14 @@
  */
 public abstract class AbstractCreationTask extends AbstractTask {
 
-    protected final CyNetworkManager networkManager;
-    protected final CyNetworkViewManager networkViewManager;
-    
-    protected final CyNetwork parentNetwork;
+       protected final CyNetworkManager networkManager;
+       protected final CyNetworkViewManager networkViewManager;
+       protected final CyNetwork parentNetwork;
 
-    public AbstractCreationTask(final CyNetwork parentNetwork, final 
CyNetworkManager networkManager,
-           final CyNetworkViewManager networkViewManager) {
-       this.parentNetwork = parentNetwork;
-       this.networkManager = networkManager;
-       this.networkViewManager = networkViewManager;
-    }
+       public AbstractCreationTask(final CyNetwork parentNetwork, final 
CyNetworkManager networkManager,
+                                   final CyNetworkViewManager 
networkViewManager) {
+               this.parentNetwork = parentNetwork;
+               this.networkManager = networkManager;
+               this.networkViewManager = networkViewManager;
+       }
 }

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
    2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
    2011-11-02 20:42:20 UTC (rev 27380)
@@ -92,28 +92,35 @@
        public void run(TaskMonitor tm) {
                if (parentNetwork == null)
                        throw new NullPointerException("Source network is 
null.");
+               tm.setProgress(0.0);
 
                final CyNetworkView curView = 
networkViewManager.getNetworkView(parentNetwork.getSUID());
+               tm.setProgress(0.1);
 
                // Get the selected nodes, but only create network if nodes are 
actually
                // selected.
                final List<CyNode> selectedNodes = 
CyTableUtil.getNodesInState(parentNetwork, CyNetwork.SELECTED, true);
+               tm.setProgress(0.2);
 
                if (selectedNodes.size() <= 0)
                        throw new IllegalArgumentException("No nodes are 
selected!");
 
                // create subnetwork and add selected nodes and appropriate 
edges
                final CySubNetwork newNet = 
rootNetworkFactory.convert(parentNetwork).addSubNetwork();
+               tm.setProgress(0.3);
 
                for (final CyNode node : selectedNodes)
                        newNet.addNode(node);
 
+               tm.setProgress(0.4);
                for (final CyEdge edge : getEdges(parentNetwork, selectedNodes))
                        newNet.addEdge(edge);
+               tm.setProgress(0.5);
 
                newNet.getCyRow().set(CyTableEntry.NAME, 
cyNetworkNaming.getSuggestedSubnetworkTitle(parentNetwork));
 
                networkManager.addNetwork(newNet);
+               tm.setProgress(0.6);
 
                appManager.setCurrentNetwork(newNet.getSUID());
 
@@ -127,11 +134,13 @@
                        appManager.setCurrentNetworkView(newNet.getSUID());
                        return;
                }
+               tm.setProgress(0.7);
 
                // create new view
                final CyNetworkView newView = 
viewFactory.getNetworkView(newNet);
 
                networkViewManager.addNetworkView(newView);
+               tm.setProgress(0.8);
 
                // copy node location only.
                for (View<CyNode> newNodeView : newView.getNodeViews()) {
@@ -149,6 +158,7 @@
                        // origNodeView.getVisualProperty(vp));
                        // }
                }
+               tm.setProgress(0.9);
 
                final VisualStyle style = vmm.getVisualStyle(curView);
                vmm.setVisualStyle(vmm.getVisualStyle(curView), newView);
@@ -156,5 +166,6 @@
                newView.fitContent();
 
                appManager.setCurrentNetworkView(newView.getModel().getSUID());
+               tm.setProgress(1.0);
        }
 }

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CloneNetworkTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CloneNetworkTask.java
    2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CloneNetworkTask.java
    2011-11-02 20:42:20 UTC (rev 27380)
@@ -80,21 +80,26 @@
        }
 
        public void run(TaskMonitor tm) {
+               tm.setProgress(0.0);
                final long start = System.currentTimeMillis();
                logger.debug("Clone Network Task start");
                
                // Create copied network model
                final CyNetwork newNet = cloneNetwork(parentNetwork);
+               tm.setProgress(0.4);
                final CyNetworkView origView = 
networkViewManager.getNetworkView(parentNetwork.getSUID());
                networkManager.addNetwork(newNet);
+               tm.setProgress(0.6);
 
                if (origView != null)
                        copyView(newNet, origView);
+               tm.setProgress(0.9);
 
                orig2NewNodeMap.clear();
                orig2NewNodeMap = null;
                
                logger.debug("Cloning finished in " + 
(System.currentTimeMillis() - start) + " msec.");
+               tm.setProgress(1.0);
        }
 
        private CyNetwork cloneNetwork(CyNetwork origNet) {

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTask.java
       2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTask.java
       2011-11-02 20:42:20 UTC (rev 27380)
@@ -71,15 +71,17 @@
        }
 
        public void run(TaskMonitor taskMonitor) throws Exception {
+               taskMonitor.setProgress(0.0);
                final long start = System.currentTimeMillis();
 
                taskMonitor.setStatusMessage("Creating network view...");
-               taskMonitor.setProgress(-1.0);
 
                try {
                        // By calling this task, actual view will be created 
even if it's a
                        // large network.
+                       taskMonitor.setProgress(0.4);
                        final CyNetworkView view = 
viewFactory.getNetworkView(network, false);
+                       taskMonitor.setProgress(0.8);
                        networkViewManager.addNetworkView(view);
                        
                        // Apply layout only when it is necessary.

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTaskFactory.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTaskFactory.java
        2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/CreateNetworkViewTaskFactory.java
        2011-11-02 20:42:20 UTC (rev 27380)
@@ -60,8 +60,8 @@
        }
 
        public TaskIterator getTaskIterator() {
-               return new TaskIterator(new CreateNetworkViewTask(undoSupport, 
network, viewFactory,
-                                                                 
networkViewManager, layouts,
-                                                                 eventHelper));
+               return new TaskIterator(2, new 
CreateNetworkViewTask(undoSupport, network, viewFactory,
+                                                                    
networkViewManager, layouts,
+                                                                    
eventHelper));
        }
 }

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewEmptyNetworkTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewEmptyNetworkTask.java
 2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewEmptyNetworkTask.java
 2011-11-02 20:42:20 UTC (rev 27380)
@@ -67,11 +67,17 @@
        }
 
        public void run(TaskMonitor tm) {
+               tm.setProgress(0.0);
                final CyNetwork newNet = cnf.getInstance();
+               tm.setProgress(0.2);
                newNet.getCyRow().set(CyTableEntry.NAME, 
namingUtil.getSuggestedNetworkTitle("Network"));
+               tm.setProgress(0.4);
                view = cnvf.getNetworkView(newNet);             
+               tm.setProgress(0.6);
                networkManager.addNetwork(newNet);
+               tm.setProgress(0.8);
                networkViewManager.addNetworkView(view);
+               tm.setProgress(1.0);
        }
 
        @Override

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesEdgesTaskFactory.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesEdgesTaskFactory.java
     2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesEdgesTaskFactory.java
     2011-11-02 20:42:20 UTC (rev 27380)
@@ -76,7 +76,7 @@
        }
 
        public TaskIterator getTaskIterator() {
-               return new TaskIterator(
+               return new TaskIterator(2,
                        new NewNetworkSelectedNodesEdgesTask(undoSupport, 
network, crnf, cnvf,
                                                             netmgr, 
networkViewManager, naming, vmm,
                                                             appManager, 
eventHelper));

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesOnlyTaskFactory.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesOnlyTaskFactory.java
      2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/NewNetworkSelectedNodesOnlyTaskFactory.java
      2011-11-02 20:42:20 UTC (rev 27380)
@@ -76,7 +76,7 @@
        }
 
        public TaskIterator getTaskIterator() {
-               return new TaskIterator(
+               return new TaskIterator(2,
                        new NewNetworkSelectedNodesOnlyTask(undoSupport, 
network, crnf, cnvf, netmgr,
                                                            networkViewManager, 
naming, vmm,
                                                            appManager, 
eventHelper));

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTask.java
        2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTask.java
        2011-11-02 20:42:20 UTC (rev 27380)
@@ -27,10 +27,12 @@
 
        @Override
        public void run(final TaskMonitor taskMonitor) throws Exception {
+               taskMonitor.setProgress(0.0);
                if (file == null) 
                        throw new NullPointerException("No file specified!");
 
                VizmapReader reader = vizmapReaderMgr.getReader(file.toURI(), 
file.getName());
+               taskMonitor.setProgress(0.9);
 
                if (reader == null) 
                        throw new NullPointerException("Failed to find 
appropriate reader for file: " + file);
@@ -38,6 +40,7 @@
                addVSTask = new AddVisualStylesTask(reader, vmMgr);
 
                insertTasksAfterCurrentTask(reader, addVSTask);
+               taskMonitor.setProgress(1.0);
        }
 
        public Set<VisualStyle> getStyles() {
@@ -58,6 +61,7 @@
 
        @Override
        public void run(TaskMonitor taskMonitor) throws Exception {
+               taskMonitor.setProgress(0.0);
                taskMonitor.setTitle("Loading visual styles...");
                styles = reader.getVisualStyles();
 
@@ -79,9 +83,9 @@
                                        vmMgr.removeVisualStyle(vs);
                                }
 
-                               taskMonitor.setProgress(1.0);
                        }
                }
+               taskMonitor.setProgress(1.0);
        }
 
        public Set<VisualStyle> getStyles() {

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTaskFactoryImpl.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTaskFactoryImpl.java
     2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTaskFactoryImpl.java
     2011-11-02 20:42:20 UTC (rev 27380)
@@ -31,7 +31,7 @@
        @Override
        public TaskIterator getTaskIterator() {
                task = new LoadVizmapFileTask(vizmapReaderMgr, vmMgr);
-               return new TaskIterator(task);
+               return new TaskIterator(2,task);
        }
 
        public Set<VisualStyle> loadStyles(File f) {

Modified: 
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/JDialogTaskManager.java
===================================================================
--- 
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/JDialogTaskManager.java
        2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/JDialogTaskManager.java
        2011-11-02 20:42:20 UTC (rev 27380)
@@ -154,6 +154,7 @@
                                return;
 
                        taskIterator = factory.getTaskIterator();
+                       taskMonitor.setExpectedNumTasks( 
taskIterator.getNumTasks() );
 
                        // Get the first task and display its tunables.  This 
is a bit of a hack.  
                        // We do this outside of the thread so that the task 
monitor only gets

Modified: 
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
===================================================================
--- 
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
  2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
  2011-11-02 20:42:20 UTC (rev 27380)
@@ -8,27 +8,45 @@
 
 import org.cytoscape.work.Task;
 import org.cytoscape.work.TaskMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 class SwingTaskMonitor implements TaskMonitor {
        
-       private Task task;
        final private ExecutorService cancelExecutorService;
        final private Window parent;
+       final static private Logger logger = 
LoggerFactory.getLogger(SwingTaskMonitor.class);
 
        private boolean cancelled = false;
        private TaskDialog dialog = null;
-       
+       private Task task;
        private String title = null;
        private String statusMessage = null;
        private int progress = 0;
        private Future<?> future = null;
+       private int expectedNumTasks = 1;
+       private int currentTaskNum = -1; // so that the first task is numbered 0
 
+       /**
+        * Based on the expected number of tasks, this is the fraction of the 
overall
+        * task monitor that a given task is allocated. So, if there are 4 
tasks 
+        * executed with this task monitor, each task is allocated 0.25 of the 
+        * space in the progress bar.
+        */
+       private double fractionOfOverall = 1.0;
+
        public SwingTaskMonitor(final ExecutorService cancelExecutorService, 
final Window parent) {
                this.cancelExecutorService = cancelExecutorService;
                this.parent = parent;
        }
 
+       public void setExpectedNumTasks(int numTasks) {
+               this.expectedNumTasks = numTasks;
+               this.fractionOfOverall = 1.0/(double)expectedNumTasks;
+       }
+
        public void setTask(final Task newTask) {
+               this.currentTaskNum++;  
                this.task = newTask;
        }
 
@@ -97,7 +115,9 @@
        }
 
        public void setProgress(double progress) {
-               this.progress = (int) Math.floor(progress * 100);
+               double completed = 
(double)currentTaskNum/(double)expectedNumTasks;
+               double adjustedProgress = (progress * fractionOfOverall) + 
completed;
+               this.progress = (int) Math.floor(100.0 * adjustedProgress); 
                if (dialog != null)
                        dialog.setPercentCompleted(this.progress);
        }

Modified: core3/support/trunk/task-testing-impl/osgi.bnd
===================================================================
--- core3/support/trunk/task-testing-impl/osgi.bnd      2011-11-02 19:11:50 UTC 
(rev 27379)
+++ core3/support/trunk/task-testing-impl/osgi.bnd      2011-11-02 20:42:20 UTC 
(rev 27380)
@@ -3,3 +3,4 @@
 #-----------------------------------------------------------------
 
 Private-Package: org.cytoscape.internal, org.cytoscape.internal.*
+Bundle-Activator: org.cytoscape.internal.test.CyActivator

Modified: core3/support/trunk/task-testing-impl/pom.xml
===================================================================
--- core3/support/trunk/task-testing-impl/pom.xml       2011-11-02 19:11:50 UTC 
(rev 27379)
+++ core3/support/trunk/task-testing-impl/pom.xml       2011-11-02 20:42:20 UTC 
(rev 27380)
@@ -79,5 +79,15 @@
                        <artifactId>work-api</artifactId>
                        <version>${cytoscape.api.version}</version>
                </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>service-api</artifactId>
+                       <version>${cytoscape.api.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.osgi</groupId>
+                       <artifactId>org.osgi.core</artifactId>
+                       <version>${osgi.api.version}</version>
+               </dependency>
        </dependencies>
 </project>

Added: 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/CyActivator.java
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/CyActivator.java
                            (rev 0)
+++ 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/CyActivator.java
    2011-11-02 20:42:20 UTC (rev 27380)
@@ -0,0 +1,81 @@
+
+
+
+
+package org.cytoscape.internal.test;
+
+import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.work.TaskManager;
+
+import org.cytoscape.internal.test.MultipleTaskFactory;
+import org.cytoscape.internal.test.InfiniteTaskFactory;
+import org.cytoscape.internal.test.MultiTunableAction;
+import org.cytoscape.internal.test.tunables.TunablesTestTaskFactory2;
+import org.cytoscape.internal.test.tunables.TunablesTestTaskFactory3;
+import org.cytoscape.internal.test.WaitAction;
+import org.cytoscape.internal.test.tunables.TunablesTestTaskFactory;
+
+import org.cytoscape.application.swing.CyAction;
+import org.cytoscape.work.TaskFactory;
+
+
+import org.osgi.framework.BundleContext;
+
+import org.cytoscape.service.util.AbstractCyActivator;
+
+import java.util.Properties;
+
+
+
+public class CyActivator extends AbstractCyActivator {
+       public CyActivator() {
+               super();
+       }
+
+
+       public void start(BundleContext bc) {
+
+               CyApplicationManager cyApplicationManagerServiceRef = 
getService(bc,CyApplicationManager.class);
+               TaskManager taskManagerServiceRef = 
getService(bc,TaskManager.class);
+               
+               WaitAction waitAction = new 
WaitAction(cyApplicationManagerServiceRef,taskManagerServiceRef);
+               MultiTunableAction multiTunableAction = new 
MultiTunableAction(cyApplicationManagerServiceRef,taskManagerServiceRef);
+               TunablesTestTaskFactory tunablesTestTaskFactory = new 
TunablesTestTaskFactory();
+               TunablesTestTaskFactory2 tunablesTestTaskFactory2 = new 
TunablesTestTaskFactory2();
+               TunablesTestTaskFactory3 tunablesTestTaskFactory3 = new 
TunablesTestTaskFactory3();
+               InfiniteTaskFactory infiniteTaskFactory = new 
InfiniteTaskFactory();
+               MultipleTaskFactory multipleTaskFactory = new 
MultipleTaskFactory();
+               
+               registerService(bc,waitAction,CyAction.class, new Properties());
+               registerService(bc,multiTunableAction,CyAction.class, new 
Properties());
+
+               Properties tunablesTestTaskFactoryProps = new Properties();
+               
tunablesTestTaskFactoryProps.setProperty("preferredMenu","Help");
+               tunablesTestTaskFactoryProps.setProperty("title","Tunable Task 
Test...");
+               registerService(bc,tunablesTestTaskFactory,TaskFactory.class, 
tunablesTestTaskFactoryProps);
+
+               Properties tunablesTestTaskFactory2Props = new Properties();
+               
tunablesTestTaskFactory2Props.setProperty("cytoPanelComponentTitle","Tunable 
Factory Test");
+               
tunablesTestTaskFactory2Props.setProperty("preferredMenu","Help");
+               tunablesTestTaskFactory2Props.setProperty("title","Tunable 
Factory Test...");
+               registerService(bc,tunablesTestTaskFactory2,TaskFactory.class, 
tunablesTestTaskFactory2Props);
+
+               Properties tunablesTestTaskFactory3Props = new Properties();
+               
tunablesTestTaskFactory3Props.setProperty("cytoPanelComponentTitle","Complex 
Tunable Test");
+               
tunablesTestTaskFactory3Props.setProperty("preferredMenu","Help");
+               tunablesTestTaskFactory3Props.setProperty("title","Complex 
Tunable Test...");
+               registerService(bc,tunablesTestTaskFactory3,TaskFactory.class, 
tunablesTestTaskFactory3Props);
+
+               Properties infiniteTaskFactoryProps = new Properties();
+               infiniteTaskFactoryProps.setProperty("preferredMenu","Help");
+               infiniteTaskFactoryProps.setProperty("title","Infinite 
Test...");
+               registerService(bc,infiniteTaskFactory,TaskFactory.class, 
infiniteTaskFactoryProps);
+
+               Properties multipleTaskFactoryProps = new Properties();
+               multipleTaskFactoryProps.setProperty("preferredMenu","Help");
+               multipleTaskFactoryProps.setProperty("title","Multiple Task 
Test...");
+               registerService(bc,multipleTaskFactory,TaskFactory.class, 
multipleTaskFactoryProps);
+
+       }
+}
+

Added: 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultipleTaskFactory.java
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultipleTaskFactory.java
                            (rev 0)
+++ 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultipleTaskFactory.java
    2011-11-02 20:42:20 UTC (rev 27380)
@@ -0,0 +1,14 @@
+
+package org.cytoscape.internal.test;
+
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TaskFactory;
+
+
+public class MultipleTaskFactory implements TaskFactory {
+       public MultipleTaskFactory() { }
+
+       public TaskIterator getTaskIterator() {
+               return new TaskIterator(new SingleTask(), new SingleTask(), new 
SingleTask(), new SingleTask());
+       }
+}

Added: 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/SingleTask.java
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/SingleTask.java
                             (rev 0)
+++ 
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/SingleTask.java
     2011-11-02 20:42:20 UTC (rev 27380)
@@ -0,0 +1,22 @@
+
+package org.cytoscape.internal.test;
+
+
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+
+
+public class SingleTask extends AbstractTask {
+
+       public void run(final TaskMonitor taskMonitor) throws Exception {
+               double progress = 0.0;
+               taskMonitor.setProgress(progress);
+               taskMonitor.setStatusMessage("Excuting task...");
+               while(progress < 1.0){ 
+                       taskMonitor.setStatusMessage("executing step: " + 
progress);
+                       taskMonitor.setProgress(progress);
+                       Thread.sleep(200);
+                       progress += 0.1;
+               }
+       }
+}

Deleted: 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
    2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
    2011-11-02 20:42:20 UTC (rev 27380)
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
-       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-                      http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
-       default-lazy-init="false">
-
-       <!-- Import OSGi services -->
-
-       <osgi:reference id="cyApplicationManagerServiceRef"
-               interface="org.cytoscape.application.CyApplicationManager" />
-
-       <osgi:reference id="taskManagerServiceRef" 
-               interface="org.cytoscape.work.TaskManager" />
-
-       <!-- Export OSGi services -->
-
-       <osgi:service id="waitActionService" ref="waitAction" 
-               interface="org.cytoscape.application.swing.CyAction" />
-       <osgi:service id="waitValueActionService" ref="waitValueAction" 
-               interface="org.cytoscape.application.swing.CyAction" />
-       <osgi:service id="multiTunableActionService" ref="multiTunableAction" 
-               interface="org.cytoscape.application.swing.CyAction" />
-
-    <osgi:service id="tunablesTestTaskFactoryService" 
ref="tunablesTestTaskFactory"
-        interface="org.cytoscape.work.TaskFactory">
-        <osgi:service-properties>
-            <entry key="title" value="Tunable Task Test..." />
-            <entry key="preferredMenu" value="Help" />
-        </osgi:service-properties>
-    </osgi:service>
-
-    <osgi:service id="tunablesTestTaskFactoryService2" 
ref="tunablesTestTaskFactory2"
-        interface="org.cytoscape.work.TaskFactory">
-        <osgi:service-properties>
-            <entry key="title" value="Tunable Factory Test..." />
-            <entry key="preferredMenu" value="Help" />
-            <entry key="cytoPanelComponentTitle" value="Tunable Factory Test" 
/>
-        </osgi:service-properties>
-    </osgi:service>
-
-    <osgi:service id="tunablesTestTaskFactoryService3" 
ref="tunablesTestTaskFactory3"
-        interface="org.cytoscape.work.TaskFactory">
-        <osgi:service-properties>
-            <entry key="title" value="Complex Tunable Test..." />
-            <entry key="preferredMenu" value="Help" />
-            <entry key="cytoPanelComponentTitle" value="Complex Tunable Test" 
/>
-        </osgi:service-properties>
-    </osgi:service>
-
-    <osgi:service id="infiniteTaskFactoryService" ref="infiniteTaskFactory"
-        interface="org.cytoscape.work.TaskFactory">
-        <osgi:service-properties>
-            <entry key="title" value="Infinite Test..." />
-            <entry key="preferredMenu" value="Help" />
-        </osgi:service-properties>
-    </osgi:service>
-
-</beans>

Copied: 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml-legacy
 (from rev 27375, 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml)
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml-legacy
                             (rev 0)
+++ 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml-legacy
     2011-11-02 20:42:20 UTC (rev 27380)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
+       default-lazy-init="false">
+
+       <!-- Import OSGi services -->
+
+       <osgi:reference id="cyApplicationManagerServiceRef"
+               interface="org.cytoscape.application.CyApplicationManager" />
+
+       <osgi:reference id="taskManagerServiceRef" 
+               interface="org.cytoscape.work.TaskManager" />
+
+       <!-- Export OSGi services -->
+
+       <osgi:service id="waitActionService" ref="waitAction" 
+               interface="org.cytoscape.application.swing.CyAction" />
+       <osgi:service id="waitValueActionService" ref="waitValueAction" 
+               interface="org.cytoscape.application.swing.CyAction" />
+       <osgi:service id="multiTunableActionService" ref="multiTunableAction" 
+               interface="org.cytoscape.application.swing.CyAction" />
+
+    <osgi:service id="tunablesTestTaskFactoryService" 
ref="tunablesTestTaskFactory"
+        interface="org.cytoscape.work.TaskFactory">
+        <osgi:service-properties>
+            <entry key="title" value="Tunable Task Test..." />
+            <entry key="preferredMenu" value="Help" />
+        </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service id="tunablesTestTaskFactoryService2" 
ref="tunablesTestTaskFactory2"
+        interface="org.cytoscape.work.TaskFactory">
+        <osgi:service-properties>
+            <entry key="title" value="Tunable Factory Test..." />
+            <entry key="preferredMenu" value="Help" />
+            <entry key="cytoPanelComponentTitle" value="Tunable Factory Test" 
/>
+        </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service id="tunablesTestTaskFactoryService3" 
ref="tunablesTestTaskFactory3"
+        interface="org.cytoscape.work.TaskFactory">
+        <osgi:service-properties>
+            <entry key="title" value="Complex Tunable Test..." />
+            <entry key="preferredMenu" value="Help" />
+            <entry key="cytoPanelComponentTitle" value="Complex Tunable Test" 
/>
+        </osgi:service-properties>
+    </osgi:service>
+
+    <osgi:service id="infiniteTaskFactoryService" ref="infiniteTaskFactory"
+        interface="org.cytoscape.work.TaskFactory">
+        <osgi:service-properties>
+            <entry key="title" value="Infinite Test..." />
+            <entry key="preferredMenu" value="Help" />
+        </osgi:service-properties>
+    </osgi:service>
+
+</beans>

Deleted: 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml
 2011-11-02 19:11:50 UTC (rev 27379)
+++ 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml
 2011-11-02 20:42:20 UTC (rev 27380)
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:aop="http://www.springframework.org/schema/aop";
-       xmlns:context="http://www.springframework.org/schema/context";
-       xmlns:lang="http://www.springframework.org/schema/lang"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
-       xmlns:util="http://www.springframework.org/schema/util";
-       xsi:schemaLocation="
-               http://www.springframework.org/schema/beans 
-                       
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-               http://www.springframework.org/schema/aop 
-                       
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
-               http://www.springframework.org/schema/context 
-                       
http://www.springframework.org/schema/context/spring-context-3.0.xsd
-               http://www.springframework.org/schema/util 
-                       
http://www.springframework.org/schema/util/spring-util-3.0.xsd
-               http://www.springframework.org/schema/lang 
-                       
http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
-               http://www.springframework.org/schema/osgi 
-                       
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
-       default-lazy-init="false">
-       
-       <import resource="bundle-context-osgi.xml" />
-
-       <context:annotation-config />
-
-       <bean id="waitAction" class="org.cytoscape.internal.test.WaitAction">
-               <constructor-arg ref="cyApplicationManagerServiceRef" />
-               <constructor-arg ref="taskManagerServiceRef" />
-       </bean>
-
-       <bean id="waitValueAction" 
class="org.cytoscape.internal.test.WaitValueAction">
-               <constructor-arg ref="cyApplicationManagerServiceRef" />
-               <constructor-arg ref="taskManagerServiceRef" />
-       </bean>
-
-       <bean id="multiTunableAction" 
class="org.cytoscape.internal.test.MultiTunableAction">
-               <constructor-arg ref="cyApplicationManagerServiceRef" />
-               <constructor-arg ref="taskManagerServiceRef" />
-       </bean>
-
-    <bean id="tunablesTestTaskFactory"
-          class="org.cytoscape.internal.test.tunables.TunablesTestTaskFactory">
-    </bean>
-
-    <bean id="tunablesTestTaskFactory2"
-          
class="org.cytoscape.internal.test.tunables.TunablesTestTaskFactory2">
-    </bean>
-
-    <bean id="tunablesTestTaskFactory3"
-          
class="org.cytoscape.internal.test.tunables.TunablesTestTaskFactory3">
-    </bean>
-
-    <bean id="infiniteTaskFactory"
-          class="org.cytoscape.internal.test.InfiniteTaskFactory">
-    </bean>
-
-</beans>

Copied: 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml-legacy
 (from rev 27375, 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml)
===================================================================
--- 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml-legacy
                          (rev 0)
+++ 
core3/support/trunk/task-testing-impl/src/main/resources/META-INF/spring/bundle-context.xml-legacy
  2011-11-02 20:42:20 UTC (rev 27380)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:aop="http://www.springframework.org/schema/aop";
+       xmlns:context="http://www.springframework.org/schema/context";
+       xmlns:lang="http://www.springframework.org/schema/lang"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
+       xmlns:util="http://www.springframework.org/schema/util";
+       xsi:schemaLocation="
+               http://www.springframework.org/schema/beans 
+                       
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+               http://www.springframework.org/schema/aop 
+                       
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+               http://www.springframework.org/schema/context 
+                       
http://www.springframework.org/schema/context/spring-context-3.0.xsd
+               http://www.springframework.org/schema/util 
+                       
http://www.springframework.org/schema/util/spring-util-3.0.xsd
+               http://www.springframework.org/schema/lang 
+                       
http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
+               http://www.springframework.org/schema/osgi 
+                       
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
+       default-lazy-init="false">
+       
+       <import resource="bundle-context-osgi.xml" />
+
+       <context:annotation-config />
+
+       <bean id="waitAction" class="org.cytoscape.internal.test.WaitAction">
+               <constructor-arg ref="cyApplicationManagerServiceRef" />
+               <constructor-arg ref="taskManagerServiceRef" />
+       </bean>
+
+       <bean id="waitValueAction" 
class="org.cytoscape.internal.test.WaitValueAction">
+               <constructor-arg ref="cyApplicationManagerServiceRef" />
+               <constructor-arg ref="taskManagerServiceRef" />
+       </bean>
+
+       <bean id="multiTunableAction" 
class="org.cytoscape.internal.test.MultiTunableAction">
+               <constructor-arg ref="cyApplicationManagerServiceRef" />
+               <constructor-arg ref="taskManagerServiceRef" />
+       </bean>
+
+    <bean id="tunablesTestTaskFactory"
+          class="org.cytoscape.internal.test.tunables.TunablesTestTaskFactory">
+    </bean>
+
+    <bean id="tunablesTestTaskFactory2"
+          
class="org.cytoscape.internal.test.tunables.TunablesTestTaskFactory2">
+    </bean>
+
+    <bean id="tunablesTestTaskFactory3"
+          
class="org.cytoscape.internal.test.tunables.TunablesTestTaskFactory3">
+    </bean>
+
+    <bean id="infiniteTaskFactory"
+          class="org.cytoscape.internal.test.InfiniteTaskFactory">
+    </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