Search in sources :

Example 11 with CyTableManager

use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method restoreTables.

private void restoreTables(final CySession sess) {
    final Set<CyTable> allTables = new HashSet<>();
    // Register all tables sent through the CySession, if not already registered
    for (final CyTableMetadata metadata : sess.getTables()) {
        allTables.add(metadata.getTable());
    }
    // There may be other network tables in the CyNetworkTableManager that were not serialized in the session file
    // (e.g. Table Facades), so it's necessary to add them to CyTableManager as well
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
    for (final CyNetwork net : sess.getNetworks()) {
        allTables.addAll(netTblMgr.getTables(net, CyNetwork.class).values());
        allTables.addAll(netTblMgr.getTables(net, CyNode.class).values());
        allTables.addAll(netTblMgr.getTables(net, CyEdge.class).values());
        if (!(net instanceof CyRootNetwork)) {
            final CyRootNetwork root = rootNetMgr.getRootNetwork(net);
            allTables.addAll(netTblMgr.getTables(root, CyNetwork.class).values());
            allTables.addAll(netTblMgr.getTables(root, CyNode.class).values());
            allTables.addAll(netTblMgr.getTables(root, CyEdge.class).values());
        }
    }
    // Register all tables sent through the CySession, if not already registered
    final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
    for (final CyTable tbl : allTables) {
        if (tblMgr.getTable(tbl.getSUID()) == null)
            tblMgr.addTable(tbl);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager) CyTableMetadata(org.cytoscape.model.CyTableMetadata) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 12 with CyTableManager

use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.

the class Util method maybeOpenSession.

public static void maybeOpenSession(File file, Component owner, CyServiceRegistrar serviceRegistrar, TaskObserver observer) {
    if (file.exists() && file.canRead()) {
        final CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
        final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
        if (netManager.getNetworkSet().isEmpty() && tableManager.getAllTables(false).isEmpty())
            openSession(file, serviceRegistrar, observer);
        else
            openSessionWithWarning(file, owner, serviceRegistrar, observer);
    }
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager)

Example 13 with CyTableManager

use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.

the class CytoscapeDesktop method handleEvent.

@Override
public void handleEvent(AppsFinishedStartingEvent e) {
    invokeOnEDT(() -> {
        // Only show Starter Panel the first time if the initial session is empty
        // (for instance, Cystoscape can start up with a session file specified through the terminal)
        final CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
        final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
        if (netManager.getNetworkSet().isEmpty() && tableManager.getAllTables(false).isEmpty())
            showStarterPanel();
    });
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager)

Example 14 with CyTableManager

use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.

the class BrowserTable method selectFromTable.

private void selectFromTable() {
    final TableModel model = this.getModel();
    if (model instanceof BrowserTableModel == false)
        return;
    final BrowserTableModel btModel = (BrowserTableModel) model;
    if (btModel.getViewMode() != BrowserTableModel.ViewMode.ALL)
        return;
    final CyTable table = btModel.getDataTable();
    final CyColumn pKey = table.getPrimaryKey();
    final String pKeyName = pKey.getName();
    final int[] rowsSelected = getSelectedRows();
    if (rowsSelected.length == 0)
        return;
    final int selectedRowCount = getSelectedRowCount();
    final Set<CyRow> targetRows = new HashSet<CyRow>();
    for (int i = 0; i < selectedRowCount; i++) {
        // 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) btModel.getValueAt(convertRowIndexToModel(rowsSelected[i]), pKeyName);
        targetRows.add(btModel.getRow(selected.getValidatedObject()));
    }
    // Clear selection for non-global table
    final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
    if (tableManager.getGlobalTables().contains(table) == false) {
        List<CyRow> allRows = btModel.getDataTable().getAllRows();
        try {
            ignoreRowSetEvents = true;
            for (CyRow row : allRows) {
                final Boolean val = row.get(CyNetwork.SELECTED, Boolean.class);
                if (targetRows.contains(row)) {
                    row.set(CyNetwork.SELECTED, true);
                    continue;
                }
                if (val != null && (val == true))
                    row.set(CyNetwork.SELECTED, false);
            }
            final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
            final CyNetworkView curView = applicationManager.getCurrentNetworkView();
            if (curView != null) {
                final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
                eventHelper.flushPayloadEvents();
                curView.updateView();
            }
        } finally {
            ignoreRowSetEvents = false;
        }
        repaint();
    }
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) ValidatedObjectAndEditString(org.cytoscape.browser.internal.util.ValidatedObjectAndEditString) CyColumn(org.cytoscape.model.CyColumn) ValidatedObjectAndEditString(org.cytoscape.browser.internal.util.ValidatedObjectAndEditString) CyRow(org.cytoscape.model.CyRow) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) CyTableManager(org.cytoscape.model.CyTableManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) TableModel(javax.swing.table.TableModel) HashSet(java.util.HashSet)

Example 15 with CyTableManager

use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.

the class DefaultTableBrowser method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    if (!ignoreSetCurrentTable) {
        final CyTable table = (CyTable) getTableChooser().getSelectedItem();
        currentTable = table;
        final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
        if (table != null && !table.equals(applicationManager.getCurrentTable())) {
            final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
            if (tableManager.getTable(table.getSUID()) != null)
                applicationManager.setCurrentTable(table);
        }
        showSelectedTable();
        changeSelectionMode();
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) CyTableManager(org.cytoscape.model.CyTableManager)

Aggregations

CyTableManager (org.cytoscape.model.CyTableManager)19 CyTable (org.cytoscape.model.CyTable)10 CyApplicationManager (org.cytoscape.application.CyApplicationManager)7 CyNetworkManager (org.cytoscape.model.CyNetworkManager)6 Properties (java.util.Properties)4 CyTableFactory (org.cytoscape.model.CyTableFactory)4 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)4 CyGroupManager (org.cytoscape.group.CyGroupManager)3 HashSet (java.util.HashSet)2 CyEventHelper (org.cytoscape.event.CyEventHelper)2 CyGroupFactory (org.cytoscape.group.CyGroupFactory)2 CyNetwork (org.cytoscape.model.CyNetwork)2 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)2 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)2 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)2 UndoSupport (org.cytoscape.work.undo.UndoSupport)2 AttributeClusterTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.AttributeClusterTaskFactory)1 ChengChurchTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.ChengChurch.ChengChurchTaskFactory)1 DBSCANTaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.DBSCAN.DBSCANTaskFactory)1 AutoSOMETaskFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.autosome.AutoSOMETaskFactory)1