Search in sources :

Example 21 with CyServiceRegistrar

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);
    // Mapping Factories:
    final DiscreteMappingFactory dmFactory = new DiscreteMappingFactory(serviceRegistrar);
    {
        final Properties props = new Properties();
        props.setProperty("service.type", "factory");
        props.setProperty("mapping.type", "discrete");
        registerService(bc, dmFactory, VisualMappingFunctionFactory.class, props);
    }
    final ContinuousMappingFactory cmFactory = new ContinuousMappingFactory(serviceRegistrar);
    {
        final Properties props = new Properties();
        props.setProperty("service.type", "factory");
        props.setProperty("mapping.type", "continuous");
        registerService(bc, cmFactory, VisualMappingFunctionFactory.class, props);
    }
    final PassthroughMappingFactory pmFactory = new PassthroughMappingFactory(serviceRegistrar);
    {
        final Properties props = new Properties();
        props.setProperty("service.type", "factory");
        props.setProperty("mapping.type", "passthrough");
        registerService(bc, pmFactory, VisualMappingFunctionFactory.class, props);
        registerServiceListener(bc, pmFactory::addValueTranslator, pmFactory::removeValueTranslator, ValueTranslator.class);
    }
    final VisualStyleFactoryImpl visualStyleFactory = new VisualStyleFactoryImpl(serviceRegistrar, pmFactory);
    registerService(bc, visualStyleFactory, VisualStyleFactory.class);
    final VisualMappingManagerImpl visualMappingManager = new VisualMappingManagerImpl(visualStyleFactory, serviceRegistrar);
    registerAllServices(bc, visualMappingManager);
}
Also used : ContinuousMappingFactory(org.cytoscape.view.vizmap.internal.mappings.ContinuousMappingFactory) VisualMappingFunctionFactory(org.cytoscape.view.vizmap.VisualMappingFunctionFactory) PassthroughMappingFactory(org.cytoscape.view.vizmap.internal.mappings.PassthroughMappingFactory) DiscreteMappingFactory(org.cytoscape.view.vizmap.internal.mappings.DiscreteMappingFactory) ValueTranslator(org.cytoscape.view.vizmap.mappings.ValueTranslator) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Example 22 with CyServiceRegistrar

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);
    // UI for Network Import Clients
    WebServiceImportDialog<NetworkImportWebServiceClient> unifiedNetworkImportDialog = new WebServiceImportDialog<NetworkImportWebServiceClient>(NetworkImportWebServiceClient.class, "Import Network from Public Databases", serviceRegistrar);
    // UI for Table Import Clients
    WebServiceImportDialog<TableImportWebServiceClient> unifiedTableImportDialog = new WebServiceImportDialog<TableImportWebServiceClient>(TableImportWebServiceClient.class, "Import Table from Public Databases", serviceRegistrar);
    WebServiceGUIImpl webServiceGui = new WebServiceGUIImpl();
    webServiceGui.addClient(NetworkImportWebServiceClient.class, unifiedNetworkImportDialog);
    webServiceGui.addClient(TableImportWebServiceClient.class, unifiedTableImportDialog);
    // ALT (for Mac, it's Option)
    final KeyStroke networkImportShortcut = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.ALT_DOWN_MASK);
    final KeyStroke tableImportShortcut = KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_DOWN_MASK);
    ShowImportDialogAction showImportNetworkFromWebServiceDialogAction = new ShowImportDialogAction(unifiedNetworkImportDialog, "File.Import.Network", 3.0f, "Public Databases...", networkImportShortcut, "Import Network from Database...", serviceRegistrar);
    ShowImportDialogAction showImportTableFromWebServiceDialogAction = new ShowImportDialogAction(unifiedTableImportDialog, "File.Import.Table", 3.0f, "Public Databases...", tableImportShortcut, serviceRegistrar);
    {
        Properties props = new Properties();
        props.setProperty("id", "showImportNetworkFromWebServiceDialogAction");
        registerService(bc, showImportNetworkFromWebServiceDialogAction, CyAction.class, props);
    }
    registerService(bc, showImportTableFromWebServiceDialogAction, CyAction.class, new Properties());
    registerService(bc, webServiceGui, WebServiceGUI.class, new Properties());
    registerServiceListener(bc, unifiedNetworkImportDialog::addClient, unifiedNetworkImportDialog::removeClient, WebServiceClient.class);
    registerServiceListener(bc, unifiedTableImportDialog::addClient, unifiedTableImportDialog::removeClient, WebServiceClient.class);
}
Also used : WebServiceImportDialog(org.cytoscape.webservice.internal.ui.WebServiceImportDialog) ShowImportDialogAction(org.cytoscape.webservice.internal.task.ShowImportDialogAction) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) NetworkImportWebServiceClient(org.cytoscape.io.webservice.NetworkImportWebServiceClient) TableImportWebServiceClient(org.cytoscape.io.webservice.TableImportWebServiceClient) KeyStroke(javax.swing.KeyStroke) CyAction(org.cytoscape.application.swing.CyAction) WebServiceGUIImpl(org.cytoscape.webservice.internal.ui.WebServiceGUIImpl)

