mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 10:10:43 +00:00
#429 Disable/Enable rename identifiers feature implemented
This commit is contained in:
@@ -65,6 +65,8 @@ public class Configuration {
|
||||
public static final ConfigurationItem<Boolean> internalFlashViewer = null;
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
public static final ConfigurationItem<Boolean> gotoMainClassOnStartup = null;
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
public static final ConfigurationItem<Boolean> autoRenameIdentifiers = null;
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
public static final ConfigurationItem<Boolean> deobfuscateUsePrevTagOnly = null;
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
|
||||
@@ -954,7 +954,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
tagTree.setModel(new TagTreeModel(this, swfs, hasAbc ? abcPanel : null));
|
||||
tagTree.setModel(new TagTreeModel(this, swfs));
|
||||
expandSwfRoots();
|
||||
|
||||
for (Tag t : swf.tags) {
|
||||
@@ -968,6 +968,20 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
swf.characters = new HashMap<>();
|
||||
parseCharacters(swf, list2);
|
||||
|
||||
if (Configuration.autoRenameIdentifiers.get()) {
|
||||
try {
|
||||
swf.deobfuscateIdentifiers(RenameType.TYPENUMBER);
|
||||
swf.assignClassesToSymbols();
|
||||
clearCache();
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
updateClassesList();
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
showDetail(DETAILCARDEMPTYPANEL);
|
||||
showCard(CARDEMPTYPANEL);
|
||||
updateUi(swf);
|
||||
@@ -1036,7 +1050,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
|
||||
private void updateTagTree() {
|
||||
tagTree.setModel(new TagTreeModel(this, swfs, null));
|
||||
tagTree.setModel(new TagTreeModel(this, swfs));
|
||||
expandSwfRoots();
|
||||
}
|
||||
|
||||
@@ -1062,6 +1076,28 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
}
|
||||
}
|
||||
|
||||
public void updateClassesList() {
|
||||
List<TagNode> nodes = getASTagNode(tagTree);
|
||||
boolean updateNeeded = false;
|
||||
for (TagNode n : nodes) {
|
||||
if (n.tag instanceof ClassesListTreeModel) {
|
||||
((ClassesListTreeModel) n.tag).update();
|
||||
updateNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
refreshTree();
|
||||
|
||||
if (updateNeeded) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tagTree.updateUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void doFilter() {
|
||||
List<TagNode> nodes = getASTagNode(tagTree);
|
||||
boolean updateNeeded = false;
|
||||
@@ -1408,7 +1444,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
if (!oldName.equals(newName)) {
|
||||
swf.renameAS2Identifier(oldName, newName);
|
||||
View.showMessageDialog(null, translate("rename.finished.identifier"));
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
reload(true);
|
||||
}
|
||||
}
|
||||
@@ -1441,7 +1477,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
reload(true);
|
||||
abcPanel.hilightScript(abcPanel.decompiledTextArea.getScriptLeaf().getPath().toString());
|
||||
}
|
||||
@@ -1613,7 +1649,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
|
||||
TreeNode treeNode = (TreeNode) tagTree.getLastSelectedPathComponent();
|
||||
if (treeNode == null) {
|
||||
return null;
|
||||
return swfs.get(0);
|
||||
}
|
||||
|
||||
return treeNode.getSwf();
|
||||
@@ -1658,7 +1694,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
abcPanel.reload();
|
||||
}
|
||||
reload(true);
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
}
|
||||
|
||||
public void searchAs() {
|
||||
@@ -1715,7 +1751,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
abcPanel.reload();
|
||||
}
|
||||
reload(true);
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
}
|
||||
|
||||
public void renameOneIdentifier(final SWF swf) {
|
||||
@@ -1932,7 +1968,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
@Override
|
||||
public void run() {
|
||||
abcPanel.reload();
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1967,7 +2003,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
reload(true);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Error during renaming identifiers", ex);
|
||||
@@ -2036,7 +2072,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
public void run() {
|
||||
clearCache();
|
||||
abcPanel.reload();
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2062,7 +2098,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
abcPanel.reload();
|
||||
}
|
||||
reload(true);
|
||||
doFilter();
|
||||
updateClassesList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2865,7 +2901,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T
|
||||
public void refreshTree() {
|
||||
List<List<String>> expandedNodes = getExpandedNodes(tagTree);
|
||||
|
||||
tagTree.setModel(new TagTreeModel(this, swfs, abcPanel));
|
||||
tagTree.setModel(new TagTreeModel(this, swfs));
|
||||
|
||||
expandSwfRoots();
|
||||
expandTreeNodes(tagTree, expandedNodes);
|
||||
|
||||
@@ -70,6 +70,7 @@ public class MainFrameRibbon implements ActionListener {
|
||||
static final String ACTION_LOAD_MEMORY = "LOADMEMORY";
|
||||
static final String ACTION_LOAD_CACHE = "LOADCACHE";
|
||||
static final String ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP = "GOTODOCUMENTCLASSONSTARTUP";
|
||||
static final String ACTION_AUTO_RENAME_IDENTIFIERS = "AUTORENAMEIDENTIFIERS";
|
||||
static final String ACTION_CACHE_ON_DISK = "CACHEONDISK";
|
||||
static final String ACTION_SET_LANGUAGE = "SETLANGUAGE";
|
||||
static final String ACTION_DISABLE_DECOMPILATION = "DISABLEDECOMPILATION";
|
||||
@@ -111,6 +112,7 @@ public class MainFrameRibbon implements ActionListener {
|
||||
private JCheckBox miDecompile;
|
||||
private JCheckBox miCacheDisk;
|
||||
private JCheckBox miGotoMainClassOnStartup;
|
||||
private JCheckBox miAutoRenameIdentifiers;
|
||||
private JCommandButton saveCommandButton;
|
||||
private JCommandButton saveasCommandButton;
|
||||
private JCommandButton exportAllCommandButton;
|
||||
@@ -288,13 +290,18 @@ public class MainFrameRibbon implements ActionListener {
|
||||
miGotoMainClassOnStartup.setActionCommand(ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP);
|
||||
miGotoMainClassOnStartup.addActionListener(this);
|
||||
|
||||
miAutoRenameIdentifiers.setSelected(Configuration.autoRenameIdentifiers.get());
|
||||
miAutoRenameIdentifiers.setActionCommand(ACTION_AUTO_RENAME_IDENTIFIERS);
|
||||
miAutoRenameIdentifiers.addActionListener(this);
|
||||
|
||||
/*JMenu menuSettings = new JMenu(translate("menu.settings"));
|
||||
menuSettings.add(autoDeobfuscateMenuItem);
|
||||
menuSettings.add(miInternalViewer);
|
||||
menuSettings.add(miParallelSpeedUp);
|
||||
menuSettings.add(miDecompile);
|
||||
menuSettings.add(miCacheDisk);
|
||||
menuSettings.add(miGotoMainClassOnStartup);*/
|
||||
menuSettings.add(miGotoMainClassOnStartup);
|
||||
menuSettings.add(miAutoRenameIdentifiers);*/
|
||||
|
||||
miAssociate.setActionCommand(ACTION_ASSOCIATE);
|
||||
miAssociate.addActionListener(this);
|
||||
@@ -506,6 +513,7 @@ public class MainFrameRibbon implements ActionListener {
|
||||
miAssociate = new JCheckBox(translate("menu.settings.addtocontextmenu"));
|
||||
miCacheDisk = new JCheckBox(translate("menu.settings.cacheOnDisk"));
|
||||
miGotoMainClassOnStartup = new JCheckBox(translate("menu.settings.gotoMainClassOnStartup"));
|
||||
miAutoRenameIdentifiers = new JCheckBox(translate("menu.settings.autoRenameIdentifiers"));
|
||||
|
||||
settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation));
|
||||
settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer));
|
||||
@@ -514,6 +522,7 @@ public class MainFrameRibbon implements ActionListener {
|
||||
settingsBand.addRibbonComponent(new JRibbonComponent(miAssociate));
|
||||
settingsBand.addRibbonComponent(new JRibbonComponent(miCacheDisk));
|
||||
settingsBand.addRibbonComponent(new JRibbonComponent(miGotoMainClassOnStartup));
|
||||
settingsBand.addRibbonComponent(new JRibbonComponent(miAutoRenameIdentifiers));
|
||||
|
||||
JRibbonBand languageBand = new JRibbonBand(translate("menu.language"), null);
|
||||
List<RibbonBandResizePolicy> languageBandResizePolicies = new ArrayList<>();
|
||||
@@ -626,6 +635,9 @@ public class MainFrameRibbon implements ActionListener {
|
||||
case ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP:
|
||||
Configuration.gotoMainClassOnStartup.set(miGotoMainClassOnStartup.isSelected());
|
||||
break;
|
||||
case ACTION_AUTO_RENAME_IDENTIFIERS:
|
||||
Configuration.autoRenameIdentifiers.set(miAutoRenameIdentifiers.isSelected());
|
||||
break;
|
||||
case ACTION_CACHE_ON_DISK:
|
||||
Configuration.cacheOnDisk.set(miCacheDisk.isSelected());
|
||||
if (miCacheDisk.isSelected()) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class TagTreeModel implements TreeModel {
|
||||
private List<SWFRoot> swfs;
|
||||
private MainFrame mainFrame;
|
||||
|
||||
public TagTreeModel(MainFrame mainFrame, List<SWF> swfs, ABCPanel abcPanel) {
|
||||
public TagTreeModel(MainFrame mainFrame, List<SWF> swfs) {
|
||||
this.mainFrame = mainFrame;
|
||||
this.swfs = new ArrayList<>();
|
||||
for (SWF swf : swfs) {
|
||||
|
||||
@@ -38,7 +38,6 @@ import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
public final class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
|
||||
public List<MyEntry<ClassPath, ScriptPack>> treeList;
|
||||
private ABCPanel abcPanel;
|
||||
private SWF swf;
|
||||
|
||||
@@ -94,15 +93,13 @@ public final class ClassesListTree extends JTree implements TreeSelectionListene
|
||||
}
|
||||
|
||||
public void clearDoABCTags() {
|
||||
this.treeList = null;
|
||||
this.swf = null;
|
||||
setModel(null);
|
||||
}
|
||||
|
||||
public void setDoABCTags(List<ABCContainerTag> list, SWF swf) {
|
||||
this.treeList = swf.getAS3Packs();
|
||||
this.swf = swf;
|
||||
ClassesListTreeModel model = new ClassesListTreeModel(this.treeList, swf);
|
||||
ClassesListTreeModel model = new ClassesListTreeModel(swf);
|
||||
this.swf.classTreeModel = model;
|
||||
setModel(model);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.TreeNode;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
@@ -82,22 +84,33 @@ public class ClassesListTreeModel implements TreeModel, TreeElementItem {
|
||||
private SWF swf;
|
||||
private Tree classTree;
|
||||
private List<MyEntry<ClassPath, ScriptPack>> list;
|
||||
private String filter;
|
||||
private List<TreeModelListener> listeners = new ArrayList<>();
|
||||
|
||||
public List<MyEntry<ClassPath, ScriptPack>> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public ClassesListTreeModel(List<MyEntry<ClassPath, ScriptPack>> list, SWF swf) {
|
||||
this(list, swf, null);
|
||||
public ClassesListTreeModel(SWF swf) {
|
||||
this(swf, null);
|
||||
}
|
||||
|
||||
public ClassesListTreeModel(List<MyEntry<ClassPath, ScriptPack>> list, SWF swf, String filter) {
|
||||
public ClassesListTreeModel(SWF swf, String filter) {
|
||||
this.swf = swf;
|
||||
this.list = list;
|
||||
this.list = swf.getAS3Packs();
|
||||
setFilter(filter);
|
||||
}
|
||||
|
||||
public final void update() {
|
||||
this.list = swf.getAS3Packs();
|
||||
TreeModelEvent event = new TreeModelEvent(this, new TreePath(classTree.getRoot()));
|
||||
for (TreeModelListener listener : listeners) {
|
||||
listener.treeStructureChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setFilter(String filter) {
|
||||
this.filter = filter;
|
||||
classTree = new Tree(swf);
|
||||
for (MyEntry<ClassPath, ScriptPack> item : list) {
|
||||
if (filter != null) {
|
||||
@@ -164,10 +177,12 @@ public class ClassesListTreeModel implements TreeModel, TreeElementItem {
|
||||
|
||||
@Override
|
||||
public void addTreeModelListener(TreeModelListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTreeModelListener(TreeModelListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -380,3 +380,4 @@ menu.recentFiles = Recent files
|
||||
work.restoringControlFlow.complete = Control flow restored
|
||||
message.confirm.recentFileNotFound = File not found. Do you want to remove it from the recent file list?
|
||||
contextmenu.closeSwf = Close SWF
|
||||
menu.settings.autoRenameIdentifiers = Auto rename identifiers
|
||||
|
||||
@@ -380,3 +380,4 @@ menu.recentFiles = El\u0151zm\u00e9nyek
|
||||
work.restoringControlFlow.complete = Vez\u00e9rl\u00e9si-folyam helyre\u00e1ll\u00edt\u00e1s befejez\u0151d\u00f6tt
|
||||
message.confirm.recentFileNotFound = F\u00e1jl nem tal\u00e1lhat\u00f3. Szeretn\u00e9 elt\u00e1vol\u00edtani az el\u0151zm\u00e9nyek k\u00f6z\u00fcl?
|
||||
contextmenu.closeSwf = SWF bez\u00e1r\u00e1sa
|
||||
menu.settings.autoRenameIdentifiers = Azonos\u00edt\u00f3k automatikus \u00e1tnevez\u00e9se
|
||||
|
||||
Reference in New Issue
Block a user