1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-10 21:24:12 +01:00

Fix indent and typos on FindReplace.java

This commit is contained in:
Cristian Maglie 2014-07-25 12:10:42 +02:00
parent cd75cc24a2
commit 82401c84bb

View File

@ -44,6 +44,7 @@ import javax.swing.*;
* <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=244"> Bug 244</A> * <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=244"> Bug 244</A>
* should anyone have clues about how to fix. * should anyone have clues about how to fix.
*/ */
@SuppressWarnings("serial")
public class FindReplace extends JFrame implements ActionListener { public class FindReplace extends JFrame implements ActionListener {
static final int EDGE = Base.isMacOS() ? 20 : 13; static final int EDGE = Base.isMacOS() ? 20 : 13;
@ -77,37 +78,31 @@ public class FindReplace extends JFrame implements ActionListener {
setResizable(false); setResizable(false);
this.editor = editor; this.editor = editor;
FlowLayout searchLayout = new FlowLayout(FlowLayout.RIGHT,5,0); FlowLayout searchLayout = new FlowLayout(FlowLayout.RIGHT,5,0);
Container pain = getContentPane(); Container pane = getContentPane();
pain.setLayout(searchLayout); pane.setLayout(searchLayout);
JLabel findLabel = new JLabel(_("Find:")); JLabel findLabel = new JLabel(_("Find:"));
JLabel replaceLabel = new JLabel(_("Replace with:")); JLabel replaceLabel = new JLabel(_("Replace with:"));
Dimension labelDimension = replaceLabel.getPreferredSize(); Dimension labelDimension = replaceLabel.getPreferredSize();
JPanel find = new JPanel(); JPanel find = new JPanel();
find.add(findLabel); find.add(findLabel);
find.add(findField = new JTextField(20)); find.add(findField = new JTextField(20));
pane.add(find);
pain.add(find);
JPanel replace = new JPanel(); JPanel replace = new JPanel();
replace.add(replaceLabel); replace.add(replaceLabel);
replace.add(replaceField = new JTextField(20)); replace.add(replaceField = new JTextField(20));
pane.add(replace);
pain.add(replace);
int fieldHeight = findField.getPreferredSize().height; int fieldHeight = findField.getPreferredSize().height;
JPanel checkbox = new JPanel(); JPanel checkbox = new JPanel();
// Fill the findString with selected text if no previous value // Fill the findString with selected text if no previous value
if(editor.getSelectedText()!=null && editor.getSelectedText().length()>0) if (editor.getSelectedText() != null &&
editor.getSelectedText().length() > 0)
findString = editor.getSelectedText(); findString = editor.getSelectedText();
if (findString != null) findField.setText(findString); if (findString != null) findField.setText(findString);
@ -142,10 +137,9 @@ public class FindReplace extends JFrame implements ActionListener {
searchAllFilesBox.setSelected(searchAllFiles); searchAllFilesBox.setSelected(searchAllFiles);
checkbox.add(searchAllFilesBox); checkbox.add(searchAllFilesBox);
pain.add(checkbox); pane.add(checkbox);
JPanel buttons = new JPanel(); JPanel buttons = new JPanel();
buttons.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONGAP, 0)); buttons.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONGAP, 0));
// ordering is different on mac versus pc // ordering is different on mac versus pc
@ -163,7 +157,7 @@ public class FindReplace extends JFrame implements ActionListener {
buttons.add(replaceButton = new JButton(_("Replace"))); buttons.add(replaceButton = new JButton(_("Replace")));
buttons.add(replaceAllButton = new JButton(_("Replace All"))); buttons.add(replaceAllButton = new JButton(_("Replace All")));
} }
pain.add(buttons); pane.add(buttons);
// to fix ugliness.. normally macosx java 1.3 puts an // to fix ugliness.. normally macosx java 1.3 puts an
// ugly white border around this object, so turn it off. // ugly white border around this object, so turn it off.
@ -370,32 +364,27 @@ public class FindReplace extends JFrame implements ActionListener {
if (nextIndex == -1) { if (nextIndex == -1) {
// Nothing found on this tab: Search other tabs if required // Nothing found on this tab: Search other tabs if required
if(searchTabs) if (searchTabs) {
{
// editor. // editor.
Sketch sketch = editor.getSketch(); Sketch sketch = editor.getSketch();
if(sketch.getCodeCount()>1) if (sketch.getCodeCount() > 1) {
{
int realCurrentTab = sketch.getCodeIndex(sketch.getCurrentCode()); int realCurrentTab = sketch.getCodeIndex(sketch.getCurrentCode());
if(originTab!=realCurrentTab) if (originTab != realCurrentTab) {
{
if (originTab < 0) if (originTab < 0)
originTab = realCurrentTab; originTab = realCurrentTab;
if (!wrap) if (!wrap)
if((!backwards && realCurrentTab+1 >= sketch.getCodeCount()) || (backwards && realCurrentTab-1 < 0)) if ((!backwards && realCurrentTab + 1 >= sketch.getCodeCount()) ||
(backwards && realCurrentTab - 1 < 0))
return false; // Can't continue without wrap return false; // Can't continue without wrap
if(backwards) if (backwards) {
{
sketch.handlePrevCode(); sketch.handlePrevCode();
this.setVisible(true); this.setVisible(true);
int l = editor.getText().length() - 1; int l = editor.getText().length() - 1;
editor.setSelection(l, l); editor.setSelection(l, l);
} } else {
else
{
sketch.handleNextCode(); sketch.handleNextCode();
this.setVisible(true); this.setVisible(true);
editor.setSelection(0, 0); editor.setSelection(0, 0);
@ -428,7 +417,8 @@ public class FindReplace extends JFrame implements ActionListener {
return; return;
int newpos = editor.getSelectionStart() - findField.getText().length(); int newpos = editor.getSelectionStart() - findField.getText().length();
if (newpos < 0) newpos = 0; if (newpos < 0)
newpos = 0;
editor.setSelection(newpos, newpos); editor.setSelection(newpos, newpos);
boolean foundAtLeastOne = false; boolean foundAtLeastOne = false;