Example 23 with CyServiceRegistrar

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);
    {
        // NetworkView (empty space) context menus
        SIFInterpreterTaskFactory factory = new SIFInterpreterTaskFactory(serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(ENABLE_FOR, "networkAndView");
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NETWORK_ADD_MENU);
        props.setProperty(MENU_GRAVITY, "1.0");
        props.setProperty(IN_MENU_BAR, "false");
        props.setProperty(TITLE, "Edge (and possibly Nodes) using SIF...");
        registerService(bc, factory, NetworkViewTaskFactory.class, props);
    }
    {
        NetworkViewLocationTaskFactory factory = new AddNodeTaskFactory(serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NETWORK_ADD_MENU);
        props.setProperty(MENU_GRAVITY, "1.1");
        props.setProperty(TITLE, "Node");
        registerService(bc, factory, NetworkViewLocationTaskFactory.class, props);
    }
    // We need a place to hold the objects themselves
    ClipboardManagerImpl clipboardManager = new ClipboardManagerImpl(serviceRegistrar);
    {
        // Copy node
        NetworkViewTaskFactory factory = new CopyTaskFactory(clipboardManager);
        Properties props = new Properties();
        props.setProperty(ENABLE_FOR, "networkAndView");
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NETWORK_EDIT_MENU);
        props.setProperty(ACCELERATOR, "cmd c");
        props.setProperty(TITLE, "Copy");
        props.setProperty(MENU_GRAVITY, "0.0f");
        registerService(bc, factory, NetworkViewTaskFactory.class, props);
    }
    {
        // Cut node
        NetworkViewTaskFactory factory = new CutTaskFactory(clipboardManager, serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(ENABLE_FOR, "networkAndView");
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NETWORK_EDIT_MENU);
        props.setProperty(ACCELERATOR, "cmd x");
        props.setProperty(MENU_GRAVITY, "0.1f");
        props.setProperty(TITLE, "Cut");
        registerService(bc, factory, NetworkViewTaskFactory.class, props);
    }
    {
        // Paste node
        NetworkViewLocationTaskFactory pasteTaskFactory = new PasteTaskFactory(clipboardManager, serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(ENABLE_FOR, "networkAndView");
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NETWORK_EDIT_MENU);
        props.setProperty(TITLE, "Paste");
        props.setProperty(MENU_GRAVITY, "0.2f");
        props.setProperty(ACCELERATOR, "cmd v");
        props.setProperty(IN_MENU_BAR, "true");
        registerService(bc, pasteTaskFactory, NetworkViewLocationTaskFactory.class, props);
    }
    // At some point, add Paste Special.  Paste special would allow paste node only, paste copy, etc.
    // NodeView context menus
    {
        // Copy node
        NodeViewTaskFactory factory = new CopyNodeTaskFactory(clipboardManager);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NODE_EDIT_MENU);
        props.setProperty(ACCELERATOR, "cmd c");
        props.setProperty(MENU_GRAVITY, "0.0f");
        props.setProperty(TITLE, "Copy");
        registerService(bc, factory, NodeViewTaskFactory.class, props);
    }
    {
        // Cut node
        NodeViewTaskFactory factory = new CutNodeTaskFactory(clipboardManager, serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NODE_EDIT_MENU);
        props.setProperty(ACCELERATOR, "cmd x");
        props.setProperty(MENU_GRAVITY, "0.1f");
        props.setProperty(TITLE, "Cut");
        registerService(bc, factory, NodeViewTaskFactory.class, props);
    }
    {
        // Rename node
        NodeViewTaskFactory factory = new RenameNodeTaskFactory(serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NODE_EDIT_MENU);
        props.setProperty(INSERT_SEPARATOR_AFTER, "true");
        props.setProperty(MENU_GRAVITY, "0.2f");
        props.setProperty(TITLE, "Rename Node");
        registerService(bc, factory, NodeViewTaskFactory.class, props);
    }
    {
        NodeViewTaskFactory factory = new AddNestedNetworkTaskFactory(serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NODE_NESTED_NETWORKS_MENU);
        props.setProperty(MENU_GRAVITY, "0.1f");
        props.setProperty(TITLE, "Add Nested Network");
        registerService(bc, factory, NodeViewTaskFactory.class, props);
    }
    {
        NodeViewTaskFactory factory = new DeleteNestedNetworkTaskFactory(serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NODE_NESTED_NETWORKS_MENU);
        props.setProperty(MENU_GRAVITY, "0.2f");
        props.setProperty(TITLE, "Remove Nested Network");
        registerService(bc, factory, NodeViewTaskFactory.class, props);
    }
    {
        NodeViewTaskFactory factory = new GoToNestedNetworkTaskFactory(serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, NODE_NESTED_NETWORKS_MENU);
        props.setProperty(MENU_GRAVITY, "0.3f");
        props.setProperty(TITLE, "Go to Nested Network");
        registerService(bc, factory, NodeViewTaskFactory.class, props);
    }
    // EdgeView context menus
    {
        // Copy node
        EdgeViewTaskFactory factory = new CopyEdgeTaskFactory(clipboardManager);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, EDGE_EDIT_MENU);
        props.setProperty(ACCELERATOR, "cmd c");
        props.setProperty(MENU_GRAVITY, "0.0f");
        props.setProperty(TITLE, "Copy");
        registerService(bc, factory, EdgeViewTaskFactory.class, props);
    }
    {
        // Cut edge
        EdgeViewTaskFactory factory = new CutEdgeTaskFactory(clipboardManager, serviceRegistrar);
        Properties props = new Properties();
        props.setProperty(PREFERRED_ACTION, "NEW");
        props.setProperty(PREFERRED_MENU, EDGE_EDIT_MENU);
        props.setProperty(ACCELERATOR, "cmd x");
        props.setProperty(MENU_GRAVITY, "0.1f");
        props.setProperty(TITLE, "Cut");
        registerService(bc, factory, EdgeViewTaskFactory.class, props);
    }
}
Also used : NetworkViewLocationTaskFactory(org.cytoscape.task.NetworkViewLocationTaskFactory) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) NetworkViewTaskFactory(org.cytoscape.task.NetworkViewTaskFactory) NodeViewTaskFactory(org.cytoscape.task.NodeViewTaskFactory) EdgeViewTaskFactory(org.cytoscape.task.EdgeViewTaskFactory)

