Search in sources :

Example 21 with RowSetRecord

use of org.cytoscape.model.events.RowSetRecord in project cytoscape-impl by cytoscape.

the class ColumnSetListener method handleEvent.

public void handleEvent(RowsSetEvent e) {
    final CyTable local = e.getSource();
    synchronized (lock) {
        final List<CyTable> sharedList = tables.get(local);
        for (CyTable shared : sharedList) {
            for (RowSetRecord record : e.getColumnRecords(columnName)) {
                // assume payload collection is for same column
                final CyRow r = shared.getRow(record.getRow().get(CyIdentifiable.SUID, Long.class));
                if (r != null) {
                    final Object name = record.getValue();
                    String sharedName = r.get(sharedColumnName, String.class);
                    if (sharedName == null) {
                        r.set(sharedColumnName, name);
                    }
                }
            }
        }
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyRow(org.cytoscape.model.CyRow)

Example 22 with RowSetRecord

use of org.cytoscape.model.events.RowSetRecord in project cytoscape-impl by cytoscape.

the class BrowserTable method bulkUpdate.

/**
 * Select rows in the table when something selected in the network view.
 * @param rows
 */
private void bulkUpdate(final Collection<RowSetRecord> rows) {
    final Set<Long> suidSelected = new HashSet<Long>();
    final Set<Long> suidUnselected = new HashSet<Long>();
    for (RowSetRecord rowSetRecord : rows) {
        if (rowSetRecord.getColumn().equals(CyNetwork.SELECTED)) {
            if (((Boolean) rowSetRecord.getValue()) == true)
                suidSelected.add(rowSetRecord.getRow().get(CyIdentifiable.SUID, Long.class));
            else
                suidUnselected.add(rowSetRecord.getRow().get(CyIdentifiable.SUID, Long.class));
        }
    }
    changeRowSelection(suidSelected, suidUnselected);
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) HashSet(java.util.HashSet)

Example 23 with RowSetRecord

use of org.cytoscape.model.events.RowSetRecord in project cytoscape-impl by cytoscape.

the class NetworkViewMediator method updateNetworkViewTitle.

private final void updateNetworkViewTitle(final Collection<RowSetRecord> records, final CyTable source) {
    final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
    final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
    for (final RowSetRecord record : records) {
        if (CyNetwork.NAME.equals(record.getColumn())) {
            // Assume payload collection is for same column
            for (CyNetwork net : netMgr.getNetworkSet()) {
                if (net.getDefaultNetworkTable() == source) {
                    final String name = record.getRow().get(CyNetwork.NAME, String.class);
                    if (name == null || name.trim().isEmpty())
                        continue;
                    final Collection<CyNetworkView> netViews = netViewMgr.getNetworkViews(net);
                    int count = 0;
                    for (CyNetworkView view : netViews) {
                        // TODO: Only update the view's title if the current title and the network name are in sync,
                        // because users can change the Network View title at any time
                        String title = name.trim();
                        title += (netViews.size() > 1 ? " (" + ++count + ")" : "");
                        view.setVisualProperty(BasicVisualLexicon.NETWORK_TITLE, title);
                        // if this visual property is locked
                        if (!view.isValueLocked(BasicVisualLexicon.NETWORK_TITLE)) {
                            invokeOnEDT(() -> {
                                getNetworkViewMainPanel().update(view);
                            });
                        }
                    }
                    break;
                }
            }
        }
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 24 with RowSetRecord

use of org.cytoscape.model.events.RowSetRecord in project cytoscape-impl by cytoscape.

the class NetworkViewMediator method handleEvent.

@Override
public void handleEvent(final RowsSetEvent e) {
    if (loadingSession || getNetworkViewMainPanel().isEmpty())
        return;
    final CyTable tbl = e.getSource();
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final CyNetwork net = netTblMgr.getNetworkForTable(tbl);
    final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
    // And if there is no related view, nothing needs to be done
    if (net != null && netViewMgr.viewExists(net)) {
        // Update Network View Title
        final Collection<RowSetRecord> nameRecords = e.getColumnRecords(CyNetwork.NAME);
        if (!nameRecords.isEmpty())
            updateNetworkViewTitle(nameRecords, tbl);
        if (tbl.equals(net.getDefaultNodeTable()) || tbl.equals(net.getDefaultEdgeTable())) {
            final Collection<CyNetworkView> networkViews = netViewMgr.getNetworkViews(net);
            // Update node/edge selection info
            final Collection<RowSetRecord> selectedRecords = e.getColumnRecords(CyNetwork.SELECTED);
            if (!selectedRecords.isEmpty()) {
                for (final CyNetworkView view : networkViews) getNetworkViewMainPanel().updateSelectionInfo(view);
            }
            // Update views with styles affected by this RowsSetEvent
            final Set<CyNetworkView> viewsToUpdate = new HashSet<>();
            for (String columnName : e.getColumns()) {
                // Reapply locked values that map to changed columns
                final boolean lockedValuesApplyed = reapplyLockedValues(columnName, networkViews);
                if (lockedValuesApplyed)
                    viewsToUpdate.addAll(networkViews);
                // Find views that had their styles affected by the RowsSetEvent
                final Set<VisualStyle> styles = findStylesWithMappedColumn(columnName);
                viewsToUpdate.addAll(findNetworkViewsWithStyles(styles));
            }
            // Update views
            for (final CyNetworkView view : viewsToUpdate) updateView(view, null);
        }
    }
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork) CyTable(org.cytoscape.model.CyTable) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 25 with RowSetRecord

use of org.cytoscape.model.events.RowSetRecord in project cytoscape-impl by cytoscape.

the class SelectUtils method setSelected.

private void setSelected(final CyNetwork network, final Collection<? extends CyIdentifiable> objects, final boolean select, final CyTable table) {
    // Don't autobox
    Boolean value;
    if (select)
        value = Boolean.TRUE;
    else
        value = Boolean.FALSE;
    // Disable all events from our table
    eventHelper.silenceEventSource(table);
    // Create the RowSetRecord collection
    List<RowSetRecord> rowsChanged = new ArrayList<RowSetRecord>();
    // The list of objects will be all nodes or all edges
    for (final CyIdentifiable nodeOrEdge : objects) {
        CyRow row = table.getRow(nodeOrEdge.getSUID());
        if (row != null) {
            row.set(CyNetwork.SELECTED, value);
            rowsChanged.add(new RowSetRecord(row, CyNetwork.SELECTED, value, value));
        }
    }
    // Enable all events from our table
    eventHelper.unsilenceEventSource(table);
    RowsSetEvent event = new RowsSetEvent(table, rowsChanged);
    eventHelper.fireEvent(event);
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) ArrayList(java.util.ArrayList) CyRow(org.cytoscape.model.CyRow) CyIdentifiable(org.cytoscape.model.CyIdentifiable) RowsSetEvent(org.cytoscape.model.events.RowsSetEvent)

Aggregations

RowSetRecord (org.cytoscape.model.events.RowSetRecord)26 CyTable (org.cytoscape.model.CyTable)11 CyNetwork (org.cytoscape.model.CyNetwork)8 ArrayList (java.util.ArrayList)6 CyRow (org.cytoscape.model.CyRow)6 RowsSetEvent (org.cytoscape.model.events.RowsSetEvent)6 Test (org.junit.Test)6 CyNode (org.cytoscape.model.CyNode)5 CyNetworkView (org.cytoscape.view.model.CyNetworkView)5 CyColumn (org.cytoscape.model.CyColumn)4 CyIdentifiable (org.cytoscape.model.CyIdentifiable)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Equation (org.cytoscape.equations.Equation)3 CyEdge (org.cytoscape.model.CyEdge)3 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)3 ColumnData (org.cytoscape.model.internal.column.ColumnData)3 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)3 List (java.util.List)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2