mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-01 12:21:35 +00:00
autosave for AS3 editing
This commit is contained in:
@@ -1612,7 +1612,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
return (TreeItem) scriptsPath.getLastPathComponent();
|
||||
}
|
||||
|
||||
private void saveDecompiledButtonActionPerformed(ActionEvent evt) {
|
||||
private void saveDecompiled(boolean refreshTree) {
|
||||
final ABC localAbc = abc;
|
||||
int oldIndex = pack.scriptIndex;
|
||||
SWF.uncache(pack);
|
||||
@@ -1633,7 +1633,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
reload();
|
||||
mainPanel.clearEditingStatus();
|
||||
ViewMessages.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
|
||||
if (refreshTree) {
|
||||
ViewMessages.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
|
||||
}
|
||||
} catch (As3ScriptReplaceException asre) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int firstErrorLine = As3ScriptReplaceExceptionItem.LINE_UNKNOWN;
|
||||
@@ -1667,13 +1669,17 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
ViewMessages.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", firstErrorText).replace("%line%", Long.toString(firstErrorLine)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
ViewMessages.showMessageDialog(this, sb.toString(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
decompiledTextArea.requestFocus();
|
||||
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveDecompiledButtonActionPerformed(ActionEvent evt) {
|
||||
saveDecompiled(true);
|
||||
}
|
||||
|
||||
private void deobfuscateButtonActionPerformed(ActionEvent evt) {
|
||||
JToggleButton toggleButton = (JToggleButton)evt.getSource();
|
||||
@@ -1901,8 +1907,15 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
public boolean tryAutoSave() {
|
||||
View.checkAccess();
|
||||
|
||||
// todo: implement
|
||||
return false;
|
||||
boolean ok = true;
|
||||
if (saveDecompiledButton.isVisible() && saveDecompiledButton.isEnabled() && Configuration.autoSaveTagModifications.get()) {
|
||||
saveDecompiled(false);
|
||||
ok = ok && !(saveDecompiledButton.isVisible() && saveDecompiledButton.isEnabled());
|
||||
}
|
||||
|
||||
ok = ok && detailPanel.tryAutoSave();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
@@ -331,10 +332,16 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
|
||||
mainPanel.clearEditingStatus();
|
||||
}
|
||||
|
||||
private void saveButtonActionPerformed(ActionEvent evt) {
|
||||
private void save(boolean refreshTree) {
|
||||
if (cardMap.get(selectedCard) instanceof TraitDetail) {
|
||||
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
|
||||
|
||||
DecompiledEditorPane decompiledTextArea = abcPanel.decompiledTextArea;
|
||||
if (!refreshTree) {
|
||||
decompiledTextArea.reloadClass();
|
||||
setEditMode(false);
|
||||
return;
|
||||
}
|
||||
int lastTrait = decompiledTextArea.lastTraitIndex;
|
||||
|
||||
Runnable reloadComplete = new Runnable() {
|
||||
@@ -347,8 +354,8 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
|
||||
decompiledTextArea.gotoTrait(lastTrait);
|
||||
}
|
||||
setEditMode(false);
|
||||
mainPanel.clearEditingStatus();
|
||||
ViewMessages.showMessageDialog(DetailPanel.this, AppStrings.translate("message.trait.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showTraitSavedMessage);
|
||||
mainPanel.clearEditingStatus();
|
||||
ViewMessages.showMessageDialog(DetailPanel.this, AppStrings.translate("message.trait.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showTraitSavedMessage);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,10 +364,17 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveButtonActionPerformed(ActionEvent evt) {
|
||||
save(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAutoSave() {
|
||||
// todo: implement
|
||||
if (saveButton.isVisible() && saveButton.isEnabled() && Configuration.autoSaveTagModifications.get()) {
|
||||
save(false);
|
||||
return !(saveButton.isVisible() && saveButton.isEnabled());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user