Author: rozagh
Date: 2012-03-26 18:12:23 -0700 (Mon, 26 Mar 2012)
New Revision: 28662
Added:
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.eclipse.jdt.core.prefs
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.maven.ide.eclipse.prefs
Modified:
core3/api/trunk/core-task-api/src/main/java/org/cytoscape/task/loadvizmap/LoadVisualStyles.java
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/CyActivator.java
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTaskFactoryImpl.java
core3/impl/trunk/gui-cmdline-parser-impl/pom.xml
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/CyActivator.java
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/Parser.java
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/StartupConfig.java
Log:
The command line functionality for starting up Cytoscape 3 with options to
loads session/network/table/visualstyle is added. A creatTaskFactory method
added to LoadVisualStyle API in core-task-api.
Modified:
core3/api/trunk/core-task-api/src/main/java/org/cytoscape/task/loadvizmap/LoadVisualStyles.java
===================================================================
---
core3/api/trunk/core-task-api/src/main/java/org/cytoscape/task/loadvizmap/LoadVisualStyles.java
2012-03-26 23:36:17 UTC (rev 28661)
+++
core3/api/trunk/core-task-api/src/main/java/org/cytoscape/task/loadvizmap/LoadVisualStyles.java
2012-03-27 01:12:23 UTC (rev 28662)
@@ -3,6 +3,7 @@
import org.cytoscape.view.vizmap.VisualStyle;
import org.cytoscape.work.TaskFactory;
+import org.cytoscape.work.TaskIterator;
import java.util.Set;
import java.io.File;
@@ -18,4 +19,6 @@
* @return a set of VisualStyle objects read from the specified file.
*/
Set<VisualStyle> loadStyles(File f);
+
+ TaskIterator createTaskIterator(File file);
}
Modified:
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/CyActivator.java
2012-03-26 23:36:17 UTC (rev 28661)
+++
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/CyActivator.java
2012-03-27 01:12:23 UTC (rev 28662)
@@ -211,7 +211,7 @@
CyGroupManager cyGroupManager = getService(bc,
CyGroupManager.class);
CyGroupFactory cyGroupFactory = getService(bc,
CyGroupFactory.class);
- LoadVizmapFileTaskFactoryImpl loadVizmapFileTaskFactory = new
LoadVizmapFileTaskFactoryImpl(vizmapReaderManagerServiceRef,visualMappingManagerServiceRef,synchronousTaskManagerServiceRef);
+ LoadVizmapFileTaskFactoryImpl loadVizmapFileTaskFactory = new
LoadVizmapFileTaskFactoryImpl(vizmapReaderManagerServiceRef,visualMappingManagerServiceRef,synchronousTaskManagerServiceRef,
tunableSetterServiceRef);
LoadNetworkFileTaskFactoryImpl loadNetworkFileTaskFactory = new
LoadNetworkFileTaskFactoryImpl(cyNetworkReaderManagerServiceRef,cyNetworkManagerServiceRef,cyNetworkViewManagerServiceRef,cyPropertyServiceRef,cyNetworkNamingServiceRef,
tunableSetterServiceRef);
LoadNetworkURLTaskFactoryImpl loadNetworkURLTaskFactory = new
LoadNetworkURLTaskFactoryImpl(cyNetworkReaderManagerServiceRef,cyNetworkManagerServiceRef,cyNetworkViewManagerServiceRef,cyPropertyServiceRef,cyNetworkNamingServiceRef,streamUtilRef,
synchronousTaskManagerServiceRef, tunableSetterServiceRef);
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
2012-03-26 23:36:17 UTC (rev 28661)
+++
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loadvizmap/LoadVizmapFileTaskFactoryImpl.java
2012-03-27 01:12:23 UTC (rev 28662)
@@ -12,6 +12,7 @@
import org.cytoscape.work.AbstractTaskFactory;
import org.cytoscape.work.SynchronousTaskManager;
import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TunableSetter;
public class LoadVizmapFileTaskFactoryImpl extends AbstractTaskFactory
implements LoadVisualStyles {
@@ -21,11 +22,15 @@
private final SynchronousTaskManager<?> syncTaskManager;
private LoadVizmapFileTask task;
+
+ private final TunableSetter tunableSetter;
+
- public LoadVizmapFileTaskFactoryImpl(VizmapReaderManager
vizmapReaderMgr, VisualMappingManager vmMgr, SynchronousTaskManager<?>
syncTaskManager) {
+ public LoadVizmapFileTaskFactoryImpl(VizmapReaderManager
vizmapReaderMgr, VisualMappingManager vmMgr, SynchronousTaskManager<?>
syncTaskManager, TunableSetter tunableSetter) {
this.vizmapReaderMgr = vizmapReaderMgr;
this.vmMgr = vmMgr;
this.syncTaskManager = syncTaskManager;
+ this.tunableSetter = tunableSetter;
}
@Override
@@ -45,4 +50,13 @@
return task.getStyles();
}
+
+ @Override
+ public TaskIterator createTaskIterator(File file) {
+
+ final Map<String, Object> m = new HashMap<String, Object>();
+ m.put("file", file);
+
+ return
tunableSetter.createTaskIterator(this.createTaskIterator(), m);
+ }
}
Added:
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.eclipse.jdt.core.prefs
2012-03-27 01:12:23 UTC (rev 28662)
@@ -0,0 +1,6 @@
+#Mon Mar 26 09:56:37 PDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
Added:
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.maven.ide.eclipse.prefs
===================================================================
---
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.maven.ide.eclipse.prefs
(rev 0)
+++
core3/impl/trunk/gui-cmdline-parser-impl/.settings/org.maven.ide.eclipse.prefs
2012-03-27 01:12:23 UTC (rev 28662)
@@ -0,0 +1,8 @@
+#Mon Mar 26 09:56:33 PDT 2012
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Modified: core3/impl/trunk/gui-cmdline-parser-impl/pom.xml
===================================================================
--- core3/impl/trunk/gui-cmdline-parser-impl/pom.xml 2012-03-26 23:36:17 UTC
(rev 28661)
+++ core3/impl/trunk/gui-cmdline-parser-impl/pom.xml 2012-03-27 01:12:23 UTC
(rev 28662)
@@ -111,6 +111,10 @@
<artifactId>cmdline</artifactId>
<version>${cytoscape.support.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>core-task-api</artifactId>
+ </dependency>
</dependencies>
</project>
Modified:
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/CyActivator.java
2012-03-26 23:36:17 UTC (rev 28661)
+++
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/CyActivator.java
2012-03-27 01:12:23 UTC (rev 28662)
@@ -6,6 +6,12 @@
import org.cytoscape.application.CyShutdown;
import org.cytoscape.io.util.StreamUtil;
import org.cytoscape.service.util.AbstractCyActivator;
+import org.cytoscape.task.loadnetwork.NetworkFileLoader;
+import org.cytoscape.task.loadnetwork.NetworkURLLoader;
+import org.cytoscape.task.loadvizmap.LoadVisualStyles;
+import org.cytoscape.task.session.LoadSession;
+import org.cytoscape.work.TaskManager;
+
import java.util.Properties;
import org.osgi.framework.BundleContext;
@@ -20,10 +26,15 @@
CyVersion cyVersion = getService(bc,CyVersion.class);
CyShutdown cyShutdown = getService(bc,CyShutdown.class);
StreamUtil streamUtil = getService(bc,StreamUtil.class);
+ LoadSession loadSession = getService(bc, LoadSession.class);
+ NetworkFileLoader networkFileLoader = getService(bc,
NetworkFileLoader.class);
+ NetworkURLLoader networkURLLoader = getService(bc,
NetworkURLLoader.class);
+ LoadVisualStyles visualStylesLoader = getService(bc,
LoadVisualStyles.class);
+ TaskManager <?,?> taskManager = getService(bc,
TaskManager.class);
CyProperty<Properties> props =
(CyProperty<Properties>)getService(bc, CyProperty.class,
"(cyPropertyName=cytoscape3.props)");
- StartupConfig sc = new
StartupConfig(props.getProperties(),streamUtil);
+ StartupConfig sc = new
StartupConfig(props.getProperties(),streamUtil, loadSession, networkFileLoader,
networkURLLoader, visualStylesLoader, taskManager);
Parser p = new Parser(args.getArgs(), cyShutdown, cyVersion,
sc,props.getProperties());
Modified:
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/Parser.java
===================================================================
---
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/Parser.java
2012-03-26 23:36:17 UTC (rev 28661)
+++
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/Parser.java
2012-03-27 01:12:23 UTC (rev 28662)
@@ -93,26 +93,14 @@
.withDescription( "Load a network file (any
format).")
.withValueSeparator('\0').withArgName("file").hasArgs()
.create("N"));
-
+
opt.addOption(OptionBuilder
- .withLongOpt("edge-table")
- .withDescription("Load an edge attributes table
file (any table format).")
+ .withLongOpt("table")
+ .withDescription("Load an attribute table file
(any table format).")
.withValueSeparator('\0').withArgName("file").hasArgs()
- .create("e"));
+ .create("T"));
opt.addOption(OptionBuilder
- .withLongOpt("node-table")
- .withDescription("Load a node attributes table
file (any table format).")
-
.withValueSeparator('\0').withArgName("file").hasArgs()
- .create("n"));
-
- opt.addOption(OptionBuilder
- .withLongOpt("global-table")
- .withDescription("Load a global attributes table
file (any table format).")
-
.withValueSeparator('\0').withArgName("file").hasArgs()
- .create("g"));
-
- opt.addOption(OptionBuilder
.withLongOpt("plugin")
.withDescription("Load a SIMPLIFIED plugin jar
file/URL.")
.withValueSeparator('\0').withArgName("file").hasArgs()
@@ -196,14 +184,8 @@
if (line.hasOption("V"))
startupConfig.setVizMapProps(line.getOptionValues("V"));
- if (line.hasOption("n"))
-
startupConfig.setNodeTables(line.getOptionValues("n"));
-
- if (line.hasOption("e"))
-
startupConfig.setEdgeTables(line.getOptionValues("e"));
-
- if (line.hasOption("g"))
-
startupConfig.setGlobalTables(line.getOptionValues("g"));
+ if (line.hasOption("T"))
+
startupConfig.setTables(line.getOptionValues("T"));
}
}
Modified:
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/StartupConfig.java
===================================================================
---
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/StartupConfig.java
2012-03-26 23:36:17 UTC (rev 28661)
+++
core3/impl/trunk/gui-cmdline-parser-impl/src/main/java/org/cytoscape/cmdline/gui/internal/StartupConfig.java
2012-03-27 01:12:23 UTC (rev 28662)
@@ -33,12 +33,26 @@
import org.cytoscape.application.CyShutdown;
import org.cytoscape.application.CyVersion;
import org.cytoscape.io.util.StreamUtil;
+import org.cytoscape.task.loaddatatable.AttributesFileLoader;
+import org.cytoscape.task.loaddatatable.AttributesURLLoader;
+import org.cytoscape.task.loadnetwork.NetworkFileLoader;
+import org.cytoscape.task.loadnetwork.NetworkURLLoader;
+import org.cytoscape.task.loadvizmap.LoadVisualStyles;
+import org.cytoscape.task.session.LoadSession;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TaskManager;
+import org.cytoscape.work.TaskMonitor;
import java.util.Properties;
import java.awt.Dimension;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Array;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -47,7 +61,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class StartupConfig {
private static final Logger logger =
LoggerFactory.getLogger(StartupConfig.class);
@@ -55,10 +68,36 @@
private final Properties localProps = new Properties();
private final StreamUtil streamUtil;
private boolean taskStart = false;
+ private LoadSession loadSession;
+ private NetworkFileLoader networkFileLoader;
+ private NetworkURLLoader networkURLLoader;
+ private LoadVisualStyles visualStylesLoader;
+ private AttributesURLLoader attributesURLLoader;
+ private AttributesFileLoader attributesFileLoader;
+ private final TaskManager taskManager;
+
+ private File sessionName;
+ private ArrayList<File> networkFiles;
+ private ArrayList<URL> networkURLs;
+ private ArrayList<File> vizmapFiles;
+ private ArrayList<File> tableFiles;
+ private ArrayList<URL> tableURLs;
- public StartupConfig(Properties globalProps, StreamUtil streamUtil) {
+ public StartupConfig(Properties globalProps, StreamUtil streamUtil,
+ LoadSession loadSession, NetworkFileLoader
networkFileLoader,
+ NetworkURLLoader networkURLLoader, LoadVisualStyles
visualStylesLoader, TaskManager taskManager) {
this.globalProps = globalProps;
this.streamUtil = streamUtil;
+ this.loadSession = loadSession;
+ this.networkFileLoader = networkFileLoader;
+ this.networkURLLoader = networkURLLoader;
+ this.visualStylesLoader = visualStylesLoader;
+ this.taskManager = taskManager;
+ networkFiles= new ArrayList<File>();
+ networkURLs = new ArrayList<URL>();
+ vizmapFiles = new ArrayList<File>();
+ tableFiles = new ArrayList<File>();
+ tableURLs = new ArrayList<URL>();
}
public void setProperties(String[] potentialProps) {
@@ -110,29 +149,68 @@
}
public void setSession(String args){
+ try{
+ sessionName = new File(args);
+ }catch(Exception e){
+ logger.error(e.toString());
+ }
taskStart = true;
}
public void setNetworks(String[] args){
+
+ networkFiles = new ArrayList<File>();
+ networkURLs = new ArrayList<URL>();
+
+ for (String name : args){
+ try{
+ if (StreamUtil.URL_PATTERN.matches(name))
+ networkURLs.add(new URL(name));
+ else
+ networkFiles.add(new File(name));
+ }catch (Exception e){
+ logger.error(e.toString());
+ }
+ }
+
taskStart = true;
}
public void setVizMapProps(String[] args){
+
+ vizmapFiles = new ArrayList<File>();
+
+ for (String name: args){
+ try{
+ vizmapFiles.add(new File(name));
+ }catch(Exception e){
+
+ }
+ }
+
taskStart = true;
}
- public void setNodeTables(String[] args){
- taskStart = true;
- }
- public void setEdgeTables(String[] args){
+ public void setTables(String[] args){
+
+ tableFiles = new ArrayList<File>();
+ tableURLs = new ArrayList<URL>();
+
+ for (String name : args){
+ try{
+ if (StreamUtil.URL_PATTERN.matches(name))
+ tableURLs.add(new URL(name));
+ else
+ tableFiles.add(new File(name));
+ }catch (Exception e){
+ logger.error(e.toString());
+ }
+ }
+
taskStart = true;
}
- public void setGlobalTables(String[] args){
- taskStart = true;
- }
-
public void start() {
// set the properties
// no need to do this in a task since it's so fast
@@ -148,28 +226,45 @@
// disable it here.
globalProps.setProperty("tempHideWelcomeScreen","true");
+ ArrayList<TaskIterator> taskIteratorList = new
ArrayList<TaskIterator>();
+
/*
-
taskIterator.append( pluginManager.loadSimplifiedPlugins() );
taskIterator.append( pluginManager.loadBundlePlugins() );
-
+ */
if ( sessionName != null ) {
- taskIterator.append( sessionTaskFactory.loadSession(
sessionName ) );
+ taskIteratorList.add(
loadSession.createTaskIterator(sessionName));
} else {
- for ( String network : networkNames )
- taskIterator.append( loadNetwork.loadNetwork(
network ) );
- for ( String nodeTable : nodeTables )
- taskIterator.append( loadTable.loadTable(
nodeTable, CyNode.class ) );
- for ( String edgeTable : edgeTables )
- taskIterator.append( loadTable.loadTable(
edgeTable, CyEdge.class ) );
- for ( String globalTable : globalTables )
- taskIterator.append( loadTable.loadTable(
globalTable, null ) );
- for ( String vizmap : vizmapProps )
- taskIterator.append( vizmapLoader.loadVizmap(
vizmap ) );
+ for ( File network : networkFiles )
+ taskIteratorList.add(
networkFileLoader.creatTaskIterator(network) );
+ for ( URL network : networkURLs )
+ taskIteratorList.add(
networkURLLoader.loadCyNetworks(network) );
+ for ( File table : tableFiles )
+ taskIteratorList.add(
attributesFileLoader.createTaskIterator(table) );
+ for ( URL table : tableURLs )
+ taskIteratorList.add(
attributesURLLoader.createTaskIterator(table) );
+ for ( File vizmap : vizmapFiles )
+ taskIteratorList.add(
visualStylesLoader.createTaskIterator(vizmap));
}
+ Task initTask = new DummyTaks();
+ TaskIterator taskIterator = new
TaskIterator(taskIteratorList.size(), initTask);
+ for (int i= taskIteratorList.size()-1; i>= 0 ; i--){
+ TaskIterator ti = taskIteratorList.get(i);
+ taskIterator.insertTasksAfter(initTask, ti);
+ }
+
taskManager.execute(taskIterator);
- */
+
}
+
+ private class DummyTaks extends AbstractTask{
+
+ @Override
+ public void run(TaskMonitor taskMonitor) throws Exception {
+ //DO nothing it is a dummy tas just to initiate the
iterator
+ }
+
+ }
}
--
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.