Search in sources :

Example 1 with DialogTaskManager

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

the class NetworkViewMainPanel method showExportPopup.

private void showExportPopup(JComponent source, CyNetworkView view) {
    DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
    final JPopupMenu popupMenu = new JPopupMenu();
    {
        final JMenuItem mi = new JMenuItem("Export as Network...");
        mi.addActionListener(evt -> {
            ExportNetworkViewTaskFactory factory = serviceRegistrar.getService(ExportNetworkViewTaskFactory.class);
            taskMgr.execute(factory.createTaskIterator(view));
        });
        popupMenu.add(mi);
    }
    {
        final JMenuItem mi = new JMenuItem("Export as Image...");
        mi.addActionListener(evt -> {
            ExportNetworkImageTaskFactory factory = serviceRegistrar.getService(ExportNetworkImageTaskFactory.class);
            taskMgr.execute(factory.createTaskIterator(view));
        });
        popupMenu.add(mi);
    }
    popupMenu.show(source, 0, source.getHeight());
}
Also used : UIManager(javax.swing.UIManager) ViewUtil.createUniqueKey(org.cytoscape.internal.util.ViewUtil.createUniqueKey) ComponentListener(java.awt.event.ComponentListener) WindowListener(java.awt.event.WindowListener) CyNetwork(org.cytoscape.model.CyNetwork) Map(java.util.Map) MouseAdapter(java.awt.event.MouseAdapter) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) JMenuBar(javax.swing.JMenuBar) RenderingEngineFactory(org.cytoscape.view.presentation.RenderingEngineFactory) GraphicsConfiguration(java.awt.GraphicsConfiguration) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) Collection(java.util.Collection) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) Component(java.awt.Component) WindowEvent(java.awt.event.WindowEvent) Dimension(java.awt.Dimension) List(java.util.List) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) ThumbnailPanel(org.cytoscape.internal.view.NetworkViewGrid.ThumbnailPanel) JPanel(javax.swing.JPanel) Toolkit(java.awt.Toolkit) ViewUtil.getTitle(org.cytoscape.internal.util.ViewUtil.getTitle) CreateNetworkViewTaskFactory(org.cytoscape.task.create.CreateNetworkViewTaskFactory) ViewUtil.isScreenMenuBar(org.cytoscape.internal.util.ViewUtil.isScreenMenuBar) CardLayout(java.awt.CardLayout) Mode(org.cytoscape.internal.view.GridViewToggleModel.Mode) ExportNetworkViewTaskFactory(org.cytoscape.task.write.ExportNetworkViewTaskFactory) HashMap(java.util.HashMap) KeyAdapter(java.awt.event.KeyAdapter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) AWTEvent(java.awt.AWTEvent) DestroyNetworkViewTaskFactory(org.cytoscape.task.destroy.DestroyNetworkViewTaskFactory) FocusAdapter(java.awt.event.FocusAdapter) SwingUtilities(javax.swing.SwingUtilities) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) ExportNetworkImageTaskFactory(org.cytoscape.task.write.ExportNetworkImageTaskFactory) JMenuItem(javax.swing.JMenuItem) LinkedHashSet(java.util.LinkedHashSet) JComponent(javax.swing.JComponent) Window(java.awt.Window) JPopupMenu(javax.swing.JPopupMenu) MouseEvent(java.awt.event.MouseEvent) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) KeyboardFocusManager(java.awt.KeyboardFocusManager) FocusEvent(java.awt.event.FocusEvent) CyNetworkView(org.cytoscape.view.model.CyNetworkView) RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) AWTEventListener(java.awt.event.AWTEventListener) Comparator(java.util.Comparator) Collections(java.util.Collections) ExportNetworkViewTaskFactory(org.cytoscape.task.write.ExportNetworkViewTaskFactory) ExportNetworkImageTaskFactory(org.cytoscape.task.write.ExportNetworkImageTaskFactory) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 2 with DialogTaskManager

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

the class NetworkViewMainPanel method init.

