use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.
the class CySessionManagerImpl method restoreTables.
private void restoreTables(final CySession sess) {
final Set<CyTable> allTables = new HashSet<>();
// Register all tables sent through the CySession, if not already registered
for (final CyTableMetadata metadata : sess.getTables()) {
allTables.add(metadata.getTable());
}
// There may be other network tables in the CyNetworkTableManager that were not serialized in the session file
// (e.g. Table Facades), so it's necessary to add them to CyTableManager as well
final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
for (final CyNetwork net : sess.getNetworks()) {
allTables.addAll(netTblMgr.getTables(net, CyNetwork.class).values());
allTables.addAll(netTblMgr.getTables(net, CyNode.class).values());
allTables.addAll(netTblMgr.getTables(net, CyEdge.class).values());
if (!(net instanceof CyRootNetwork)) {
final CyRootNetwork root = rootNetMgr.getRootNetwork(net);
allTables.addAll(netTblMgr.getTables(root, CyNetwork.class).values());
allTables.addAll(netTblMgr.getTables(root, CyNode.class).values());
allTables.addAll(netTblMgr.getTables(root, CyEdge.class).values());
}
}
// Register all tables sent through the CySession, if not already registered
final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
for (final CyTable tbl : allTables) {
if (tblMgr.getTable(tbl.getSUID()) == null)
tblMgr.addTable(tbl);
}
}
use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.
the class Util method maybeOpenSession.
public static void maybeOpenSession(File file, Component owner, CyServiceRegistrar serviceRegistrar, TaskObserver observer) {
if (file.exists() && file.canRead()) {
final CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
if (netManager.getNetworkSet().isEmpty() && tableManager.getAllTables(false).isEmpty())
openSession(file, serviceRegistrar, observer);
else
openSessionWithWarning(file, owner, serviceRegistrar, observer);
}
}
use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.
the class CytoscapeDesktop method handleEvent.
@Override
public void handleEvent(AppsFinishedStartingEvent e) {
invokeOnEDT(() -> {
// Only show Starter Panel the first time if the initial session is empty
// (for instance, Cystoscape can start up with a session file specified through the terminal)
final CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
if (netManager.getNetworkSet().isEmpty() && tableManager.getAllTables(false).isEmpty())
showStarterPanel();
});
}
use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.
the class BrowserTable method selectFromTable.
private void selectFromTable() {
final TableModel model = this.getModel();
if (model instanceof BrowserTableModel == false)
return;
final BrowserTableModel btModel = (BrowserTableModel) model;
if (btModel.getViewMode() != BrowserTableModel.ViewMode.ALL)
return;
final CyTable table = btModel.getDataTable();
final CyColumn pKey = table.getPrimaryKey();
final String pKeyName = pKey.getName();
final int[] rowsSelected = getSelectedRows();
if (rowsSelected.length == 0)
return;
final int selectedRowCount = getSelectedRowCount();
final Set<CyRow> targetRows = new HashSet<CyRow>();
for (int i = 0; i < selectedRowCount; i++) {
// getting the row from data table solves the problem with hidden or
// moved SUID column. However, since the rows might be sorted we
// need to convert the index to model
final ValidatedObjectAndEditString selected = (ValidatedObjectAndEditString) btModel.getValueAt(convertRowIndexToModel(rowsSelected[i]), pKeyName);
targetRows.add(btModel.getRow(selected.getValidatedObject()));
}
// Clear selection for non-global table
final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
if (tableManager.getGlobalTables().contains(table) == false) {
List<CyRow> allRows = btModel.getDataTable().getAllRows();
try {
ignoreRowSetEvents = true;
for (CyRow row : allRows) {
final Boolean val = row.get(CyNetwork.SELECTED, Boolean.class);
if (targetRows.contains(row)) {
row.set(CyNetwork.SELECTED, true);
continue;
}
if (val != null && (val == true))
row.set(CyNetwork.SELECTED, false);
}
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetworkView curView = applicationManager.getCurrentNetworkView();
if (curView != null) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.flushPayloadEvents();
curView.updateView();
}
} finally {
ignoreRowSetEvents = false;
}
repaint();
}
}
use of org.cytoscape.model.CyTableManager in project cytoscape-impl by cytoscape.
the class DefaultTableBrowser method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
if (!ignoreSetCurrentTable) {
final CyTable table = (CyTable) getTableChooser().getSelectedItem();
currentTable = table;
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
if (table != null && !table.equals(applicationManager.getCurrentTable())) {
final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
if (tableManager.getTable(table.getSUID()) != null)
applicationManager.setCurrentTable(table);
}
showSelectedTable();
changeSelectionMode();
}
}
Aggregations