Skip to content

Commit 3020432

Browse files
committed
If a classname doesn't have any URLS associated with it, then search
in DuckDuckGo.
1 parent 4583ccf commit 3020432

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/org/scijava/ui/swing/script/TextEditor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,10 +2712,18 @@ public void run() {
27122712
final JLabel class_label = new JLabel(classname);
27132713
gridbag.setConstraints(class_label, c);
27142714
panel.add(class_label);
2715-
for (final String url: matches.get(classname)) {
2715+
ArrayList<String> urls = matches.get(classname);
2716+
if (urls.isEmpty()) {
2717+
urls = new ArrayList<String>();
2718+
urls.add("https://duckduckgo.com/?q=" + classname);
2719+
}
2720+
for (final String url: urls) {
27162721
c.gridx += 1;
27172722
c.anchor = GridBagConstraints.WEST;
2718-
final JButton link = new JButton(url.endsWith("java") ? "Source" : "JavaDoc");
2723+
String title = "JavaDoc";
2724+
if (url.endsWith(".java")) title = "Source";
2725+
else if (url.contains("duckduckgo")) title = "Search...";
2726+
final JButton link = new JButton(title);
27192727
gridbag.setConstraints(link, c);
27202728
panel.add(link);
27212729
link.addActionListener(new ActionListener() {

0 commit comments

Comments
 (0)