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();
});
}
}
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);
}
}
}
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());
}
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());
}
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);
}
}
Aggregations