Search in sources :

Example 1 with OpenBrowser

use of org.cytoscape.util.swing.OpenBrowser in project cytoscape-impl by cytoscape.

the class HelpReportABugTask method run.

@Override
public void run(TaskMonitor tm) {
    // get OS string
    String os_str = System.getProperty("os.name") + "_" + System.getProperty("os.version");
    os_str = os_str.replace(" ", "_");
    final OpenBrowser openBrowser = serviceRegistrar.getService(OpenBrowser.class);
    final CyVersion cyVersion = serviceRegistrar.getService(CyVersion.class);
    openBrowser.openURL(BUG_REPORT_URL + "?cyversion=" + cyVersion.getVersion() + "&os=" + os_str);
}
Also used : OpenBrowser(org.cytoscape.util.swing.OpenBrowser) CyVersion(org.cytoscape.application.CyVersion)

Example 2 with OpenBrowser

use of org.cytoscape.util.swing.OpenBrowser in project cytoscape-impl by cytoscape.

the class HelpUserManualTask method run.

@Override
public void run(TaskMonitor tm) {
    final OpenBrowser openBrowser = serviceRegistrar.getService(OpenBrowser.class);
    final CyVersion cyVersion = serviceRegistrar.getService(CyVersion.class);
    openBrowser.openURL(MANUAL_URL + cyVersion.getMajorVersion() + "." + cyVersion.getMinorVersion() + "." + cyVersion.getBugFixVersion());
}
Also used : OpenBrowser(org.cytoscape.util.swing.OpenBrowser) CyVersion(org.cytoscape.application.CyVersion)

Example 3 with OpenBrowser

use of org.cytoscape.util.swing.OpenBrowser in project cytoscape-impl by cytoscape.

the class LinkOut method addStaticNodeLinks.

private void addStaticNodeLinks() {
    final Properties props = linkoutProps.getProperties();
    final OpenBrowser browser = registrar.getService(OpenBrowser.class);
    try {
        for (Object pk : props.keySet()) {
            String propKey = pk.toString();
            String url = props.getProperty(propKey);
            Properties dict = createProperties(propKey, NODEMARKER);
            if (url == null || dict == null) {
                logger.debug("Bad URL for propKey: " + propKey);
                continue;
            }
            NodeViewTaskFactory evtf = new NodeLinkoutTaskFactory(browser, url);
            registrar.registerService(evtf, NodeViewTaskFactory.class, dict);
            propKey2NodeVTF.put(propKey, (NodeLinkoutTaskFactory) evtf);
        }
    } catch (Exception e) {
        logger.warn("Problem processing node URLs", e);
    }
}
Also used : OpenBrowser(org.cytoscape.util.swing.OpenBrowser) Properties(java.util.Properties) NodeViewTaskFactory(org.cytoscape.task.NodeViewTaskFactory)

Example 4 with OpenBrowser

use of org.cytoscape.util.swing.OpenBrowser in project cytoscape-impl by cytoscape.

the class LinkOut method handleEvent.

