Skip to content

Commit 4f65ffd

Browse files
committed
Add Auto Open Search Option
This re-implements the original BCV search functionality. Instead of opening all at once, you need to type "enter" for each file you want to open. It maintains the focus in the search box for this effect.
1 parent d96aa2b commit 4f65ffd

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
public class ResourceListPane extends TranslatedVisibleComponent implements FileDrop.Listener
7474
{
7575
public final JPopupMenu rightClickMenu = new JPopupMenu();
76+
public final JCheckBox autoOpen = new TranslatedJCheckBox("Auto open", TranslatedComponents.EXACT_PATH);
7677
public final JCheckBox exact = new TranslatedJCheckBox("Exact path", TranslatedComponents.EXACT_PATH);
7778
public final JCheckBox caseSensitive = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
7879
public final JButton open = new JButton(IconResources.add);
@@ -125,6 +126,7 @@ public ResourceListPane()
125126
JPanel btns = new JPanel(new FlowLayout());
126127
btns.add(exact);
127128
btns.add(caseSensitive);
129+
btns.add(autoOpen);
128130
exactPanel.add(btns, BorderLayout.WEST);
129131

130132
buttonPanel.add(open, BorderLayout.EAST);
@@ -533,5 +535,4 @@ public void focusLost(final FocusEvent arg0)
533535
}
534536
});
535537
}
536-
537-
}
538+
}

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/SearchKeyAdapter.java

+7
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ public void keyPressed(final KeyEvent ke)
157157
resourceListPane.tree.setSelectionPath(pathOpen);
158158
resourceListPane.tree.makeVisible(pathOpen);
159159
resourceListPane.tree.scrollPathToVisible(pathOpen);
160+
161+
if(resourceListPane.autoOpen.isSelected())
162+
{
163+
resourceListPane.openPath(pathOpen);
164+
resourceListPane.quickSearch.requestFocusInWindow();
165+
}
166+
160167
iteratePast++;
161168
success = true;
162169
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ public enum TranslatedComponents
256256
MATCH_CASE,
257257
EXACT_PATH,
258258
PRINT_LINE_NUMBERS,
259+
AUTO_OPEN,
259260
;
260261

261262
private final TranslatedComponentReference componentReference;

0 commit comments

Comments
 (0)