Search in sources :

Example 1 with ColumnElement

use of org.cytoscape.filter.internal.filters.column.ColumnElement in project cytoscape-impl by cytoscape.

the class ModelMonitor method handleEvent.

@Override
public void handleEvent(ColumnNameChangedEvent event) {
    synchronized (lock) {
        if (network == null) {
            return;
        }
        CyTable nodeTable = network.getDefaultNodeTable();
        CyTable edgeTable = network.getDefaultEdgeTable();
        CyTable table = event.getSource();
        CyColumn column = table.getColumn(event.getNewColumnName());
        Class<?> type;
        if (table == nodeTable) {
            type = CyNode.class;
        } else if (table == edgeTable) {
            type = CyEdge.class;
        } else {
            return;
        }
        for (int i = 0; i < columnNames.size(); i++) {
            ColumnElement element = columnNames.get(i);
            if (element.getName().equals(event.getOldColumnName()) && type.equals(element.getTableType())) {
                columnNames.remove(i);
                columnNames.add(new ColumnElement(element.getTableType(), column));
                break;
            }
        }
        Collections.sort(columnNames);
        updateColumnViews();
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyColumn(org.cytoscape.model.CyColumn) ColumnElement(org.cytoscape.filter.internal.filters.column.ColumnElement) CyEdge(org.cytoscape.model.CyEdge)

Example 2 with ColumnElement

use of org.cytoscape.filter.internal.filters.column.ColumnElement in project cytoscape-impl by cytoscape.

the class ModelMonitor method addFilterElements.

private void addFilterElements(CyTable table, Class<? extends CyIdentifiable> type) {
    if (table == null) {
        return;
    }
    for (CyColumn column : table.getColumns()) {
        Class<?> elementType = column.getType();
        Class<?> listElementType = column.getListElementType();
        if (List.class.equals(elementType) && (String.class.equals(listElementType) || Number.class.isAssignableFrom(listElementType) || Boolean.class.equals(listElementType))) {
            columnNames.add(new ColumnElement(type, column));
        } else if (String.class.equals(elementType) || Number.class.isAssignableFrom(elementType) || Boolean.class.equals(elementType)) {
            columnNames.add(new ColumnElement(type, column));
        }
    }
}
Also used : CyColumn(org.cytoscape.model.CyColumn) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ColumnElement(org.cytoscape.filter.internal.filters.column.ColumnElement)

Example 3 with ColumnElement

use of org.cytoscape.filter.internal.filters.column.ColumnElement in project cytoscape-impl by cytoscape.

the class ModelMonitor method handleEvent.

@Override
public void handleEvent(ColumnCreatedEvent event) {
    synchronized (lock) {
        if (network == null) {
            return;
        }
        CyTable nodeTable = network.getDefaultNodeTable();
        CyTable edgeTable = network.getDefaultEdgeTable();
        CyTable table = event.getSource();
        Class<?> type;
        if (table == nodeTable) {
            type = CyNode.class;
        } else if (table == edgeTable) {
            type = CyEdge.class;
        } else {
            return;
        }
        CyColumn column = table.getColumn(event.getColumnName());
        columnNames.add(new ColumnElement(type, column));
        Collections.sort(columnNames);
        updateColumnViews();
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyColumn(org.cytoscape.model.CyColumn) ColumnElement(org.cytoscape.filter.internal.filters.column.ColumnElement) CyEdge(org.cytoscape.model.CyEdge)

Example 4 with ColumnElement

use of org.cytoscape.filter.internal.filters.column.ColumnElement in project cytoscape-impl by cytoscape.

the class ModelMonitor method handleEvent.

@Override
public void handleEvent(ColumnDeletedEvent event) {
    synchronized (lock) {
        if (network == null) {
            return;
        }
        CyTable nodeTable = network.getDefaultNodeTable();
        CyTable edgeTable = network.getDefaultEdgeTable();
        CyTable table = event.getSource();
        Class<?> type;
        if (table == nodeTable) {
            type = CyNode.class;
        } else if (table == edgeTable) {
            type = CyEdge.class;
        } else {
            return;
        }
        for (int i = 0; i < columnNames.size(); i++) {
            ColumnElement element = columnNames.get(i);
            if (element.getName().equals(event.getColumnName()) && type.equals(element.getTableType())) {
                columnNames.remove(i);
                break;
            }
        }
        updateColumnViews();
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) ColumnElement(org.cytoscape.filter.internal.filters.column.ColumnElement) CyEdge(org.cytoscape.model.CyEdge)

Aggregations

ColumnElement (org.cytoscape.filter.internal.filters.column.ColumnElement)4 CyColumn (org.cytoscape.model.CyColumn)3 CyEdge (org.cytoscape.model.CyEdge)3 CyTable (org.cytoscape.model.CyTable)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1