use of org.cytoscape.model.events.ColumnDeletedEvent 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);
}
use of org.cytoscape.model.events.ColumnDeletedEvent in project cytoscape-impl by cytoscape.
the class CyTableImpl method deleteColumn.
@Override
public void deleteColumn(final String columnName) {
synchronized (lock) {
if (columnName == null)
throw new NullPointerException("\"columnName\" must not be null.");
final String normalizedColName = normalizeColumnName(columnName);
final CyColumn column = types.get(normalizedColName);
if (column == null)
return;
if (column.isImmutable())
throw new IllegalArgumentException("cannot delete immutable column \"" + columnName + "\".");
final VirtualColumn virtColumn = virtualColumnMap.get(normalizedColName);
if (attributes.containsKey(normalizedColName) || virtColumn != null) {
if (virtColumn != null) {
final CyColumn cyColumn = types.get(normalizedColName);
virtualColumnMap.remove(normalizedColName);
attributes.remove(normalizedColName);
types.remove(normalizedColName);
colList.remove(cyColumn);
VirtualColumnInfo info = cyColumn.getVirtualColumnInfo();
((CyTableImpl) info.getSourceTable()).removeDependent(info.getSourceColumn(), cyColumn);
} else {
attributes.remove(normalizedColName);
colList.remove(types.get(normalizedColName));
types.remove(normalizedColName);
}
}
}
// This event must be synchronous!
eventHelper.fireEvent(new ColumnDeletedEvent(this, columnName));
}
Aggregations