Search in sources :

Example 1 with TableAboutToBeDeletedEvent

use of org.cytoscape.model.events.TableAboutToBeDeletedEvent 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 2 with TableAboutToBeDeletedEvent

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

the class CyTableManagerImpl method deleteTableInternal.

void deleteTableInternal(final long suid, boolean force) {
    CyTable table;
    synchronized (lock) {
        table = tables.get(suid);
        if (table == null) {
            return;
        }
    }
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    eventHelper.fireEvent(new TableAboutToBeDeletedEvent(this, table));
    synchronized (lock) {
        table = tables.get(suid);
        if (table == null) {
            return;
        }
        if (!force && (table.getMutability() != Mutability.MUTABLE)) {
            throw new IllegalArgumentException("can't delete an immutable table.");
        }
        if (table instanceof CyTableImpl)
            ((CyTableImpl) table).removeAllVirtColumns();
        tables.remove(suid);
    }
    eventHelper.fireEvent(new TableDeletedEvent(this));
    logger.debug("CyTable removed: table ID = " + table.getSUID());
    table = null;
}
Also used : TableDeletedEvent(org.cytoscape.model.events.TableDeletedEvent) CyTable(org.cytoscape.model.CyTable) CyEventHelper(org.cytoscape.event.CyEventHelper) TableAboutToBeDeletedEvent(org.cytoscape.model.events.TableAboutToBeDeletedEvent)

Aggregations

CyEventHelper (org.cytoscape.event.CyEventHelper)2 CyTable (org.cytoscape.model.CyTable)2 TableAboutToBeDeletedEvent (org.cytoscape.model.events.TableAboutToBeDeletedEvent)2 TableDeletedEvent (org.cytoscape.model.events.TableDeletedEvent)1