Search in sources :

Example 1 with RowSetRecord

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

the class NetworkMediator method handleEvent.

@Override
public void handleEvent(final RowsSetEvent e) {
    if (loadingSession || networkMainPanel.getRootNetworkListPanel().isEmpty())
        return;
    // We only care about network name changes
    final Collection<RowSetRecord> nameRecords = e.getColumnRecords(CyNetwork.NAME);
    if (nameRecords == null || nameRecords.isEmpty())
        return;
    final CyTable tbl = e.getSource();
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final CyNetwork net = netTblMgr.getNetworkForTable(tbl);
    // And if there is no related network, nothing needs to be done
    if (net != null && tbl.equals(net.getDefaultNetworkTable())) {
        invokeOnEDT(() -> {
            final AbstractNetworkPanel<?> item = networkMainPanel.getNetworkItem(net);
            if (item != null)
                item.update();
        });
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyTable(org.cytoscape.model.CyTable) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyNetwork(org.cytoscape.model.CyNetwork)

Example 2 with RowSetRecord

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

the class BrowserTable method handleEvent.

@Override
public void handleEvent(final RowsSetEvent e) {
    if (isEditing()) {
        getCellEditor().stopCellEditing();
    }
    if (ignoreRowSetEvents)
        return;
    final BrowserTableModel model = (BrowserTableModel) getModel();
    final CyTable dataTable = model.getDataTable();
    if (e.getSource() != dataTable)
        return;
    if (model.getViewMode() == BrowserTableModel.ViewMode.SELECTED || model.getViewMode() == BrowserTableModel.ViewMode.AUTO) {
        model.clearSelectedRows();
        boolean foundANonSelectedColumnName = false;
        for (String column : e.getColumns()) {
            if (!CyNetwork.SELECTED.equals(column)) {
                foundANonSelectedColumnName = true;
                break;
            }
        }
        if (!foundANonSelectedColumnName) {
            model.fireTableDataChanged();
            return;
        }
    }
    final Collection<RowSetRecord> rows = e.getPayloadCollection();
    synchronized (this) {
        if (model.getViewMode() == BrowserTableModel.ViewMode.SELECTED || model.getViewMode() == BrowserTableModel.ViewMode.AUTO) {
            model.fireTableDataChanged();
        } else {
            final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
            if (!tableManager.getGlobalTables().contains(dataTable))
                bulkUpdate(rows);
        }
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyTableManager(org.cytoscape.model.CyTableManager) ValidatedObjectAndEditString(org.cytoscape.browser.internal.util.ValidatedObjectAndEditString)

Example 3 with RowSetRecord

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

the class BrowserTableTest method testTableAutoMode.

@Test
public void testTableAutoMode() {
    // to reset the columns and rows
    browserTable.setModel(btm);
    btm.setViewMode(BrowserTableModel.ViewMode.AUTO);
    btm.fireTableDataChanged();
    assertEquals(3, browserTable.getRowCount());
    table.getRow((long) 3).set(CyNetwork.SELECTED, true);
    browserTable.handleEvent(new RowsSetEvent(table, Arrays.asList(new RowSetRecord(table.getRow((long) 3), CyNetwork.SELECTED, (Object) true, (Object) true))));
    assertEquals(1, browserTable.getRowCount());
    table.getRow((long) 2).set(CyNetwork.SELECTED, true);
    browserTable.handleEvent(new RowsSetEvent(table, Arrays.asList(new RowSetRecord(table.getRow((long) 2), CyNetwork.SELECTED, (Object) true, (Object) true))));
    assertEquals(2, browserTable.getRowCount());
    table.getRow((long) 1).set(CyNetwork.SELECTED, true);
    browserTable.handleEvent(new RowsSetEvent(table, Arrays.asList(new RowSetRecord(table.getRow((long) 1), CyNetwork.SELECTED, (Object) true, (Object) true))));
    assertEquals(3, browserTable.getRowCount());
    table.getRow((long) 1).set(CyNetwork.SELECTED, false);
    table.getRow((long) 2).set(CyNetwork.SELECTED, false);
    table.getRow((long) 3).set(CyNetwork.SELECTED, false);
    browserTable.handleEvent(new RowsSetEvent(table, Arrays.asList(new RowSetRecord(table.getRow((long) 1), CyNetwork.SELECTED, (Object) false, (Object) false), new RowSetRecord(table.getRow((long) 2), CyNetwork.SELECTED, (Object) false, (Object) false), new RowSetRecord(table.getRow((long) 3), CyNetwork.SELECTED, (Object) false, (Object) false))));
    assertEquals(3, browserTable.getRowCount());
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) RowsSetEvent(org.cytoscape.model.events.RowsSetEvent) Test(org.junit.Test)

Example 4 with RowSetRecord

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

the class BrowserTableTest method testTableModeAndSelection.

@Test
public void testTableModeAndSelection() {
    // to reset the columns and rows
    browserTable.setModel(btm);
    btm.setViewMode(BrowserTableModel.ViewMode.ALL);
    btm.fireTableDataChanged();
    assertEquals(3, browserTable.getRowCount());
    btm.setViewMode(BrowserTableModel.ViewMode.SELECTED);
    btm.fireTableDataChanged();
    assertEquals(0, browserTable.getRowCount());
    table.getRow((long) 1).set(CyNetwork.SELECTED, true);
    assertEquals(1, browserTable.getRowCount());
    btm.setViewMode(BrowserTableModel.ViewMode.ALL);
    RowSetRecord rsc = new RowSetRecord(table.getRow((long) 1), CyNetwork.SELECTED, (Object) true, (Object) true);
    final List<RowSetRecord> rscs = new ArrayList<RowSetRecord>();
    rscs.add(rsc);
    try {
        SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                browserTable.handleEvent(new RowsSetEvent(table, rscs));
                assertEquals(1, browserTable.getSelectedRowCount());
            }
        });
    } catch (InterruptedException e) {
        assertEquals(1, browserTable.getSelectedRowCount());
    } catch (InvocationTargetException e) {
        assertEquals(1, browserTable.getSelectedRowCount());
    }
    table.getRow((long) 2).set(CyNetwork.SELECTED, true);
    rsc = new RowSetRecord(table.getRow((long) 2), CyNetwork.SELECTED, (Object) true, (Object) true);
    rscs.clear();
    rscs.add(rsc);
    browserTable.handleEvent(new RowsSetEvent(table, rscs));
    assertEquals(2, browserTable.getSelectedRowCount());
    table.getRow((long) 2).set(CyNetwork.SELECTED, false);
    rsc = new RowSetRecord(table.getRow((long) 2), CyNetwork.SELECTED, (Object) false, (Object) false);
    rscs.clear();
    rscs.add(rsc);
    browserTable.handleEvent(new RowsSetEvent(table, rscs));
    assertEquals(1, browserTable.getSelectedRowCount());
    browserTable.mouseReleased(new MouseEvent(browserTable, 0, 0, 0, browserTable.getCellRect(1, 0, true).x, browserTable.getCellRect(1, 0, true).y, Math.abs(browserTable.getCellRect(1, 0, true).x), Math.abs(browserTable.getCellRect(1, 0, true).y), 1, true, MouseEvent.BUTTON1));
    assertEquals(1, browserTable.getSelectedRowCount());
    browserTable.selectAll();
    assertEquals(3, browserTable.getSelectedRowCount());
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) MouseEvent(java.awt.event.MouseEvent) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) RowsSetEvent(org.cytoscape.model.events.RowsSetEvent) Test(org.junit.Test)

