Search in sources :

Example 21 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class DefaultTableBrowser method handleEvent.

@Override
public void handleEvent(final TableAboutToBeDeletedEvent e) {
    final CyTable cyTable = e.getTable();
    final BrowserTable table = getBrowserTable(cyTable);
    if (table != null) {
        ((DefaultComboBoxModel<CyTable>) getTableChooser().getModel()).removeElement(cyTable);
        // We need this to happen synchronously or we get royally messed up by the new table selection
        invokeOnEDTAndWait(() -> {
            getToolBar().updateEnableState(getTableChooser());
            removeTable(cyTable);
        });
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 22 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class FormulaBuilderDialog method updateCells.

private boolean updateCells(final StringBuilder errorMessage) {
    String formula = getFormulaTextField().getText();
    if (formula.charAt(formula.length() - 1) != ')')
        formula = formula + ")";
    final int cellColum = table.convertColumnIndexToModel(table.getSelectedColumn());
    final String attribName = tableModel.getColumnName(cellColum);
    final CyTable attribs = tableModel.getDataTable();
    final Equation equation = compileEquation(attribs, attribName, formula, errorMessage);
    if (equation == null)
        return false;
    switch(applicationDomain) {
        case CURRENT_CELL:
            final int cellRow = table.convertRowIndexToModel(table.getSelectedRow());
            tableModel.setValueAt(formula, cellRow, cellColum);
            break;
        case CURRENT_SELECTION:
            final Collection<CyRow> selectedRows = tableModel.getDataTable().getMatchingRows(CyNetwork.SELECTED, true);
            for (final CyRow selectedRow : selectedRows) {
                if (!setAttribute(selectedRow, attribName, equation, errorMessage))
                    return false;
            }
            break;
        case ENTIRE_ATTRIBUTE:
            final List<CyRow> rows = tableModel.getDataTable().getAllRows();
            for (final CyRow row : rows) {
                if (!setAttribute(row, attribName, equation, errorMessage))
                    return false;
            }
            break;
        default:
            throw new IllegalStateException("unknown application domain: " + applicationDomain + ".");
    }
    return true;
}
Also used : CyTable(org.cytoscape.model.CyTable) Equation(org.cytoscape.equations.Equation) CyRow(org.cytoscape.model.CyRow)

Example 23 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class TableChooserCellRenderer method getListCellRendererComponent.

@Override
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
    } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
    }
    if (value instanceof CyTable == false) {
        setText("-- No Table --");
        return this;
    }
    final CyTable table = (CyTable) value;
    String label = tableToStringMap.get(table);
    if (label == null)
        label = table == null ? "-- No Table --" : table.getTitle();
    if (!label.toLowerCase().contains("table"))
        label += " Table";
    if (table != null && !table.isPublic())
        label += " [ PRIVATE ]";
    setText(label);
    if (!isSelected)
        setForeground(table.isPublic() ? list.getForeground() : LookAndFeelUtil.getErrorColor());
    return this;
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 24 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class BrowserTable method handleEvent.

@Override
public void handleEvent(final ColumnNameChangedEvent e) {
    BrowserTableModel model = (BrowserTableModel) getModel();
    CyTable dataTable = model.getDataTable();
    if (e.getSource() != dataTable)
        return;
    renameColumnName(e.getOldColumnName(), e.getNewColumnName());
    if (SwingUtilities.isEventDispatchThread()) {
        tableHeader.repaint();
    } else {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                tableHeader.repaint();
            }
        });
    }
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 25 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class BrowserTable method handleEvent.

@Override
public void handleEvent(final RowsSetEvent e) {
    if (isEditing()) {
        getCellEditor().stopCellEditing();
    }
    if (ignoreRowSetEvents)
        return;
    final BrowserTableModel model = (BrowserTableModel) getModel();
    final CyTable dataTable = model.getDataTable();
    if (e.getSource() != dataTable)
        return;
    if (model.getViewMode() == BrowserTableModel.ViewMode.SELECTED || model.getViewMode() == BrowserTableModel.ViewMode.AUTO) {
        model.clearSelectedRows();
        boolean foundANonSelectedColumnName = false;
        for (String column : e.getColumns()) {
            if (!CyNetwork.SELECTED.equals(column)) {
                foundANonSelectedColumnName = true;
                break;
            }
        }
        if (!foundANonSelectedColumnName) {
            model.fireTableDataChanged();
            return;
        }
    }
    final Collection<RowSetRecord> rows = e.getPayloadCollection();
    synchronized (this) {
        if (model.getViewMode() == BrowserTableModel.ViewMode.SELECTED || model.getViewMode() == BrowserTableModel.ViewMode.AUTO) {
            model.fireTableDataChanged();
        } else {
            final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
            if (!tableManager.getGlobalTables().contains(dataTable))
                bulkUpdate(rows);
        }
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyTableManager(org.cytoscape.model.CyTableManager) ValidatedObjectAndEditString(org.cytoscape.browser.internal.util.ValidatedObjectAndEditString)

Aggregations

CyTable (org.cytoscape.model.CyTable)282 CyNetwork (org.cytoscape.model.CyNetwork)79 CyRow (org.cytoscape.model.CyRow)73 CyColumn (org.cytoscape.model.CyColumn)71 ArrayList (java.util.ArrayList)55 CyNode (org.cytoscape.model.CyNode)43 CyEdge (org.cytoscape.model.CyEdge)35 Test (org.junit.Test)29 List (java.util.List)26 HashMap (java.util.HashMap)24 CyApplicationManager (org.cytoscape.application.CyApplicationManager)19 HashSet (java.util.HashSet)18 CyIdentifiable (org.cytoscape.model.CyIdentifiable)14 CyNetworkView (org.cytoscape.view.model.CyNetworkView)14 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)13 RowSetRecord (org.cytoscape.model.events.RowSetRecord)11 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)11 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)11 CyEventHelper (org.cytoscape.event.CyEventHelper)10 CyTableManager (org.cytoscape.model.CyTableManager)10