diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java
similarity index 88%
rename from src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java
rename to libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java
index 516475876..5fda2a46f 100644
--- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.jpexs.decompiler.flash.gui.abc;
+package com.jpexs.decompiler.flash.search;
import com.jpexs.decompiler.flash.abc.ScriptPack;
@@ -22,11 +22,11 @@ import com.jpexs.decompiler.flash.abc.ScriptPack;
*
* @author JPEXS
*/
-public class ABCPanelSearchResult {
+public class ABCSearchResult {
private final ScriptPack scriptPack;
- public ABCPanelSearchResult(ScriptPack scriptPack) {
+ public ABCSearchResult(ScriptPack scriptPack) {
this.scriptPack = scriptPack;
}
diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionScriptSearch.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionScriptSearch.java
new file mode 100644
index 000000000..f613ba4fc
--- /dev/null
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionScriptSearch.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2010-2016 JPEXS, All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.
+ */
+package com.jpexs.decompiler.flash.search;
+
+import com.jpexs.decompiler.flash.AppResources;
+import com.jpexs.decompiler.flash.SWF;
+import com.jpexs.decompiler.flash.abc.ScriptPack;
+import com.jpexs.decompiler.flash.cache.ScriptDecompiledListener;
+import com.jpexs.decompiler.flash.configuration.Configuration;
+import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
+import com.jpexs.decompiler.flash.helpers.HighlightedText;
+import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
+import com.jpexs.decompiler.flash.tags.base.ASMSource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Pattern;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class ActionScriptSearch {
+
+ public List searchAs2(SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, ScriptSearchListener listener) {
+ if (txt != null && !txt.isEmpty()) {
+ Map asms = swf.getASMs(false);
+ final List found = new ArrayList<>();
+ Pattern pat = regexp
+ ? Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
+ : Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
+
+ int pos = 0;
+ List> futures = new ArrayList<>();
+ String workText = AppResources.translate("work.searching");
+ String decAdd = ", " + AppResources.translate("work.decompiling");
+ try {
+ for (Map.Entry item : asms.entrySet()) {
+ pos++;
+ ASMSource asm = item.getValue();
+
+ if (pcode) {
+ //Main.startWork(workText + " \"" + txt + "\" - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
+ HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
+ asm.getASMSource(ScriptExportMode.PCODE, writer, null);
+ String text = writer.toString();
+ if (pat.matcher(text).find()) {
+ found.add(new ActionSearchResult(asm, pcode, item.getKey()));
+ }
+ } else {
+ int fpos = pos;
+ Future text = SWF.getCachedFuture(asm, null, new ScriptDecompiledListener() {
+ @Override
+ public void onStart() {
+ if (listener != null) {
+ listener.onWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + asms.size() + ") " + item.getKey() + "... ");
+ }
+ }
+
+ @Override
+ public void onComplete(HighlightedText result) {
+ if (listener != null) {
+ listener.onWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + asms.size() + ") " + item.getKey() + "... ");
+ }
+
+ if (pat.matcher(result.text).find()) {
+ ActionSearchResult searchResult = new ActionSearchResult(asm, pcode, item.getKey());
+ found.add(searchResult);
+ }
+ }
+ });
+
+ futures.add(text);
+ }
+ }
+ } catch (InterruptedException ex) {
+ for (Future future : futures) {
+ future.cancel(true);
+ }
+ }
+
+ return found;
+ }
+
+ return null;
+ }
+
+ public List searchAs3(final SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, ScriptSearchListener listener) {
+ // todo: pcode seach
+ if (txt != null && !txt.isEmpty()) {
+ List ignoredClasses = new ArrayList<>();
+ List ignoredNss = new ArrayList<>();
+
+ if (Configuration._ignoreAdditionalFlexClasses.get()) {
+ swf.getFlexMainClass(ignoredClasses, ignoredNss);
+ }
+
+ final List found = new ArrayList<>();
+ List allpacks = swf.getAS3Packs();
+ final Pattern pat = regexp
+ ? Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
+ : Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
+
+ int pos = 0;
+ List> futures = new ArrayList<>();
+ String workText = AppResources.translate("work.searching");
+ String decAdd = ", " + AppResources.translate("work.decompiling");
+ try {
+ loop:
+ for (final ScriptPack pack : allpacks) {
+ pos++;
+ if (!pack.isSimple && Configuration.ignoreCLikePackages.get()) {
+ continue;
+ }
+ if (Configuration._ignoreAdditionalFlexClasses.get()) {
+ String fullName = pack.getClassPath().packageStr.add(pack.getClassPath().className, pack.getClassPath().namespaceSuffix).toRawString();
+ if (ignoredClasses.contains(fullName)) {
+ continue;
+ }
+ for (String ns : ignoredNss) {
+ if (fullName.startsWith(ns + ".")) {
+ continue loop;
+ }
+ }
+ }
+
+ int fpos = pos;
+ Future text = SWF.getCachedFuture(pack, new ScriptDecompiledListener() {
+ @Override
+ public void onStart() {
+ if (listener != null) {
+ listener.onWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ");
+ }
+ }
+
+ @Override
+ public void onComplete(HighlightedText result) {
+ if (listener != null) {
+ listener.onWork(workText + " \"" + txt + "\" - (" + fpos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ");
+ }
+
+ if (pat.matcher(result.text).find()) {
+ ABCSearchResult searchResult = new ABCSearchResult(pack);
+ found.add(searchResult);
+ }
+ }
+ });
+
+ futures.add(text);
+ }
+
+ for (Future future : futures) {
+ try {
+ future.get();
+ } catch (ExecutionException ex) {
+ Logger.getLogger(ActionScriptSearch.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ } catch (InterruptedException ex) {
+ for (Future future : futures) {
+ future.cancel(true);
+ }
+ }
+
+ return found;
+ }
+
+ return null;
+ }
+}
diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionSearchResult.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java
similarity index 96%
rename from src/com/jpexs/decompiler/flash/gui/action/ActionSearchResult.java
rename to libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java
index 92726b12b..bc541dbd6 100644
--- a/src/com/jpexs/decompiler/flash/gui/action/ActionSearchResult.java
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.jpexs.decompiler.flash.gui.action;
+package com.jpexs.decompiler.flash.search;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ScriptSearchListener.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ScriptSearchListener.java
new file mode 100644
index 000000000..9122c2cd8
--- /dev/null
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ScriptSearchListener.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2010-2016 JPEXS, All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.
+ */
+package com.jpexs.decompiler.flash.search;
+
+/**
+ *
+ * @author JPEXS
+ */
+public interface ScriptSearchListener {
+
+ public void onWork(String message);
+}
diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java
index d5abab96c..8fbe0077a 100644
--- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java
+++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java
@@ -77,12 +77,10 @@ import com.jpexs.decompiler.flash.exporters.swf.SwfJavaExporter;
import com.jpexs.decompiler.flash.exporters.swf.SwfXmlExporter;
import com.jpexs.decompiler.flash.flexsdk.MxmlcAs3ScriptReplacer;
import com.jpexs.decompiler.flash.gui.abc.ABCPanel;
-import com.jpexs.decompiler.flash.gui.abc.ABCPanelSearchResult;
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
import com.jpexs.decompiler.flash.gui.abc.DecompiledEditorPane;
import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog;
import com.jpexs.decompiler.flash.gui.action.ActionPanel;
-import com.jpexs.decompiler.flash.gui.action.ActionSearchResult;
import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
import com.jpexs.decompiler.flash.gui.dumpview.DumpTree;
import com.jpexs.decompiler.flash.gui.dumpview.DumpTreeModel;
@@ -107,6 +105,8 @@ import com.jpexs.decompiler.flash.importers.SwfXmlImporter;
import com.jpexs.decompiler.flash.importers.SymbolClassImporter;
import com.jpexs.decompiler.flash.importers.TextImporter;
import com.jpexs.decompiler.flash.importers.svg.SvgImporter;
+import com.jpexs.decompiler.flash.search.ABCSearchResult;
+import com.jpexs.decompiler.flash.search.ActionSearchResult;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
@@ -1734,7 +1734,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
new CancellableWorker() {
@Override
protected Void doInBackground() throws Exception {
- List abcResult = null;
+ List abcResult = null;
List actionResult = null;
if (swf.isAS3()) {
abcResult = getABCPanel().search(swf, txt, ignoreCase, regexp, pCodeSearch, this);
@@ -1742,14 +1742,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
actionResult = getActionPanel().search(swf, txt, ignoreCase, regexp, pCodeSearch, this);
}
- List fAbcResult = abcResult;
+ List fAbcResult = abcResult;
List fActionResult = actionResult;
View.execInEventDispatch(() -> {
boolean found = false;
if (fAbcResult != null) {
found = true;
getABCPanel().searchPanel.setSearchText(txt);
- SearchResultsDialog sr = new SearchResultsDialog<>(getMainFrame().getWindow(), txt, getABCPanel());
+ SearchResultsDialog sr = new SearchResultsDialog<>(getMainFrame().getWindow(), txt, getABCPanel());
sr.setResults(fAbcResult);
sr.setVisible(true);
} else if (fActionResult != null) {
diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java
index 9f72ccd59..59f6a1d63 100644
--- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java
+++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java
@@ -44,7 +44,6 @@ import com.jpexs.decompiler.flash.action.parser.ActionParseException;
import com.jpexs.decompiler.flash.action.parser.script.ActionScriptLexer;
import com.jpexs.decompiler.flash.action.parser.script.ParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.script.SymbolType;
-import com.jpexs.decompiler.flash.cache.ScriptDecompiledListener;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.gui.AppDialog;
@@ -69,11 +68,13 @@ import com.jpexs.decompiler.flash.gui.abc.tablemodels.UIntTableModel;
import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
import com.jpexs.decompiler.flash.gui.editor.LinkHandler;
import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel;
-import com.jpexs.decompiler.flash.helpers.HighlightedText;
import com.jpexs.decompiler.flash.importers.As3ScriptReplaceException;
import com.jpexs.decompiler.flash.importers.As3ScriptReplaceExceptionItem;
import com.jpexs.decompiler.flash.importers.As3ScriptReplacerInterface;
import com.jpexs.decompiler.flash.importers.FFDecAs3ScriptReplacer;
+import com.jpexs.decompiler.flash.search.ABCSearchResult;
+import com.jpexs.decompiler.flash.search.ActionScriptSearch;
+import com.jpexs.decompiler.flash.search.ScriptSearchListener;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
@@ -102,11 +103,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.regex.Pattern;
import javax.swing.AbstractAction;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@@ -137,7 +135,7 @@ import jsyntaxpane.TokenType;
*
* @author JPEXS
*/
-public class ABCPanel extends JPanel implements ItemListener, SearchListener, TagEditorPanel {
+public class ABCPanel extends JPanel implements ItemListener, SearchListener, TagEditorPanel {
private As3ScriptReplacerInterface scriptReplacer = null;
@@ -169,7 +167,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener searchPanel;
+ public final SearchPanel searchPanel;
private NewTraitDialog newTraitDialog;
@@ -191,84 +189,15 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener search(final SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, CancellableWorker worker) {
- // todo: pcode seach
- List ignoredClasses = new ArrayList<>();
- List ignoredNss = new ArrayList<>();
-
- if (Configuration._ignoreAdditionalFlexClasses.get()) {
- abc.getSwf().getFlexMainClass(ignoredClasses, ignoredNss);
- }
+ public List search(final SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, CancellableWorker worker) {
if (txt != null && !txt.isEmpty()) {
searchPanel.setOptions(ignoreCase, regexp);
- TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
- TreeItem scriptsNode = ttm.getScriptsNode(swf);
- final List found = new ArrayList<>();
- if (scriptsNode instanceof ClassesListTreeModel) {
- ClassesListTreeModel clModel = (ClassesListTreeModel) scriptsNode;
- List allpacks = clModel.getList();
- final Pattern pat = regexp
- ? Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
- : Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
-
- int pos = 0;
- List> futures = new ArrayList<>();
- String workText = AppStrings.translate("work.searching");
- String decAdd = ", " + AppStrings.translate("work.decompiling");
- try {
- loop:
- for (final ScriptPack pack : allpacks) {
- pos++;
- if (!pack.isSimple && Configuration.ignoreCLikePackages.get()) {
- continue;
- }
- if (Configuration._ignoreAdditionalFlexClasses.get()) {
- String fullName = pack.getClassPath().packageStr.add(pack.getClassPath().className, pack.getClassPath().namespaceSuffix).toRawString();
- if (ignoredClasses.contains(fullName)) {
- continue;
- }
- for (String ns : ignoredNss) {
- if (fullName.startsWith(ns + ".")) {
- continue loop;
- }
- }
- }
-
- int fpos = pos;
- Future text = SWF.getCachedFuture(pack, new ScriptDecompiledListener() {
- @Override
- public void onStart() {
- Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
- }
-
- @Override
- public void onComplete(HighlightedText result) {
- Main.startWork(workText + " \"" + txt + "\" - (" + fpos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
- if (pat.matcher(result.text).find()) {
- ABCPanelSearchResult searchResult = new ABCPanelSearchResult(pack);
- found.add(searchResult);
- }
- }
- });
-
- futures.add(text);
- }
-
- for (Future future : futures) {
- try {
- future.get();
- } catch (ExecutionException ex) {
- Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- } catch (InterruptedException ex) {
- for (Future future : futures) {
- future.cancel(true);
- }
+ return new ActionScriptSearch().searchAs3(swf, txt, ignoreCase, regexp, pcode, new ScriptSearchListener() {
+ @Override
+ public void onWork(String message) {
+ Main.startWork(message, worker);
}
- }
-
- return found;
+ });
}
return null;
@@ -1275,6 +1204,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener search(SWF swf, final String txt, boolean ignoreCase, boolean regexp, boolean pcode, CancellableWorker worker) {
if (txt != null && !txt.isEmpty()) {
searchPanel.setOptions(ignoreCase, regexp);
- Map asms = swf.getASMs(false);
- final List found = new ArrayList<>();
- Pattern pat;
- if (regexp) {
- pat = Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
- } else {
- pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
- }
-
- int pos = 0;
- List> futures = new ArrayList<>();
- String workText = AppStrings.translate("work.searching");
- String decAdd = ", " + AppStrings.translate("work.decompiling");
- try {
- for (Entry item : asms.entrySet()) {
- pos++;
- ASMSource asm = item.getValue();
-
- if (pcode) {
- Main.startWork(workText + " \"" + txt + "\" - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
- HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
- asm.getASMSource(ScriptExportMode.PCODE, writer, null);
- String text = writer.toString();
- if (pat.matcher(text).find()) {
- found.add(new ActionSearchResult(asm, pcode, item.getKey()));
- }
- } else {
- int fpos = pos;
- Future text = SWF.getCachedFuture(asm, null, new ScriptDecompiledListener() {
- @Override
- public void onStart() {
- Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
- }
-
- @Override
- public void onComplete(HighlightedText result) {
- Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
- if (pat.matcher(result.text).find()) {
- ActionSearchResult searchResult = new ActionSearchResult(asm, pcode, item.getKey());
- found.add(searchResult);
- }
- }
- });
-
- futures.add(text);
- }
+ return new ActionScriptSearch().searchAs2(swf, txt, ignoreCase, regexp, pcode, new ScriptSearchListener() {
+ @Override
+ public void onWork(String message) {
+ Main.startWork(message, worker);
}
- } catch (InterruptedException ex) {
- for (Future future : futures) {
- future.cancel(true);
- }
- }
-
- return found;
+ });
}
return null;