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