Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:cytoscape/cytoscape-impl into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
scootermorris committed Nov 1, 2018
2 parents 8c5f877 + ecd205b commit a1aabf3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 56 deletions.
Expand Up @@ -196,6 +196,10 @@ public void handleEvent(SessionAboutToBeLoadedEvent evt) {
@Override
public void handleEvent(SessionLoadedEvent evt) {
loadingSession = false;

if (mainPanel == null)
return;

mainPanel.clearAnnotationButtonSelection();

final Set<CyNetworkView> allViews = serviceRegistrar.getService(CyNetworkViewManager.class).getNetworkViewSet();
Expand Down
4 changes: 4 additions & 0 deletions gui-cmdline-parser-impl/pom.xml
Expand Up @@ -104,6 +104,10 @@
<groupId>org.cytoscape</groupId>
<artifactId>core-task-api</artifactId>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>app-api</artifactId>
</dependency>
</dependencies>


Expand Down
@@ -1,12 +1,28 @@
package org.cytoscape.cmdline.gui.internal;

import java.util.Properties;

import org.cytoscape.app.event.AppsFinishedStartingListener;
import org.cytoscape.application.CyShutdown;
import org.cytoscape.application.CyVersion;
import org.cytoscape.cmdline.CommandLineArgs;
import org.cytoscape.io.util.StreamUtil;
import org.cytoscape.property.CyProperty;
import org.cytoscape.service.util.AbstractCyActivator;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.task.read.LoadNetworkFileTaskFactory;
import org.cytoscape.task.read.LoadNetworkURLTaskFactory;
import org.cytoscape.task.read.LoadVizmapFileTaskFactory;
import org.cytoscape.task.read.OpenSessionTaskFactory;
import org.osgi.framework.BundleContext;

/*
* #%L
* Cytoscape GUI Command Line Parser Impl (gui-cmdline-parser-impl)
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2006 - 2013 The Cytoscape Consortium
* Copyright (C) 2006 - 2018 The Cytoscape Consortium
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand All @@ -24,45 +40,28 @@
* #L%
*/

import java.util.Properties;

import org.cytoscape.application.CyShutdown;
import org.cytoscape.application.CyVersion;
import org.cytoscape.cmdline.CommandLineArgs;
import org.cytoscape.io.util.StreamUtil;
import org.cytoscape.property.CyProperty;
import org.cytoscape.service.util.AbstractCyActivator;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.task.read.LoadNetworkFileTaskFactory;
import org.cytoscape.task.read.LoadNetworkURLTaskFactory;
import org.cytoscape.task.read.LoadVizmapFileTaskFactory;
import org.cytoscape.task.read.OpenSessionTaskFactory;
import org.cytoscape.work.TaskManager;
import org.osgi.framework.BundleContext;

public class CyActivator extends AbstractCyActivator {
public CyActivator() {
super();
}

@Override
@SuppressWarnings("unchecked")
public void start(BundleContext bc) {
CommandLineArgs args = getService(bc,CommandLineArgs.class);
CyVersion cyVersion = getService(bc,CyVersion.class);
CyShutdown cyShutdown = getService(bc,CyShutdown.class);
StreamUtil streamUtil = getService(bc,StreamUtil.class);
CommandLineArgs args = getService(bc, CommandLineArgs.class);
CyVersion cyVersion = getService(bc, CyVersion.class);
CyShutdown cyShutdown = getService(bc, CyShutdown.class);
StreamUtil streamUtil = getService(bc, StreamUtil.class);
OpenSessionTaskFactory loadSession = getService(bc, OpenSessionTaskFactory.class);
LoadNetworkFileTaskFactory networkFileLoader = getService(bc, LoadNetworkFileTaskFactory.class);
LoadNetworkURLTaskFactory networkURLLoader = getService(bc, LoadNetworkURLTaskFactory.class);
LoadVizmapFileTaskFactory visualStylesLoader = getService(bc, LoadVizmapFileTaskFactory.class);
TaskManager <?,?> taskManager = getService(bc, TaskManager.class);
CyServiceRegistrar registrar = getService(bc, CyServiceRegistrar.class);

CyProperty<Properties> props = (CyProperty<Properties>)getService(bc, CyProperty.class, "(cyPropertyName=cytoscape3.props)");

StartupConfig sc = new StartupConfig(props.getProperties(),streamUtil, loadSession, networkFileLoader, networkURLLoader, visualStylesLoader, taskManager, registrar);
CyProperty<Properties> props = (CyProperty<Properties>) getService(bc, CyProperty.class, "(cyPropertyName=cytoscape3.props)");

StartupConfig sc = new StartupConfig(props.getProperties(), streamUtil, loadSession, networkFileLoader,
networkURLLoader, visualStylesLoader, registrar);
registerService(bc, sc, AppsFinishedStartingListener.class);

Parser p = new Parser(args.getArgs(), cyShutdown, cyVersion, sc,props.getProperties());
Parser p = new Parser(args.getArgs(), cyShutdown, cyVersion, sc, props.getProperties());
sc.start();
}
}
Expand Up @@ -9,6 +9,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.cytoscape.app.event.AppsFinishedStartingEvent;
import org.cytoscape.app.event.AppsFinishedStartingListener;
import org.cytoscape.application.CyUserLog;
import org.cytoscape.io.util.StreamUtil;
import org.cytoscape.property.CyProperty;
Expand Down Expand Up @@ -50,7 +52,7 @@
* #L%
*/

public class StartupConfig {
public class StartupConfig implements AppsFinishedStartingListener {

private static final Logger logger = LoggerFactory.getLogger(CyUserLog.NAME);

Expand All @@ -62,14 +64,14 @@ public class StartupConfig {
private LoadNetworkFileTaskFactory networkFileLoader;
private LoadNetworkURLTaskFactory networkURLLoader;
private LoadVizmapFileTaskFactory visualStylesLoader;
private final TaskManager taskManager;

private final CyServiceRegistrar registrar;

private File sessionName;
private ArrayList<File> networkFiles;
private ArrayList<URL> networkURLs;
private ArrayList<File> vizmapFiles;
private ArrayList<TaskIterator> taskIteratorList;

public StartupConfig(
Properties globalProps,
Expand All @@ -78,7 +80,6 @@ public StartupConfig(
LoadNetworkFileTaskFactory networkFileLoader,
LoadNetworkURLTaskFactory networkURLLoader,
LoadVizmapFileTaskFactory visualStylesLoader,
TaskManager taskManager,
CyServiceRegistrar registrar
) {
this.globalProps = globalProps;
Expand All @@ -87,14 +88,32 @@ public StartupConfig(
this.networkFileLoader = networkFileLoader;
this.networkURLLoader = networkURLLoader;
this.visualStylesLoader = visualStylesLoader;
this.taskManager = taskManager;

this.registrar = registrar;
networkFiles= new ArrayList<>();
networkURLs = new ArrayList<>();
vizmapFiles = new ArrayList<>();
taskIteratorList = new ArrayList<>();
}

@Override
public void handleEvent(AppsFinishedStartingEvent evt) {
// We should only load sessions after Cytoscape and apps have been initialized!
if (!taskIteratorList.isEmpty()) {
Task initTask = new DummyTask();
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);
}

taskIteratorList.clear();

TaskManager <?,?> taskManager = registrar.getService(TaskManager.class);
taskManager.execute(taskIterator);
}
}

public void setProperties(String[] potentialProps) {
Properties argProps = new Properties();

Expand Down Expand Up @@ -205,32 +224,27 @@ public void setVizMapProps(String[] args){
taskStart = true;
}

public void start() {
protected void start() {
// set the properties
// no need to do this in a task since it's so fast
//globalProps.putAll(localProps);

CyProperty<Properties> commandline = new SimpleCyProperty<>("commandline", localProps,
Properties.class, CyProperty.SavePolicy.DO_NOT_SAVE);
Properties cmdlnProps = new Properties();
cmdlnProps.setProperty("cyPropertyName","commandline.props");
cmdlnProps.setProperty("cyPropertyName", "commandline.props");
registrar.registerService(commandline, CyProperty.class, cmdlnProps);

// Only proceed if we've specified tasks for execution
// on the command line.
if ( !taskStart )
// Only proceed if we've specified tasks for execution on the command line.
if (!taskStart)
return;

// Since we've set command line args we presumably
// don't want to see the welcome screen, so we
// disable it here.
globalProps.setProperty("tempHideWelcomeScreen","true");

ArrayList<TaskIterator> taskIteratorList = new ArrayList<>();
// don't want to see the welcome screen, so we disable it here.
globalProps.setProperty("tempHideWelcomeScreen", "true");

if (sessionName != null) {
taskIteratorList.add(loadSession.createTaskIterator(sessionName));

} else {
for (File network : networkFiles)
taskIteratorList.add(networkFileLoader.createTaskIterator(network));
Expand All @@ -239,16 +253,6 @@ public void start() {
for (File vizmap : vizmapFiles)
taskIteratorList.add(visualStylesLoader.createTaskIterator(vizmap));
}

Task initTask = new DummyTask();
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 DummyTask extends AbstractTask{
Expand All @@ -257,6 +261,5 @@ private class DummyTask extends AbstractTask{
public void run(TaskMonitor taskMonitor) throws Exception {
//DO nothing it is a dummy task just to initiate the iterator
}

}
}

0 comments on commit a1aabf3

Please sign in to comment.