Search in sources :

Example 6 with DialogTaskManager

use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.

the class RetrieveTask method setVisible.

@Override
public void setVisible(boolean b) {
    if (b) {
        DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
        taskMgr.execute(new TaskIterator(new RetrieveTask(webQuerier, textPane, appManager)));
        pack();
    }
    super.setVisible(b);
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 7 with DialogTaskManager

use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.

the class PopupMenuHelper method createNetworkViewMenu.

/**
 * Creates a menu based on the NetworkView.
 *
 * @param action Acceptable values are "NEW" or "OPEN." Case does not matter.
 */
void createNetworkViewMenu(Point rawPt, Point xformPt, String action) {
    Collection<NetworkViewTaskFactory> usableTFs = getPreferredActions(graphView.emptySpaceTFs, action);
    Collection<NetworkViewLocationTaskFactory> usableTFs2 = getPreferredActions(graphView.networkViewLocationTfs, action);
    Collection<CyNetworkViewContextMenuFactory> usableCMFs = getPreferredActions(graphView.cyNetworkViewContextMenuFactory, action);
    // remove TaskFactories that can't be executed from double-click menu
    if (action.equalsIgnoreCase("OPEN")) {
        Iterator<NetworkViewTaskFactory> i = usableTFs.iterator();
        while (i.hasNext()) {
            if (!i.next().isReady(graphView))
                i.remove();
        }
        Iterator<NetworkViewLocationTaskFactory> i2 = usableTFs2.iterator();
        while (i2.hasNext()) {
            if (!i2.next().isReady(graphView, rawPt, xformPt))
                i2.remove();
        }
    }
    int menuItemCount = usableTFs.size() + usableTFs2.size() + usableCMFs.size();
    int tfCount = usableTFs.size() + usableTFs2.size();
    if (action.equalsIgnoreCase("OPEN") && menuItemCount == 1 && tfCount == 1) {
        // Double click on open space and there is only one menu item, execute it
        final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
        if (usableTFs.size() == 1) {
            NetworkViewTaskFactory tf = usableTFs.iterator().next();
            taskManager.execute(tf.createTaskIterator(graphView));
        } else if (usableTFs2.size() == 1) {
            NetworkViewLocationTaskFactory tf = usableTFs2.iterator().next();
            taskManager.execute(tf.createTaskIterator(graphView, rawPt, xformPt));
        }
    } else {
        final JPopupMenu menu = createMenu("Double Click Menu: empty");
        final JMenuTracker tracker = new JMenuTracker(menu);
        if (!action.equalsIgnoreCase("OPEN")) {
            initializeNetworkTracker(tracker);
            tracker.getGravityTracker(".").addMenuSeparator(-0.1);
            tracker.getGravityTracker(".").addMenuSeparator(999.99);
        }
        for (NetworkViewTaskFactory nvtf : usableTFs) {
            NamedTaskFactory provisioner = factoryProvisioner.createFor(nvtf, graphView);
            addMenuItem(null, menu, provisioner, null, tracker, graphView.emptySpaceTFs.get(nvtf));
        }
        for (NetworkViewLocationTaskFactory nvltf : usableTFs2) {
            NamedTaskFactory provisioner = factoryProvisioner.createFor(nvltf, graphView, rawPt, xformPt);
            addMenuItem(null, menu, provisioner, null, tracker, graphView.networkViewLocationTfs.get(nvltf));
        }
        for (CyNetworkViewContextMenuFactory netVMF : usableCMFs) {
            try {
                CyMenuItem menuItem = netVMF.createMenuItem(graphView);
                addCyMenuItem(graphView, menu, menuItem, tracker, graphView.cyNetworkViewContextMenuFactory.get(netVMF));
            } catch (Throwable t) {
                logger.error("Could not display context menu.", t);
            }
        }
        // There are more than one menu item, let user make the selection
        menu.show(invoker, (int) (rawPt.getX()), (int) (rawPt.getY()));
    }
}
Also used : CyMenuItem(org.cytoscape.application.swing.CyMenuItem) JMenuTracker(org.cytoscape.util.swing.JMenuTracker) NetworkViewLocationTaskFactory(org.cytoscape.task.NetworkViewLocationTaskFactory) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) Point(java.awt.Point) JPopupMenu(javax.swing.JPopupMenu) CyNetworkViewContextMenuFactory(org.cytoscape.application.swing.CyNetworkViewContextMenuFactory) NetworkViewTaskFactory(org.cytoscape.task.NetworkViewTaskFactory)

Example 8 with DialogTaskManager

use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.

the class TaskFactoryTunableAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent a) {
    logger.debug("About to execute task from factory: " + factory.toString());
    // execute the task(s) in a separate thread
    final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
    taskManager.execute(factory.createTaskIterator());
}
Also used : DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 9 with DialogTaskManager

use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.

the class WebServiceImportDialog method searchButtonActionPerformed.

private void searchButtonActionPerformed() {
    final Object selected = datasourceComboBox.getSelectedItem();
    if (selected == null)
        return;
    WebServiceClient client = null;
    if (selected instanceof WebServiceClient) {
        client = (WebServiceClient) selected;
    } else {
        throw new IllegalStateException("Selected client is not a compatible one.");
    }
    final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
    // Set query. Just pass the text in the panel.
    taskManager.execute(client.createTaskIterator(this.queryTextPane.getText()));
}
Also used : WebServiceClient(org.cytoscape.io.webservice.WebServiceClient) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 10 with DialogTaskManager

use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.

the class DestroyNetworkViewsAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
    final CyNetworkViewManager netViewManager = serviceRegistrar.getService(CyNetworkViewManager.class);
    final Set<CyNetworkView> views = new HashSet<>();
    for (CyNetwork n : networks) views.addAll(netViewManager.getNetworkViews(n));
    if (!views.isEmpty()) {
        final DestroyNetworkViewTaskFactory factory = serviceRegistrar.getService(DestroyNetworkViewTaskFactory.class);
        final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
        taskManager.execute(factory.createTaskIterator(views));
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) DestroyNetworkViewTaskFactory(org.cytoscape.task.destroy.DestroyNetworkViewTaskFactory) CyNetwork(org.cytoscape.model.CyNetwork) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet)

Aggregations

DialogTaskManager (org.cytoscape.work.swing.DialogTaskManager)22 CyNetworkView (org.cytoscape.view.model.CyNetworkView)7 CyNetwork (org.cytoscape.model.CyNetwork)6 HashSet (java.util.HashSet)4 CyApplicationManager (org.cytoscape.application.CyApplicationManager)4 CreateNetworkViewTaskFactory (org.cytoscape.task.create.CreateNetworkViewTaskFactory)4 VizMapperProxy (org.cytoscape.view.vizmap.gui.internal.model.VizMapperProxy)4 TaskIterator (org.cytoscape.work.TaskIterator)4 DestroyNetworkViewTaskFactory (org.cytoscape.task.destroy.DestroyNetworkViewTaskFactory)3 BorderLayout (java.awt.BorderLayout)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JPopupMenu (javax.swing.JPopupMenu)2 CyIdentifiable (org.cytoscape.model.CyIdentifiable)2 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)2 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)2 DeleteTableTaskFactory (org.cytoscape.task.destroy.DeleteTableTaskFactory)2 DestroyNetworkTaskFactory (org.cytoscape.task.destroy.DestroyNetworkTaskFactory)2