Example 24 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImplTest method setUp.

@Before
public void setUp() {
    InputStream is = mock(InputStream.class);
    GroupUtil groupUtil = mock(GroupUtil.class);
    SUIDUpdater suidUpdater = mock(SUIDUpdater.class);
    CyNetworkReaderManager netReaderMgr = mock(CyNetworkReaderManager.class);
    CyPropertyReaderManager propReaderMgr = mock(CyPropertyReaderManager.class);
    VizmapReaderManager vizmapReaderMgr = mock(VizmapReaderManager.class);
    CSVCyReaderFactory csvCyReaderFactory = mock(CSVCyReaderFactory.class);
    CyNetworkTableManager netTblMgr = mock(CyNetworkTableManager.class);
    CyRootNetworkManager rootNetMgr = mock(CyRootNetworkManager.class);
    EquationCompiler compiler = mock(EquationCompiler.class);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyNetworkTableManager.class)).thenReturn(netTblMgr);
    when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetMgr);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    ReadCache cache = new ReadCache(serviceRegistrar);
    reader = new Cy3SessionReaderImpl(is, cache, groupUtil, suidUpdater, netReaderMgr, propReaderMgr, vizmapReaderMgr, csvCyReaderFactory, serviceRegistrar);
    tblTestSupport = new TableTestSupport();
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) InputStream(java.io.InputStream) CyNetworkReaderManager(org.cytoscape.io.read.CyNetworkReaderManager) ReadCache(org.cytoscape.io.internal.util.ReadCache) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) GroupUtil(org.cytoscape.io.internal.util.GroupUtil) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager) CyPropertyReaderManager(org.cytoscape.io.read.CyPropertyReaderManager) TableTestSupport(org.cytoscape.model.TableTestSupport) SUIDUpdater(org.cytoscape.io.internal.util.SUIDUpdater) CSVCyReaderFactory(org.cytoscape.io.internal.read.datatable.CSVCyReaderFactory) EquationCompiler(org.cytoscape.equations.EquationCompiler) Before(org.junit.Before)

Example 25 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class GenericXGMMLFileFilterTest method setUp.

@Before
public void setUp() {
    Set<String> extensions = new HashSet<String>();
    Set<String> contentTypes = new HashSet<String>();
    String description = "XGMML";
    Properties props = new Properties();
    CyProperty<Properties> cyProperties = new SimpleCyProperty<Properties>("test", props, Properties.class, SavePolicy.DO_NOT_SAVE);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=cytoscape3.props)")).thenReturn(cyProperties);
    filter = new GenericXGMMLFileFilter(extensions, contentTypes, description, DataCategory.NETWORK, new StreamUtilImpl(serviceRegistrar));
}
Also used : Properties(java.util.Properties) SimpleCyProperty(org.cytoscape.property.SimpleCyProperty) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) StreamUtilImpl(org.cytoscape.io.internal.util.StreamUtilImpl) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)62 Properties (java.util.Properties)32 CyEventHelper (org.cytoscape.event.CyEventHelper)14 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)13 CyApplicationManager (org.cytoscape.application.CyApplicationManager)12 UndoSupport (org.cytoscape.work.undo.UndoSupport)12 TaskIterator (org.cytoscape.work.TaskIterator)11 CyNetwork (org.cytoscape.model.CyNetwork)10 Task (org.cytoscape.work.Task)10 Before (org.junit.Before)10 Test (org.junit.Test)10 CyNetworkManager (org.cytoscape.model.CyNetworkManager)7 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)7 TaskFactory (org.cytoscape.work.TaskFactory)7 CyGroupManager (org.cytoscape.group.CyGroupManager)6 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)6 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)6 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)6 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)6 CyNetworkView (org.cytoscape.view.model.CyNetworkView)5