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);
}
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();
}
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());
});
}
}
}
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));
}
}
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;
}
Aggregations