Search in sources :

Example 1 with TableAddedEvent

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

the class CyTableTest method setUp.

@Before
public void setUp() {
    eventHelper = new DummyCyEventHelper();
    compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
    final Interpreter interpreter = new InterpreterImpl();
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
    table = new CyTableImpl("homer", CyIdentifiable.SUID, Long.class, false, true, SavePolicy.SESSION_FILE, eventHelper, ColumnDataFactory.createDefaultFactory(), interpreter, 1000);
    attrs = table.getRow(1L);
    table2 = new CyTableImpl("marge", CyIdentifiable.SUID, Long.class, false, true, SavePolicy.SESSION_FILE, eventHelper, ColumnDataFactory.createDefaultFactory(), interpreter, 1000);
    CyTableManagerImpl tblMgr = new CyTableManagerImpl(new CyNetworkTableManagerImpl(), new CyNetworkManagerImpl(serviceRegistrar), serviceRegistrar);
    tblMgr.addTable(table);
    ((CyTableImpl) table).handleEvent(new TableAddedEvent(tblMgr, table));
    tblMgr.addTable(table2);
    ((CyTableImpl) table2).handleEvent(new TableAddedEvent(tblMgr, table2));
}
Also used : EquationParserImpl(org.cytoscape.equations.internal.EquationParserImpl) EquationCompilerImpl(org.cytoscape.equations.internal.EquationCompilerImpl) Interpreter(org.cytoscape.equations.Interpreter) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) TableAddedEvent(org.cytoscape.model.events.TableAddedEvent) DummyCyEventHelper(org.cytoscape.event.DummyCyEventHelper) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) CyTableImpl(org.cytoscape.model.internal.CyTableImpl) Before(org.junit.Before)

Example 2 with TableAddedEvent

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

the class TableTestSupportTest method setUp.

@Before
public void setUp() {
    eventHelper = support.getDummyCyEventHelper();
    EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    table = factory.createTable(Integer.toString(rand.nextInt(10000)), CyIdentifiable.SUID, Long.class, false, true);
    table2 = factory.createTable(Integer.toString(rand.nextInt(10000)), CyIdentifiable.SUID, Long.class, false, true);
    attrs = table.getRow(1l);
    CyTableManagerImpl tblMgr = new CyTableManagerImpl(new CyNetworkTableManagerImpl(), new CyNetworkManagerImpl(serviceRegistrar), serviceRegistrar);
    tblMgr.addTable(table);
    ((CyTableImpl) table).handleEvent(new TableAddedEvent(tblMgr, table));
    tblMgr.addTable(table2);
    ((CyTableImpl) table2).handleEvent(new TableAddedEvent(tblMgr, table2));
}
Also used : EquationParserImpl(org.cytoscape.equations.internal.EquationParserImpl) EquationCompilerImpl(org.cytoscape.equations.internal.EquationCompilerImpl) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) TableAddedEvent(org.cytoscape.model.events.TableAddedEvent) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) CyTableImpl(org.cytoscape.model.internal.CyTableImpl) Before(org.junit.Before)

Example 3 with TableAddedEvent

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

the class CyTableManagerImpl method addTable.

@Override
public void addTable(final CyTable t) {
    boolean fireEvent = false;
    synchronized (lock) {
        if (t == null)
            throw new NullPointerException("added table is null");
        final Long suid = t.getSUID();
        if (tables.get(suid) == null) {
            tables.put(suid, t);
            fireEvent = true;
        }
    }
    if (fireEvent) {
        final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
        eventHelper.fireEvent(new TableAddedEvent(this, t));
    }
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) TableAddedEvent(org.cytoscape.model.events.TableAddedEvent)

Aggregations

TableAddedEvent (org.cytoscape.model.events.TableAddedEvent)3 EquationCompilerImpl (org.cytoscape.equations.internal.EquationCompilerImpl)2 EquationParserImpl (org.cytoscape.equations.internal.EquationParserImpl)2 CyNetworkManagerImpl (org.cytoscape.model.internal.CyNetworkManagerImpl)2 CyNetworkTableManagerImpl (org.cytoscape.model.internal.CyNetworkTableManagerImpl)2 CyTableImpl (org.cytoscape.model.internal.CyTableImpl)2 CyTableManagerImpl (org.cytoscape.model.internal.CyTableManagerImpl)2 Before (org.junit.Before)2 EquationCompiler (org.cytoscape.equations.EquationCompiler)1 Interpreter (org.cytoscape.equations.Interpreter)1 InterpreterImpl (org.cytoscape.equations.internal.interpreter.InterpreterImpl)1 CyEventHelper (org.cytoscape.event.CyEventHelper)1 DummyCyEventHelper (org.cytoscape.event.DummyCyEventHelper)1