Search in sources :

Example 16 with DialogTaskManager

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

the class CreateNetworkViewsAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
    if (!networks.isEmpty()) {
        final CreateNetworkViewTaskFactory factory = serviceRegistrar.getService(CreateNetworkViewTaskFactory.class);
        final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
        taskManager.execute(factory.createTaskIterator(networks));
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CreateNetworkViewTaskFactory(org.cytoscape.task.create.CreateNetworkViewTaskFactory) CyNetwork(org.cytoscape.model.CyNetwork) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 17 with DialogTaskManager

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

the class DestroyNetworksAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Set<CyNetwork> subNetworks = getSelectedSubNetworks();
    if (!subNetworks.isEmpty()) {
        final DestroyNetworkTaskFactory factory = serviceRegistrar.getService(DestroyNetworkTaskFactory.class);
        final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
        taskManager.execute(factory.createTaskIterator(subNetworks));
    }
}
Also used : DestroyNetworkTaskFactory(org.cytoscape.task.destroy.DestroyNetworkTaskFactory) CyNetwork(org.cytoscape.model.CyNetwork) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 18 with DialogTaskManager

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

the class NetworkViewMainPanel method createNetworkViewGrid.

private NetworkViewGrid createNetworkViewGrid() {
    final NetworkViewGrid nvg = new NetworkViewGrid(gridViewToggleModel, viewComparator, serviceRegistrar);
    nvg.getDetachSelectedViewsButton().addActionListener(evt -> {
        final List<ThumbnailPanel> selectedItems = networkViewGrid.getSelectedItems();
        if (selectedItems != null) {
            // Get the current view first
            final CyNetworkView currentView = getCurrentNetworkView();
            // Detach the views
            for (ThumbnailPanel tp : selectedItems) {
                if (getNetworkViewCard(tp.getNetworkView()) != null)
                    detachNetworkView(tp.getNetworkView());
            }
            // Set the original current view by bringing its frame to front, if it is detached
            final NetworkViewFrame frame = getNetworkViewFrame(currentView);
            if (frame != null)
                frame.toFront();
        }
    });
    nvg.getReattachAllViewsButton().addActionListener(evt -> {
        final Collection<NetworkViewFrame> allFrames = new ArrayList<>(viewFrames.values());
        for (NetworkViewFrame f : allFrames) reattachNetworkView(f.getNetworkView());
    });
    nvg.getDestroySelectedViewsButton().addActionListener(evt -> {
        final List<CyNetworkView> selectedViews = getSelectedNetworkViews();
        if (selectedViews != null && !selectedViews.isEmpty()) {
            final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
            final DestroyNetworkViewTaskFactory taskFactory = serviceRegistrar.getService(DestroyNetworkViewTaskFactory.class);
            taskMgr.execute(taskFactory.createTaskIterator(selectedViews));
        }
    });
    return nvg;
}
Also used : ArrayList(java.util.ArrayList) DestroyNetworkViewTaskFactory(org.cytoscape.task.destroy.DestroyNetworkViewTaskFactory) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) ThumbnailPanel(org.cytoscape.internal.view.NetworkViewGrid.ThumbnailPanel)

Example 19 with DialogTaskManager

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

the class NetworkSearchMediator method runSearch.

private void runSearch() {
    NetworkSearchTaskFactory tf = networkSearchBar.getSelectedProvider();
    if (tf != null && tf.isReady()) {
        DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
        TaskObserver taskObserver = tf.getTaskObserver();
        if (taskObserver != null)
            taskManager.execute(tf.createTaskIterator(), taskObserver);
        else
            taskManager.execute(tf.createTaskIterator());
    }
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) AbstractNetworkSearchTaskFactory(org.cytoscape.application.swing.search.AbstractNetworkSearchTaskFactory) NetworkSearchTaskFactory(org.cytoscape.application.swing.search.NetworkSearchTaskFactory) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 20 with DialogTaskManager

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

the class TableBrowserToolBar method removeTable.

private void removeTable() {
    final CyTable table = browserTableModel.getDataTable();
    if (table.getMutability() == CyTable.Mutability.MUTABLE) {
        String title = "Please confirm this action";
        String msg = "Are you sure you want to delete this table?";
        int confirmValue = JOptionPane.showConfirmDialog(this, msg, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        // if user selects yes delete the table
        if (confirmValue == JOptionPane.OK_OPTION) {
            final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
            final DeleteTableTaskFactory deleteTableTaskFactory = serviceRegistrar.getService(DeleteTableTaskFactory.class);
            taskMgr.execute(deleteTableTaskFactory.createTaskIterator(table));
        }
    } else if (table.getMutability() == CyTable.Mutability.PERMANENTLY_IMMUTABLE) {
        String title = "Error";
        String msg = "Can not delete this table, it is PERMANENTLY_IMMUTABLE";
        JOptionPane.showMessageDialog(this, msg, title, JOptionPane.ERROR_MESSAGE);
    } else if (table.getMutability() == CyTable.Mutability.IMMUTABLE_DUE_TO_VIRT_COLUMN_REFERENCES) {
        String title = "Error";
        String msg = "Can not delete this table, it is IMMUTABLE_DUE_TO_VIRT_COLUMN_REFERENCES";
        JOptionPane.showMessageDialog(this, msg, title, JOptionPane.ERROR_MESSAGE);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) DeleteTableTaskFactory(org.cytoscape.task.destroy.DeleteTableTaskFactory)

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