提交 befd23f4 编写于 作者: D deathmarine

#79 Add Wrap Checkbox to Find Dialog

上级 ea25dfc8
...@@ -31,6 +31,7 @@ public class FindBox extends JDialog { ...@@ -31,6 +31,7 @@ public class FindBox extends JDialog {
JCheckBox regex; JCheckBox regex;
JCheckBox wholew; JCheckBox wholew;
JCheckBox reverse; JCheckBox reverse;
JCheckBox wrap;
private JButton findButton; private JButton findButton;
JTextField textField; JTextField textField;
private MainWindow mainWindow; private MainWindow mainWindow;
...@@ -61,7 +62,8 @@ public class FindBox extends JDialog { ...@@ -61,7 +62,8 @@ public class FindBox extends JDialog {
regex = new JCheckBox("Regex"); regex = new JCheckBox("Regex");
wholew = new JCheckBox("Whole Words"); wholew = new JCheckBox("Whole Words");
reverse = new JCheckBox("Search Backwards"); reverse = new JCheckBox("Search Backwards");
wrap = new JCheckBox("Wrap");
findButton = new JButton("Find"); findButton = new JButton("Find");
findButton.addActionListener(new FindButton()); findButton.addActionListener(new FindButton());
this.getRootPane().setDefaultButton(findButton); this.getRootPane().setDefaultButton(findButton);
...@@ -78,6 +80,7 @@ public class FindBox extends JDialog { ...@@ -78,6 +80,7 @@ public class FindBox extends JDialog {
regex.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); regex.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
wholew.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); wholew.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
reverse.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); reverse.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
wrap.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
final Dimension center = new Dimension((int) (screenSize.width * 0.35), final Dimension center = new Dimension((int) (screenSize.width * 0.35),
...@@ -96,7 +99,7 @@ public class FindBox extends JDialog { ...@@ -96,7 +99,7 @@ public class FindBox extends JDialog {
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(textField) .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(textField)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(mcase) .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(mcase)
.addComponent(wholew)) .addComponent(wholew).addComponent(wrap))
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(regex) .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(regex)
.addComponent(reverse)))) .addComponent(reverse))))
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(findButton))); .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(findButton)));
...@@ -110,7 +113,8 @@ public class FindBox extends JDialog { ...@@ -110,7 +113,8 @@ public class FindBox extends JDialog {
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(mcase) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(mcase)
.addComponent(regex)) .addComponent(regex))
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wholew) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wholew)
.addComponent(reverse))))); .addComponent(reverse))
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wrap)))));
this.adjustWindowPositionBySavedState(); this.adjustWindowPositionBySavedState();
this.setSaveWindowPositionOnClosing(); this.setSaveWindowPositionOnClosing();
...@@ -140,8 +144,12 @@ public class FindBox extends JDialog { ...@@ -140,8 +144,12 @@ public class FindBox extends JDialog {
context.setWholeWord(wholew.isSelected()); context.setWholeWord(wholew.isSelected());
if (!SearchEngine.find(pane, context).wasFound()) { if (!SearchEngine.find(pane, context).wasFound()) {
pane.setSelectionStart(0); if(wrap.isSelected()){
pane.setSelectionEnd(0); pane.setSelectionStart(0);
pane.setSelectionEnd(0);
}else{
mainWindow.getLabel().setText("Search Complete");
}
} }
} }
...@@ -207,8 +215,12 @@ public class FindBox extends JDialog { ...@@ -207,8 +215,12 @@ public class FindBox extends JDialog {
context.setWholeWord(wholew.isSelected()); context.setWholeWord(wholew.isSelected());
if (!SearchEngine.find(pane, context).wasFound()) { if (!SearchEngine.find(pane, context).wasFound()) {
pane.setSelectionStart(0); if(wrap.isSelected()){
pane.setSelectionEnd(0); pane.setSelectionStart(0);
pane.setSelectionEnd(0);
}else{
mainWindow.getLabel().setText("Search Complete");
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册