use of org.cytoscape.model.CyNetwork 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.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CreateNetworkViewsAction method updateEnableState.
@Override
public void updateEnableState() {
final List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
final List<CyNetwork> networksWithoutViews = new ArrayList<>();
final CyNetworkViewManager netViewManager = serviceRegistrar.getService(CyNetworkViewManager.class);
// TODO Remove when multiple views per network are fully supported
for (CyNetwork n : networks) {
if (!netViewManager.viewExists(n))
networksWithoutViews.add(n);
}
int count = networksWithoutViews.size();
if (count > 0)
setName("Create " + count + " View" + (count == 1 ? "" : "s"));
else
setName("Create Views");
setEnabled(count > 0);
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class ExportNetworkAction method updateEnableState.
@Override
public void updateEnableState() {
List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
CyNetwork currentNet = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetwork();
setEnabled(networks.size() == 1 && networks.get(0).equals(currentNet));
}
use of org.cytoscape.model.CyNetwork 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.model.CyNetwork 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");
}
}
Aggregations