■ ■ ■ ■ ■ ■
src/main/java/com/nccgroup/loggerplusplus/grepper/GrepperPanel.java
| skipped 27 lines |
28 | 28 | | private final JButton searchButton; |
29 | 29 | | private final JButton resetButton; |
30 | 30 | | private final JProgressBar progressBar; |
| 31 | + | private final JCheckBox searchRequests; |
| 32 | + | private final JCheckBox searchResponses; |
31 | 33 | | private final JCheckBox inScopeOnly; |
32 | 34 | | private final JTabbedPane resultsPane; |
33 | 35 | | private final GrepResultsTable grepResultsTable; |
34 | 36 | | private final RequestViewerController requestViewerController; |
35 | 37 | | private final UniquePatternMatchTable uniqueTable; |
36 | 38 | | |
37 | | - | GrepperPanel(GrepperController controller, Preferences preferences){ |
| 39 | + | GrepperPanel(GrepperController controller, Preferences preferences) { |
38 | 40 | | this.controller = controller; |
39 | 41 | | this.preferences = preferences; |
40 | 42 | | |
| skipped 1 lines |
42 | 44 | | searchField.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { |
43 | 45 | | @Override |
44 | 46 | | public void keyPressed(KeyEvent e) { |
45 | | - | if(e.getKeyChar() == KeyEvent.VK_ENTER){ |
| 47 | + | if (e.getKeyChar() == KeyEvent.VK_ENTER) { |
46 | 48 | | startSearch(); |
47 | 49 | | } |
48 | 50 | | } |
| skipped 1 lines |
50 | 52 | | |
51 | 53 | | this.progressBar = new JProgressBar(); |
52 | 54 | | this.inScopeOnly = new JCheckBox("In Scope Only"); |
| 55 | + | this.searchRequests = new JCheckBox("Search Requests", true); |
| 56 | + | this.searchResponses = new JCheckBox("Search Responses", true); |
53 | 57 | | |
54 | 58 | | this.searchButton = new JButton(new AbstractAction("Search") { |
55 | 59 | | @Override |
| skipped 47 lines |
103 | 107 | | this.resultsPane.addTab("Results", resultsSplitPane); |
104 | 108 | | this.resultsPane.addTab("Unique Results", new JScrollPane(uniqueTable)); |
105 | 109 | | |
| 110 | + | JLabel regexLabel = new JLabel("Regex: "); |
106 | 111 | | JPanel wrapperPanel = PanelBuilder.build(new JComponent[][]{ |
107 | | - | new JComponent[]{new JLabel("Regex: "), searchField, inScopeOnly, searchButton, resetButton}, |
108 | | - | new JComponent[]{resultsPane, resultsPane, resultsPane, resultsPane, resultsPane}, |
109 | | - | new JComponent[]{progressBar, progressBar, progressBar, progressBar, progressBar} |
| 112 | + | new JComponent[]{regexLabel, searchField, searchRequests, searchResponses, inScopeOnly, searchButton, resetButton}, |
| 113 | + | new JComponent[]{resultsPane, resultsPane, resultsPane, resultsPane, resultsPane, resultsPane, resultsPane}, |
| 114 | + | new JComponent[]{progressBar, progressBar, progressBar, progressBar, progressBar, progressBar, progressBar} |
110 | 115 | | }, new int[][]{ |
111 | | - | new int[]{0, 1, 0, 0, 0}, |
112 | | - | new int[]{1, 100, 1, 1, 0}, |
113 | | - | new int[]{0, 0, 0, 0, 0} |
| 116 | + | new int[]{0, 1, 0, 0, 0, 0}, |
| 117 | + | new int[]{1, 100, 1, 1, 1, 0}, |
| 118 | + | new int[]{0, 0, 0, 0, 0, 0} |
114 | 119 | | }, Alignment.FILL, 1.0, 1.0); |
115 | 120 | | |
116 | 121 | | this.setLayout(new BorderLayout()); |
| skipped 2 lines |
119 | 124 | | this.controller.addListener(this); |
120 | 125 | | } |
121 | 126 | | |
122 | | - | private void startSearch(){ |
| 127 | + | private void startSearch() { |
123 | 128 | | String patternString = ((JTextField) this.searchField.getEditor().getEditorComponent()).getText(); |
124 | 129 | | Pattern pattern; |
125 | 130 | | try { |
126 | 131 | | pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE); |
127 | | - | }catch (PatternSyntaxException e){ |
| 132 | + | } catch (PatternSyntaxException e) { |
128 | 133 | | JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(controller.getLoggerPlusPlus().getMainViewController().getUiComponent()), "Pattern Syntax Invalid", "Invalid Pattern", JOptionPane.ERROR_MESSAGE); |
129 | 134 | | return; |
130 | 135 | | } |
131 | 136 | | |
132 | | - | this.controller.beginSearch(pattern, this.inScopeOnly.isSelected()); |
| 137 | + | this.controller.beginSearch(pattern, this.inScopeOnly.isSelected(), |
| 138 | + | this.searchRequests.isSelected(), this.searchResponses.isSelected()); |
133 | 139 | | } |
134 | 140 | | |
135 | 141 | | @Override |
136 | 142 | | public void onSearchStarted(Pattern pattern, int totalRequests) { |
137 | 143 | | SwingUtilities.invokeLater(() -> { |
| 144 | + | this.searchRequests.setEnabled(false); |
| 145 | + | this.searchResponses.setEnabled(false); |
138 | 146 | | this.searchField.setEnabled(false); |
139 | 147 | | this.resetButton.setEnabled(false); |
140 | 148 | | this.searchButton.setText("Cancel"); |
| skipped 11 lines |
152 | 160 | | |
153 | 161 | | @Override |
154 | 162 | | public void onSearchComplete() { |
155 | | - | SwingUtilities.invokeLater(() -> { |
156 | | - | this.searchButton.setText("Search"); |
157 | | - | this.progressBar.setValue(0); |
158 | | - | this.searchField.setEnabled(true); |
159 | | - | this.resetButton.setEnabled(true); |
160 | | - | }); |
| 163 | + | unlockUI(); |
161 | 164 | | } |
162 | 165 | | |
163 | 166 | | @Override |
| skipped 10 lines |
174 | 177 | | |
175 | 178 | | @Override |
176 | 179 | | public void onShutdownComplete() { |
| 180 | + | unlockUI(); |
| 181 | + | } |
| 182 | + | |
| 183 | + | private void unlockUI() { |
177 | 184 | | SwingUtilities.invokeLater(() -> { |
178 | 185 | | this.searchButton.setText("Search"); |
179 | 186 | | this.progressBar.setValue(0); |
180 | 187 | | this.searchField.setEnabled(true); |
181 | 188 | | this.resetButton.setEnabled(true); |
| 189 | + | this.searchRequests.setEnabled(true); |
| 190 | + | this.searchResponses.setEnabled(true); |
182 | 191 | | }); |
183 | 192 | | } |
184 | 193 | | } |
| skipped 1 lines |