Search in sources :

Example 26 with CyTable

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

the class AbstractTableBrowser method handleEvent.

@Override
public void handleEvent(SessionAboutToBeSavedEvent e) {
    Map<CyTable, BrowserTable> browserTables = getAllBrowserTablesMap();
    List<TableColumnStat> tableColumnStatList = new ArrayList<>();
    for (CyTable table : browserTables.keySet()) {
        TableColumnStat tcs = new TableColumnStat(table.getTitle());
        BrowserTable browserTable = browserTables.get(table);
        BrowserTableModel model = (BrowserTableModel) browserTable.getModel();
        BrowserTableColumnModel colM = (BrowserTableColumnModel) browserTable.getColumnModel();
        List<String> visAttrs = browserTable.getVisibleAttributeNames();
        colM.setAllColumnsVisible();
        Collection<String> attrs = model.getAllAttributeNames();
        for (String name : attrs) {
            int viewIndex = browserTable.convertColumnIndexToView(model.mapColumnNameToColumnIndex(name));
            tcs.addColumnStat(name, viewIndex, visAttrs.contains(name));
        }
        browserTable.setVisibleAttributeNames(visAttrs);
        tableColumnStatList.add(tcs);
    }
    TableColumnStatFileIO.write(tableColumnStatList, e, appFileName);
}
Also used : CyTable(org.cytoscape.model.CyTable) TableColumnStat(org.cytoscape.browser.internal.util.TableColumnStat) ArrayList(java.util.ArrayList)

Example 27 with CyTable

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

the class GlobalTableBrowser method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final CyTable table = (CyTable) tableChooser.getSelectedItem();
    if (table == currentTable || table == null)
        return;
    currentTable = table;
    serviceRegistrar.getService(CyApplicationManager.class).setCurrentTable(table);
    showSelectedTable();
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable)

Example 28 with CyTable

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

the class GlobalTableBrowser method handleEvent.

/**
 * Switch to new table when it is registered to the table manager.
 *
 * Note: This combo box only displays Global Table.
 */
@Override
public void handleEvent(TableAddedEvent e) {
    final CyTable newTable = e.getTable();
    if (newTable.isPublic() || showPrivateTables()) {
        final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
        if (tableManager.getGlobalTables().contains(newTable)) {
            final GlobalTableComboBoxModel comboBoxModel = (GlobalTableComboBoxModel) tableChooser.getModel();
            comboBoxModel.addAndSetSelectedItem(newTable);
            getToolBar().updateEnableState(tableChooser);
        }
        if (tableChooser.getItemCount() == 1) {
            invokeOnEDT(() -> {
                serviceRegistrar.registerService(GlobalTableBrowser.this, CytoPanelComponent.class, new Properties());
            });
        }
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyTableManager(org.cytoscape.model.CyTableManager) Properties(java.util.Properties)

Example 29 with CyTable

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

the class ClearErrorsEdit method run.

@Override
public void run(final TaskMonitor tm) throws Exception {
    final CyTable table = column.getTable();
    final EquationCompiler compiler = serviceRegistrar.getService(EquationCompiler.class);
    final List<ErrorEquation> errorEquations = new ArrayList<>();
    for (CyRow row : table.getAllRows()) {
        if (cancelled)
            return;
        final Object raw = row.getRaw(column.getName());
        if (raw instanceof Equation) {
            final Equation eq = (Equation) raw;
            final boolean success = compiler.compile(eq.toString(), TableBrowserUtil.getAttNameToTypeMap(table, null));
            // TODO: success is incorrectly set to yes on broken equations [=ABS(String)]
            if (!success || row.get(column.getName(), column.getType()) == null)
                errorEquations.add(new ErrorEquation(row, column.getName(), eq));
        }
    }
    for (ErrorEquation err : errorEquations) {
        if (cancelled) {
            restoreDeletedEquations();
            return;
        }
        deletedEquations.add(err);
        err.clear();
    }
    if (!deletedEquations.isEmpty()) {
        final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
        undoSupport.postEdit(new ClearErrorsEdit(column.getName(), deletedEquations));
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) ArrayList(java.util.ArrayList) Equation(org.cytoscape.equations.Equation) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyRow(org.cytoscape.model.CyRow) UndoSupport(org.cytoscape.work.undo.UndoSupport)

Example 30 with CyTable

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

the class ClearAllErrorsTaskFactory method isReady.

@Override
public boolean isReady(final CyColumn column) {
    final CyTable table = column.getTable();
    final EquationCompiler compiler = serviceRegistrar.getService(EquationCompiler.class);
    for (CyRow row : table.getAllRows()) {
        final Object raw = row.getRaw(column.getName());
        if (raw instanceof Equation) {
            final Equation eq = (Equation) raw;
            final boolean success = compiler.compile(eq.toString(), TableBrowserUtil.getAttNameToTypeMap(table, null));
            // TODO: success is incorrectly set to yes on broken equations [=ABS(String)]
            if (!success || row.get(column.getName(), column.getType()) == null)
                return true;
        }
    }
    return false;
}
Also used : CyTable(org.cytoscape.model.CyTable) Equation(org.cytoscape.equations.Equation) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyRow(org.cytoscape.model.CyRow)

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