From f4c0e7147519acffed5fbc24749e305ee0670c38 Mon Sep 17 00:00:00 2001 From: Konloch Date: Thu, 29 Jul 2021 19:32:32 -0700 Subject: [PATCH] Better Searching Instead of providing the entire path in the search result now we can return only what the user is looking for --- .../gui/resourcesearch/PerformSearch.java | 14 ++--- .../gui/resourcesearch/SearchBoxPane.java | 30 ++++------- .../gui/resourcesearch/SearchType.java | 11 ++-- .../gui/resourceviewer/Workspace.java | 1 + ...fier.java => LDCSearchTreeNodeResult.java} | 32 +++++++++--- ...earchTypeDetails.java => SearchPanel.java} | 14 +++-- .../searching/impl/FieldCallSearch.java | 6 +-- .../searching/impl/LDCSearch.java | 51 +++++++++---------- .../searching/impl/MethodCallSearch.java | 42 +++++++-------- .../searching/impl/RegexSearch.java | 24 ++++++--- 10 files changed, 114 insertions(+), 111 deletions(-) rename src/main/java/the/bytecode/club/bytecodeviewer/searching/{SearchResultNotifier.java => LDCSearchTreeNodeResult.java} (61%) rename src/main/java/the/bytecode/club/bytecodeviewer/searching/{SearchTypeDetails.java => SearchPanel.java} (87%) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java index 0ce6766a..0b663e2a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java @@ -4,8 +4,8 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread; import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder; +import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch; import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch; -import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; @@ -38,12 +38,10 @@ import java.util.regex.PatternSyntaxException; class PerformSearch extends BackgroundSearchThread { private final SearchBoxPane searchBoxPane; - private final SearchResultNotifier srn; - public PerformSearch(SearchBoxPane searchBoxPane, SearchResultNotifier srn) + public PerformSearch(SearchBoxPane searchBoxPane) { this.searchBoxPane = searchBoxPane; - this.srn = srn; } @Override @@ -51,7 +49,8 @@ class PerformSearch extends BackgroundSearchThread { try { - Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), Pattern.MULTILINE); + if(RegexSearch.searchText != null) + Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), Pattern.MULTILINE); } catch (PatternSyntaxException ex) { @@ -59,8 +58,9 @@ class PerformSearch extends BackgroundSearchThread } for (ResourceContainer container : BytecodeViewer.resourceContainers.values()) - for (ClassNode c : container.resourceClasses.values()) - searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected()); + container.resourceClasses.forEach((key,cn)->{ + searchBoxPane.searchType.panel.search(container, key, cn, searchBoxPane.exact.isSelected()); + }); BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true); BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java index 076091d1..f707e4da 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java @@ -18,7 +18,7 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer; import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread; -import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; +import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.components.*; @@ -49,8 +49,6 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; * @author WaterWolf * @since 09/29/2011 */ - -@SuppressWarnings("rawtypes") public class SearchBoxPane extends TranslatedVisibleComponent { public static final SearchRadius[] SEARCH_RADII = SearchRadius.values(); @@ -59,7 +57,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent public final JCheckBox exact = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT); public final TranslatedDefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", TranslatedComponents.RESULTS); public final JTree tree; - public final JComboBox typeBox; + public final JComboBox typeBox; public SearchType searchType = null; public final JComboBox searchRadiusBox; @@ -91,13 +89,13 @@ public class SearchBoxPane extends TranslatedVisibleComponent for (final SearchType st : SEARCH_TYPES) model.addElement(st); - typeBox = new JComboBox(model); + typeBox = new JComboBox(model); final JPanel searchOptPanel = new JPanel(); final ItemListener il = arg0 -> { searchOptPanel.removeAll(); searchType = (SearchType) typeBox.getSelectedItem(); - searchOptPanel.add(Objects.requireNonNull(searchType).details.getPanel()); + searchOptPanel.add(Objects.requireNonNull(searchType).panel.getPanel()); searchOptPanel.revalidate(); searchOptPanel.repaint(); @@ -138,18 +136,11 @@ public class SearchBoxPane extends TranslatedVisibleComponent if (selectionEvent.getPath().getPathComponent(0).equals(TranslatedStrings.RESULTS)) return; - selectionEvent.getPath().getPathComponent(1); + LDCSearchTreeNodeResult result = (LDCSearchTreeNodeResult) tree.getLastSelectedPathComponent(); - String path = selectionEvent.getPath().getPathComponent(1).toString(); - - String containerName = path.split(">", 2)[0]; - String className = path.split(">", 2)[1].split("\\.")[0]; - ResourceContainer container = BytecodeViewer.getFileContainer(containerName); - - final ClassNode fN = Objects.requireNonNull(container).getClassNode(className); - - if (fN != null) - BytecodeViewer.viewer.workPane.addClassResource(container, className + ".class"); + final String name = result.resourceWorkingName; + + BytecodeViewer.viewer.workPane.addClassResource(result.container, name); } catch (Exception e) { @@ -166,7 +157,6 @@ public class SearchBoxPane extends TranslatedVisibleComponent treeRoot.removeAllChildren(); searchType = (SearchType) typeBox.getSelectedItem(); final SearchRadius radius = (SearchRadius) searchRadiusBox.getSelectedItem(); - final SearchResultNotifier srn = debug -> treeRoot.add(new DefaultMutableTreeNode(debug)); if (radius == SearchRadius.All_Classes) { @@ -175,7 +165,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent BytecodeViewer.viewer.searchBoxPane.search.setEnabled(false); BytecodeViewer.viewer.searchBoxPane.search.setText("Searching, please wait.."); - performSearchThread = new PerformSearch(this, srn); + performSearchThread = new PerformSearch(this); performSearchThread.start(); } else @@ -188,7 +178,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent final ResourceViewer cv = BytecodeViewer.getActiveResource(); if (cv != null) - searchType.details.search(cv.resource.container, cv.resource.getResourceClassNode(), srn, exact.isSelected()); + searchType.panel.search(cv.resource.container, cv.resource.workingName, cv.resource.getResourceClassNode(), exact.isSelected()); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchType.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchType.java index 9aeb1312..4ed49f29 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchType.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchType.java @@ -1,6 +1,6 @@ package the.bytecode.club.bytecodeviewer.gui.resourcesearch; -import the.bytecode.club.bytecodeviewer.searching.*; +import the.bytecode.club.bytecodeviewer.searching.SearchPanel; import the.bytecode.club.bytecodeviewer.searching.impl.FieldCallSearch; import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch; import the.bytecode.club.bytecodeviewer.searching.impl.MethodCallSearch; @@ -33,12 +33,13 @@ public enum SearchType Strings(new LDCSearch()), Regex(new RegexSearch()), MethodCall(new MethodCallSearch()), - FieldCall(new FieldCallSearch()); + FieldCall(new FieldCallSearch()), + ; - public final SearchTypeDetails details; + public final SearchPanel panel; - SearchType(final SearchTypeDetails details) + SearchType(final SearchPanel panel) { - this.details = details; + this.panel = panel; } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java index 96f8152e..4dc13eff 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java @@ -69,6 +69,7 @@ public class Workspace extends TranslatedVisibleComponent if (index != -1) tabs.remove(index); }); + closeAllTabs.addActionListener(e -> { TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchResultNotifier.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/LDCSearchTreeNodeResult.java similarity index 61% rename from src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchResultNotifier.java rename to src/main/java/the/bytecode/club/bytecodeviewer/searching/LDCSearchTreeNodeResult.java index 533afbf1..d57bdd8e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchResultNotifier.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/LDCSearchTreeNodeResult.java @@ -1,5 +1,12 @@ package the.bytecode.club.bytecodeviewer.searching; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.MethodNode; +import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; + +import javax.swing.tree.DefaultMutableTreeNode; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -19,13 +26,24 @@ package the.bytecode.club.bytecodeviewer.searching; ***************************************************************************/ /** - * Used to update the search pane that there's been a result found. - * * @author Konloch - * @author WaterWolf - * @since 09/26/2011 + * @since 7/29/2021 */ - -public interface SearchResultNotifier { - void notifyOfResult(String debug); +public class LDCSearchTreeNodeResult extends DefaultMutableTreeNode +{ + public final ResourceContainer container; + public final String resourceWorkingName; + public final String ldc; + public final String ldcType; + + public LDCSearchTreeNodeResult(ResourceContainer container, String resourceWorkingName, + ClassNode cn, MethodNode method, FieldNode field, + String ldc, String ldcType) + { + super("'"+ldc+"' -> " + cn.name); + this.container = container; + this.resourceWorkingName = resourceWorkingName; + this.ldc = ldc; + this.ldcType = ldcType; + } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchTypeDetails.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchPanel.java similarity index 87% rename from src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchTypeDetails.java rename to src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchPanel.java index 83188ea8..00eed3fb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchTypeDetails.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/SearchPanel.java @@ -1,9 +1,10 @@ package the.bytecode.club.bytecodeviewer.searching; -import javax.swing.JPanel; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; +import javax.swing.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -23,16 +24,13 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; ***************************************************************************/ /** - * Search type details - * * @author Konloch * @author WaterWolf * @since 09/26/2011 */ - -public interface SearchTypeDetails +public interface SearchPanel { - JPanel getPanel(); - - void search(ResourceContainer container, ClassNode node, SearchResultNotifier srn, boolean exact); + JPanel getPanel(); + + void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/FieldCallSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/FieldCallSearch.java index f7387b1f..5ab3c0d6 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/FieldCallSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/FieldCallSearch.java @@ -7,7 +7,6 @@ import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldInsnNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.MethodNode; -import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; /*************************************************************************** @@ -38,8 +37,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; public class FieldCallSearch extends MethodCallSearch { @Override - public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn, - boolean exact) + public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact) { final Iterator methods = node.methods.iterator(); @@ -88,7 +86,7 @@ public class FieldCallSearch extends MethodCallSearch continue; } - found(container, node, method, insnNode, srn); + found(container, resourceWorkingName, node, method, insnNode); } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java index e6cafad8..7c9cdd34 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java @@ -4,16 +4,17 @@ import java.awt.GridLayout; import java.util.Iterator; import javax.swing.JPanel; import javax.swing.JTextField; -import org.objectweb.asm.Type; + import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodNode; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; -import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; -import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails; +import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; +import the.bytecode.club.bytecodeviewer.searching.SearchPanel; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; @@ -44,7 +45,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; * @since 09/29/2011 */ -public class LDCSearch implements SearchTypeDetails +public class LDCSearch implements SearchPanel { JTextField searchText; JPanel myPanel = null; @@ -68,8 +69,7 @@ public class LDCSearch implements SearchTypeDetails return myPanel; } - @Override - public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn, + public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, boolean caseSensitive) { final Iterator methods = node.methods.iterator(); @@ -90,13 +90,6 @@ public class LDCSearch implements SearchTypeDetails { final LdcInsnNode ldcObject = ((LdcInsnNode) insnNode); final String ldcString = ldcObject.cst.toString(); - String desc2 = method.desc; - try - { - desc2 = Type.getType(method.desc).toString(); - if (desc2.equals("null")) - desc2 = method.desc; - } catch (ArrayIndexOutOfBoundsException ignored) { } //TODO re-add this at some point when the search pane is redone boolean exact = false; @@ -107,10 +100,15 @@ public class LDCSearch implements SearchTypeDetails if (anyMatch) { - srn.notifyOfResult(container.name + ">" + node.name + "." + method.name - + desc2 - + " -> \"" + ldcString + "\" > " - + ldcObject.cst.getClass().getCanonicalName()); + BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult( + container, + resourceWorkingName, + node, + method, + null, + ldcString, + ldcObject.cst.getClass().getCanonicalName() + )); } } } @@ -120,20 +118,17 @@ public class LDCSearch implements SearchTypeDetails while (methods.hasNext()) { final FieldNode field = fields.next(); - String desc2 = field.desc; - - try - { - desc2 = Type.getType(field.desc).toString(); - - if (desc2.equals("null")) - desc2 = field.desc; - } catch (java.lang.ArrayIndexOutOfBoundsException ignored) { } if (field.value instanceof String) { - srn.notifyOfResult(container.name + ">" + node.name + "." + field.name + desc2 - + " -> \"" + field.value + "\" > field"); + BytecodeViewer.viewer.resourcePane.treeRoot.add(new LDCSearchTreeNodeResult(container, + resourceWorkingName, + node, + null, + field, + String.valueOf(field.value), + field.value.getClass().getCanonicalName() + )); } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java index 79aa7c56..17bfacfb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java @@ -12,9 +12,10 @@ import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; -import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; -import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails; +import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; +import the.bytecode.club.bytecodeviewer.searching.SearchPanel; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; @@ -45,7 +46,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; * @since 09/29/2011 */ -public class MethodCallSearch implements SearchTypeDetails +public class MethodCallSearch implements SearchPanel { JTextField mOwner; JTextField mName; @@ -62,7 +63,6 @@ public class MethodCallSearch implements SearchTypeDetails mDesc.addKeyListener(EnterKeyEvent.SINGLETON); } - @Override public JPanel getPanel() { if (myPanel == null) @@ -78,10 +78,9 @@ public class MethodCallSearch implements SearchTypeDetails return myPanel; } - + @Override - public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn, - boolean exact) + public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact) { final Iterator methods = node.methods.iterator(); @@ -130,29 +129,22 @@ public class MethodCallSearch implements SearchTypeDetails continue; } - found(container, node, method, insnNode, srn); + found(container, resourceWorkingName, node, method, insnNode); } } } } - public void found(final ResourceContainer container, final ClassNode node, final MethodNode method, final AbstractInsnNode insnNode, final SearchResultNotifier srn) + public void found(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, final MethodNode method, final AbstractInsnNode insnNode) { - String desc = method.desc; - try - { - desc = Type.getType(method.desc).toString(); - - if (desc.equals("null")) - desc = method.desc; - } catch (ArrayIndexOutOfBoundsException ignored) { } - - srn.notifyOfResult(container.name + ">" + node.name - + "." - + method.name - + desc - + " > " - + OpcodeInfo.OPCODES.get(insnNode.getOpcode()) - .toLowerCase()); + BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult( + container, + resourceWorkingName, + node, + method, + null, + OpcodeInfo.OPCODES.get(insnNode.getOpcode()).toLowerCase(), + "" + )); } } \ No newline at end of file diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java index ed919dc7..5c3e8042 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java @@ -5,13 +5,16 @@ import java.util.Iterator; import java.util.regex.Pattern; import javax.swing.JPanel; import javax.swing.JTextField; + +import eu.bibl.banalysis.asm.desc.OpcodeInfo; import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; +import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder; -import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; -import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails; +import the.bytecode.club.bytecodeviewer.searching.SearchPanel; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; @@ -44,7 +47,7 @@ import static the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder.process * @since 09/29/2011 */ -public class RegexSearch implements SearchTypeDetails +public class RegexSearch implements SearchPanel { public static JTextField searchText; JPanel myPanel = null; @@ -69,8 +72,7 @@ public class RegexSearch implements SearchTypeDetails } @Override - public void search(final ResourceContainer container, final ClassNode node, final SearchResultNotifier srn, - boolean exact) + public void search(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, boolean exact) { final Iterator methods = node.methods.iterator(); final String srchText = searchText.getText(); @@ -93,8 +95,16 @@ public class RegexSearch implements SearchTypeDetails if (desc2.equals("null")) desc2 = method.desc; } catch (java.lang.ArrayIndexOutOfBoundsException ignored) {} - - srn.notifyOfResult(container.name + ">" + node.name + "." + method.name + desc2); + + BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult( + container, + resourceWorkingName, + node, + method, + null, + node.name + "." + method.name + desc2, + "" + )); } } }