mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 16:00:46 +00:00
Multi thread AS search
This commit is contained in:
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import com.jpexs.decompiler.flash.DecompilerPool;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.ReadOnlyTagList;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -245,6 +246,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
private final MainFrameStatusPanel statusPanel;
|
||||
|
||||
private Thread taskThread;
|
||||
|
||||
private final MainFrameMenu mainMenu;
|
||||
|
||||
private final JProgressBar progressBar = new JProgressBar(0, 100);
|
||||
@@ -843,6 +846,29 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
mainMenu.updateComponents(swf);
|
||||
|
||||
if (taskThread != null) {
|
||||
taskThread.interrupt();
|
||||
}
|
||||
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
DecompilerPool d = swf.getDecompilerPool();
|
||||
statusPanel.setStatus(swf.getFileTitle() + " " + d.getStat());
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
t.start();
|
||||
taskThread = t;
|
||||
}
|
||||
|
||||
private void updateUi() {
|
||||
|
||||
@@ -68,6 +68,7 @@ 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;
|
||||
@@ -100,6 +101,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -207,38 +209,45 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
? 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;
|
||||
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)) {
|
||||
List<Future<HighlightedText>> futures = new ArrayList<>();
|
||||
try {
|
||||
loop:
|
||||
for (final ScriptPack pack : allpacks) {
|
||||
pos++;
|
||||
if (!pack.isSimple && Configuration.ignoreCLikePackages.get()) {
|
||||
continue;
|
||||
}
|
||||
for (String ns : ignoredNss) {
|
||||
if (fullName.startsWith(ns + ".")) {
|
||||
continue loop;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = "";
|
||||
if (!SWF.isCached(pack)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
try {
|
||||
if (pat.matcher(SWF.getCached(pack).text).find()) {
|
||||
ABCPanelSearchResult searchResult = new ABCPanelSearchResult(pack);
|
||||
found.add(searchResult);
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = "";
|
||||
if (!SWF.isCached(pack)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
Future<HighlightedText> text = SWF.getCachedFuture(pack, (HighlightedText result) -> {
|
||||
if (pat.matcher(result.text).find()) {
|
||||
ABCPanelSearchResult searchResult = new ABCPanelSearchResult(pack);
|
||||
found.add(searchResult);
|
||||
}
|
||||
});
|
||||
|
||||
futures.add(text);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
for (Future<HighlightedText> future : futures) {
|
||||
future.cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public final class FlashPlayerPanel extends Panel implements Closeable, MediaDis
|
||||
}
|
||||
};
|
||||
|
||||
// hack: Kernel32.INSTANCE.ConnectNamedPipe never completes in AciveXControl static constructor
|
||||
// hack: Kernel32.INSTANCE.ConnectNamedPipe never completes in ActiveXControl static constructor
|
||||
flash = CancellableWorker.call(callable, 5, TimeUnit.SECONDS);
|
||||
} catch (ActiveXException | TimeoutException | InterruptedException | ExecutionException ex) {
|
||||
throw new FlashUnsupportedException();
|
||||
@@ -205,7 +205,6 @@ public final class FlashPlayerPanel extends Panel implements Closeable, MediaDis
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
private boolean isPlaying = false;
|
||||
|
||||
private int currentFrame = 0;
|
||||
|
||||
Reference in New Issue
Block a user