Search in sources :

Example 1 with ColumnNameChangedEvent

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

the class TableEventHelperFacade method fireEvent.

@Override
public <E extends CyEvent<?>> void fireEvent(final E event) {
    final CyEventHelper eventHelper = getEventHelper();
    // always propagate the actual event
    eventHelper.fireEvent(event);
    // make sure the source is something we care about
    Object source = event.getSource();
    if (!(source instanceof CyTable))
        return;
    Reference<LocalTableFacade> reference;
    synchronized (lock) {
        reference = facadeMap.get((CyTable) source);
    }
    if (reference == null)
        return;
    LocalTableFacade facade = reference.get();
    if (facade == null)
        return;
    // create a new event for the facade table based on the actual event
    CyEvent<?> facadeEvent = null;
    if (event instanceof TableTitleChangedEvent) {
        TableTitleChangedEvent e = (TableTitleChangedEvent) event;
        facadeEvent = new TableTitleChangedEvent(facade, e.getOldTitle());
    } else if (event instanceof TablePrivacyChangedEvent) {
        facadeEvent = new TablePrivacyChangedEvent(facade);
    } else if (event instanceof ColumnNameChangedEvent) {
        ColumnNameChangedEvent e = (ColumnNameChangedEvent) event;
        facadeEvent = new ColumnNameChangedEvent(facade, e.getOldColumnName(), e.getNewColumnName());
    } else if (event instanceof ColumnDeletedEvent) {
        ColumnDeletedEvent e = (ColumnDeletedEvent) event;
        facadeEvent = new ColumnDeletedEvent(facade, e.getColumnName());
    } else if (event instanceof ColumnCreatedEvent) {
        ColumnCreatedEvent e = (ColumnCreatedEvent) event;
        facadeEvent = new ColumnCreatedEvent(facade, e.getColumnName());
    }
    // fire the new facade event
    if (facadeEvent != null)
        eventHelper.fireEvent(facadeEvent);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) CyTable(org.cytoscape.model.CyTable) TableTitleChangedEvent(org.cytoscape.model.events.TableTitleChangedEvent) ColumnNameChangedEvent(org.cytoscape.model.events.ColumnNameChangedEvent) ColumnDeletedEvent(org.cytoscape.model.events.ColumnDeletedEvent) TablePrivacyChangedEvent(org.cytoscape.model.events.TablePrivacyChangedEvent) ColumnCreatedEvent(org.cytoscape.model.events.ColumnCreatedEvent)

Example 2 with ColumnNameChangedEvent

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

the class CyTableImpl method updateColumnName.

void updateColumnName(final String oldColumnName, final String newColumnName) {
    synchronized (lock) {
        if (currentlyActiveAttributes.remove(oldColumnName)) {
            currentlyActiveAttributes.add(newColumnName);
        }
        String normalizedOldColName = normalizeColumnName(oldColumnName);
        String normalizedNewColName = normalizeColumnName(newColumnName);
        final ColumnData keyValuePairs = attributes.get(normalizedOldColName);
        if (keyValuePairs != null) {
            attributes.remove(normalizedOldColName);
            attributes.put(normalizedNewColName, keyValuePairs);
        }
        final CyColumn column = types.get(normalizedOldColName);
        types.remove(normalizedOldColName);
        types.put(normalizedNewColName, column);
        final VirtualColumn virtualColumn = virtualColumnMap.get(normalizedOldColName);
        if (virtualColumn != null) {
            virtualColumnMap.remove(normalizedOldColName);
            virtualColumnMap.put(normalizedNewColName, virtualColumn);
        }
        final Set<CyColumn> columnDependents = dependents.get(normalizedOldColName);
        if (columnDependents != null) {
            dependents.remove(normalizedOldColName);
            dependents.put(normalizedNewColName, columnDependents);
        }
    }
    eventHelper.fireEvent(new ColumnNameChangedEvent(this, oldColumnName, newColumnName));
}
Also used : ColumnNameChangedEvent(org.cytoscape.model.events.ColumnNameChangedEvent) CyColumn(org.cytoscape.model.CyColumn) ColumnData(org.cytoscape.model.internal.column.ColumnData)

Aggregations

ColumnNameChangedEvent (org.cytoscape.model.events.ColumnNameChangedEvent)2 CyEventHelper (org.cytoscape.event.CyEventHelper)1 CyColumn (org.cytoscape.model.CyColumn)1 CyTable (org.cytoscape.model.CyTable)1 ColumnCreatedEvent (org.cytoscape.model.events.ColumnCreatedEvent)1 ColumnDeletedEvent (org.cytoscape.model.events.ColumnDeletedEvent)1 TablePrivacyChangedEvent (org.cytoscape.model.events.TablePrivacyChangedEvent)1 TableTitleChangedEvent (org.cytoscape.model.events.TableTitleChangedEvent)1 ColumnData (org.cytoscape.model.internal.column.ColumnData)1