Search in sources :

Example 16 with RowSetRecord

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

the class CyTableTest method testVirtualColumnSet.

@Test
public void testVirtualColumnSet() {
    table.createColumn("real", String.class, false);
    table2.addVirtualColumn("virtual", "real", table, table.getPrimaryKey().getName(), true);
    CyRow row = table2.getRow(1L);
    row.set("virtual", "foo");
    for (Object payload : eventHelper.getAllPayloads()) {
        if (payload instanceof RowSetRecord) {
            RowSetRecord record = (RowSetRecord) payload;
            CyTable affectedTable = record.getRow().getTable();
            if (affectedTable == table) {
                assertEquals("real", record.getColumn());
            }
            if (affectedTable == table2) {
                assertEquals("virtual", record.getColumn());
            }
        }
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) Test(org.junit.Test)

Example 17 with RowSetRecord

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

the class CyTableTest method testSetWithAnEvaluableCompatibleEquation.

@Test
public void testSetWithAnEvaluableCompatibleEquation() {
    table.createColumn("strings", String.class, false);
    final Map<String, Class<?>> varnameToTypeMap = new HashMap<String, Class<?>>();
    compiler.compile("=\"one\"", new HashMap<String, Class<?>>());
    final Equation eqn = compiler.getEquation();
    attrs.set("strings", eqn);
    Object last = eventHelper.getLastPayload();
    assertNotNull(last);
    assertTrue(last instanceof RowSetRecord);
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) HashMap(java.util.HashMap) Equation(org.cytoscape.equations.Equation) Test(org.junit.Test)

Example 18 with RowSetRecord

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

the class NetworkNameSetListener method updateSubNetworkTableNames.

private void updateSubNetworkTableNames(Collection<RowSetRecord> payloadCollection, CyTable sourceTable) {
    for (CyNetwork net : rootNetwork.getSubNetworkList()) {
        if (sourceTable.equals(net.getDefaultNetworkTable())) {
            for (RowSetRecord record : payloadCollection) {
                // assume payload collection is for same column
                final Object name = record.getValue();
                setTablesName(name.toString() + " default ", net.getDefaultEdgeTable(), net.getDefaultNodeTable(), net.getDefaultNetworkTable());
                // assuming that this even is fired only for a single row
                return;
            }
        }
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyNetwork(org.cytoscape.model.CyNetwork)

Example 19 with RowSetRecord

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

the class NetworkNameSetListener method updateRootNetworkTableNames.

private void updateRootNetworkTableNames(Collection<RowSetRecord> payloadCollection) {
    for (RowSetRecord record : payloadCollection) {
        // assume payload collection is for same column
        final Object name = record.getValue();
        setTablesName(name + " root shared ", rootNetwork.getSharedEdgeTable(), rootNetwork.getSharedNodeTable(), rootNetwork.getSharedNetworkTable());
        setTablesName(name + " root default ", rootNetwork.getDefaultEdgeTable(), rootNetwork.getDefaultNodeTable(), rootNetwork.getDefaultNetworkTable());
        return;
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord)

Example 20 with RowSetRecord

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

the class TableEventHelperFacade method addEventPayload.

@Override
@SuppressWarnings("unchecked")
public <S, P, E extends CyPayloadEvent<S, P>> void addEventPayload(S source, P payload, Class<E> eventType) {
    final CyEventHelper eventHelper = getEventHelper();
    // always propagate the payload from the original source
    eventHelper.addEventPayload(source, payload, eventType);
    // only propagate the payload with a facade source if it's one we care about
    if (source instanceof CyTable) {
        Reference<LocalTableFacade> reference;
        synchronized (lock) {
            reference = facadeMap.get((CyTable) source);
        }
        if (reference == null)
            return;
        LocalTableFacade facade = reference.get();
        if (facade == null)
            return;
        if (payload instanceof RowSetRecord) {
            P newRSC = (P) new RowSetRecord(facade.getRow(((RowSetRecord) payload).getRow().get(CyNetwork.SUID, Long.class)), ((RowSetRecord) payload).getColumn(), ((RowSetRecord) payload).getValue(), ((RowSetRecord) payload).getRawValue());
            eventHelper.addEventPayload((S) facade, newRSC, eventType);
        } else {
            eventHelper.addEventPayload((S) facade, payload, eventType);
        }
    }
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) CyTable(org.cytoscape.model.CyTable) RowSetRecord(org.cytoscape.model.events.RowSetRecord)

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