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