use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
{
UndoSupportImpl undoSupport = new UndoSupportImpl();
Properties props = new Properties();
registerService(bc, undoSupport, UndoSupport.class, props);
registerService(bc, undoSupport, SwingUndoSupport.class, props);
}
JDialogTunableMutator jDialogTunableMutator = new JDialogTunableMutator();
JPanelTunableMutator jPanelTunableMutator = new JPanelTunableMutator();
final TaskStatusBar taskStatusBar = new TaskStatusBar(serviceRegistrar);
final TaskHistory taskHistory = new TaskHistory();
taskStatusBar.addPropertyChangeListener(TaskStatusBar.TASK_HISTORY_CLICK, new PropertyChangeListener() {
TaskHistoryWindow window = null;
// don't need to wrap this method in a SwingUtilities.invokeLater -- it will only be called on the EDT anyway
@Override
public void propertyChange(PropertyChangeEvent e) {
if (window == null)
window = new TaskHistoryWindow(taskHistory);
window.open();
}
});
{
Properties props = new Properties();
props.setProperty("type", "TaskStatus");
registerService(bc, taskStatusBar, StatusBarPanelFactory.class, props);
}
registerService(bc, new CyUserLogAppender(taskStatusBar, taskHistory), PaxAppender.class, ezProps("org.ops4j.pax.logging.appender.name", "CyUserLog"));
JDialogTaskManager jDialogTaskManager = new JDialogTaskManager(jDialogTunableMutator, taskStatusBar, taskHistory, serviceRegistrar);
PanelTaskManager jPanelTaskManager = new JPanelTaskManager(jPanelTunableMutator, jDialogTaskManager);
SupportedFileTypesManager supportedFileTypesManager = new SupportedFileTypesManager();
SimpleGUITunableHandlerFactory<BooleanHandler> booleanHandlerFactory = new SimpleGUITunableHandlerFactory<>(BooleanHandler.class, Boolean.class, boolean.class);
SimpleGUITunableHandlerFactory<IntegerHandler> integerHandlerFactory = new SimpleGUITunableHandlerFactory<>(IntegerHandler.class, Integer.class, int.class);
SimpleGUITunableHandlerFactory<FloatHandler> floatHandlerFactory = new SimpleGUITunableHandlerFactory<>(FloatHandler.class, Float.class, float.class);
SimpleGUITunableHandlerFactory<DoubleHandler> doubleHandlerFactory = new SimpleGUITunableHandlerFactory<>(DoubleHandler.class, Double.class, double.class);
SimpleGUITunableHandlerFactory<LongHandler> longHandlerFactory = new SimpleGUITunableHandlerFactory<>(LongHandler.class, Long.class, long.class);
SimpleGUITunableHandlerFactory<StringHandler> stringHandlerFactory = new SimpleGUITunableHandlerFactory<>(StringHandler.class, String.class);
SimpleGUITunableHandlerFactory<BoundedHandler> boundedIntegerHandlerFactory = new SimpleGUITunableHandlerFactory<>(BoundedHandler.class, BoundedInteger.class);
SimpleGUITunableHandlerFactory<BoundedHandler> boundedFloatHandlerFactory = new SimpleGUITunableHandlerFactory<>(BoundedHandler.class, BoundedFloat.class);
SimpleGUITunableHandlerFactory<BoundedHandler> boundedDoubleHandlerFactory = new SimpleGUITunableHandlerFactory<>(BoundedHandler.class, BoundedDouble.class);
SimpleGUITunableHandlerFactory<BoundedHandler> boundedLongHandlerFactory = new SimpleGUITunableHandlerFactory<>(BoundedHandler.class, BoundedLong.class);
SimpleGUITunableHandlerFactory<ListSingleHandler> listSingleSelectionHandlerFactory = new SimpleGUITunableHandlerFactory<>(ListSingleHandler.class, ListSingleSelection.class);
SimpleGUITunableHandlerFactory<ListMultipleHandler> listMultipleSelectionHandlerFactory = new SimpleGUITunableHandlerFactory<>(ListMultipleHandler.class, ListMultipleSelection.class);
SimpleGUITunableHandlerFactory<UserActionHandler> userActionHandlerFactory = new SimpleGUITunableHandlerFactory<>(UserActionHandler.class, UserAction.class);
URLHandlerFactory urlHandlerFactory = new URLHandlerFactory(serviceRegistrar);
registerService(bc, urlHandlerFactory, GUITunableHandlerFactory.class);
FileHandlerFactory fileHandlerFactory = new FileHandlerFactory(supportedFileTypesManager, serviceRegistrar);
registerService(bc, fileHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, jDialogTaskManager, DialogTaskManager.class);
registerService(bc, jDialogTaskManager, TaskManager.class);
registerService(bc, jPanelTaskManager, PanelTaskManager.class);
registerService(bc, integerHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, floatHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, doubleHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, longHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, booleanHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, stringHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, boundedIntegerHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, boundedFloatHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, boundedDoubleHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, boundedLongHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, listSingleSelectionHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, listMultipleSelectionHandlerFactory, GUITunableHandlerFactory.class);
registerService(bc, userActionHandlerFactory, GUITunableHandlerFactory.class);
registerServiceListener(bc, supportedFileTypesManager::addInputStreamTaskFactory, supportedFileTypesManager::removeInputStreamTaskFactory, InputStreamTaskFactory.class);
registerServiceListener(bc, supportedFileTypesManager::addCyWriterTaskFactory, supportedFileTypesManager::removeCyWriterTaskFactory, CyWriterFactory.class);
registerServiceListener(bc, jDialogTaskManager::addTunableRecorder, jDialogTaskManager::removeTunableRecorder, TunableRecorder.class);
registerServiceListener(bc, jPanelTunableMutator::addTunableHandlerFactory, jPanelTunableMutator::removeTunableHandlerFactory, GUITunableHandlerFactory.class);
registerServiceListener(bc, jDialogTunableMutator::addTunableHandlerFactory, jDialogTunableMutator::removeTunableHandlerFactory, GUITunableHandlerFactory.class);
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
DataSourceManagerImpl dataSourceManager = new DataSourceManagerImpl();
registerService(bc, dataSourceManager, DataSourceManager.class, new Properties());
registerServiceListener(bc, dataSourceManager::addDataSource, dataSourceManager::removeDataSource, DataSource.class);
BookmarkDataSourceBuilder bkBuilder = new BookmarkDataSourceBuilder(serviceRegistrar);
final Set<DataSource> bkDataSources = bkBuilder.getDataSources();
for (final DataSource ds : bkDataSources) registerService(bc, ds, DataSource.class, new Properties());
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
LockedVisualPropertiesManager lockedVisualPropertiesManager = new LockedVisualPropertiesManager(serviceRegistrar);
CyGroupManagerImpl cyGroupManager = new CyGroupManagerImpl(serviceRegistrar);
CyGroupFactoryImpl cyGroupFactory = new CyGroupFactoryImpl(cyGroupManager, lockedVisualPropertiesManager);
registerService(bc, cyGroupManager, CyGroupManager.class);
registerService(bc, cyGroupManager, AddedEdgesListener.class);
registerService(bc, cyGroupManager, AboutToRemoveEdgesListener.class);
registerService(bc, cyGroupFactory, CyGroupFactory.class);
// Create the aggregation manager
CyGroupAggregationManagerImpl cyAggMgr = new CyGroupAggregationManagerImpl(cyGroupManager);
registerService(bc, cyAggMgr, CyGroupAggregationManager.class, new Properties());
// Get our Settings object
CyGroupSettingsImpl cyGroupSettings = new CyGroupSettingsImpl(cyGroupManager, cyAggMgr, serviceRegistrar);
GroupIO groupIO = new GroupIO(cyGroupManager, lockedVisualPropertiesManager, cyGroupSettings);
registerAllServices(bc, groupIO);
// Register our settings menu
CyGroupSettingsTaskFactory settingsFactory = new CyGroupSettingsTaskFactory(cyGroupManager, cyAggMgr, cyGroupSettings);
Properties settingsProps = new Properties();
settingsProps.setProperty(ID, "settingsFactory");
settingsProps.setProperty(PREFERRED_MENU, "Edit.Preferences");
settingsProps.setProperty(TITLE, "Group Preferences...");
settingsProps.setProperty(MENU_GRAVITY, "4.0");
settingsProps.setProperty(TOOL_BAR_GRAVITY, "4");
settingsProps.setProperty(IN_TOOL_BAR, "false");
registerService(bc, settingsFactory, TaskFactory.class, settingsProps);
// Now register our node-specific settings menu
CyGroupNodeSettingsTaskFactory nodeSettingsFactory = new CyGroupNodeSettingsTaskFactory(cyGroupManager, cyAggMgr, cyGroupSettings);
settingsProps = new Properties();
settingsProps.setProperty(ID, "groupNodeSettingsFactory");
settingsProps.setProperty(PREFERRED_MENU, NODE_PREFERENCES_MENU);
settingsProps.setProperty(MENU_GRAVITY, "-1");
settingsProps.setProperty(TITLE, "Group Preferences...");
settingsProps.setProperty(PREFERRED_ACTION, "NEW");
settingsProps.setProperty(COMMAND, "group-node-settings");
settingsProps.setProperty(COMMAND_NAMESPACE, "network-view");
registerService(bc, nodeSettingsFactory, NodeViewTaskFactory.class, settingsProps);
// Make the settings available to consumers
registerService(bc, cyGroupSettings, GroupAddedListener.class, new Properties());
registerService(bc, cyGroupSettings, NetworkAddedListener.class, new Properties());
registerService(bc, cyGroupSettings, CyGroupSettingsManager.class, new Properties());
registerService(bc, cyGroupSettings, PropertyUpdatedListener.class, new Properties());
// Set up listener for node movement
NodeChangeListener nodeChangeListener = new NodeChangeListener(cyGroupManager, cyGroupSettings);
registerService(bc, nodeChangeListener, ViewChangedListener.class, new Properties());
settingsProps = new Properties();
settingsProps.setProperty(ID, "groupViewCollapseFactory");
settingsProps.setProperty(TITLE, "Collapse Group View");
settingsProps.setProperty(COMMAND, "groupViewCollapseFactory");
settingsProps.setProperty(COMMAND_NAMESPACE, "network-view");
settingsProps.setProperty(COMMAND_SUPPORTS_JSON, "true");
GroupViewCollapseHandler gvcHandler = new GroupViewCollapseHandler(cyGroupManager, cyGroupSettings, nodeChangeListener);
registerService(bc, gvcHandler, GroupAboutToCollapseListener.class, settingsProps);
registerService(bc, gvcHandler, GroupAboutToBeDestroyedListener.class, settingsProps);
registerService(bc, gvcHandler, GroupCollapsedListener.class, settingsProps);
registerService(bc, gvcHandler, SessionLoadedListener.class, settingsProps);
registerService(bc, gvcHandler, GroupAddedListener.class, settingsProps);
registerService(bc, gvcHandler, GroupViewTypeChangedListener.class, settingsProps);
GroupDataCollapseHandler gdcHandler = new GroupDataCollapseHandler(cyGroupManager, cyGroupSettings);
registerService(bc, gdcHandler, GroupAboutToCollapseListener.class, new Properties());
// Listen for double-click
GroupViewDoubleClickListener gvsListener = new GroupViewDoubleClickListener(cyGroupManager, cyGroupSettings);
Properties doubleClickProperties = new Properties();
doubleClickProperties.setProperty(PREFERRED_ACTION, "OPEN");
doubleClickProperties.setProperty(TITLE, "Expand/Collapse Group");
registerService(bc, gvsListener, NodeViewTaskFactory.class, doubleClickProperties);
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
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);
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);
Parser p = new Parser(args.getArgs(), cyShutdown, cyVersion, sc, props.getProperties());
sc.start();
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class VisualStyleTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
NetworkViewTestSupport nvts = new NetworkViewTestSupport();
network = nvts.getNetworkFactory().createNetwork();
node1 = network.addNode();
node2 = network.addNode();
node3 = network.addNode();
edge = network.addEdge(node1, node2, true);
CyTable nodeTable = network.getDefaultNodeTable();
nodeTable.createColumn(attrName, String.class, true);
nodeTable.getRow(node1.getSUID()).set(attrName, "red");
nodeTable.getRow(node2.getSUID()).set(attrName, "green");
nodeTable.getRow(node3.getSUID()).set(attrName, "foo");
networkView = nvts.getNetworkViewFactory().createNetworkView(network);
// Create root node.
final NullVisualProperty minimalRoot = new NullVisualProperty("MINIMAL_ROOT", "Minimal Root Visual Property");
final BasicVisualLexicon minimalLex = new BasicVisualLexicon(minimalRoot);
final Set<VisualLexicon> lexSet = new HashSet<VisualLexicon>();
lexSet.add(minimalLex);
final VisualMappingFunctionFactory ptFactory = mock(VisualMappingFunctionFactory.class);
eventHelper = mock(CyEventHelper.class);
final RenderingEngineFactory<CyNetwork> reFatory = mock(RenderingEngineFactory.class);
when(reFatory.getVisualLexicon()).thenReturn(minimalLex);
final NetworkViewRenderer nvRenderer = mock(NetworkViewRenderer.class);
when(nvRenderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT)).thenReturn(reFatory);
final CyApplicationManager appManager = mock(CyApplicationManager.class);
when(appManager.getCurrentNetworkViewRenderer()).thenReturn(nvRenderer);
final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(appManager);
VisualProperty<NullDataType> rootVisualProperty = mock(VisualProperty.class);
BasicVisualLexicon lexicon = new BasicVisualLexicon(rootVisualProperty);
vpSet = new HashSet<VisualProperty<Paint>>();
vpSet.add(BasicVisualLexicon.NODE_BORDER_PAINT);
vpSet.add(BasicVisualLexicon.NODE_FILL_COLOR);
dependency = new VisualPropertyDependency<Paint>("dep1", "Dep 1", vpSet, lexicon);
final VisualStyleFactoryImpl visualStyleFactory = new VisualStyleFactoryImpl(serviceRegistrar, ptFactory);
originalTitle = "Style 1";
newTitle = "Style 2";
style = visualStyleFactory.createVisualStyle(originalTitle);
style.setDefaultValue(NODE_SIZE, DEF_NODE_SIZE);
style.setDefaultValue(NODE_FILL_COLOR, DEF_NODE_COLOR);
reset(eventHelper);
}
Aggregations