mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-12 17:38:26 +00:00
canceling tasks fixes
This commit is contained in:
@@ -66,6 +66,9 @@ public abstract class CancellableWorker<T> implements RunnableFuture<T> {
|
||||
future.run();
|
||||
}
|
||||
|
||||
protected void onStart() {
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1103,7 +1103,8 @@ public class CommandLineArgumentParser {
|
||||
SWF swf;
|
||||
try {
|
||||
swf = new SWF(new FileInputStream(inFile), sourceInfo.getFile(), sourceInfo.getFileTitle(), Configuration.parallelSpeedUp.get());
|
||||
} catch (SwfOpenException ex) {
|
||||
} catch (FileNotFoundException | SwfOpenException ex) {
|
||||
// FileNotFoundException when anti virus software blocks to open the file
|
||||
logger.log(Level.SEVERE, "Failed to open swf: " + inFile.getName(), ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -200,14 +200,6 @@ public class Main {
|
||||
proxyFrame.setState(Frame.NORMAL);
|
||||
}
|
||||
|
||||
public static void startWork(String name) {
|
||||
startWork(name, -1, null);
|
||||
}
|
||||
|
||||
public static void startWork(String name, int percent) {
|
||||
startWork(name, percent, null);
|
||||
}
|
||||
|
||||
public static void startWork(String name, CancellableWorker worker) {
|
||||
startWork(name, -1, worker);
|
||||
}
|
||||
@@ -275,10 +267,11 @@ public class Main {
|
||||
CancellableWorker<SWF> worker = new CancellableWorker<SWF>() {
|
||||
@Override
|
||||
public SWF doInBackground() throws Exception {
|
||||
final CancellableWorker worker = this;
|
||||
SWF swf = new SWF(stream, null, streamEntry.getKey(), new ProgressListener() {
|
||||
@Override
|
||||
public void progress(int p) {
|
||||
startWork(AppStrings.translate("work.reading.swf"), p);
|
||||
startWork(AppStrings.translate("work.reading.swf"), p, worker);
|
||||
}
|
||||
}, Configuration.parallelSpeedUp.get());
|
||||
return swf;
|
||||
@@ -298,10 +291,11 @@ public class Main {
|
||||
CancellableWorker<SWF> worker = new CancellableWorker<SWF>() {
|
||||
@Override
|
||||
public SWF doInBackground() throws Exception {
|
||||
final CancellableWorker worker = this;
|
||||
SWF swf = new SWF(fInputStream, sourceInfo.getFile(), sourceInfo.getFileTitle(), new ProgressListener() {
|
||||
@Override
|
||||
public void progress(int p) {
|
||||
startWork(AppStrings.translate("work.reading.swf"), p);
|
||||
startWork(AppStrings.translate("work.reading.swf"), p, worker);
|
||||
}
|
||||
}, Configuration.parallelSpeedUp.get());
|
||||
return swf;
|
||||
@@ -346,7 +340,7 @@ public class Main {
|
||||
text += " " + type;
|
||||
}
|
||||
|
||||
startWork(text + " " + index + "/" + count + " " + data);
|
||||
startWork(text + " " + index + "/" + count + " " + data, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -356,7 +350,7 @@ public class Main {
|
||||
text += " " + type;
|
||||
}
|
||||
|
||||
startWork(text + " " + index + "/" + count + " " + data);
|
||||
startWork(text + " " + index + "/" + count + " " + data, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -365,13 +359,13 @@ public class Main {
|
||||
throw new Error("Event is not supported by this handler.");
|
||||
}
|
||||
if (event.equals("getVariables")) {
|
||||
startWork(AppStrings.translate("work.gettingvariables") + "..." + (String) data);
|
||||
startWork(AppStrings.translate("work.gettingvariables") + "..." + (String) data, null);
|
||||
}
|
||||
if (event.equals("deobfuscate")) {
|
||||
startWork(AppStrings.translate("work.deobfuscating") + "..." + (String) data);
|
||||
startWork(AppStrings.translate("work.deobfuscating") + "..." + (String) data, null);
|
||||
}
|
||||
if (event.equals("rename")) {
|
||||
startWork(AppStrings.translate("work.renaming") + "..." + (String) data);
|
||||
startWork(AppStrings.translate("work.renaming") + "..." + (String) data, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -493,7 +487,7 @@ public class Main {
|
||||
for (final SWFSourceInfo sourceInfo : sourceInfos) {
|
||||
SWFList swfs = null;
|
||||
try {
|
||||
Main.startWork(AppStrings.translate("work.reading.swf") + "...");
|
||||
Main.startWork(AppStrings.translate("work.reading.swf") + "...", null);
|
||||
try {
|
||||
swfs = parseSWF(sourceInfo);
|
||||
} catch (ExecutionException ex) {
|
||||
@@ -527,7 +521,7 @@ public class Main {
|
||||
|
||||
try {
|
||||
View.execInEventDispatch(() -> {
|
||||
Main.startWork(AppStrings.translate("work.creatingwindow") + "...");
|
||||
Main.startWork(AppStrings.translate("work.creatingwindow") + "...", null);
|
||||
ensureMainFrame();
|
||||
mainFrame.getPanel().load(swfs1, first1);
|
||||
});
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javax.swing.BoxLayout;
|
||||
@@ -70,18 +69,14 @@ public class MainFrameStatusPanel extends JPanel {
|
||||
cancelButton.setPreferredSize(new Dimension(100, 30));
|
||||
cancelButton.setBorderPainted(false);
|
||||
cancelButton.setOpaque(false);
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (currentWorker != null) {
|
||||
currentWorker.cancel(true);
|
||||
}
|
||||
cancelButton.addActionListener((ActionEvent e) -> {
|
||||
if (currentWorker != null) {
|
||||
currentWorker.cancel(true);
|
||||
}
|
||||
});
|
||||
statusLeftPanel.add(loadingPanel);
|
||||
statusLeftPanel.add(statusLabel);
|
||||
statusLeftPanel.add(cancelButton);
|
||||
statusLeftPanel.add(statusLabel);
|
||||
setPreferredSize(new Dimension(1, 30));
|
||||
setBorder(new BevelBorder(BevelBorder.LOWERED));
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
@@ -72,10 +72,12 @@ import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.swf.SwfJavaExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.swf.SwfXmlExporter;
|
||||
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;
|
||||
@@ -1143,13 +1145,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
}
|
||||
|
||||
if (selFile == null) {
|
||||
selFile = selectExportDir();
|
||||
if (selFile == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
EventListener evl = swf.getExportEventListener();
|
||||
|
||||
if (export.isOptionEnabled(ImageExportMode.class)) {
|
||||
@@ -1247,7 +1242,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
if (!tls.isSimple && Configuration.ignoreCLikePackages.get()) {
|
||||
continue;
|
||||
}
|
||||
Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + as3scripts.size() + " " + tls.getPath() + " ...");
|
||||
|
||||
Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + as3scripts.size() + " " + tls.getPath() + " ...", null);
|
||||
ret.add(tls.export(scriptsFolder, scriptExportSettings, parallel));
|
||||
}
|
||||
}
|
||||
@@ -1575,44 +1571,96 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
final String txt = searchDialog.searchField.getText();
|
||||
if (!txt.isEmpty()) {
|
||||
final SWF swf = getCurrentSwf();
|
||||
if (swf.isAS3()) {
|
||||
getABCPanel();
|
||||
} else {
|
||||
getActionPanel();
|
||||
}
|
||||
|
||||
new CancellableWorker() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
boolean found = false;
|
||||
if (searchDialog.searchInASRadioButton.isSelected()) {
|
||||
boolean ignoreCase = searchDialog.ignoreCaseCheckBox.isSelected();
|
||||
boolean regexp = searchDialog.regexpCheckBox.isSelected();
|
||||
|
||||
if (searchDialog.searchInASRadioButton.isSelected()) {
|
||||
new CancellableWorker<Void>() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
List<ABCPanelSearchResult> abcResult = null;
|
||||
List<ActionSearchResult> actionResult = null;
|
||||
if (swf.isAS3()) {
|
||||
// todo: honfika: do not call this from background thread
|
||||
View.execInEventDispatch(() -> {
|
||||
getActionPanel();
|
||||
});
|
||||
|
||||
if (getABCPanel().search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
|
||||
found = true;
|
||||
}
|
||||
abcResult = getABCPanel().search(txt, ignoreCase, regexp, this);
|
||||
} else {
|
||||
// todo: honfika: do not call this from background thread
|
||||
View.execInEventDispatch(() -> {
|
||||
getActionPanel();
|
||||
});
|
||||
actionResult = getActionPanel().search(txt, ignoreCase, regexp, this);
|
||||
}
|
||||
|
||||
if (getActionPanel().search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
|
||||
List<ABCPanelSearchResult> fAbcResult = abcResult;
|
||||
List<ActionSearchResult> fActionResult = actionResult;
|
||||
View.execInEventDispatch(() -> {
|
||||
boolean found = false;
|
||||
if (fAbcResult != null) {
|
||||
found = true;
|
||||
getABCPanel().searchPanel.setSearchText(txt);
|
||||
SearchResultsDialog<ABCPanelSearchResult> sr = new SearchResultsDialog<>(getMainFrame().getWindow(), txt, getABCPanel());
|
||||
sr.setResults(fAbcResult);
|
||||
sr.setVisible(true);
|
||||
} else if (fActionResult != null) {
|
||||
found = true;
|
||||
getActionPanel().searchPanel.setSearchText(txt);
|
||||
|
||||
SearchResultsDialog<ActionSearchResult> sr = new SearchResultsDialog<>(getMainFrame().getWindow(), txt, getActionPanel());
|
||||
sr.setResults(fActionResult);
|
||||
sr.setVisible(true);
|
||||
}
|
||||
}
|
||||
} else if (searchDialog.searchInTextsRadioButton.isSelected()) {
|
||||
if (searchText(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected(), swf)) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
View.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
View.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE);
|
||||
@Override
|
||||
protected void done() {
|
||||
View.execInEventDispatch(() -> {
|
||||
Main.stopWork();
|
||||
});
|
||||
|
||||
}
|
||||
}.execute();
|
||||
} else if (searchDialog.searchInTextsRadioButton.isSelected()) {
|
||||
new CancellableWorker<Void>() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
List<TextTag> textResult = null;
|
||||
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
|
||||
textSearchPanel.setOptions(ignoreCase, regexp);
|
||||
textResult = searchText(txt, ignoreCase, regexp, swf);
|
||||
|
||||
List<TextTag> fTextResult = textResult;
|
||||
View.execInEventDispatch(() -> {
|
||||
textSearchPanel.setSearchText(txt);
|
||||
boolean found = textSearchPanel.setResults(fTextResult);
|
||||
if (!found) {
|
||||
View.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
@Override
|
||||
protected void done() {
|
||||
View.execInEventDispatch(() -> {
|
||||
Main.stopWork();
|
||||
});
|
||||
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1683,10 +1731,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
}
|
||||
|
||||
private boolean searchText(String txt, boolean ignoreCase, boolean regexp, SWF swf) {
|
||||
private List<TextTag> searchText(String txt, boolean ignoreCase, boolean regexp, SWF swf) {
|
||||
if (txt != null && !txt.isEmpty()) {
|
||||
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
|
||||
textSearchPanel.setOptions(ignoreCase, regexp);
|
||||
List<TextTag> found = new ArrayList<>();
|
||||
Pattern pat;
|
||||
if (regexp) {
|
||||
@@ -1702,10 +1748,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
}
|
||||
}
|
||||
textSearchPanel.setSearchText(txt);
|
||||
return textSearchPanel.setResults(found);
|
||||
|
||||
return found;
|
||||
}
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1759,11 +1806,15 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
new CancellableWorker() {
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
Main.startWork(translate("work.renaming") + "...");
|
||||
renameMultiname(abcList, multiName);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.renaming") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
Main.stopWork();
|
||||
@@ -1779,7 +1830,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
new CancellableWorker() {
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
Main.startWork(translate("work.renaming") + "...");
|
||||
try {
|
||||
renameIdentifier(swf, identifier);
|
||||
} catch (InterruptedException ex) {
|
||||
@@ -1788,6 +1838,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.renaming") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
Main.stopWork();
|
||||
@@ -1862,7 +1917,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath());
|
||||
File sf = Helper.fixDialogFile(fc.getSelectedFile());
|
||||
|
||||
Main.startWork(translate("work.exporting.fla") + "...");
|
||||
final boolean compressed = flaFilters.contains(fc.getFileFilter());
|
||||
if (!compressed) {
|
||||
if (sf.getName().endsWith(".fla")) {
|
||||
@@ -1889,9 +1943,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.exporting.fla") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
Main.stopWork();
|
||||
if (Configuration.openFolderAfterFlaExport.get()) {
|
||||
try {
|
||||
Desktop.getDesktop().open(selfile.getAbsoluteFile().getParentFile());
|
||||
@@ -1899,6 +1957,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
@@ -2012,7 +2072,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
chooser.setAcceptAllFileFilterUsed(false);
|
||||
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
Main.startWork(translate("work.exporting") + "...");
|
||||
final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath();
|
||||
Configuration.lastExportDir.set(Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath());
|
||||
return selFile;
|
||||
@@ -2036,9 +2095,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
final String selFile = selectExportDir();
|
||||
if (selFile != null) {
|
||||
final long timeBefore = System.currentTimeMillis();
|
||||
Main.startWork(translate("work.exporting") + "...");
|
||||
|
||||
new CancellableWorker() {
|
||||
new CancellableWorker<Void>() {
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
try {
|
||||
@@ -2055,6 +2113,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.exporting") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
Main.stopWork();
|
||||
@@ -2078,6 +2141,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
SWF swf = (SWF) item;
|
||||
final String selFile = selectExportDir();
|
||||
if (selFile != null) {
|
||||
Main.startWork(translate("work.exporting") + "...", null);
|
||||
|
||||
try {
|
||||
new SwfJavaExporter().exportJavaCode(swf, selFile);
|
||||
Main.stopWork();
|
||||
@@ -2100,6 +2165,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
for (SWF swf : swfs) {
|
||||
final String selFile = selectExportDir();
|
||||
if (selFile != null) {
|
||||
Main.startWork(translate("work.exporting") + "...", null);
|
||||
|
||||
try {
|
||||
File outFile = new File(selFile + File.separator + Helper.makeFileName("swf.xml"));
|
||||
new SwfXmlExporter().exportXml(swf, outFile);
|
||||
@@ -2140,11 +2207,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void restoreControlFlow(final boolean all) {
|
||||
Main.startWork(translate("work.restoringControlFlow"));
|
||||
if ((!all) || confirmExperimental()) {
|
||||
new CancellableWorker() {
|
||||
new CancellableWorker<Void>() {
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
protected Void doInBackground() throws Exception {
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
if (all) {
|
||||
for (ABCContainerTag tag : abcPanel.getAbcList()) {
|
||||
@@ -2159,7 +2225,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, abcPanel.decompiledTextArea.getCurrentTrait(), abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getScriptIndex());
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.restoringControlFlow"), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2184,7 +2255,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
RenameDialog renameDialog = new RenameDialog();
|
||||
if (renameDialog.showRenameDialog() == AppDialog.OK_OPTION) {
|
||||
final RenameType renameType = renameDialog.getRenameType();
|
||||
Main.startWork(translate("work.renaming.identifiers") + "...");
|
||||
new CancellableWorker<Integer>() {
|
||||
@Override
|
||||
protected Integer doInBackground() throws Exception {
|
||||
@@ -2192,6 +2262,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.renaming.identifiers") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
View.execInEventDispatch(() -> {
|
||||
@@ -2221,12 +2296,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
public void deobfuscate() {
|
||||
DeobfuscationDialog deobfuscationDialog = new DeobfuscationDialog();
|
||||
if (deobfuscationDialog.showDialog() == AppDialog.OK_OPTION) {
|
||||
Main.startWork(translate("work.deobfuscating") + "...");
|
||||
new CancellableWorker() {
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
protected Void doInBackground() throws Exception {
|
||||
try {
|
||||
ABCPanel aBCPanel = getABCPanel();
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
if (deobfuscationDialog.processAllCheckbox.isSelected()) {
|
||||
for (ABCContainerTag tag : abcPanel.getAbcList()) {
|
||||
if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE.getLevel()) {
|
||||
@@ -2259,7 +2333,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Deobfuscation error", ex);
|
||||
}
|
||||
return true;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.deobfuscating") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2823,11 +2903,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
public void loadFromBinaryTag(final List<DefineBinaryDataTag> binaryDataTags) {
|
||||
|
||||
Main.loadingDialog.setVisible(true);
|
||||
Main.startWork(AppStrings.translate("work.reading.swf") + "...");
|
||||
new Thread() {
|
||||
new CancellableWorker<Void>() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
protected Void doInBackground() throws Exception {
|
||||
try {
|
||||
for (DefineBinaryDataTag binaryDataTag : binaryDataTags) {
|
||||
try {
|
||||
@@ -2849,12 +2928,22 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
//ignore
|
||||
}
|
||||
|
||||
Main.loadingDialog.setVisible(false);
|
||||
Main.stopWork();
|
||||
return null;
|
||||
}
|
||||
|
||||
}.start();
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(AppStrings.translate("work.reading.swf") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
View.execInEventDispatch(() -> {
|
||||
Main.loadingDialog.setVisible(false);
|
||||
Main.stopWork();
|
||||
});
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void closeTag() {
|
||||
@@ -2920,7 +3009,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
setSourceWorker = null;
|
||||
}
|
||||
if (!Main.isWorking()) {
|
||||
Main.startWork(AppStrings.translate("work.decompiling") + "...");
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
|
||||
@Override
|
||||
@@ -2933,11 +3021,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Main.startWork(translate("work.decompiling") + "...", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
View.execInEventDispatch(() -> {
|
||||
Main.stopWork();
|
||||
|
||||
setSourceWorker = null;
|
||||
try {
|
||||
get();
|
||||
@@ -2947,13 +3038,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, "Error", ex);
|
||||
getABCPanel().decompiledTextArea.setText("// " + AppStrings.translate("decompilationError") + ": " + ex);
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
worker.execute();
|
||||
setSourceWorker = worker;
|
||||
|
||||
Main.startWork(translate("work.decompiling") + "...", worker);
|
||||
}
|
||||
|
||||
showDetail(DETAILCARDAS3NAVIGATOR);
|
||||
|
||||
@@ -47,7 +47,6 @@ import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchListener;
|
||||
import com.jpexs.decompiler.flash.gui.SearchPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchResultsDialog;
|
||||
import com.jpexs.decompiler.flash.gui.TagEditorPanel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.gui.abc.tablemodels.DecimalTableModel;
|
||||
@@ -83,7 +82,6 @@ import java.awt.event.MouseMotionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -140,7 +138,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
public final JTabbedPane tabbedPane;
|
||||
|
||||
private final SearchPanel<ABCPanelSearchResult> searchPanel;
|
||||
public final SearchPanel<ABCPanelSearchResult> searchPanel;
|
||||
|
||||
private NewTraitDialog newTraitDialog;
|
||||
|
||||
@@ -160,8 +158,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
public List<ABCPanelSearchResult> search(final String txt, boolean ignoreCase, boolean regexp, CancellableWorker<Void> worker) {
|
||||
if (txt != null && !txt.isEmpty()) {
|
||||
searchPanel.setOptions(ignoreCase, regexp);
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
TreeItem scriptsNode = ttm.getScriptsNode(mainPanel.getCurrentSwf());
|
||||
@@ -184,45 +182,23 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
try {
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
if (pat.matcher(SWF.getCached(pack).text).find()) {
|
||||
ABCPanelSearchResult searchResult = new ABCPanelSearchResult();
|
||||
searchResult.scriptPack = pack;
|
||||
found.add(searchResult);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
worker.execute();
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
worker.get();
|
||||
if (pat.matcher(SWF.getCached(pack).text).find()) {
|
||||
ABCPanelSearchResult searchResult = new ABCPanelSearchResult();
|
||||
searchResult.scriptPack = pack;
|
||||
found.add(searchResult);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
} catch (ExecutionException ex) {
|
||||
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
|
||||
searchPanel.setSearchText(txt);
|
||||
|
||||
View.execInEventDispatch(() -> {
|
||||
SearchResultsDialog<ABCPanelSearchResult> sr = new SearchResultsDialog<>(ABCPanel.this.mainPanel.getMainFrame().getWindow(), txt, ABCPanel.this);
|
||||
sr.setResults(found);
|
||||
sr.setVisible(true);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
//return searchPanel.setResults(found);
|
||||
return found;
|
||||
}
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAbc(ABC abc) {
|
||||
@@ -750,7 +726,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
String oldSp = pack.getClassPath().toString();
|
||||
/*List<ScriptPack> packs = abc.script_info.get(oldIndex).getPacks(abc, oldIndex, null, pack.allABCs);
|
||||
if (!packs.isEmpty()) {
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
String as = decompiledTextArea.getText();
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchListener;
|
||||
import com.jpexs.decompiler.flash.gui.SearchPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchResultsDialog;
|
||||
import com.jpexs.decompiler.flash.gui.TagEditorPanel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
|
||||
@@ -236,8 +235,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
public List<ActionSearchResult> search(final String txt, boolean ignoreCase, boolean regexp, CancellableWorker<Void> worker) {
|
||||
if (txt != null && !txt.isEmpty()) {
|
||||
searchPanel.setOptions(ignoreCase, regexp);
|
||||
SWF swf = mainPanel.getCurrentSwf();
|
||||
Map<String, ASMSource> asms = swf.getASMs(false);
|
||||
@@ -257,7 +256,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
if (!SWF.isCached(asm)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ");
|
||||
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
|
||||
try {
|
||||
if (pat.matcher(SWF.getCached(asm, null).text).find()) {
|
||||
found.add(new ActionSearchResult(asm, item.getKey()));
|
||||
@@ -267,17 +267,10 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
searchPanel.setSearchText(txt);
|
||||
View.execInEventDispatch(() -> {
|
||||
SearchResultsDialog<ActionSearchResult> sr = new SearchResultsDialog<>(ActionPanel.this.mainPanel.getMainFrame().getWindow(), txt, ActionPanel.this);
|
||||
sr.setResults(found);
|
||||
sr.setVisible(true);
|
||||
});
|
||||
return true;
|
||||
//return searchPanel.setResults(found);
|
||||
return found;
|
||||
}
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setDecompiledText(final String text) {
|
||||
|
||||
Reference in New Issue
Block a user