Example 5 with RowSetRecord

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

the class DGraphView method updateSelection.

private void updateSelection(Class<? extends CyIdentifiable> type, Collection<RowSetRecord> records) {
    if (type == null)
        return;
    synchronized (m_lock) {
        nodeSelectionList.clear();
        edgeSelectionList.clear();
    }
    if (type == CyNode.class) {
        for (RowSetRecord rec : records) {
            // Get the SUID
            Long suid = rec.getRow().get(CyNetwork.SUID, Long.class);
            CyNode node = getModel().getNode(suid);
            if (node == null)
                continue;
            DNodeView nv = (DNodeView) getNodeView(node);
            if (nv == null)
                continue;
            Boolean value = rec.getRow().get(CyNetwork.SELECTED, Boolean.class);
            synchronized (m_lock) {
                if (Boolean.TRUE.equals(value))
                    nv.selectInternal();
                else
                    nv.unselectInternal();
                nodeSelectionList.add(node);
            }
        }
    } else if (type == CyEdge.class) {
        for (RowSetRecord rec : records) {
            // Get the SUID
            Long suid = rec.getRow().get(CyNetwork.SUID, Long.class);
            CyEdge edge = getModel().getEdge(suid);
            if (edge == null)
                continue;
            DEdgeView ev = (DEdgeView) getEdgeView(edge);
            if (ev == null)
                continue;
            Boolean value = rec.getRow().get(CyNetwork.SELECTED, Boolean.class);
            synchronized (m_lock) {
                if (Boolean.TRUE.equals(value))
                    ev.selectInternal(false);
                else
                    ev.unselectInternal();
                edgeSelectionList.add(edge);
            }
        }
    }
    if (nodeSelectionList.size() > 0 || edgeSelectionList.size() > 0) {
        // Update renderings
        m_networkCanvas.updateSubgraph(nodeSelectionList, edgeSelectionList);
        if (m_navigationCanvas != null)
            m_navigationCanvas.updateSubgraph(nodeSelectionList, edgeSelectionList);
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

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