bcv-vf/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java

56 lines
1.9 KiB
Java
Raw Normal View History

package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
2021-07-04 07:03:40 +00:00
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch;
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
2021-07-11 09:14:42 +00:00
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import javax.swing.tree.TreePath;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/**
* @author Konloch
* @since 6/25/2021
*/
class PerformSearch extends BackgroundSearchThread
{
private final SearchBoxPane searchBoxPane;
private final SearchResultNotifier srn;
public PerformSearch(SearchBoxPane searchBoxPane, SearchResultNotifier srn)
{
this.searchBoxPane = searchBoxPane;
this.srn = srn;
}
@Override
2021-07-04 07:03:40 +00:00
public void search()
{
try
{
Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), Pattern.MULTILINE);
}
catch (PatternSyntaxException ex)
{
BytecodeViewer.showMessage("You have an error in your regex syntax.");
}
for (ResourceContainer container : BytecodeViewer.files)
2021-07-10 16:05:08 +00:00
for (ClassNode c : container.resourceClasses.values())
searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected());
Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).search.setEnabled(true);
Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).search.setText(TranslatedStrings.SEARCH.getText());
searchBoxPane.tree.expandPath(new TreePath(searchBoxPane.tree.getModel().getRoot()));
searchBoxPane.tree.updateUI();
}
}