use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
CyEventHelper cyEventHelperRef = getService(bc, CyEventHelper.class);
CyNetworkNaming cyNetworkNamingServiceRef = getService(bc, CyNetworkNaming.class);
UndoSupport undoSupportServiceRef = getService(bc, UndoSupport.class);
CyNetworkViewFactory cyNetworkViewFactoryServiceRef = getService(bc, CyNetworkViewFactory.class);
CyNetworkFactory cyNetworkFactoryServiceRef = getService(bc, CyNetworkFactory.class);
CyRootNetworkManager cyRootNetworkFactoryServiceRef = getService(bc, CyRootNetworkManager.class);
VisualMappingManager visualMappingManagerServiceRef = getService(bc, VisualMappingManager.class);
CyNetworkViewWriterManager networkViewWriterManagerServiceRef = getService(bc, CyNetworkViewWriterManager.class);
CyNetworkManager cyNetworkManagerServiceRef = getService(bc, CyNetworkManager.class);
CyNetworkViewManager cyNetworkViewManagerServiceRef = getService(bc, CyNetworkViewManager.class);
CyApplicationManager cyApplicationManagerServiceRef = getService(bc, CyApplicationManager.class);
CySessionManager cySessionManagerServiceRef = getService(bc, CySessionManager.class);
CyTableFactory cyTableFactoryServiceRef = getService(bc, CyTableFactory.class);
CyTableManager cyTableManagerServiceRef = getService(bc, CyTableManager.class);
CyLayoutAlgorithmManager cyLayoutsServiceRef = getService(bc, CyLayoutAlgorithmManager.class);
CyTableWriterManager cyTableWriterManagerRef = getService(bc, CyTableWriterManager.class);
SynchronousTaskManager<?> synchronousTaskManagerServiceRef = getService(bc, SynchronousTaskManager.class);
TunableSetter tunableSetterServiceRef = getService(bc, TunableSetter.class);
CyRootNetworkManager rootNetworkManagerServiceRef = getService(bc, CyRootNetworkManager.class);
CyNetworkTableManager cyNetworkTableManagerServiceRef = getService(bc, CyNetworkTableManager.class);
RenderingEngineManager renderingEngineManagerServiceRef = getService(bc, RenderingEngineManager.class);
CyNetworkViewFactory nullNetworkViewFactory = getService(bc, CyNetworkViewFactory.class, "(id=NullCyNetworkViewFactory)");
CyGroupManager cyGroupManager = getService(bc, CyGroupManager.class);
CyGroupFactory cyGroupFactory = getService(bc, CyGroupFactory.class);
{
DynamicTaskFactoryProvisionerImpl factory = new DynamicTaskFactoryProvisionerImpl(serviceRegistrar);
registerAllServices(bc, factory);
}
createPreferencesTaskFactories(bc, serviceRegistrar);
createFilterTaskFactories(bc, serviceRegistrar);
createTableTaskFactories(bc, serviceRegistrar, undoSupportServiceRef, cyNetworkManagerServiceRef, cyApplicationManagerServiceRef, cyTableFactoryServiceRef, cyTableManagerServiceRef, cyTableWriterManagerRef, tunableSetterServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef);
createNetworkTaskFactories(bc, serviceRegistrar, cyEventHelperRef, cyNetworkNamingServiceRef, undoSupportServiceRef, cyNetworkViewFactoryServiceRef, cyNetworkFactoryServiceRef, cyRootNetworkFactoryServiceRef, visualMappingManagerServiceRef, cyNetworkManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, synchronousTaskManagerServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef, renderingEngineManagerServiceRef, nullNetworkViewFactory, cyGroupManager, cyGroupFactory, networkViewWriterManagerServiceRef, tunableSetterServiceRef);
createViewTaskFactories(bc, cyEventHelperRef, undoSupportServiceRef, visualMappingManagerServiceRef, networkViewWriterManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, cyLayoutsServiceRef, tunableSetterServiceRef, renderingEngineManagerServiceRef, cyNetworkManagerServiceRef, cySessionManagerServiceRef, serviceRegistrar);
createVizmapTaskFactories(bc, serviceRegistrar);
createSessionTaskFactories(bc, serviceRegistrar);
createGroupTaskFactories(bc, undoSupportServiceRef, cyApplicationManagerServiceRef, cyGroupManager, cyGroupFactory, serviceRegistrar);
createNodeEdgeTaskFactories(bc, serviceRegistrar, cyEventHelperRef, undoSupportServiceRef, cyNetworkViewManagerServiceRef, tunableSetterServiceRef, cyApplicationManagerServiceRef, cyTableManagerServiceRef, renderingEngineManagerServiceRef, visualMappingManagerServiceRef);
createLayoutTaskFactories(bc, serviceRegistrar);
createHelpTaskFactories(bc, serviceRegistrar);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class UnHideTask method run.
@Override
public void run(TaskMonitor e) {
e.setProgress(0.0);
final CyNetwork network = view.getModel();
final List<CyIdentifiable> elements = new ArrayList<>();
nodes = null;
edges = null;
e.setProgress(0.1);
if (unhideNodes) {
nodes = network.getNodeList();
elements.addAll(nodes);
}
if (unhideEdges) {
edges = network.getEdgeList();
elements.addAll(edges);
}
e.setProgress(0.2);
final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
undoSupport.postEdit(new HideEdit(description, view, elements, true, eventHelper, vmMgr));
e.setProgress(0.3);
if (nodes != null)
HideUtils.setVisibleNodes(nodes, true, view);
e.setProgress(0.5);
if (edges != null)
HideUtils.setVisibleEdges(edges, true, view);
e.setProgress(0.7);
vmMgr.getVisualStyle(view).apply(view);
view.updateView();
e.setProgress(1.0);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class RenameNodeTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
if (node == null)
return;
CyRow nodeRow = net.getRow(node);
String oldName = nodeRow.get(CyNetwork.NAME, String.class);
nodeRow.set(CyNetwork.NAME, newName);
nodeRow.set(CyRootNetwork.SHARED_NAME, newName);
final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
undoSupport.postEdit(new RenameNodeEdit(net, node, oldName, newName));
}
use of org.cytoscape.work.undo.UndoSupport 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.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class DeselectAllEdgesTaskTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
Set<CyRow> selectedEdges = new HashSet<CyRow>();
selectedEdges.add(r1);
selectedEdges.add(r2);
when(edgeTable.getMatchingRows(CyNetwork.SELECTED, true)).thenReturn(selectedEdges);
// run the task
Task t = new DeselectAllEdgesTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
verify(r1, times(1)).set("selected", false);
verify(r2, times(1)).set("selected", false);
}
Aggregations