private void init() {
    setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, UIManager.getColor("Separator.foreground")));
    setLayout(new BorderLayout());
    add(getContentPane(), BorderLayout.CENTER);
    // Add Listeners
    nullViewPanel.getCreateViewButton().addActionListener(evt -> {
        if (nullViewPanel.getNetwork() instanceof CySubNetwork) {
            final CreateNetworkViewTaskFactory factory = serviceRegistrar.getService(CreateNetworkViewTaskFactory.class);
            final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
            taskManager.execute(factory.createTaskIterator(Collections.singleton(nullViewPanel.getNetwork())));
        }
    });
    nullViewPanel.getInfoIconLabel().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (!e.isPopupTrigger() && nullViewPanel.getNetworkView() != null) {
                final NetworkViewFrame frame = getNetworkViewFrame(nullViewPanel.getNetworkView());
                if (frame != null)
                    showViewFrame(frame);
            }
        }
    });
    nullViewPanel.getReattachViewButton().addActionListener(evt -> {
        if (nullViewPanel.getNetworkView() != null)
            reattachNetworkView(nullViewPanel.getNetworkView());
    });
    networkViewGrid.addPropertyChangeListener("selectedNetworkViews", evt -> {
        // Just fire the same event
        firePropertyChange("selectedNetworkViews", evt.getOldValue(), evt.getNewValue());
    });
    networkViewGrid.addPropertyChangeListener("currentNetworkView", evt -> {
        final CyNetworkView curView = (CyNetworkView) evt.getNewValue();
        for (NetworkViewContainer vc : getAllNetworkViewContainers()) vc.setCurrent(vc.getNetworkView().equals(curView));
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(mousePressedAWTEventListener, MouseEvent.MOUSE_EVENT_MASK);
    // Update
    updateGrid();
}
Also used : CreateNetworkViewTaskFactory(org.cytoscape.task.create.CreateNetworkViewTaskFactory) MouseEvent(java.awt.event.MouseEvent) BorderLayout(java.awt.BorderLayout) MouseAdapter(java.awt.event.MouseAdapter) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 3 with DialogTaskManager

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

the class Util method openSession.

public static void openSession(File file, CyServiceRegistrar serviceRegistrar, TaskObserver observer) {
    final OpenSessionTaskFactory taskFactory = serviceRegistrar.getService(OpenSessionTaskFactory.class);
    final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
    if (observer == null)
        taskManager.execute(taskFactory.createTaskIterator(file));
    else
        taskManager.execute(taskFactory.createTaskIterator(file), observer);
}
Also used : OpenSessionTaskFactory(org.cytoscape.task.read.OpenSessionTaskFactory) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 4 with DialogTaskManager

use of org.cytoscape.work.swing.DialogTaskManager 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");
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) SearchTaskFactory(org.cytoscape.search.internal.SearchTaskFactory) CyNetwork(org.cytoscape.model.CyNetwork) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 5 with DialogTaskManager

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

the class MacCyActivator method start.

@Override
public void start(BundleContext context) throws Exception {
    final CyServiceRegistrar serviceRegistrar = getService(context, CyServiceRegistrar.class);
    final CyShutdown shutdown = getService(context, CyShutdown.class);
    final TaskFactory aboutTaskFactory = new HelpAboutTaskFactory(serviceRegistrar);
    final DialogTaskManager taskManager = getService(context, DialogTaskManager.class);
    final CyShutdownEvent[] lastShutdownEvent = new CyShutdownEvent[1];
    CyShutdownListener listener = (CyShutdownEvent e) -> {
        lastShutdownEvent[0] = e;
    };
    registerService(context, listener, CyShutdownListener.class, new Properties());
    Application application = Application.getApplication();
    application.setQuitHandler((QuitEvent event, QuitResponse response) -> {
        shutdown.exit(0);
        if (lastShutdownEvent[0] != null && !lastShutdownEvent[0].actuallyShutdown()) {
            response.cancelQuit();
        }
    });
    application.setAboutHandler((AboutEvent event) -> {
        taskManager.execute(aboutTaskFactory.createTaskIterator());
    });
}
Also used : AboutEvent(com.apple.eawt.AppEvent.AboutEvent) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyShutdownListener(org.cytoscape.application.events.CyShutdownListener) HelpAboutTaskFactory(org.cytoscape.internal.view.help.HelpAboutTaskFactory) HelpAboutTaskFactory(org.cytoscape.internal.view.help.HelpAboutTaskFactory) TaskFactory(org.cytoscape.work.TaskFactory) Application(com.apple.eawt.Application) CyShutdownEvent(org.cytoscape.application.events.CyShutdownEvent) QuitResponse(com.apple.eawt.QuitResponse) CyShutdown(org.cytoscape.application.CyShutdown) QuitEvent(com.apple.eawt.AppEvent.QuitEvent)

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