Author: mes Date: 2011-01-21 13:27:11 -0800 (Fri, 21 Jan 2011) New Revision: 23551
Added: core3/task-testing-impl/trunk/ core3/task-testing-impl/trunk/osgi.bnd core3/task-testing-impl/trunk/pom.xml core3/task-testing-impl/trunk/src/ core3/task-testing-impl/trunk/src/main/ core3/task-testing-impl/trunk/src/main/java/ core3/task-testing-impl/trunk/src/main/java/org/ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitAction.java core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitValueAction.java core3/task-testing-impl/trunk/src/main/resources/ core3/task-testing-impl/trunk/src/main/resources/META-INF/ core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/ core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml Log: initial import Added: core3/task-testing-impl/trunk/osgi.bnd =================================================================== --- core3/task-testing-impl/trunk/osgi.bnd (rev 0) +++ core3/task-testing-impl/trunk/osgi.bnd 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,5 @@ +#----------------------------------------------------------------- +# Use this file to add customized Bnd instructions for the bundle +#----------------------------------------------------------------- + +Private-Package: org.cytoscape.internal, org.cytoscape.internal.* Added: core3/task-testing-impl/trunk/pom.xml =================================================================== --- core3/task-testing-impl/trunk/pom.xml (rev 0) +++ core3/task-testing-impl/trunk/pom.xml 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <parent> + <groupId>org.cytoscape</groupId> + <artifactId>parent</artifactId> + <version>3.0.0-alpha4-SNAPSHOT</version> + </parent> + + <properties> + <bundle.symbolicName>org.cytoscape.task-testing-impl</bundle.symbolicName> + <bundle.namespace>org.cytoscape.internal</bundle.namespace> + </properties> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.cytoscape</groupId> + <artifactId>task-testing-impl</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Tasks for Testing</name> + <packaging>bundle</packaging> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.ops4j</groupId> + <artifactId>maven-pax-plugin</artifactId> + <version>1.4</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>1.4.3</version> + <configuration> + <instructions> + <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName> + <Bundle-Version>${pom.version}</Bundle-Version> + <_include>-osgi.bnd</_include> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <repositories> + <!-- bootstrap for cytoscape dependencies, namely the parent POM snapshots --> + <repository> + <id>cytoscape_snapshots</id> + <snapshots> + <enabled>true</enabled> + </snapshots> + <releases> + <enabled>false</enabled> + </releases> + <name>Cytoscape Snapshots</name> + <url>http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/</url> + </repository> + <!-- bootstrap for cytoscape dependencies, namely the parent POM releases --> + <repository> + <id>cytoscape_releases</id> + <snapshots> + <enabled>false</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + <name>Cytoscape Releases</name> + <url>http://cytoscape.wodaklab.org/nexus/content/repositories/releases/</url> + </repository> + </repositories> + + + <dependencies> + <dependency> + <groupId>org.cytoscape</groupId> + <artifactId>swing-application-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.cytoscape</groupId> + <artifactId>work-api</artifactId> + <version>3.0.0-alpha2-SNAPSHOT</version> + </dependency> + </dependencies> +</project> Added: core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java =================================================================== --- core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java (rev 0) +++ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,98 @@ +/* + Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org) + + The Cytoscape Consortium is: + - Institute for Systems Biology + - University of California San Diego + - Memorial Sloan-Kettering Cancer Center + - Institut Pasteur + - Agilent Technologies + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and + documentation provided hereunder is on an "as is" basis, and the + Institute for Systems Biology and the Whitehead Institute + have no obligations to provide maintenance, support, + updates, enhancements or modifications. In no event shall the + Institute for Systems Biology and the Whitehead Institute + be liable to any party for direct, indirect, special, + incidental or consequential damages, including lost profits, arising + out of the use of this software and its documentation, even if the + Institute for Systems Biology and the Whitehead Institute + have been advised of the possibility of such damage. See + the GNU Lesser General Public License for more details. + + 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 org.cytoscape.internal.test; + +import java.awt.event.ActionEvent; +import javax.swing.JPanel; +import javax.swing.JLabel; + +import org.cytoscape.session.CyApplicationManager; +import org.cytoscape.application.swing.AbstractCyAction; +import org.cytoscape.work.*; + + +/** + * + */ +public class MultiTunableAction extends AbstractCyAction { + private final static long serialVersionUID = 1502339870257629L; + + private TaskManager tm; + public MultiTunableAction(CyApplicationManager appMgr, TaskManager tm) { + super("Multi Tunable Normal", appMgr ); + this.tm = tm; + setPreferredMenu("Help"); + } + + public void actionPerformed(ActionEvent e) { + TaskFactory tf = new DummyTaskFactory(); + tm.execute(tf); + } + + public class DummyTaskFactory implements TaskFactory { + public TaskIterator getTaskIterator() { + return new TaskIterator( new DummyTask(), new DummyTask2() ); + } + } + + public class DummyTask extends AbstractTask { + @Tunable(description="int value1") + public int value; + public void run(TaskMonitor taskMonitor) throws Exception { + Thread.sleep(1000); + System.out.println("dummy 1 got value: " + value); + Thread.sleep(1000); + } + } + + public class DummyTask2 extends AbstractTask { + + @ProvidesGUI + public JPanel getGUI() { + JPanel jpanel = new JPanel(); + jpanel.add( new JLabel("hello")); + return jpanel; + } + + public void run(TaskMonitor taskMonitor) throws Exception { + Thread.sleep(1000); + System.out.println("dummy 2 executed "); + Thread.sleep(1000); + } + } +} + + Added: core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitAction.java =================================================================== --- core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitAction.java (rev 0) +++ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitAction.java 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,93 @@ +/* + Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org) + + The Cytoscape Consortium is: + - Institute for Systems Biology + - University of California San Diego + - Memorial Sloan-Kettering Cancer Center + - Institut Pasteur + - Agilent Technologies + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and + documentation provided hereunder is on an "as is" basis, and the + Institute for Systems Biology and the Whitehead Institute + have no obligations to provide maintenance, support, + updates, enhancements or modifications. In no event shall the + Institute for Systems Biology and the Whitehead Institute + be liable to any party for direct, indirect, special, + incidental or consequential damages, including lost profits, arising + out of the use of this software and its documentation, even if the + Institute for Systems Biology and the Whitehead Institute + have been advised of the possibility of such damage. See + the GNU Lesser General Public License for more details. + + 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 org.cytoscape.internal.test; + +import java.awt.event.ActionEvent; + +import org.cytoscape.session.CyApplicationManager; +import org.cytoscape.application.swing.AbstractCyAction; +import org.cytoscape.work.*; + + +/** + * + */ +public class WaitAction extends AbstractCyAction { + private final static long serialVersionUID = 1502339870257629L; + + private TaskManager tm; + public WaitAction(CyApplicationManager appMgr, TaskManager tm) { + super("Wait Normal", appMgr ); + this.tm = tm; + setPreferredMenu("Help"); + } + + public void actionPerformed(ActionEvent e) { + TaskFactory tf = new DummyTaskFactory(); + tm.execute(tf); + System.out.println("finished waiting"); + } + + private class DummyTaskFactory implements TaskFactory { + public TaskIterator getTaskIterator() { + return new TaskIterator( new DummyTask() ); + } + } + + private class DummyTask implements Task { + boolean cancelled = false; + public void run(TaskMonitor taskMonitor) throws Exception { + taskMonitor.setProgress(0.0); + taskMonitor.setStatusMessage("Excuting DUMMY ..."); + int i = 0; + while(i++ < 10){ + System.out.println("still DUMMY working..."); + Thread.sleep(1000); + if ( cancelled ) { + System.out.println("cancelling Infinite DUMMY Task"); + return; + } + } + System.out.println("DUMMY finished..."); + } + public void cancel() { + System.out.println("task cancel called"); + cancelled = true; + } + } +} + + Added: core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitValueAction.java =================================================================== --- core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitValueAction.java (rev 0) +++ core3/task-testing-impl/trunk/src/main/java/org/cytoscape/internal/test/WaitValueAction.java 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,103 @@ +/* + Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org) + + The Cytoscape Consortium is: + - Institute for Systems Biology + - University of California San Diego + - Memorial Sloan-Kettering Cancer Center + - Institut Pasteur + - Agilent Technologies + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and + documentation provided hereunder is on an "as is" basis, and the + Institute for Systems Biology and the Whitehead Institute + have no obligations to provide maintenance, support, + updates, enhancements or modifications. In no event shall the + Institute for Systems Biology and the Whitehead Institute + be liable to any party for direct, indirect, special, + incidental or consequential damages, including lost profits, arising + out of the use of this software and its documentation, even if the + Institute for Systems Biology and the Whitehead Institute + have been advised of the possibility of such damage. See + the GNU Lesser General Public License for more details. + + 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 org.cytoscape.internal.test; + +import java.awt.event.ActionEvent; + +import org.cytoscape.session.CyApplicationManager; +import org.cytoscape.application.swing.AbstractCyAction; +import org.cytoscape.work.*; + + +/** + * + */ +public class WaitValueAction extends AbstractCyAction { + private final static long serialVersionUID = 1502339870257629L; + + private TaskManager tm; + public WaitValueAction(CyApplicationManager appMgr, TaskManager tm) { + super("Wait Value", appMgr ); + this.tm = tm; + setPreferredMenu("Help"); + } + + public void actionPerformed(ActionEvent e) { + Runnable asdf = new Runnable() { + public void run() { + DummyTaskFactory tf = new DummyTaskFactory(); + tm.execute(tf); + System.out.println("got value: " + tf.getValue()); + }}; + new Thread(asdf).start(); + } + + private class DummyTaskFactory implements TaskFactory { + ValuedTaskExecutor<Integer> vte; + public TaskIterator getTaskIterator() { + vte = new ValuedTaskExecutor<Integer>(new DummyTask()); + return new TaskIterator( vte ); + } + public int getValue() { + try { + return vte.get(); + } catch (Exception e) { return -2; } + } + } + + private class DummyTask implements ValuedTask<Integer> { + boolean cancelled = false; + public Integer run(TaskMonitor taskMonitor) throws Exception { + taskMonitor.setProgress(0.0); + taskMonitor.setStatusMessage("Excuting Valued DUMMY "); + int i = 0; + while(i++ < 10){ + System.out.println("still value dummy working..." + Thread.currentThread()); + Thread.sleep(1000); + if ( cancelled ) { + System.out.println("cancelling Infinite DUMMY Task"); + return Integer.valueOf(-1); + } + } + return Integer.valueOf(i); + } + public void cancel() { + cancelled = true; + } + } +} + + Added: core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml =================================================================== --- core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml (rev 0) +++ core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,24 @@ +<?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-2.5.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.session.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" /> +</beans> Added: core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml =================================================================== --- core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml (rev 0) +++ core3/task-testing-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml 2011-01-21 21:27:11 UTC (rev 23551) @@ -0,0 +1,41 @@ +<?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-2.5.xsd + http://www.springframework.org/schema/aop + http://www.springframework.org/schema/aop/spring-aop-2.5.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-2.5.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util-2.5.xsd + http://www.springframework.org/schema/lang + http://www.springframework.org/schema/lang/spring-lang-2.5.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="guiTaskManagerServiceRef" /> + </bean> + + <bean id="waitValueAction" class="org.cytoscape.internal.test.WaitValueAction"> + <constructor-arg ref="cyApplicationManagerServiceRef" /> + <constructor-arg ref="guiTaskManagerServiceRef" /> + </bean> + + <bean id="multiTunableAction" class="org.cytoscape.internal.test.MultiTunableAction"> + <constructor-arg ref="cyApplicationManagerServiceRef" /> + <constructor-arg ref="guiTaskManagerServiceRef" /> + </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.
