use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class CySessionManagerImpl method disposeCurrentSession.
@Override
public void disposeCurrentSession() {
logger.debug("Disposing current session...");
// Destroy network views
final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
final Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
for (final CyNetworkView nv : netViews) nvMgr.destroyNetworkView(nv);
nvMgr.reset();
// Destroy networks
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
final Set<CyNetwork> networks = netMgr.getNetworkSet();
for (final CyNetwork n : networks) netMgr.destroyNetwork(n);
netMgr.reset();
// Destroy styles
logger.debug("Removing current visual styles...");
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
final VisualStyle defaultStyle = vmMgr.getDefaultVisualStyle();
final List<VisualStyle> allStyles = new ArrayList<>(vmMgr.getAllVisualStyles());
for (final VisualStyle vs : allStyles) {
if (!vs.equals(defaultStyle))
vmMgr.removeVisualStyle(vs);
}
// Destroy tables
final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
tblMgr.reset();
// Reset groups
serviceRegistrar.getService(CyGroupManager.class).reset();
// Unregister session properties
final Set<CyProperty<?>> cyPropsClone = getAllProperties();
for (CyProperty<?> cyProps : cyPropsClone) {
if (cyProps.getSavePolicy().equals(CyProperty.SavePolicy.SESSION_FILE)) {
serviceRegistrar.unregisterAllServices(cyProps);
sessionProperties.remove(cyProps.getName());
}
}
// Clear undo stack
serviceRegistrar.getService(UndoSupport.class).reset();
// Reset current table and rendering engine
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
appMgr.reset();
currentFileName = null;
disposed = true;
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class LayoutMenuPopulator method checkEnabled.
private boolean checkEnabled() {
CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
CyNetwork network = appMgr.getCurrentNetwork();
if (network == null)
return false;
CyNetworkView view = appMgr.getCurrentNetworkView();
if (view == null)
return false;
else
return true;
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class EnhancedSearchPanel method doSearching.
// Do searching based on the query string from user on text-field
private void doSearching() {
final String queryStr = tfSearchText.getText().trim();
// Ignore if the search term is empty
if (queryStr == null || queryStr.length() == 0)
return;
final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetwork currentNetwork = appManager.getCurrentNetwork();
if (currentNetwork != null) {
final SearchTaskFactory factory = new SearchTaskFactory(searchMgr, queryStr, serviceRegistrar);
final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
taskMgr.execute(factory.createTaskIterator(currentNetwork));
} else {
logger.error("Could not find network for search");
}
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class ExportSelectedNetworkTaskFactoryImpl method createTaskIterator.
@Override
public TaskIterator createTaskIterator() {
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
CyNetworkView view = applicationManager.getCurrentNetworkView();
if (view != null)
return getExportNetworkViewTaskFactory().createTaskIterator(view);
CyNetwork network = applicationManager.getCurrentNetwork();
if (network != null)
return getExportNetworkTaskFactory().createTaskIterator(network);
return null;
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class PopupMenuHelper method selectElementsFromSelectedRows.
private void selectElementsFromSelectedRows(final JTable table, final Class<? extends CyIdentifiable> tableType) {
final Thread t = new Thread() {
@Override
public void run() {
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetwork net = applicationManager.getCurrentNetwork();
if (net != null) {
final BrowserTableModel tableModel = (BrowserTableModel) table.getModel();
final int[] selectedRows = table.getSelectedRows();
final Set<CyRow> targetRows = new HashSet<CyRow>();
for (final int rowIndex : selectedRows) {
// 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) tableModel.getValueAt(table.convertRowIndexToModel(rowIndex), CyNetwork.SUID);
targetRows.add(tableModel.getRow(selected.getValidatedObject()));
}
final CyTable cyTable = tableType == CyNode.class ? net.getDefaultNodeTable() : net.getDefaultEdgeTable();
for (final CyRow cyRow : cyTable.getAllRows()) cyRow.set(CyNetwork.SELECTED, targetRows.contains(cyRow));
final CyNetworkView view = applicationManager.getCurrentNetworkView();
if (view != null) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.flushPayloadEvents();
view.updateView();
}
}
}
};
t.start();
}
Aggregations