Search in sources :

Example 36 with CyEventHelper

use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.

the class VisualMappingManagerImpl method setCurrentVisualStyle.

@Override
public void setCurrentVisualStyle(VisualStyle newStyle) {
    if (newStyle == null)
        newStyle = defaultStyle;
    boolean changed = !newStyle.equals(currentStyle);
    this.currentStyle = newStyle;
    if (changed) {
        final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
        eventHelper.fireEvent(new SetCurrentVisualStyleEvent(this, currentStyle));
    }
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) SetCurrentVisualStyleEvent(org.cytoscape.view.vizmap.events.SetCurrentVisualStyleEvent)

Example 37 with CyEventHelper

use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.

the class VisualMappingManagerTest method setUp.

@Before
public void setUp() throws Exception {
    final VisualStyleFactory factory = mock(VisualStyleFactory.class);
    final VisualStyle dummyDefaultStyle = mock(VisualStyle.class);
    when(factory.createVisualStyle(VisualMappingManagerImpl.DEFAULT_STYLE_NAME)).thenReturn(dummyDefaultStyle);
    final CyEventHelper eventHelper = mock(CyEventHelper.class);
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    vmm = new VisualMappingManagerImpl(factory, serviceRegistrar);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManagerImpl(org.cytoscape.view.vizmap.internal.VisualMappingManagerImpl) VisualStyleFactory(org.cytoscape.view.vizmap.VisualStyleFactory) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Example 38 with CyEventHelper

use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.

the class CyTableManagerImpl method reset.

@Override
public void reset() {
    Collection<CyTable> values;
    synchronized (lock) {
        values = tables.values();
    }
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    for (CyTable table : values) {
        eventHelper.fireEvent(new TableAboutToBeDeletedEvent(this, table));
    }
    synchronized (lock) {
        tables.clear();
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyEventHelper(org.cytoscape.event.CyEventHelper) TableAboutToBeDeletedEvent(org.cytoscape.model.events.TableAboutToBeDeletedEvent)

Example 39 with CyEventHelper

use of org.cytoscape.event.CyEventHelper 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)

Example 40 with CyEventHelper

use of org.cytoscape.event.CyEventHelper 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

CyEventHelper (org.cytoscape.event.CyEventHelper)63 CyNetworkView (org.cytoscape.view.model.CyNetworkView)19 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)19 CyNode (org.cytoscape.model.CyNode)15 UndoSupport (org.cytoscape.work.undo.UndoSupport)14 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)13 ArrayList (java.util.ArrayList)11 CyApplicationManager (org.cytoscape.application.CyApplicationManager)11 CyNetwork (org.cytoscape.model.CyNetwork)10 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)10 Test (org.junit.Test)10 Task (org.cytoscape.work.Task)9 CyTable (org.cytoscape.model.CyTable)8 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)8 TaskIterator (org.cytoscape.work.TaskIterator)8 CyEdge (org.cytoscape.model.CyEdge)7 CyRow (org.cytoscape.model.CyRow)7 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)6 CyNetworkManager (org.cytoscape.model.CyNetworkManager)5 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)5