Search in sources :

Example 11 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method disposeCurrentSession.

@Override
public void disposeCurrentSession() {
    logger.debug("Disposing current session...");
    // Destroy network views
    final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
    final Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
    for (final CyNetworkView nv : netViews) nvMgr.destroyNetworkView(nv);
    nvMgr.reset();
    // Destroy networks
    final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
    final Set<CyNetwork> networks = netMgr.getNetworkSet();
    for (final CyNetwork n : networks) netMgr.destroyNetwork(n);
    netMgr.reset();
    // Destroy styles
    logger.debug("Removing current visual styles...");
    final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
    final VisualStyle defaultStyle = vmMgr.getDefaultVisualStyle();
    final List<VisualStyle> allStyles = new ArrayList<>(vmMgr.getAllVisualStyles());
    for (final VisualStyle vs : allStyles) {
        if (!vs.equals(defaultStyle))
            vmMgr.removeVisualStyle(vs);
    }
    // Destroy tables
    final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
    tblMgr.reset();
    // Reset groups
    serviceRegistrar.getService(CyGroupManager.class).reset();
    // Unregister session properties
    final Set<CyProperty<?>> cyPropsClone = getAllProperties();
    for (CyProperty<?> cyProps : cyPropsClone) {
        if (cyProps.getSavePolicy().equals(CyProperty.SavePolicy.SESSION_FILE)) {
            serviceRegistrar.unregisterAllServices(cyProps);
            sessionProperties.remove(cyProps.getName());
        }
    }
    // Clear undo stack
    serviceRegistrar.getService(UndoSupport.class).reset();
    // Reset current table and rendering engine
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    appMgr.reset();
    currentFileName = null;
    disposed = true;
}
Also used : CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyApplicationManager(org.cytoscape.application.CyApplicationManager) SimpleCyProperty(org.cytoscape.property.SimpleCyProperty) CyProperty(org.cytoscape.property.CyProperty) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyGroupManager(org.cytoscape.group.CyGroupManager)

Example 12 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class LayoutMenuPopulator method checkEnabled.

private boolean checkEnabled() {
    CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    CyNetwork network = appMgr.getCurrentNetwork();
    if (network == null)
        return false;
    CyNetworkView view = appMgr.getCurrentNetworkView();
    if (view == null)
        return false;
    else
        return true;
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 13 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class EnhancedSearchPanel method doSearching.

// Do searching based on the query string from user on text-field
private void doSearching() {
    final String queryStr = tfSearchText.getText().trim();
    // Ignore if the search term is empty
    if (queryStr == null || queryStr.length() == 0)
        return;
    final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
    final CyNetwork currentNetwork = appManager.getCurrentNetwork();
    if (currentNetwork != null) {
        final SearchTaskFactory factory = new SearchTaskFactory(searchMgr, queryStr, serviceRegistrar);
        final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
        taskMgr.execute(factory.createTaskIterator(currentNetwork));
    } else {
        logger.error("Could not find network for search");
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) SearchTaskFactory(org.cytoscape.search.internal.SearchTaskFactory) CyNetwork(org.cytoscape.model.CyNetwork) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 14 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class ExportSelectedNetworkTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator() {
    final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
    CyNetworkView view = applicationManager.getCurrentNetworkView();
    if (view != null)
        return getExportNetworkViewTaskFactory().createTaskIterator(view);
    CyNetwork network = applicationManager.getCurrentNetwork();
    if (network != null)
        return getExportNetworkTaskFactory().createTaskIterator(network);
    return null;
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 15 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class PopupMenuHelper method selectElementsFromSelectedRows.

private void selectElementsFromSelectedRows(final JTable table, final Class<? extends CyIdentifiable> tableType) {
    final Thread t = new Thread() {

        @Override
        public void run() {
            final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
            final CyNetwork net = applicationManager.getCurrentNetwork();
            if (net != null) {
                final BrowserTableModel tableModel = (BrowserTableModel) table.getModel();
                final int[] selectedRows = table.getSelectedRows();
                final Set<CyRow> targetRows = new HashSet<CyRow>();
                for (final int rowIndex : selectedRows) {
                    // Getting the row from data table solves the problem with hidden or moved SUID column.
                    // However, since the rows might be sorted we need to convert the index to model.
                    final ValidatedObjectAndEditString selected = (ValidatedObjectAndEditString) tableModel.getValueAt(table.convertRowIndexToModel(rowIndex), CyNetwork.SUID);
                    targetRows.add(tableModel.getRow(selected.getValidatedObject()));
                }
                final CyTable cyTable = tableType == CyNode.class ? net.getDefaultNodeTable() : net.getDefaultEdgeTable();
                for (final CyRow cyRow : cyTable.getAllRows()) cyRow.set(CyNetwork.SELECTED, targetRows.contains(cyRow));
                final CyNetworkView view = applicationManager.getCurrentNetworkView();
                if (view != null) {
                    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
                    eventHelper.flushPayloadEvents();
                    view.updateView();
                }
            }
        }
    };
    t.start();
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) ValidatedObjectAndEditString(org.cytoscape.browser.internal.util.ValidatedObjectAndEditString) CyNetwork(org.cytoscape.model.CyNetwork) CyRow(org.cytoscape.model.CyRow) Point(java.awt.Point) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet)

Aggregations

CyApplicationManager (org.cytoscape.application.CyApplicationManager)80 CyNetwork (org.cytoscape.model.CyNetwork)40 CyNetworkView (org.cytoscape.view.model.CyNetworkView)30 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)18 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)16 CyNetworkManager (org.cytoscape.model.CyNetworkManager)14 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyTable (org.cytoscape.model.CyTable)12 ArrayList (java.util.ArrayList)11 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)10 CyNode (org.cytoscape.model.CyNode)9 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)9 Test (org.junit.Test)9 HashSet (java.util.HashSet)8 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)8 TaskIterator (org.cytoscape.work.TaskIterator)8 HashMap (java.util.HashMap)7 CyGroupManager (org.cytoscape.group.CyGroupManager)7 CyTableManager (org.cytoscape.model.CyTableManager)7