Index reference page is shown when no text selected if clicking 'Find in

reference' command.
This commit is contained in:
s17t.net 2012-08-20 00:08:17 +02:00
parent 8a1cf335ad
commit ab2d83fc80
1 changed files with 18 additions and 20 deletions

View File

@ -27,6 +27,7 @@ import processing.app.syntax.*;
import processing.app.tools.*; import processing.app.tools.*;
import processing.core.*; import processing.core.*;
import static processing.app.I18n._; import static processing.app.I18n._;
import static processing.app.ObjectUtil.defaultIfEmpty;
import java.awt.*; import java.awt.*;
import java.awt.datatransfer.*; import java.awt.datatransfer.*;
@ -1073,9 +1074,10 @@ public class Editor extends JFrame implements RunnerListener {
item = newJMenuItemShift(_("Find in Reference"), 'F'); item = newJMenuItemShift(_("Find in Reference"), 'F');
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (textarea.isSelectionActive()) { // if (textarea.isSelectionActive()) {
handleFindReference(); // handleFindReference();
} // }
handleFindReference();
} }
}); });
menu.add(item); menu.add(item);
@ -1809,24 +1811,20 @@ public class Editor extends JFrame implements RunnerListener {
} }
protected void handleFindReference() { protected void handleFindReference() {
String text = textarea.getSelectedText().trim(); String text = defaultIfEmpty(textarea.getSelectedText(), "").trim();
if (text.length() == 0) { if (text.length() == 0) {
statusNotice(_("First select a word to find in the reference.")); Base.showReference();
} else {
} else { String referenceFile = PdeKeywords.getReference(text);
String referenceFile = PdeKeywords.getReference(text); if (referenceFile == null) {
//System.out.println("reference file is " + referenceFile); statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
if (referenceFile == null) { } else {
statusNotice( Base.showReference(I18n.format(_("{0}.html"), referenceFile));
I18n.format(_("No reference available for \"{0}\""), text) }
); }
} else { }
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
}
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .