mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 04:35:35 +00:00
UI thread invoke fixes/improvements
This commit is contained in:
@@ -497,17 +497,16 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void showRestartConfirmDialod() {
|
||||
private void showRestartConfirmDialog() {
|
||||
if (View.showConfirmDialog(this, translate("advancedSettings.restartConfirmation"), AppStrings.translate("message.warning"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
View.execInEventDispatchLater(() -> {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
SelectLanguageDialog.reloadUi();
|
||||
});
|
||||
try {
|
||||
// todo: honfika: why?
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
SelectLanguageDialog.reloadUi();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,7 +596,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
Configuration.saveConfig();
|
||||
setVisible(false);
|
||||
if (modified) {
|
||||
showRestartConfirmDialod();
|
||||
showRestartConfirmDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,6 +619,6 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
}
|
||||
Configuration.saveConfig();
|
||||
setVisible(false);
|
||||
showRestartConfirmDialod();
|
||||
showRestartConfirmDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ public class LoadFromMemoryFrame extends AppFrame {
|
||||
@Override
|
||||
protected List<SwfInMemory> doInBackground() throws Exception {
|
||||
return new SearchInMemory(new SearchInMemoryListener() {
|
||||
|
||||
@Override
|
||||
public void publish(Object... chunks) {
|
||||
SelectProcessWorker.this.publish(chunks);
|
||||
@@ -151,6 +150,8 @@ public class LoadFromMemoryFrame extends AppFrame {
|
||||
}
|
||||
|
||||
private void openSwf() {
|
||||
View.checkAccess();
|
||||
|
||||
if (foundIs == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1220,10 +1220,14 @@ public class Main {
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(String swfFile, String fileTitle) {
|
||||
View.checkAccess();
|
||||
|
||||
return openFile(swfFile, fileTitle, null);
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(String swfFile, String fileTitle, Runnable executeAfterOpen) {
|
||||
View.checkAccess();
|
||||
|
||||
try {
|
||||
File file = new File(swfFile);
|
||||
if (!file.exists()) {
|
||||
@@ -1241,26 +1245,38 @@ public class Main {
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(SWFSourceInfo sourceInfo) {
|
||||
View.checkAccess();
|
||||
|
||||
return openFile(new SWFSourceInfo[]{sourceInfo});
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(SWFSourceInfo sourceInfo, Runnable executeAfterOpen) {
|
||||
View.checkAccess();
|
||||
|
||||
return openFile(new SWFSourceInfo[]{sourceInfo}, executeAfterOpen);
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(SWFSourceInfo sourceInfo, Runnable executeAfterOpen, int reloadIndex) {
|
||||
View.checkAccess();
|
||||
|
||||
return openFile(new SWFSourceInfo[]{sourceInfo}, executeAfterOpen, new int[]{reloadIndex});
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos) {
|
||||
View.checkAccess();
|
||||
|
||||
return openFile(newSourceInfos, null);
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos, Runnable executeAfterOpen) {
|
||||
View.checkAccess();
|
||||
|
||||
return openFile(newSourceInfos, executeAfterOpen, null);
|
||||
}
|
||||
|
||||
public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos, Runnable executeAfterOpen, int[] reloadIndices) {
|
||||
View.checkAccess();
|
||||
|
||||
if (mainFrame != null && !Configuration.openMultipleFiles.get()) {
|
||||
sourceInfos.clear();
|
||||
mainFrame.getPanel().closeAll(false);
|
||||
@@ -1292,16 +1308,21 @@ public class Main {
|
||||
}
|
||||
|
||||
public static void closeFile(SWFList swf) {
|
||||
View.checkAccess();
|
||||
|
||||
sourceInfos.remove(swf.sourceInfo);
|
||||
mainFrame.getPanel().close(swf);
|
||||
}
|
||||
|
||||
public static void reloadFile(SWFList swf) {
|
||||
//mainFrame.getPanel().close(swf);
|
||||
View.checkAccess();
|
||||
|
||||
openFile(swf.sourceInfo, null, sourceInfos.indexOf(swf.sourceInfo));
|
||||
}
|
||||
|
||||
public static boolean closeAll() {
|
||||
View.checkAccess();
|
||||
|
||||
boolean closeResult = mainFrame.getPanel().closeAll(true);
|
||||
if (closeResult) {
|
||||
sourceInfos.clear();
|
||||
@@ -1428,6 +1449,8 @@ public class Main {
|
||||
}
|
||||
|
||||
public static boolean openFileDialog() {
|
||||
View.checkAccess();
|
||||
|
||||
JFileChooser fc = new JFileChooser();
|
||||
if (Configuration.openMultipleFiles.get()) {
|
||||
fc.setMultiSelectionEnabled(true);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -134,7 +134,6 @@ import com.jpexs.decompiler.flash.tags.base.SoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SymbolClassTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextImportErrorHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.tags.text.TextAlign;
|
||||
import com.jpexs.decompiler.flash.tags.text.TextParseException;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
@@ -340,11 +339,15 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
private static final Logger logger = Logger.getLogger(MainPanel.class.getName());
|
||||
|
||||
public void setPercent(int percent) {
|
||||
View.checkAccess();
|
||||
|
||||
progressBar.setValue(percent);
|
||||
progressBar.setVisible(true);
|
||||
}
|
||||
|
||||
public void hidePercent() {
|
||||
View.checkAccess();
|
||||
|
||||
if (progressBar.isVisible()) {
|
||||
progressBar.setVisible(false);
|
||||
}
|
||||
@@ -779,12 +782,16 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void closeTagTreeSearch() {
|
||||
View.checkAccess();
|
||||
|
||||
filterField.setText("");
|
||||
doFilter();
|
||||
searchPanel.setVisible(false);
|
||||
}
|
||||
|
||||
public void loadSwfAtPos(SWFList newSwfs, int index) {
|
||||
View.checkAccess();
|
||||
|
||||
previewPanel.clear();
|
||||
swfs.set(index, newSwfs);
|
||||
SWF swf = newSwfs.size() > 0 ? newSwfs.get(0) : null;
|
||||
@@ -797,6 +804,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void load(SWFList newSwfs, boolean first) {
|
||||
View.checkAccess();
|
||||
|
||||
previewPanel.clear();
|
||||
|
||||
@@ -830,6 +838,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
private void updateUi(final SWF swf) {
|
||||
View.checkAccess();
|
||||
|
||||
List<ABCContainerTag> abcList = swf.getAbcList();
|
||||
|
||||
@@ -874,6 +883,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
private void updateUi() {
|
||||
View.checkAccess();
|
||||
|
||||
if (!isWelcomeScreen && swfs.isEmpty()) {
|
||||
CardLayout cl = (CardLayout) (contentPanel.getLayout());
|
||||
cl.show(contentPanel, WELCOME_PANEL);
|
||||
@@ -888,6 +899,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
private boolean closeConfirmation(SWFList swfList) {
|
||||
View.checkAccess();
|
||||
|
||||
String message = swfList == null
|
||||
? translate("message.confirm.closeAll")
|
||||
: translate("message.confirm.close").replace("{swfName}", swfList.toString());
|
||||
@@ -908,6 +921,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public boolean closeAll(boolean showCloseConfirmation) {
|
||||
View.checkAccess();
|
||||
|
||||
if (showCloseConfirmation && isModified()) {
|
||||
boolean closeConfirmResult = closeConfirmation(swfs.size() == 1 ? swfs.get(0) : null);
|
||||
if (!closeConfirmResult) {
|
||||
@@ -932,6 +947,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public boolean close(SWFList swfList) {
|
||||
View.checkAccess();
|
||||
|
||||
boolean modified = false;
|
||||
for (SWF swf : swfList) {
|
||||
if (swf.isModified()) {
|
||||
@@ -959,7 +976,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return true;
|
||||
}
|
||||
|
||||
public void enableDrop(boolean value) {
|
||||
private void enableDrop(boolean value) {
|
||||
if (value) {
|
||||
setDropTarget(new DropTarget() {
|
||||
@Override
|
||||
@@ -1002,6 +1019,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void doFilter() {
|
||||
View.checkAccess();
|
||||
|
||||
List<TreeItem> nodes = getASTreeNodes(tagTree);
|
||||
for (TreeItem n : nodes) {
|
||||
if (n instanceof ClassesListTreeModel) {
|
||||
@@ -1056,15 +1075,18 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
}
|
||||
|
||||
View.showMessageDialog(null, translate("rename.finished.multiname").replace("%count%", Integer.toString(mulCount)));
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
int fmulCount = mulCount;
|
||||
View.execInEventDispatchLater(() -> {
|
||||
View.showMessageDialog(null, translate("rename.finished.multiname").replace("%count%", Integer.toString(fmulCount)));
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
|
||||
updateClassesList();
|
||||
reload(true);
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
abcPanel.hilightScript(abcPanel.getSwf(), abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().toRawString());
|
||||
updateClassesList();
|
||||
reload(true);
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
abcPanel.hilightScript(abcPanel.getSwf(), abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().toRawString());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1094,6 +1116,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public boolean confirmExperimental() {
|
||||
View.checkAccess();
|
||||
|
||||
return View.showConfirmDialog(null, translate("message.confirm.experimental"), translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION;
|
||||
}
|
||||
|
||||
@@ -1571,6 +1595,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void gotoFrame(int frame) {
|
||||
View.checkAccess();
|
||||
|
||||
TreeItem treeItem = (TreeItem) tagTree.getLastSelectedPathComponent();
|
||||
if (treeItem == null) {
|
||||
return;
|
||||
@@ -1585,6 +1611,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void gotoScriptLine(SWF swf, String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
|
||||
View.checkAccess();
|
||||
|
||||
gotoScriptName(swf, scriptName);
|
||||
if (abcPanel != null) {
|
||||
if (Main.isDebugPCode()) {
|
||||
@@ -1639,6 +1667,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
}*/
|
||||
public void gotoScriptName(SWF swf, String scriptName) {
|
||||
View.checkAccess();
|
||||
|
||||
if (swf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1667,6 +1697,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void gotoDocumentClass(SWF swf) {
|
||||
View.checkAccess();
|
||||
|
||||
if (swf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1688,6 +1720,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void disableDecompilationChanged() {
|
||||
View.checkAccess();
|
||||
|
||||
clearAllScriptCache();
|
||||
|
||||
if (abcPanel != null) {
|
||||
@@ -1706,6 +1740,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void searchInActionScriptOrText(Boolean searchInText, SWF swf) {
|
||||
View.checkAccess();
|
||||
|
||||
SearchDialog searchDialog = new SearchDialog(getMainFrame().getWindow(), false);
|
||||
if (searchInText != null) {
|
||||
if (searchInText) {
|
||||
@@ -1907,6 +1943,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
@Override
|
||||
public void updateSearchPos(TextTag item) {
|
||||
View.checkAccess();
|
||||
|
||||
setTagTreeSelectedNode(item);
|
||||
previewPanel.getTextPanel().updateSearchPos();
|
||||
}
|
||||
@@ -1944,6 +1982,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void renameColliding(final SWF swf) {
|
||||
View.checkAccess();
|
||||
|
||||
if (swf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1986,6 +2026,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void renameOneIdentifier(final SWF swf) {
|
||||
View.checkAccess();
|
||||
|
||||
if (swf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2296,6 +2338,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void export(final boolean onlySel) {
|
||||
View.checkAccess();
|
||||
|
||||
final SWF swf = getCurrentSwf();
|
||||
List<TreeItem> sel = tagTree.getAllSelected();
|
||||
@@ -2369,6 +2412,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void exportSwfXml() {
|
||||
View.checkAccess();
|
||||
|
||||
List<TreeItem> sel = tagTree.getSelected();
|
||||
Set<SWF> swfs = new HashSet<>();
|
||||
|
||||
@@ -2393,6 +2438,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void importSwfXml() {
|
||||
View.checkAccess();
|
||||
|
||||
List<TreeItem> sel = tagTree.getSelected();
|
||||
Set<SWF> swfs = new HashSet<>();
|
||||
for (TreeItem item : sel) {
|
||||
@@ -2421,6 +2468,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void renameIdentifiers(final SWF swf) {
|
||||
View.checkAccess();
|
||||
|
||||
if (swf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2467,6 +2516,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void deobfuscate() {
|
||||
View.checkAccess();
|
||||
|
||||
DeobfuscationDialog deobfuscationDialog = new DeobfuscationDialog();
|
||||
if (deobfuscationDialog.showDialog() == AppDialog.OK_OPTION) {
|
||||
DeobfuscationLevel level = DeobfuscationLevel.getByLevel(deobfuscationDialog.codeProcessingLevel.getValue());
|
||||
@@ -2666,14 +2717,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean alignText(TextTag textTag, TextAlign textAlign) {
|
||||
return (textTag.alignText(textAlign));
|
||||
}
|
||||
|
||||
public boolean translateText(TextTag textTag, int diff) {
|
||||
return textTag.translateText(diff);
|
||||
}
|
||||
|
||||
public boolean previousTag() {
|
||||
if (getCurrentView() == VIEW_RESOURCES) {
|
||||
if (tagTree.getSelectionRows().length > 0) {
|
||||
@@ -3236,6 +3279,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
private void closeTag() {
|
||||
View.checkAccess();
|
||||
|
||||
previewPanel.closeTag();
|
||||
}
|
||||
|
||||
@@ -3314,6 +3359,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
|
||||
public void reload(boolean forceReload) {
|
||||
View.checkAccess();
|
||||
|
||||
tagTree.scrollPathToVisible(tagTree.getSelectionPath());
|
||||
if (Configuration.dumpView.get()) {
|
||||
dumpViewReload(forceReload);
|
||||
@@ -3373,11 +3420,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
if (!Main.isInited() || !Main.isWorking() || Main.isDebugging()) {
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.clear();
|
||||
abcPanel.setAbc(scriptLeaf.abc);
|
||||
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.clear();
|
||||
abcPanel.setAbc(scriptLeaf.abc);
|
||||
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
|
||||
abcPanel.decompiledTextArea.setNoTrait();
|
||||
return null;
|
||||
|
||||
@@ -87,6 +87,8 @@ public class SearchPanel<E> extends JPanel {
|
||||
}
|
||||
|
||||
public boolean setResults(List<E> results) {
|
||||
View.checkAccess();
|
||||
|
||||
found = results;
|
||||
if (found.isEmpty()) {
|
||||
setVisible(false);
|
||||
@@ -104,20 +106,24 @@ public class SearchPanel<E> extends JPanel {
|
||||
}
|
||||
|
||||
public void setPos(int pos) {
|
||||
View.checkAccess();
|
||||
|
||||
foundPos = pos;
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
View.checkAccess();
|
||||
|
||||
foundPos = 0;
|
||||
found.clear();
|
||||
}
|
||||
|
||||
private void doUpdate() {
|
||||
View.execInEventDispatchLater(() -> {
|
||||
searchPos.setText((foundPos + 1) + "/" + found.size());
|
||||
listener.updateSearchPos(found.get(foundPos));
|
||||
});
|
||||
View.checkAccess();
|
||||
|
||||
searchPos.setText((foundPos + 1) + "/" + found.size());
|
||||
listener.updateSearchPos(found.get(foundPos));
|
||||
}
|
||||
|
||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||
|
||||
@@ -111,9 +111,7 @@ public class SearchResultsDialog<E> extends AppDialog {
|
||||
|
||||
private void gotoElement() {
|
||||
if (resultsList.getSelectedIndex() != -1) {
|
||||
View.execInEventDispatchLater(() -> {
|
||||
listener.updateSearchPos(resultsList.getSelectedValue());
|
||||
});
|
||||
listener.updateSearchPos(resultsList.getSelectedValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,12 +117,10 @@ public class SelectLanguageDialog extends AppDialog {
|
||||
}
|
||||
|
||||
public static void reloadUi() {
|
||||
View.execInEventDispatchLater(() -> {
|
||||
Locale.setDefault(Locale.forLanguageTag(Configuration.locale.get()));
|
||||
DefaultSyntaxKit.reloadConfigs();
|
||||
Main.initLang();
|
||||
Main.reloadApp();
|
||||
});
|
||||
Locale.setDefault(Locale.forLanguageTag(Configuration.locale.get()));
|
||||
DefaultSyntaxKit.reloadConfigs();
|
||||
Main.initLang();
|
||||
Main.reloadApp();
|
||||
}
|
||||
|
||||
public static String[] getAvailableLanguages() {
|
||||
|
||||
@@ -322,9 +322,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
|
||||
|
||||
public void updateSearchPos() {
|
||||
textValue.setCaretPosition(0);
|
||||
View.execInEventDispatchLater(() -> {
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
});
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
}
|
||||
|
||||
private void editText() {
|
||||
@@ -349,7 +347,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
|
||||
}
|
||||
|
||||
private void textAlign(TextAlign textAlign) {
|
||||
if (mainPanel.alignText(textTag, textAlign)) {
|
||||
if (textTag.alignText(textAlign)) {
|
||||
updateButtonsVisibility();
|
||||
textTag.getSwf().clearImageCache();
|
||||
mainPanel.repaintTree();
|
||||
@@ -357,7 +355,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
|
||||
}
|
||||
|
||||
private void translateX(int delta, int repeatCount) {
|
||||
if (mainPanel.translateText(textTag, delta * (repeatCount + 1))) {
|
||||
if (textTag.translateText(delta * (repeatCount + 1))) {
|
||||
updateButtonsVisibility();
|
||||
textTag.getSwf().clearImageCache();
|
||||
mainPanel.repaintTree();
|
||||
|
||||
@@ -438,6 +438,12 @@ public class View {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAccess() {
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
throw new RuntimeException("This method should be called from UI thread.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void execInEventDispatch(Runnable r) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
r.run();
|
||||
|
||||
@@ -186,6 +186,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
private String lastDecompiled = null;
|
||||
|
||||
public MainPanel getMainPanel() {
|
||||
View.checkAccess();
|
||||
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
@@ -212,9 +214,12 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
public void setAbc(ABC abc) {
|
||||
View.checkAccess();
|
||||
|
||||
if (abc == this.abc) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.abc = abc;
|
||||
setDecompiledEditMode(false);
|
||||
navigator.setAbc(abc);
|
||||
@@ -222,6 +227,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
public void updateConstList() {
|
||||
View.checkAccess();
|
||||
|
||||
switch (constantTypeList.getSelectedIndex()) {
|
||||
case 0:
|
||||
View.autoResizeColWidth(constantTable, new UIntTableModel(abc));
|
||||
@@ -262,6 +269,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
public void clearSwf() {
|
||||
View.checkAccess();
|
||||
|
||||
this.abc = null;
|
||||
constantTable.setModel(new DefaultTableModel());
|
||||
navigator.clearAbc();
|
||||
@@ -1003,10 +1012,14 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
private boolean isModified() {
|
||||
View.checkAccess();
|
||||
|
||||
return saveDecompiledButton.isVisible() && saveDecompiledButton.isEnabled();
|
||||
}
|
||||
|
||||
private void setModified(boolean value) {
|
||||
View.checkAccess();
|
||||
|
||||
saveDecompiledButton.setEnabled(value);
|
||||
cancelDecompiledButton.setEnabled(value);
|
||||
}
|
||||
@@ -1066,6 +1079,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
private void gotoDeclaration(int pos) {
|
||||
View.checkAccess();
|
||||
|
||||
Reference<Integer> abcIndex = new Reference<>(0);
|
||||
Reference<Integer> classIndex = new Reference<>(0);
|
||||
Reference<Integer> traitIndex = new Reference<>(0);
|
||||
@@ -1177,6 +1192,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
View.checkAccess();
|
||||
|
||||
lastDecompiled = "";
|
||||
SWF swf = getSwf();
|
||||
if (swf != null) {
|
||||
@@ -1189,6 +1206,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
View.checkAccess();
|
||||
|
||||
if (e.getSource() == constantTypeList) {
|
||||
int index = ((JComboBox) e.getSource()).getSelectedIndex();
|
||||
if (index == -1) {
|
||||
@@ -1199,10 +1218,14 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
public void display() {
|
||||
View.checkAccess();
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void hilightScript(SWF swf, String name) {
|
||||
View.checkAccess();
|
||||
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
TreeItem scriptsNode = ttm.getScriptsNode(swf);
|
||||
if (scriptsNode instanceof ClassesListTreeModel) {
|
||||
@@ -1229,6 +1252,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
|
||||
public void hilightScript(ScriptPack pack) {
|
||||
View.checkAccess();
|
||||
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
TreePath tp0 = ttm.getTreePath(pack);
|
||||
if (tp0 == null) {
|
||||
@@ -1236,15 +1261,15 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
tp0 = ttm.getTreePath(pack);
|
||||
}
|
||||
final TreePath tp = tp0;
|
||||
View.execInEventDispatchLater(() -> {
|
||||
mainPanel.tagTree.setSelectionPath(tp);
|
||||
mainPanel.tagTree.scrollPathToVisible(tp);
|
||||
});
|
||||
mainPanel.tagTree.setSelectionPath(tp);
|
||||
mainPanel.tagTree.scrollPathToVisible(tp);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSearchPos(ABCSearchResult item) {
|
||||
View.checkAccess();
|
||||
|
||||
ScriptPack pack = item.getScriptPack();
|
||||
setAbc(pack.abc);
|
||||
decompiledTextArea.setScript(pack, false);
|
||||
@@ -1258,45 +1283,38 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
decompiledTextArea.setCaretPosition(0);
|
||||
|
||||
View.execInEventDispatchLater(() -> {
|
||||
if (pcode) {
|
||||
searchPanel.showQuickFindDialog(detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea());
|
||||
} else {
|
||||
searchPanel.showQuickFindDialog(decompiledTextArea);
|
||||
}
|
||||
});
|
||||
|
||||
if (pcode) {
|
||||
searchPanel.showQuickFindDialog(detailPanel.methodTraitPanel.methodCodePanel.getSourceTextArea());
|
||||
} else {
|
||||
searchPanel.showQuickFindDialog(decompiledTextArea);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDirectEditing() {
|
||||
View.checkAccess();
|
||||
|
||||
return saveDecompiledButton.isVisible() && saveDecompiledButton.isEnabled();
|
||||
}
|
||||
|
||||
public void setDecompiledEditMode(boolean val) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (val) {
|
||||
lastDecompiled = decompiledTextArea.getText();
|
||||
} else {
|
||||
decompiledTextArea.setText(lastDecompiled);
|
||||
}
|
||||
if (val) {
|
||||
lastDecompiled = decompiledTextArea.getText();
|
||||
} else {
|
||||
decompiledTextArea.setText(lastDecompiled);
|
||||
}
|
||||
|
||||
decompiledTextArea.setEditable(val);
|
||||
saveDecompiledButton.setVisible(val);
|
||||
saveDecompiledButton.setEnabled(false);
|
||||
editDecompiledButton.setVisible(!val);
|
||||
experimentalLabel.setVisible(!val);
|
||||
cancelDecompiledButton.setVisible(val);
|
||||
decompiledTextArea.getCaret().setVisible(true);
|
||||
decLabel.setIcon(val ? View.getIcon("editing16") : null);
|
||||
detailPanel.setVisible(!val);
|
||||
|
||||
decompiledTextArea.ignoreCarret = val;
|
||||
decompiledTextArea.requestFocusInWindow();
|
||||
}
|
||||
});
|
||||
decompiledTextArea.setEditable(val);
|
||||
saveDecompiledButton.setVisible(val);
|
||||
saveDecompiledButton.setEnabled(false);
|
||||
editDecompiledButton.setVisible(!val);
|
||||
experimentalLabel.setVisible(!val);
|
||||
cancelDecompiledButton.setVisible(val);
|
||||
decompiledTextArea.getCaret().setVisible(true);
|
||||
decLabel.setIcon(val ? View.getIcon("editing16") : null);
|
||||
detailPanel.setVisible(!val);
|
||||
|
||||
decompiledTextArea.ignoreCarret = val;
|
||||
decompiledTextArea.requestFocusInWindow();
|
||||
}
|
||||
|
||||
private void editDecompiledButtonActionPerformed(ActionEvent evt) {
|
||||
@@ -1493,12 +1511,16 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
@Override
|
||||
public boolean tryAutoSave() {
|
||||
View.checkAccess();
|
||||
|
||||
// todo: implement
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditing() {
|
||||
View.checkAccess();
|
||||
|
||||
return detailPanel.isEditing() || isModified();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,8 @@ public class UsageFrame extends AppDialog implements MouseListener {
|
||||
}
|
||||
|
||||
public static void gotoUsage(final ABCPanel abcPanel, final MultinameUsage usage) {
|
||||
View.checkAccess();
|
||||
|
||||
if (usage instanceof InsideClassMultinameUsageInterface) {
|
||||
final InsideClassMultinameUsageInterface icu = (InsideClassMultinameUsageInterface) usage;
|
||||
|
||||
|
||||
@@ -167,6 +167,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
private CancellableWorker setSourceWorker;
|
||||
|
||||
public void clearSource() {
|
||||
View.checkAccess();
|
||||
|
||||
lastCode = null;
|
||||
lastASM = null;
|
||||
lastDecompiled = new HighlightedText();
|
||||
@@ -179,6 +181,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
public String getStringUnderCursor() {
|
||||
View.checkAccess();
|
||||
|
||||
int pos = decompiledEditor.getCaretPosition();
|
||||
|
||||
SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(decompiledEditor);
|
||||
@@ -267,6 +271,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
private void setDecompiledText(final String scriptName, final String text) {
|
||||
View.checkAccess();
|
||||
|
||||
ignoreCarret = true;
|
||||
decompiledEditor.setScriptName(scriptName);
|
||||
decompiledEditor.setText(text);
|
||||
@@ -274,6 +280,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
private void setEditorText(final String scriptName, final String text, final String contentType) {
|
||||
View.checkAccess();
|
||||
|
||||
ignoreCarret = true;
|
||||
editor.setScriptName("#PCODE " + scriptName);
|
||||
editor.changeContentType(contentType);
|
||||
@@ -282,6 +290,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
private void setText(final HighlightedText text, final String contentType, final String scriptName) {
|
||||
View.checkAccess();
|
||||
|
||||
int pos = editor.getCaretPosition();
|
||||
Highlighting lastH = null;
|
||||
for (Highlighting h : disassembledText.getInstructionHighlights()) {
|
||||
@@ -322,12 +332,15 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
private void updateHexButtons(ScriptExportMode exportMode) {
|
||||
View.checkAccess();
|
||||
|
||||
showFileOffsetInPcodeHexButton.setVisible(exportMode == ScriptExportMode.PCODE_HEX);
|
||||
showOriginalBytesInPcodeHexButton.setVisible(exportMode == ScriptExportMode.PCODE_HEX);
|
||||
resolveConstantsButton.setVisible(exportMode != ScriptExportMode.CONSTANTS && exportMode != ScriptExportMode.HEX);
|
||||
}
|
||||
|
||||
private void setHex(ScriptExportMode exportMode, String scriptName, ActionList actions) {
|
||||
View.checkAccess();
|
||||
updateHexButtons(exportMode);
|
||||
|
||||
switch (exportMode) {
|
||||
@@ -407,6 +420,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
public void setSource(final ASMSource src, final boolean useCache) {
|
||||
View.checkAccess();
|
||||
|
||||
if (setSourceWorker != null) {
|
||||
setSourceWorker.cancel(true);
|
||||
setSourceWorker = null;
|
||||
@@ -525,9 +540,12 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
public void hilightOffset(long offset) {
|
||||
View.checkAccess();
|
||||
}
|
||||
|
||||
public int getLocalDeclarationOfPos(int pos) {
|
||||
View.checkAccess();
|
||||
|
||||
Highlighting sh = Highlighting.searchPos(lastDecompiled.getSpecialHighlights(), pos);
|
||||
Highlighting h = Highlighting.searchPos(lastDecompiled.getInstructionHighlights(), pos);
|
||||
|
||||
@@ -837,24 +855,34 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
private boolean isModified() {
|
||||
View.checkAccess();
|
||||
|
||||
return saveButton.isVisible() && saveButton.isEnabled();
|
||||
}
|
||||
|
||||
private void setModified(boolean value) {
|
||||
View.checkAccess();
|
||||
|
||||
saveButton.setEnabled(value);
|
||||
cancelButton.setEnabled(value);
|
||||
}
|
||||
|
||||
private boolean isDecompiledModified() {
|
||||
View.checkAccess();
|
||||
|
||||
return saveDecompiledButton.isVisible() && saveDecompiledButton.isEnabled();
|
||||
}
|
||||
|
||||
private void setDecompiledModified(boolean value) {
|
||||
View.checkAccess();
|
||||
|
||||
saveDecompiledButton.setEnabled(value);
|
||||
cancelDecompiledButton.setEnabled(value);
|
||||
}
|
||||
|
||||
public void setEditMode(boolean val) {
|
||||
View.checkAccess();
|
||||
|
||||
if (val) {
|
||||
if (hexOnlyButton.isSelected()) {
|
||||
setHex(ScriptExportMode.HEX, src.getScriptName(), lastCode);
|
||||
@@ -879,6 +907,8 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
}
|
||||
|
||||
public void setDecompiledEditMode(boolean val) {
|
||||
View.checkAccess();
|
||||
|
||||
if (lastASM == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1049,29 +1079,33 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
|
||||
@Override
|
||||
public void updateSearchPos(ActionSearchResult item) {
|
||||
View.checkAccess();
|
||||
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
TreePath tp = ttm.getTreePath(item.getSrc());
|
||||
mainPanel.tagTree.setSelectionPath(tp);
|
||||
mainPanel.tagTree.scrollPathToVisible(tp);
|
||||
decompiledEditor.setCaretPosition(0);
|
||||
|
||||
View.execInEventDispatchLater(() -> {
|
||||
if (item.isPcode()) {
|
||||
searchPanel.showQuickFindDialog(editor);
|
||||
} else {
|
||||
searchPanel.showQuickFindDialog(decompiledEditor);
|
||||
}
|
||||
});
|
||||
if (item.isPcode()) {
|
||||
searchPanel.showQuickFindDialog(editor);
|
||||
} else {
|
||||
searchPanel.showQuickFindDialog(decompiledEditor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAutoSave() {
|
||||
View.checkAccess();
|
||||
|
||||
// todo: implement
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditing() {
|
||||
View.checkAccess();
|
||||
|
||||
return (saveButton.isVisible() && saveButton.isEnabled())
|
||||
|| (saveDecompiledButton.isVisible() && saveDecompiledButton.isEnabled());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui.pipes;
|
||||
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.WinError;
|
||||
@@ -77,13 +78,20 @@ public class FirstInstance {
|
||||
switch (command) {
|
||||
case "open":
|
||||
int cnt = ois.readInt();
|
||||
String[] fileNames = new String[cnt];
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
Main.openFile(ois.readUTF(), null);
|
||||
fileNames[i] = ois.readUTF();
|
||||
}
|
||||
|
||||
View.execInEventDispatchLater(() -> {
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
Main.openFile(fileNames[i], null);
|
||||
}
|
||||
});
|
||||
//no break - focus too
|
||||
case "focus":
|
||||
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Window wnd = Main.getMainFrame().getWindow();
|
||||
|
||||
@@ -225,7 +225,6 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen
|
||||
}
|
||||
|
||||
tableModel = new DefaultTableModel(data, columnNames) {
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
Class[] classes = new Class[]{String.class, SizeItem.class, String.class};
|
||||
@@ -236,7 +235,6 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
replacementsTable = new JTable(tableModel);
|
||||
|
||||
@@ -349,6 +347,8 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen
|
||||
}
|
||||
|
||||
private void open() {
|
||||
View.checkAccess();
|
||||
|
||||
if (replacementsTable.getSelectedRow() > -1) {
|
||||
Replacement r = replacements.get(replacementsTable.getRowSorter().convertRowIndexToModel(replacementsTable.getSelectedRow()));
|
||||
Main.openFile(r.targetFile, r.urlPattern);
|
||||
|
||||
Reference in New Issue
Block a user