use of org.cytoscape.command.internal.tunables.URLTunableHandler in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
CommandTunableInterceptorImpl interceptor = new CommandTunableInterceptorImpl();
StringTunableHandlerFactory<FileTunableHandler> fileTHF = new SimpleStringTunableHandlerFactory<>(FileTunableHandler.class, File.class);
StringTunableHandlerFactory<IntTunableHandler> intTHF = new SimpleStringTunableHandlerFactory<>(IntTunableHandler.class, Integer.class, int.class);
StringTunableHandlerFactory<DoubleTunableHandler> doubleTHF = new SimpleStringTunableHandlerFactory<>(DoubleTunableHandler.class, Double.class, double.class);
StringTunableHandlerFactory<FloatTunableHandler> floatTHF = new SimpleStringTunableHandlerFactory<>(FloatTunableHandler.class, Float.class, float.class);
StringTunableHandlerFactory<LongTunableHandler> longTHF = new SimpleStringTunableHandlerFactory<>(LongTunableHandler.class, Long.class, long.class);
StringTunableHandlerFactory<BooleanTunableHandler> booleanTHF = new SimpleStringTunableHandlerFactory<>(BooleanTunableHandler.class, Boolean.class, boolean.class);
StringTunableHandlerFactory<StringTunableHandlerImpl> stringTHF = new SimpleStringTunableHandlerFactory<>(StringTunableHandlerImpl.class, String.class);
StringTunableHandlerFactory<BoundedIntTunableHandler> boundedIntTHF = new SimpleStringTunableHandlerFactory<>(BoundedIntTunableHandler.class, BoundedInteger.class);
StringTunableHandlerFactory<BoundedDoubleTunableHandler> boundedDoubleTHF = new SimpleStringTunableHandlerFactory<>(BoundedDoubleTunableHandler.class, BoundedDouble.class);
StringTunableHandlerFactory<BoundedFloatTunableHandler> boundedFloatTHF = new SimpleStringTunableHandlerFactory<>(BoundedFloatTunableHandler.class, BoundedFloat.class);
StringTunableHandlerFactory<BoundedLongTunableHandler> boundedLongTHF = new SimpleStringTunableHandlerFactory<>(BoundedLongTunableHandler.class, BoundedLong.class);
StringTunableHandlerFactory<URLTunableHandler> urlTHF = new SimpleStringTunableHandlerFactory<>(URLTunableHandler.class, URL.class);
StringTunableHandlerFactory<ListSingleTunableHandler> listSingleTHF = new SimpleStringTunableHandlerFactory<>(ListSingleTunableHandler.class, ListSingleSelection.class);
StringTunableHandlerFactory<ListMultipleTunableHandler> listMultipleTHF = new SimpleStringTunableHandlerFactory<>(ListMultipleTunableHandler.class, ListMultipleSelection.class);
registerService(bc, fileTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, intTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, doubleTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, floatTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, longTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, booleanTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, stringTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, boundedIntTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, boundedDoubleTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, boundedFloatTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, boundedLongTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, urlTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, listSingleTHF, StringTunableHandlerFactory.class, new Properties());
registerService(bc, listMultipleTHF, StringTunableHandlerFactory.class, new Properties());
StringToModel stm = new StringToModelImpl(serviceRegistrar);
registerService(bc, stm, StringToModel.class, new Properties());
CyIdentifiableStringTunableHandlerFactory<CyNetworkTunableHandler> networkTHF = new CyIdentifiableStringTunableHandlerFactory<>(stm, CyNetworkTunableHandler.class, CyNetwork.class);
registerService(bc, networkTHF, StringTunableHandlerFactory.class, new Properties());
CyIdentifiableStringTunableHandlerFactory<CyNetworkViewTunableHandler> networkViewTHF = new CyIdentifiableStringTunableHandlerFactory<>(stm, CyNetworkViewTunableHandler.class, CyNetworkView.class);
registerService(bc, networkViewTHF, StringTunableHandlerFactory.class, new Properties());
CyIdentifiableStringTunableHandlerFactory<CyTableTunableHandler> tableTHF = new CyIdentifiableStringTunableHandlerFactory<>(stm, CyTableTunableHandler.class, CyTable.class);
registerService(bc, tableTHF, StringTunableHandlerFactory.class, new Properties());
CyIdentifiableStringTunableHandlerFactory<NodeListTunableHandler> nodeListTHF = new CyIdentifiableStringTunableHandlerFactory<>(stm, NodeListTunableHandler.class, NodeList.class);
registerService(bc, nodeListTHF, StringTunableHandlerFactory.class, new Properties());
CyIdentifiableStringTunableHandlerFactory<EdgeListTunableHandler> edgeListTHF = new CyIdentifiableStringTunableHandlerFactory<>(stm, EdgeListTunableHandler.class, EdgeList.class);
registerService(bc, edgeListTHF, StringTunableHandlerFactory.class, new Properties());
CyIdentifiableStringTunableHandlerFactory<RowListTunableHandler> rowListTHF = new CyIdentifiableStringTunableHandlerFactory<>(stm, RowListTunableHandler.class, RowList.class);
registerService(bc, rowListTHF, StringTunableHandlerFactory.class, new Properties());
BasicArgHandlerFactory argHandlerFactory = new BasicArgHandlerFactory();
registerService(bc, argHandlerFactory, ArgHandlerFactory.class, new Properties());
ArgRecorder argRec = new ArgRecorder();
registerServiceListener(bc, argRec::addTunableHandlerFactory, argRec::removeTunableHandlerFactory, ArgHandlerFactory.class);
AvailableCommandsImpl availableCommandsImpl = new AvailableCommandsImpl(argRec, serviceRegistrar);
registerService(bc, availableCommandsImpl, AvailableCommands.class, new Properties());
registerServiceListener(bc, availableCommandsImpl::addTaskFactory, availableCommandsImpl::removeTaskFactory, TaskFactory.class);
registerServiceListener(bc, availableCommandsImpl::addNetworkTaskFactory, availableCommandsImpl::removeNetworkTaskFactory, NetworkTaskFactory.class);
registerServiceListener(bc, availableCommandsImpl::addNetworkViewTaskFactory, availableCommandsImpl::removeNetworkViewTaskFactory, NetworkViewTaskFactory.class);
registerServiceListener(bc, availableCommandsImpl::addNetworkViewCollectionTaskFactory, availableCommandsImpl::removeNetworkViewCollectionTaskFactory, NetworkViewCollectionTaskFactory.class);
registerServiceListener(bc, availableCommandsImpl::addTableTaskFactory, availableCommandsImpl::removeTableTaskFactory, TableTaskFactory.class);
CommandExecutorImpl commandExecutor = new CommandExecutorImpl(interceptor, availableCommandsImpl, serviceRegistrar);
CommandExecutorTaskFactoryImpl commandExecutorTaskFactory = new CommandExecutorTaskFactoryImpl(commandExecutor, serviceRegistrar);
Properties commandExecutorTaskFactoryProps = new Properties();
commandExecutorTaskFactoryProps.setProperty(ID, "commandExecutorTaskFactory");
registerService(bc, commandExecutorTaskFactory, TaskFactory.class, commandExecutorTaskFactoryProps);
registerService(bc, commandExecutorTaskFactory, CommandExecutorTaskFactory.class, commandExecutorTaskFactoryProps);
registerServiceListener(bc, commandExecutor::addTaskFactory, commandExecutor::removeTaskFactory, TaskFactory.class);
registerServiceListener(bc, commandExecutor::addNetworkTaskFactory, commandExecutor::removeNetworkTaskFactory, NetworkTaskFactory.class);
registerServiceListener(bc, commandExecutor::addNetworkViewTaskFactory, commandExecutor::removeNetworkViewTaskFactory, NetworkViewTaskFactory.class);
registerServiceListener(bc, commandExecutor::addNetworkViewCollectionTaskFactory, commandExecutor::removeNetworkViewCollectionTaskFactory, NetworkViewCollectionTaskFactory.class);
registerServiceListener(bc, commandExecutor::addTableTaskFactory, commandExecutor::removeTableTaskFactory, TableTaskFactory.class);
registerServiceListener(bc, interceptor::addTunableHandlerFactory, interceptor::removeTunableHandlerFactory, StringTunableHandlerFactory.class);
{
Properties props = new Properties();
props.setProperty(COMMAND, "sleep");
props.setProperty(COMMAND_NAMESPACE, "command");
props.setProperty(COMMAND_DESCRIPTION, "Stop command processing for a specified time");
props.setProperty(COMMAND_LONG_DESCRIPTION, "The **sleep** command will pause processing for a period of time as specified by *duration* seconds.");
registerService(bc, new SleepCommandTaskFactory(), TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(COMMAND, "echo");
props.setProperty(COMMAND_NAMESPACE, "command");
props.setProperty(COMMAND_DESCRIPTION, "Returns the value of the 'message' argument.");
props.setProperty(COMMAND_LONG_DESCRIPTION, "Returns the value of the **message** argument.");
props.setProperty(COMMAND_SUPPORTS_JSON, "true");
props.setProperty(COMMAND_EXAMPLE_JSON, "");
registerService(bc, new EchoCommandTaskFactory(), TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(COMMAND, "quit");
props.setProperty(COMMAND_NAMESPACE, "command");
props.setProperty(COMMAND_DESCRIPTION, "Exit Cytoscape");
props.setProperty(COMMAND_LONG_DESCRIPTION, "This command causes Cytoscape to exit. It is typically used at the end of a script file");
registerService(bc, new QuitTaskFactory(serviceRegistrar), TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(PREFERRED_MENU, "Tools");
props.setProperty(TITLE, "Execute Command File...");
props.setProperty(COMMAND, "run");
props.setProperty(COMMAND_NAMESPACE, "command");
props.setProperty(COMMAND_DESCRIPTION, "Run a series of commands from a file");
props.setProperty(IN_MENU_BAR, "true");
props.setProperty(COMMAND_LONG_DESCRIPTION, "The **run** command will execute a command script from the " + "file pointed to by the ``file`` argument, which " + "should contain Cytoscape commands, one per line. " + "Arguments to the " + "script are provided by the *args* argument");
registerService(bc, new RunCommandsTaskFactory(commandExecutorTaskFactory), TaskFactory.class, props);
}
// Get any command line arguments. The "-S" and "-R" are ours
AppsFinishedStartingListener scriptRunner = new AppsFinishedStartingListener() {
public void handleEvent(AppsFinishedStartingEvent event) {
@SuppressWarnings("unchecked") CyProperty<Properties> commandLineProps = getService(bc, CyProperty.class, "(cyPropertyName=commandline.props)");
String scriptFile = commandLineProps.getProperties().getProperty("scriptFile");
if (scriptFile != null) {
TaskIterator tasks = commandExecutorTaskFactory.createTaskIterator(new File(scriptFile), null);
SynchronousTaskManager<?> taskManager = serviceRegistrar.getService(SynchronousTaskManager.class);
taskManager.execute(tasks);
}
}
};
registerService(bc, scriptRunner, AppsFinishedStartingListener.class, new Properties());
}
Aggregations