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);
final CySwingApplication cySwingApplicationServiceRef = getService(bc, CySwingApplication.class);
final CyApplicationManager cyApplicationManagerServiceRef = getService(bc, CyApplicationManager.class);
final CyNetworkViewManager cyNetworkViewManagerServiceRef = getService(bc, CyNetworkViewManager.class);
invokeOnEDTAndWait(() -> {
controlPanel = new ControlPanel(serviceRegistrar);
controlPanelAction = new ControlPanelAction(controlPanel, cySwingApplicationServiceRef, cyApplicationManagerServiceRef, cyNetworkViewManagerServiceRef);
}, logger);
registerAllServices(bc, controlPanelAction, new Properties());
registerAllServices(bc, controlPanel, new Properties());
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(final BundleContext bc) throws Exception {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
invokeOnEDTAndWait(() -> {
setLookAndFeel(bc);
}, logger);
// ////////////
ConfigDirPropertyWriter configDirPropertyWriter = new ConfigDirPropertyWriter(serviceRegistrar);
registerService(bc, configDirPropertyWriter, CyShutdownListener.class);
CyHelpBrokerImpl cyHelpBroker = new CyHelpBrokerImpl();
registerService(bc, cyHelpBroker, CyHelpBroker.class);
registerServiceListener(bc, configDirPropertyWriter::addCyProperty, configDirPropertyWriter::removeCyProperty, CyProperty.class);
SimpleGUITunableHandlerFactory<CyPropertyConfirmationHandler> cyPropConfirmHandlerFactory = new SimpleGUITunableHandlerFactory<>(CyPropertyConfirmationHandler.class, CyPropertyConfirmation.class);
registerService(bc, cyPropConfirmHandlerFactory, GUITunableHandlerFactory.class);
invokeOnEDTAndWait(() -> {
initComponents(bc, serviceRegistrar);
});
registerService(bc, undoAction, CyAction.class);
registerService(bc, redoAction, CyAction.class);
registerService(bc, printAction, CyAction.class);
registerService(bc, preferenceAction, CyAction.class);
// registerService(bc, cy3preferenceAction, CyAction.class);
registerService(bc, bookmarkAction, CyAction.class);
registerService(bc, settingsAction, CyAction.class);
registerService(bc, settingsAction, SetCurrentNetworkViewListener.class);
registerService(bc, cytoPanelWestAction, CyAction.class);
registerService(bc, cytoPanelSouthAction, CyAction.class);
registerService(bc, cytoPanelEastAction, CyAction.class);
registerService(bc, cytoPanelSouthWestAction, CyAction.class);
registerService(bc, cytoPanelCommandAction, CyAction.class);
registerService(bc, starterPanelAction, CyAction.class);
registerService(bc, detachedViewToolBarAction, CyAction.class);
registerService(bc, closeWindowAction, CyAction.class);
registerService(bc, cyDesktopManager, CyNetworkViewDesktopMgr.class);
registerService(bc, bookmarkDialogFactory, SessionLoadedListener.class);
{
Properties props = new Properties();
props.setProperty(PREFERRED_MENU, "Help");
props.setProperty(TITLE, "User Manual");
props.setProperty(MENU_GRAVITY, "1.0");
props.setProperty(TOOLTIP, "Show User Manual");
registerService(bc, helpUserManualTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(PREFERRED_MENU, "Help");
props.setProperty(MENU_GRAVITY, "7.0");
props.setProperty(TITLE, "Contact Help Desk...");
registerService(bc, helpContactHelpDeskTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(PREFERRED_MENU, "Help");
props.setProperty(TITLE, "Report a Bug...");
props.setProperty(MENU_GRAVITY, "8.0");
registerService(bc, helpReportABugTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(ServiceProperties.ENABLE_FOR, ENABLE_FOR_NETWORK_AND_VIEW);
props.setProperty(ACCELERATOR, "cmd g");
props.setProperty(PREFERRED_MENU, "View.Arrange Network Windows[8]");
props.setProperty(TITLE, "Grid");
props.setProperty(MENU_GRAVITY, "1.0");
registerService(bc, arrangeGridTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(ServiceProperties.ENABLE_FOR, ENABLE_FOR_NETWORK_AND_VIEW);
props.setProperty(PREFERRED_MENU, "View.Arrange Network Windows[8]");
props.setProperty(TITLE, "Cascade");
props.setProperty(MENU_GRAVITY, "2.0");
registerService(bc, arrangeCascadeTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(ServiceProperties.ENABLE_FOR, ENABLE_FOR_NETWORK_AND_VIEW);
props.setProperty(PREFERRED_MENU, "View.Arrange Network Windows[8]");
props.setProperty(TITLE, "Vertical Stack");
props.setProperty(MENU_GRAVITY, "3.0");
registerService(bc, arrangeHorizontalTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(ServiceProperties.ENABLE_FOR, ENABLE_FOR_NETWORK_AND_VIEW);
props.setProperty(PREFERRED_MENU, "View.Arrange Network Windows[8]");
props.setProperty(TITLE, "Side by Side");
props.setProperty(MENU_GRAVITY, "4.0");
registerService(bc, arrangeVerticalTaskFactory, TaskFactory.class, props);
}
{
Properties props = new Properties();
props.setProperty(IN_NETWORK_PANEL_CONTEXT_MENU, "true");
registerAllServices(bc, createNetworkViewsAction, props);
}
{
Properties props = new Properties();
props.setProperty(IN_NETWORK_PANEL_CONTEXT_MENU, "true");
registerAllServices(bc, destroyNetworkViewsAction, props);
}
{
Properties props = new Properties();
props.setProperty(IN_NETWORK_PANEL_CONTEXT_MENU, "true");
registerAllServices(bc, destroyNetworksAction, props);
}
{
Properties props = new Properties();
props.setProperty(IN_NETWORK_PANEL_CONTEXT_MENU, "true");
registerAllServices(bc, exportNetworkAction, props);
}
{
Properties props = new Properties();
props.setProperty(IN_NETWORK_PANEL_CONTEXT_MENU, "true");
registerAllServices(bc, exportImageAction, props);
}
{
TaskFactory pauseCommand = new PauseCommandTaskFactory(cytoscapeDesktop);
Properties props = new Properties();
props.setProperty(COMMAND_NAMESPACE, "command");
props.setProperty(COMMAND_DESCRIPTION, "Display a message and pause until the user continues.");
props.setProperty(COMMAND, "pause");
props.setProperty(COMMAND_LONG_DESCRIPTION, "The **pause** command displays a dialog with the text provided in the *message* argument " + "and waits for the user to click **OK**");
props.setProperty(COMMAND_SUPPORTS_JSON, "true");
props.setProperty(COMMAND_EXAMPLE_JSON, "{}");
registerService(bc, pauseCommand, TaskFactory.class, props);
}
registerAllServices(bc, cytoscapeDesktop);
registerAllServices(bc, netMainPanel);
registerAllServices(bc, commandToolPanel);
registerAllServices(bc, netMediator);
registerAllServices(bc, netViewMediator);
registerService(bc, undoMonitor, SetCurrentNetworkViewListener.class);
registerService(bc, undoMonitor, NetworkDestroyedListener.class);
registerService(bc, undoMonitor, NetworkViewDestroyedListener.class);
registerAllServices(bc, rowViewTracker);
registerAllServices(bc, selecteEdgeViewUpdater);
registerAllServices(bc, selecteNodeViewUpdater);
registerAllServices(bc, rowsSetViewUpdater);
registerAllServices(bc, sessionHandler);
registerAllServices(bc, toolBarEnableUpdater);
registerAllServices(bc, recentSessionManager);
registerAllServices(bc, netSelectionMediator);
registerAllServices(bc, netSearchMediator);
registerServiceListener(bc, cytoscapeDesktop::addAction, cytoscapeDesktop::removeAction, CyAction.class);
registerServiceListener(bc, preferenceAction::addCyProperty, preferenceAction::removeCyProperty, CyProperty.class);
// registerServiceListener(bc, cy3preferenceAction::addCyProperty, cy3preferenceAction::removeCyProperty, CyProperty.class);
registerServiceListener(bc, cytoscapeDesktop::addCytoPanelComponent, cytoscapeDesktop::removeCytoPanelComponent, CytoPanelComponent.class);
registerServiceListener(bc, cytoscapeDesktop::addToolBarComponent, cytoscapeDesktop::removeToolBarComponent, ToolBarComponent.class);
registerServiceListener(bc, cytoscapeMenuPopulator::addTaskFactory, cytoscapeMenuPopulator::removeTaskFactory, TaskFactory.class);
registerServiceListener(bc, cytoscapeMenuPopulator::addNetworkTaskFactory, cytoscapeMenuPopulator::removeNetworkTaskFactory, NetworkTaskFactory.class);
registerServiceListener(bc, cytoscapeMenuPopulator::addNetworkViewTaskFactory, cytoscapeMenuPopulator::removeNetworkViewTaskFactory, NetworkViewTaskFactory.class);
registerServiceListener(bc, cytoscapeMenuPopulator::addNetworkCollectionTaskFactory, cytoscapeMenuPopulator::removeNetworkCollectionTaskFactory, NetworkCollectionTaskFactory.class);
registerServiceListener(bc, cytoscapeMenuPopulator::addNetworkViewCollectionTaskFactory, cytoscapeMenuPopulator::removeNetworkViewCollectionTaskFactory, NetworkViewCollectionTaskFactory.class);
registerServiceListener(bc, cytoscapeMenuPopulator::addTableTaskFactory, cytoscapeMenuPopulator::removeTableTaskFactory, TableTaskFactory.class);
registerServiceListener(bc, layoutSettingsManager::addLayout, layoutSettingsManager::removeLayout, CyLayoutAlgorithm.class);
registerServiceListener(bc, settingsAction::addLayout, settingsAction::removeLayout, CyLayoutAlgorithm.class);
// For Network Panel context menu
registerServiceListener(bc, netMediator::addNetworkViewTaskFactory, netMediator::removeNetworkViewTaskFactory, NetworkViewTaskFactory.class, CONTEXT_MENU_FILTER);
registerServiceListener(bc, netMediator::addNetworkTaskFactory, netMediator::removeNetworkTaskFactory, NetworkTaskFactory.class, CONTEXT_MENU_FILTER);
registerServiceListener(bc, netMediator::addNetworkViewCollectionTaskFactory, netMediator::removeNetworkViewCollectionTaskFactory, NetworkViewCollectionTaskFactory.class, CONTEXT_MENU_FILTER);
registerServiceListener(bc, netMediator::addNetworkCollectionTaskFactory, netMediator::removeNetworkCollectionTaskFactory, NetworkCollectionTaskFactory.class, CONTEXT_MENU_FILTER);
registerServiceListener(bc, netMediator::addCyAction, netMediator::removeCyAction, CyAction.class, CONTEXT_MENU_FILTER);
registerServiceListener(bc, netSearchMediator::addNetworkSearchTaskFactory, netSearchMediator::removeNetworkSearchTaskFactory, NetworkSearchTaskFactory.class);
registerServiceListener(bc, layoutMenuPopulator::addLayout, layoutMenuPopulator::removeLayout, CyLayoutAlgorithm.class);
if (LookAndFeelUtil.isMac()) {
try {
new MacCyActivator().start(bc);
} catch (Exception e) {
logger.error("Cannot start MacCyActivator", e);
}
} else {
Properties props = new Properties();
props.setProperty(PREFERRED_MENU, "Help");
props.setProperty(TITLE, "About");
props.setProperty(MENU_GRAVITY, "10.0");
registerService(bc, helpAboutTaskFactory, TaskFactory.class, props);
registerService(bc, exitAction, CyAction.class);
}
// Full screen actions. This is platform dependent
FullScreenAction fullScreenAction = null;
if (LookAndFeelUtil.isMac() && MacFullScreenEnabler.supportsNativeFullScreenMode())
fullScreenAction = new FullScreenMacAction(cytoscapeDesktop);
else
fullScreenAction = new FullScreenAction(cytoscapeDesktop);
registerService(bc, fullScreenAction, CyAction.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) {
CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
PopupMenuHelper popupMenuHelper = new PopupMenuHelper(serviceRegistrar);
AbstractTableBrowser nodeTableBrowser = new DefaultTableBrowser("Node Table", CyNode.class, serviceRegistrar, popupMenuHelper);
AbstractTableBrowser edgeTableBrowser = new DefaultTableBrowser("Edge Table", CyEdge.class, serviceRegistrar, popupMenuHelper);
AbstractTableBrowser networkTableBrowser = new DefaultTableBrowser("Network Table", CyNetwork.class, serviceRegistrar, popupMenuHelper);
AbstractTableBrowser globalTableBrowser = new GlobalTableBrowser("Unassigned Tables", serviceRegistrar, popupMenuHelper);
registerAllServices(bc, nodeTableBrowser, new Properties());
registerAllServices(bc, edgeTableBrowser, new Properties());
registerAllServices(bc, networkTableBrowser, new Properties());
final Properties globalTableProp = new Properties();
registerService(bc, globalTableBrowser, ActionListener.class, globalTableProp);
registerService(bc, globalTableBrowser, SessionLoadedListener.class, globalTableProp);
registerService(bc, globalTableBrowser, SessionAboutToBeSavedListener.class, globalTableProp);
registerService(bc, globalTableBrowser, TableAboutToBeDeletedListener.class, globalTableProp);
registerService(bc, globalTableBrowser, TableAddedListener.class, globalTableProp);
registerService(bc, globalTableBrowser, TablePrivacyChangedListener.class, globalTableProp);
registerService(bc, globalTableBrowser, RowsSetListener.class, globalTableProp);
registerService(bc, globalTableBrowser, RowsDeletedListener.class, globalTableProp);
registerServiceListener(bc, popupMenuHelper::addTableColumnTaskFactory, popupMenuHelper::removeTableColumnTaskFactory, TableColumnTaskFactory.class);
registerServiceListener(bc, popupMenuHelper::addTableCellTaskFactory, popupMenuHelper::removeTableCellTaskFactory, TableCellTaskFactory.class);
{
ClearAllErrorsTaskFactory taskFactory = new ClearAllErrorsTaskFactory(serviceRegistrar);
Properties props = new Properties();
props.setProperty(TITLE, "Clear all errors");
registerService(bc, taskFactory, TableColumnTaskFactory.class, props);
}
{
SetColumnFormatTaskFactory taskFactory = new SetColumnFormatTaskFactory(serviceRegistrar);
Properties props = new Properties();
props.setProperty(TITLE, "Format column...");
registerService(bc, taskFactory, TableColumnTaskFactory.class, props);
}
}
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);
Bundle rootBundle = bc.getBundle(0);
ShutdownHandler cytoscapeShutdown = new ShutdownHandler(rootBundle, serviceRegistrar);
CyVersionImpl cytoscapeVersion = new CyVersionImpl(serviceRegistrar);
CyApplicationConfigurationImpl cyApplicationConfiguration = new CyApplicationConfigurationImpl(cytoscapeVersion.getVersion());
CyApplicationManagerImpl cyApplicationManager = new CyApplicationManagerImpl(serviceRegistrar);
registerAllServices(bc, cyApplicationManager, new Properties());
registerAllServices(bc, cytoscapeShutdown, new Properties());
registerAllServices(bc, cytoscapeVersion, new Properties());
registerAllServices(bc, cyApplicationConfiguration, new Properties());
registerServiceListener(bc, cyApplicationManager::addNetworkViewRenderer, cyApplicationManager::removeNetworkViewRenderer, NetworkViewRenderer.class);
DefaultNetworkViewFactory viewFactory = new DefaultNetworkViewFactory(cyApplicationManager);
Properties viewFactoryProperties = new Properties();
viewFactoryProperties.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
registerService(bc, viewFactory, CyNetworkViewFactory.class, viewFactoryProperties);
// For telemetry
final CyProperty<Properties> cyPropertyServiceRef = getService(bc, CyProperty.class, "(cyPropertyName=cytoscape3.props)");
checkIsntallOptions(cyApplicationConfiguration, cyPropertyServiceRef);
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class NewNetworkSelectedNodesOnlyTaskFactoryTest method testObserver.
@Test
public void testObserver() throws Exception {
NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetworkFactory networkFactory = networkSupport.getNetworkFactory();
UndoSupport undoSupport = mock(UndoSupport.class);
CyRootNetworkManager crnf = new CyRootNetworkManagerImpl();
CyNetworkViewFactory cnvf = viewSupport.getNetworkViewFactory();
CyNetworkManager netmgr = mock(CyNetworkManager.class);
CyNetworkViewManager networkViewManager = mock(CyNetworkViewManager.class);
CyNetworkNaming naming = mock(CyNetworkNaming.class);
VisualMappingManager vmm = mock(VisualMappingManager.class);
CyApplicationManager appManager = mock(CyApplicationManager.class);
CyEventHelper eventHelper = mock(CyEventHelper.class);
CyGroupManager groupMgr = mock(CyGroupManager.class);
RenderingEngineManager renderingEngineMgr = mock(RenderingEngineManager.class);
CyLayoutAlgorithm defLayout = mock(CyLayoutAlgorithm.class);
CyLayoutAlgorithmManager layoutMgr = mock(CyLayoutAlgorithmManager.class);
when(layoutMgr.getDefaultLayout()).thenReturn(defLayout);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyLayoutAlgorithmManager.class)).thenReturn(layoutMgr);
NewNetworkSelectedNodesOnlyTaskFactoryImpl factory = new NewNetworkSelectedNodesOnlyTaskFactoryImpl(undoSupport, crnf, cnvf, netmgr, networkViewManager, naming, vmm, appManager, eventHelper, groupMgr, renderingEngineMgr, serviceRegistrar);
CyNetwork network = networkFactory.createNetwork();
CyNode node = network.addNode();
network.getRow(node).set(CyNetwork.SELECTED, true);
TaskObserver observer = mock(TaskObserver.class);
TaskMonitor taskMonitor = mock(TaskMonitor.class);
TaskIterator iterator = factory.createTaskIterator(network);
while (iterator.hasNext()) {
Task t = iterator.next();
t.run(taskMonitor);
if (t instanceof ObservableTask)
observer.taskFinished((ObservableTask) t);
}
verify(observer, times(1)).taskFinished(any(ObservableTask.class));
}
Aggregations