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