Search in sources :

Example 1 with UndoSupport

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);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyTableWriterManager(org.cytoscape.io.write.CyTableWriterManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTableFactory(org.cytoscape.model.CyTableFactory) TunableSetter(org.cytoscape.work.TunableSetter) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyTableManager(org.cytoscape.model.CyTableManager) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkViewWriterManager(org.cytoscape.io.write.CyNetworkViewWriterManager) CySessionManager(org.cytoscape.session.CySessionManager) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactory(org.cytoscape.group.CyGroupFactory) CyGroupManager(org.cytoscape.group.CyGroupManager)

Example 2 with UndoSupport

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);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 3 with UndoSupport

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));
}
Also used : CyRow(org.cytoscape.model.CyRow) UndoSupport(org.cytoscape.work.undo.UndoSupport)

Example 4 with UndoSupport

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));
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) ArrayList(java.util.ArrayList) Equation(org.cytoscape.equations.Equation) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyRow(org.cytoscape.model.CyRow) UndoSupport(org.cytoscape.work.undo.UndoSupport)

Example 5 with UndoSupport

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);
}
Also used : Task(org.cytoscape.work.Task) CyRow(org.cytoscape.model.CyRow) UndoSupport(org.cytoscape.work.undo.UndoSupport) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

UndoSupport (org.cytoscape.work.undo.UndoSupport)50 Test (org.junit.Test)21 Task (org.cytoscape.work.Task)19 CyEventHelper (org.cytoscape.event.CyEventHelper)15 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)15 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)12 HashSet (java.util.HashSet)10 TaskIterator (org.cytoscape.work.TaskIterator)10 CyNode (org.cytoscape.model.CyNode)9 ArrayList (java.util.ArrayList)8 CyEdge (org.cytoscape.model.CyEdge)7 CyNetwork (org.cytoscape.model.CyNetwork)7 CyNetworkView (org.cytoscape.view.model.CyNetworkView)7 CyRow (org.cytoscape.model.CyRow)6 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)6 Properties (java.util.Properties)5 CyNetworkManager (org.cytoscape.model.CyNetworkManager)5 CyApplicationManager (org.cytoscape.application.CyApplicationManager)4 CyGroupManager (org.cytoscape.group.CyGroupManager)4 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)4