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);
}
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());
}
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);
}
}
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);
}
}
}
});
}
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;
}
Aggregations