@Override
public void handleEvent(final PropertyUpdatedEvent e) {
    if (e.getSource() == null || e.getSource().getName() == null)
        return;
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            final OpenBrowser browser = registrar.getService(OpenBrowser.class);
            if (// when linkout prop is changed
            e.getSource().getName().equals("linkout")) {
                final Properties props = (Properties) e.getSource().getProperties();
                List<String> removedLinks = new ArrayList<>();
                for (String propKey : propKey2EdgeVTF.keySet()) {
                    if (props.keySet().contains(propKey)) {
                        String url = props.getProperty(propKey);
                        EdgeLinkoutTaskFactory eltf = propKey2EdgeVTF.get(propKey);
                        if (!url.equals(eltf.getLink())) {
                            // linkout is modified
                            eltf.setLink(url);
                            propKey2EdgeVTF.put(propKey, eltf);
                        }
                    } else {
                        // linkout is removed
                        EdgeLinkoutTaskFactory eltf = propKey2EdgeVTF.get(propKey);
                        registrar.unregisterService(eltf, EdgeViewTaskFactory.class);
                        removedLinks.add(propKey);
                    }
                }
                for (String propKey : propKey2NodeVTF.keySet()) {
                    if (props.keySet().contains(propKey)) {
                        String url = props.getProperty(propKey);
                        NodeLinkoutTaskFactory nltf = propKey2NodeVTF.get(propKey);
                        if (!url.equals(nltf.getLink())) {
                            // linkout is modified
                            nltf.setLink(url);
                            propKey2NodeVTF.put(propKey, nltf);
                        }
                    } else {
                        // linkout is removed
                        NodeLinkoutTaskFactory nltf = propKey2NodeVTF.get(propKey);
                        registrar.unregisterService((NodeViewTaskFactory) nltf, NodeViewTaskFactory.class);
                        removedLinks.add(propKey);
                    }
                }
                for (String propkey : removedLinks) {
                    propKey2EdgeVTF.remove(propkey);
                    propKey2NodeVTF.remove(propkey);
                }
                try {
                    for (Object pk : props.keySet()) {
                        // added edge linkouts
                        String propKey = pk.toString();
                        if (propKey2EdgeVTF.containsKey(propKey))
                            continue;
                        String url = props.getProperty(propKey);
                        Properties dict = createProperties(propKey, EDGEMARKER);
                        if (url == null || dict == null) {
                            logger.debug("Bad URL for propKey: " + propKey);
                            continue;
                        }
                        EdgeViewTaskFactory evtf = new EdgeLinkoutTaskFactory(browser, url);
                        registrar.registerService(evtf, EdgeViewTaskFactory.class, dict);
                        propKey2EdgeVTF.put(propKey, (EdgeLinkoutTaskFactory) evtf);
                    }
                    for (Object pk : props.keySet()) {
                        // added node linkouts
                        String propKey = pk.toString();
                        if (propKey2NodeVTF.containsKey(propKey))
                            continue;
                        String url = props.getProperty(propKey);
                        Properties dict = createProperties(propKey, NODEMARKER);
                        if (url == null || dict == null) {
                            logger.debug("Bad URL for propKey: " + propKey);
                            continue;
                        }
                        NodeViewTaskFactory nvtf = new NodeLinkoutTaskFactory(browser, url);
                        registrar.registerService(nvtf, NodeViewTaskFactory.class, dict);
                        propKey2NodeVTF.put(propKey, (NodeLinkoutTaskFactory) nvtf);
                    }
                } catch (Exception ex) {
                    logger.warn("Problem processing node URLs", ex);
                }
            } else if (e.getSource().getName().equals("commandline")) {
                // when commandline linkout prop is changed
                final Properties props = (Properties) e.getSource().getProperties();
                List<String> removedLinks = new ArrayList<>();
                for (String propKey : cpropKey2EdgeVTF.keySet()) {
                    if (props.keySet().contains(propKey)) {
                        String url = props.getProperty(propKey);
                        EdgeLinkoutTaskFactory eltf = cpropKey2EdgeVTF.get(propKey);
                        if (!url.equals(eltf.getLink())) {
                            // linkout is modified
                            eltf.setLink(url);
                            cpropKey2EdgeVTF.put(propKey, eltf);
                        }
                    } else {
                        // linkout is removed
                        EdgeLinkoutTaskFactory eltf = cpropKey2EdgeVTF.get(propKey);
                        registrar.unregisterService(eltf, EdgeViewTaskFactory.class);
                        removedLinks.add(propKey);
                    }
                }
                for (String propKey : cpropKey2NodeVTF.keySet()) {
                    if (props.keySet().contains(propKey)) {
                        String url = props.getProperty(propKey);
                        NodeLinkoutTaskFactory nltf = cpropKey2NodeVTF.get(propKey);
                        if (!url.equals(nltf.getLink())) {
                            // linkout is modified
                            nltf.setLink(url);
                            cpropKey2NodeVTF.put(propKey, nltf);
                        }
                    } else {
                        // linkout is removed
                        NodeLinkoutTaskFactory nltf = cpropKey2NodeVTF.get(propKey);
                        registrar.unregisterService((NodeViewTaskFactory) nltf, NodeViewTaskFactory.class);
                        removedLinks.add(propKey);
                    }
                }
                for (String propkey : removedLinks) {
                    cpropKey2EdgeVTF.remove(propkey);
                    cpropKey2NodeVTF.remove(propkey);
                }
                try {
                    for (Object pk : props.keySet()) {
                        // added edge linkouts
                        String propKey = pk.toString();
                        if (cpropKey2EdgeVTF.containsKey(propKey))
                            continue;
                        String url = props.getProperty(propKey);
                        Properties dict = createProperties(propKey, EDGEMARKER);
                        if (url == null || dict == null) {
                            logger.debug("Bad URL for propKey: " + propKey);
                            continue;
                        }
                        EdgeViewTaskFactory evtf = new EdgeLinkoutTaskFactory(browser, url);
                        registrar.registerService(evtf, EdgeViewTaskFactory.class, dict);
                        cpropKey2EdgeVTF.put(propKey, (EdgeLinkoutTaskFactory) evtf);
                    }
                    for (Object pk : props.keySet()) {
                        // added node linkouts
                        String propKey = pk.toString();
                        if (cpropKey2NodeVTF.containsKey(propKey))
                            continue;
                        String url = props.getProperty(propKey);
                        Properties dict = createProperties(propKey, NODEMARKER);
                        if (url == null || dict == null) {
                            logger.debug("Bad URL for propKey: " + propKey);
                            continue;
                        }
                        NodeViewTaskFactory nvtf = new NodeLinkoutTaskFactory(browser, url);
                        registrar.registerService(nvtf, NodeViewTaskFactory.class, dict);
                        cpropKey2NodeVTF.put(propKey, (NodeLinkoutTaskFactory) nvtf);
                    }
                } catch (Exception ex) {
                    logger.warn("Problem processing node URLs", ex);
                }
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Properties(java.util.Properties) OpenBrowser(org.cytoscape.util.swing.OpenBrowser) ArrayList(java.util.ArrayList) List(java.util.List) NodeViewTaskFactory(org.cytoscape.task.NodeViewTaskFactory) EdgeViewTaskFactory(org.cytoscape.task.EdgeViewTaskFactory)

Example 5 with OpenBrowser

use of org.cytoscape.util.swing.OpenBrowser in project cytoscape-impl by cytoscape.

the class PopupMenuHelper method getOpenLinkMenu.

// Preset menu item: open browser
protected JMenuItem getOpenLinkMenu(final Object urlString) {
    final JMenuItem openLinkItem = new JMenuItem();
    openLinkItem.setText("Open URL in web browser...");
    if (urlString == null || urlString.toString().startsWith("http:") == false) {
        openLinkItem.setEnabled(false);
    } else {
        openLinkItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                final OpenBrowser openBrowser = serviceRegistrar.getService(OpenBrowser.class);
                openBrowser.openURL(urlString.toString());
            }
        });
    }
    return openLinkItem;
}
Also used : OpenBrowser(org.cytoscape.util.swing.OpenBrowser) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem)

Aggregations

OpenBrowser (org.cytoscape.util.swing.OpenBrowser)10 Properties (java.util.Properties)5 CyVersion (org.cytoscape.application.CyVersion)3 EdgeViewTaskFactory (org.cytoscape.task.EdgeViewTaskFactory)3 CommandExecutorTaskFactory (org.cytoscape.command.CommandExecutorTaskFactory)2 NodeViewTaskFactory (org.cytoscape.task.NodeViewTaskFactory)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 JMenuItem (javax.swing.JMenuItem)1 AppManagerAction (org.cytoscape.app.internal.action.AppManagerAction)1 CitationsAction (org.cytoscape.app.internal.action.CitationsAction)1 App (org.cytoscape.app.internal.manager.App)1 AppManager (org.cytoscape.app.internal.manager.AppManager)1 UpdateManager (org.cytoscape.app.internal.net.UpdateManager)1 WebApp (org.cytoscape.app.internal.net.WebApp)1 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)1 AddAllowOriginHeader (org.cytoscape.app.internal.net.server.AddAllowOriginHeader)1