1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-07 01:54:26 +01:00

Indent pass, no code change

This commit is contained in:
Cristian Maglie 2015-01-07 16:01:37 +01:00
parent 858bd455d7
commit 78e098e3d7

View File

@ -79,48 +79,48 @@ public class FindReplace extends JFrame implements ActionListener {
JLabel findLabel = new JLabel(_("Find:")); JLabel findLabel = new JLabel(_("Find:"));
findField = new JTextField(20); findField = new JTextField(20);
JLabel replaceLabel = new JLabel(_("Replace with:")); JLabel replaceLabel = new JLabel(_("Replace with:"));
replaceField=new JTextField(20); replaceField = new JTextField(20);
// Fill the findString with selected text if no previous value // Fill the findString with selected text if no previous value
if (editor.getSelectedText() != null && if (editor.getSelectedText() != null
editor.getSelectedText().length() > 0) && editor.getSelectedText().length() > 0)
findString = editor.getSelectedText(); findString = editor.getSelectedText();
if (findString != null) if (findString != null)
findField.setText(findString); findField.setText(findString);
if (replaceString != null) if (replaceString != null)
replaceField.setText(replaceString); replaceField.setText(replaceString);
ignoreCaseBox = new JCheckBox(_("Ignore Case")); ignoreCaseBox = new JCheckBox(_("Ignore Case"));
ignoreCaseBox.addActionListener(new ActionListener() { ignoreCaseBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ignoreCase = ignoreCaseBox.isSelected(); ignoreCase = ignoreCaseBox.isSelected();
} }
}); });
ignoreCaseBox.setSelected(ignoreCase); ignoreCaseBox.setSelected(ignoreCase);
wrapAroundBox = new JCheckBox(_("Wrap Around")); wrapAroundBox = new JCheckBox(_("Wrap Around"));
wrapAroundBox.addActionListener(new ActionListener() { wrapAroundBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
wrapAround = wrapAroundBox.isSelected(); wrapAround = wrapAroundBox.isSelected();
} }
}); });
wrapAroundBox.setSelected(wrapAround); wrapAroundBox.setSelected(wrapAround);
searchAllFilesBox = new JCheckBox(_("Search all Sketch Tabs")); searchAllFilesBox = new JCheckBox(_("Search all Sketch Tabs"));
searchAllFilesBox.addActionListener(new ActionListener() { searchAllFilesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
searchAllFiles = searchAllFilesBox.isSelected(); searchAllFiles = searchAllFilesBox.isSelected();
} }
}); });
searchAllFilesBox.setSelected(searchAllFiles); searchAllFilesBox.setSelected(searchAllFiles);
JPanel checkboxPanel = new JPanel(); JPanel checkboxPanel = new JPanel();
checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.LINE_AXIS)); checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.LINE_AXIS));
checkboxPanel.add(ignoreCaseBox); checkboxPanel.add(ignoreCaseBox);
checkboxPanel.add(Box.createRigidArea(new Dimension(8,0))); checkboxPanel.add(Box.createRigidArea(new Dimension(8, 0)));
checkboxPanel.add(wrapAroundBox); checkboxPanel.add(wrapAroundBox);
checkboxPanel.add(Box.createRigidArea(new Dimension(8,0))); checkboxPanel.add(Box.createRigidArea(new Dimension(8, 0)));
checkboxPanel.add(searchAllFilesBox); checkboxPanel.add(searchAllFilesBox);
replaceAllButton = new JButton(_("Replace All")); replaceAllButton = new JButton(_("Replace All"));
@ -135,28 +135,30 @@ public class FindReplace extends JFrame implements ActionListener {
findButton.addActionListener(this); findButton.addActionListener(this);
JPanel buttonPanel = new JPanel(); JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
// ordering of buttons is different on mac versus pc // ordering of buttons is different on mac versus pc
if (OSUtils.isMacOS()) { if (OSUtils.isMacOS()) {
buttonPanel.add(replaceAllButton); buttonPanel.add(replaceAllButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(replaceButton); buttonPanel.add(replaceButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(replaceFindButton); buttonPanel.add(replaceFindButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(previousButton); buttonPanel.add(previousButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(findButton); buttonPanel.add(findButton);
} else { } else {
buttonPanel.add(findButton); buttonPanel.add(findButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(previousButton); // is this the right position for non-Mac? buttonPanel.add(previousButton); // is this the right position for
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); // non-Mac?
buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(replaceFindButton); buttonPanel.add(replaceFindButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(replaceButton); buttonPanel.add(replaceButton);
buttonPanel.add(Box.createRigidArea(new Dimension(8,0))); buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
buttonPanel.add(replaceAllButton); buttonPanel.add(replaceAllButton);
} }
@ -166,83 +168,82 @@ public class FindReplace extends JFrame implements ActionListener {
buttonPanel.setBorder(null); buttonPanel.setBorder(null);
} }
//Put all components onto the dialog window // Put all components onto the dialog window
GridBagLayout searchLayout=new GridBagLayout(); GridBagLayout searchLayout = new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
Container pane = getContentPane(); Container pane = getContentPane();
pane.setLayout(searchLayout); pane.setLayout(searchLayout);
gbc.insets=new Insets(4,4,4,4); gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridx=0; gbc.gridx = 0;
gbc.weightx=0.0; gbc.weightx = 0.0;
gbc.weighty=0.0; gbc.weighty = 0.0;
gbc.fill=GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
gbc.anchor=GridBagConstraints.LINE_END; gbc.anchor = GridBagConstraints.LINE_END;
pane.add(findLabel,gbc); pane.add(findLabel, gbc);
gbc.gridx=1; gbc.gridx = 1;
gbc.weightx=1.0; gbc.weightx = 1.0;
gbc.fill=GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.LINE_START; gbc.anchor = GridBagConstraints.LINE_START;
pane.add(findField,gbc); pane.add(findField, gbc);
gbc.gridx=0; gbc.gridx = 0;
gbc.gridy=1; gbc.gridy = 1;
gbc.weightx=0.0; gbc.weightx = 0.0;
gbc.fill=GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
gbc.anchor=GridBagConstraints.LINE_END; gbc.anchor = GridBagConstraints.LINE_END;
pane.add(replaceLabel,gbc); pane.add(replaceLabel, gbc);
gbc.gridx=1; gbc.gridx = 1;
gbc.weightx=1.0; gbc.weightx = 1.0;
gbc.fill=GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.LINE_START; gbc.anchor = GridBagConstraints.LINE_START;
pane.add(replaceField,gbc); pane.add(replaceField, gbc);
gbc.gridx=1; gbc.gridx = 1;
gbc.gridy=2; gbc.gridy = 2;
gbc.weighty=0.0; gbc.weighty = 0.0;
gbc.fill=GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
pane.add(checkboxPanel,gbc); pane.add(checkboxPanel, gbc);
gbc.anchor=GridBagConstraints.CENTER; gbc.anchor = GridBagConstraints.CENTER;
gbc.gridwidth=2; gbc.gridwidth = 2;
gbc.gridx=0; gbc.gridx = 0;
gbc.gridy=3; gbc.gridy = 3;
gbc.insets=new Insets(12,4,4,4); gbc.insets = new Insets(12, 4, 4, 4);
pane.add(buttonPanel,gbc); pane.add(buttonPanel, gbc);
pack(); pack();
setResizable(false); setResizable(false);
//centers the dialog on thew screen // centers the dialog on thew screen
setLocationRelativeTo( null ); setLocationRelativeTo(null);
// make the find button the blinky default // make the find button the blinky default
getRootPane().setDefaultButton(findButton); getRootPane().setDefaultButton(findButton);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
handleClose(); handleClose();
} }
}); });
Base.registerWindowCloseKeys(getRootPane(), new ActionListener() { Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
//hide(); // hide();
handleClose(); handleClose();
} }
}); });
Base.setIcon(this); Base.setIcon(this);
// hack to to get first field to focus properly on osx // hack to to get first field to focus properly on osx
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) { public void windowActivated(WindowEvent e) {
//System.out.println("activating"); // System.out.println("activating");
/*boolean ok =*/ findField.requestFocusInWindow(); /* boolean ok = */findField.requestFocusInWindow();
//System.out.println("got " + ok); // System.out.println("got " + ok);
findField.selectAll(); findField.selectAll();
} }
}); });
} }
public void handleClose() { public void handleClose() {
//System.out.println("handling close now"); // System.out.println("handling close now");
findString = findField.getText(); findString = findField.getText();
replaceString = replaceField.getText(); replaceString = replaceField.getText();
@ -250,7 +251,6 @@ public class FindReplace extends JFrame implements ActionListener {
setVisible(false); setVisible(false);
} }
/* /*
public void show() { public void show() {
findField.requestFocusInWindow(); findField.requestFocusInWindow();
@ -281,17 +281,18 @@ public class FindReplace extends JFrame implements ActionListener {
} }
} }
// look for the next instance of the find string to be found // look for the next instance of the find string to be found
// once found, select it (and go to that line) // once found, select it (and go to that line)
private boolean find(boolean wrap,boolean backwards,boolean searchTabs,int originTab) { private boolean find(boolean wrap, boolean backwards, boolean searchTabs,
//System.out.println("Find: " + originTab); int originTab) {
boolean wrapNeeded = false; // System.out.println("Find: " + originTab);
boolean wrapNeeded = false;
String search = findField.getText(); String search = findField.getText();
//System.out.println("finding for " + search + " " + findString); // System.out.println("finding for " + search + " " + findString);
// this will catch "find next" being called when no search yet // this will catch "find next" being called when no search yet
if (search.length() == 0) return false; if (search.length() == 0)
return false;
String text = editor.getText(); String text = editor.getText();
@ -302,7 +303,7 @@ public class FindReplace extends JFrame implements ActionListener {
int nextIndex; int nextIndex;
if (!backwards) { if (!backwards) {
//int selectionStart = editor.textarea.getSelectionStart(); // int selectionStart = editor.textarea.getSelectionStart();
int selectionEnd = editor.getSelectionStop(); int selectionEnd = editor.getSelectionStop();
nextIndex = text.indexOf(search, selectionEnd); nextIndex = text.indexOf(search, selectionEnd);
@ -311,10 +312,10 @@ public class FindReplace extends JFrame implements ActionListener {
wrapNeeded = true; wrapNeeded = true;
} }
} else { } else {
//int selectionStart = editor.textarea.getSelectionStart(); // int selectionStart = editor.textarea.getSelectionStart();
int selectionStart = editor.getSelectionStart()-1; int selectionStart = editor.getSelectionStart() - 1;
if ( selectionStart >= 0 ) { if (selectionStart >= 0) {
nextIndex = text.lastIndexOf(search, selectionStart); nextIndex = text.lastIndexOf(search, selectionStart);
} else { } else {
nextIndex = -1; nextIndex = -1;
@ -338,8 +339,8 @@ public class FindReplace extends JFrame implements ActionListener {
originTab = realCurrentTab; originTab = realCurrentTab;
if (!wrap) if (!wrap)
if ((!backwards && realCurrentTab + 1 >= sketch.getCodeCount()) || if ((!backwards && realCurrentTab + 1 >= sketch.getCodeCount())
(backwards && realCurrentTab - 1 < 0)) || (backwards && realCurrentTab - 1 < 0))
return false; // Can't continue without wrap return false; // Can't continue without wrap
if (backwards) { if (backwards) {
@ -359,21 +360,21 @@ public class FindReplace extends JFrame implements ActionListener {
} }
if (wrapNeeded) if (wrapNeeded)
nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0); nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search,
0);
} }
if (nextIndex != -1) { if (nextIndex != -1) {
editor.setSelection(nextIndex, nextIndex + search.length()); editor.setSelection(nextIndex, nextIndex + search.length());
return true; return true;
} }
return false; return false;
} }
/** /**
* Replace the current selection with whatever's in the * Replace the current selection with whatever's in the replacement text
* replacement text field. * field.
*/ */
public void replace() { public void replace() {
if (findField.getText().length() == 0) if (findField.getText().length() == 0)
@ -399,8 +400,8 @@ public class FindReplace extends JFrame implements ActionListener {
} }
/** /**
* Replace the current selection with whatever's in the * Replace the current selection with whatever's in the replacement text
* replacement text field, and then find the next match * field, and then find the next match
*/ */
public void replaceAndFindNext() { public void replaceAndFindNext() {
replace(); replace();
@ -408,8 +409,8 @@ public class FindReplace extends JFrame implements ActionListener {
} }
/** /**
* Replace everything that matches by doing find and replace * Replace everything that matches by doing find and replace alternately until
* alternately until nothing more found. * nothing more found.
*/ */
public void replaceAll() { public void replaceAll() {
if (findField.getText().length() == 0) if (findField.getText().length() == 0)
@ -432,19 +433,19 @@ public class FindReplace extends JFrame implements ActionListener {
} }
} }
public void setFindText( String t ) { public void setFindText(String t) {
findField.setText( t ); findField.setText(t);
findString = t; findString = t;
} }
public void findNext() { public void findNext() {
if ( !find( wrapAround, false, searchAllFiles,-1 ) ) { if (!find(wrapAround, false, searchAllFiles, -1)) {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
} }
} }
public void findPrevious() { public void findPrevious() {
if ( !find( wrapAround, true, searchAllFiles,-1 ) ) { if (!find(wrapAround, true, searchAllFiles, -1)) {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
} }
} }