From ab2d83fc80c4d2214cdf935dcfe21a0af962581b Mon Sep 17 00:00:00 2001 From: "s17t.net" Date: Mon, 20 Aug 2012 00:08:17 +0200 Subject: [PATCH] Index reference page is shown when no text selected if clicking 'Find in reference' command. --- app/src/processing/app/Editor.java | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 30d05c73f..7fe460944 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -27,6 +27,7 @@ import processing.app.syntax.*; import processing.app.tools.*; import processing.core.*; import static processing.app.I18n._; +import static processing.app.ObjectUtil.defaultIfEmpty; import java.awt.*; import java.awt.datatransfer.*; @@ -1073,9 +1074,10 @@ public class Editor extends JFrame implements RunnerListener { item = newJMenuItemShift(_("Find in Reference"), 'F'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (textarea.isSelectionActive()) { - handleFindReference(); - } +// if (textarea.isSelectionActive()) { +// handleFindReference(); +// } + handleFindReference(); } }); menu.add(item); @@ -1809,24 +1811,20 @@ public class Editor extends JFrame implements RunnerListener { } - protected void handleFindReference() { - String text = textarea.getSelectedText().trim(); + protected void handleFindReference() { + String text = defaultIfEmpty(textarea.getSelectedText(), "").trim(); - if (text.length() == 0) { - statusNotice(_("First select a word to find in the reference.")); - - } else { - String referenceFile = PdeKeywords.getReference(text); - //System.out.println("reference file is " + referenceFile); - if (referenceFile == null) { - statusNotice( - I18n.format(_("No reference available for \"{0}\""), text) - ); - } else { - Base.showReference(I18n.format(_("{0}.html"), referenceFile)); - } - } - } + if (text.length() == 0) { + Base.showReference(); + } else { + String referenceFile = PdeKeywords.getReference(text); + if (referenceFile == null) { + statusNotice(I18n.format(_("No reference available for \"{0}\""), text)); + } else { + Base.showReference(I18n.format(_("{0}.html"), referenceFile)); + } + } + } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .