diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index f136a3aab..a607e5773 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1017,29 +1017,50 @@ public class Main { private final Runnable executeAfterOpen; + private final int[] reloadIndices; + public OpenFileWorker(SWFSourceInfo sourceInfo) { - this(sourceInfo, null); + this(sourceInfo, -1); + } + + public OpenFileWorker(SWFSourceInfo sourceInfo, int reloadIndex) { + this(sourceInfo, null, reloadIndex); } public OpenFileWorker(SWFSourceInfo sourceInfo, Runnable executeAfterOpen) { + this(sourceInfo, executeAfterOpen, -1); + } + + public OpenFileWorker(SWFSourceInfo sourceInfo, Runnable executeAfterOpen, int reloadIndex) { this.sourceInfos = new SWFSourceInfo[]{sourceInfo}; this.executeAfterOpen = executeAfterOpen; + this.reloadIndices = new int[]{reloadIndex}; } public OpenFileWorker(SWFSourceInfo[] sourceInfos) { - this(sourceInfos, null); + this(sourceInfos, null, null); } public OpenFileWorker(SWFSourceInfo[] sourceInfos, Runnable executeAfterOpen) { + this(sourceInfos, executeAfterOpen, null); + } + + public OpenFileWorker(SWFSourceInfo[] sourceInfos, Runnable executeAfterOpen, int[] reloadIndices) { this.sourceInfos = sourceInfos; this.executeAfterOpen = executeAfterOpen; + int indices[] = new int[sourceInfos.length]; + for (int i = 0; i < indices.length; i++) { + indices[i] = -1; + } + this.reloadIndices = reloadIndices == null ? indices : reloadIndices; } @Override protected Object doInBackground() throws Exception { boolean first = true; SWF firstSWF = null; - for (final SWFSourceInfo sourceInfo : sourceInfos) { + for (int index = 0; index < sourceInfos.length; index++) { + SWFSourceInfo sourceInfo = sourceInfos[index]; SWFList swfs = null; try { Main.startWork(AppStrings.translate("work.reading.swf") + "...", null); @@ -1074,11 +1095,16 @@ public class Main { firstSWF = swfs1.get(0); } + final int findex = index; try { View.execInEventDispatch(() -> { Main.startWork(AppStrings.translate("work.creatingwindow") + "...", null); ensureMainFrame(); - mainFrame.getPanel().load(swfs1, first1); + if (reloadIndices[findex] > -1) { + mainFrame.getPanel().loadSwfAtPos(swfs1, reloadIndices[findex]); + } else { + mainFrame.getPanel().load(swfs1, first1); + } }); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); @@ -1204,22 +1230,38 @@ public class Main { return openFile(new SWFSourceInfo[]{sourceInfo}, executeAfterOpen); } + public static OpenFileResult openFile(SWFSourceInfo sourceInfo, Runnable executeAfterOpen, int reloadIndex) { + return openFile(new SWFSourceInfo[]{sourceInfo}, executeAfterOpen, new int[]{reloadIndex}); + } + public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos) { return openFile(newSourceInfos, null); } public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos, Runnable executeAfterOpen) { + return openFile(newSourceInfos, executeAfterOpen, null); + } + + public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos, Runnable executeAfterOpen, int[] reloadIndices) { if (mainFrame != null && !Configuration.openMultipleFiles.get()) { sourceInfos.clear(); mainFrame.getPanel().closeAll(false); mainFrame.setVisible(false); Helper.freeMem(); + reloadIndices = null; } loadingDialog.setVisible(true); - OpenFileWorker wrk = new OpenFileWorker(newSourceInfos, executeAfterOpen); + + OpenFileWorker wrk = new OpenFileWorker(newSourceInfos, executeAfterOpen, reloadIndices); wrk.execute(); - sourceInfos.addAll(Arrays.asList(newSourceInfos)); + if (reloadIndices == null) { + sourceInfos.addAll(Arrays.asList(newSourceInfos)); + } else { + for (int i = 0; i < reloadIndices.length; i++) { + sourceInfos.set(reloadIndices[i], newSourceInfos[i]); + } + } return OpenFileResult.OK; } @@ -1228,6 +1270,11 @@ public class Main { mainFrame.getPanel().close(swf); } + public static void reloadFile(SWFList swf) { + //mainFrame.getPanel().close(swf); + openFile(swf.sourceInfo, null, sourceInfos.indexOf(swf.sourceInfo)); + } + public static boolean closeAll() { boolean closeResult = mainFrame.getPanel().closeAll(true); if (closeResult) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 1cf0ae1ae..c4a81f176 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.streams.SeekableInputStream; import com.jpexs.helpers.utf8.Utf8Helper; import com.sun.jna.Platform; import java.awt.BorderLayout; @@ -44,7 +45,10 @@ import java.awt.event.KeyEvent; import java.awt.event.WindowEvent; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.PrintStream; import java.util.HashMap; import java.util.List; @@ -514,6 +518,15 @@ public abstract class MainFrameMenu implements MenuBuilder { protected boolean reloadActionPerformed(ActionEvent evt) { if (swf != null) { if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { + Main.reloadFile(swf.swfList); + } + } + return true; + } + + protected boolean reloadAllActionPerformed(ActionEvent evt) { + if (swf != null) { + if (View.showConfirmDialog(null, translate("message.confirm.reloadAll"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { Main.reloadApp(); } @@ -786,6 +799,7 @@ public abstract class MainFrameMenu implements MenuBuilder { addMenuItem("/file/saveAs", translate("menu.file.saveas"), "saveas16", this::saveAsActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+A"), false); addMenuItem("/file/saveAsExe", translate("menu.file.saveasexe"), "saveasexe16", this::saveAsExeActionPerformed, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/file/reload", translate("menu.file.reload"), "reload16", this::reloadActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+R"), false); + addMenuItem("/file/reloadAll", translate("menu.file.reloadAll"), "reload16", this::reloadAllActionPerformed, PRIORITY_MEDIUM, null, true, null, false); addSeparator("/file"); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 6324001d1..c076a754c 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -775,6 +775,18 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se searchPanel.setVisible(false); } + public void loadSwfAtPos(SWFList newSwfs, int index) { + previewPanel.clear(); + swfs.set(index, newSwfs); + SWF swf = newSwfs.size() > 0 ? newSwfs.get(0) : null; + if (swf != null) { + updateUi(swf); + } + + doFilter(); + reload(false); + } + public void load(SWFList newSwfs, boolean first) { previewPanel.clear();