Resource Refreshing

This commit is contained in:
Konloch 2021-07-13 03:37:28 -07:00
parent 33ec3f3fdb
commit 3df104c86b
7 changed files with 62 additions and 16 deletions

View file

@ -17,6 +17,8 @@ import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane;
import the.bytecode.club.bytecodeviewer.gui.resourcesearch.SearchBoxPane; import the.bytecode.club.bytecodeviewer.gui.resourcesearch.SearchBoxPane;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.DecompilerSelectionPane; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.DecompilerSelectionPane;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.WorkPaneMainComponent; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.WorkPaneMainComponent;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
import the.bytecode.club.bytecodeviewer.gui.theme.RSTATheme; import the.bytecode.club.bytecodeviewer.gui.theme.RSTATheme;
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses;
@ -27,7 +29,7 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginTemplate;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.*; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.*;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import the.bytecode.club.bytecodeviewer.resources.Resources; import the.bytecode.club.bytecodeviewer.resources.IconResources;
import the.bytecode.club.bytecodeviewer.resources.exporting.Export; import the.bytecode.club.bytecodeviewer.resources.exporting.Export;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBoxMenuItem; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBoxMenuItem;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem;
@ -119,6 +121,7 @@ public class MainViewerGUI extends JFrame
public final JMenuItem zStringArrayDecrypter = new TranslatedJMenuItem("ZStringArray Decrypter", Translation.ZSTRINGARRAY_DECRYPTER); public final JMenuItem zStringArrayDecrypter = new TranslatedJMenuItem("ZStringArray Decrypter", Translation.ZSTRINGARRAY_DECRYPTER);
public final JMenuItem viewAPKAndroidPermissions = new JMenuItem("View Android Permissions"); public final JMenuItem viewAPKAndroidPermissions = new JMenuItem("View Android Permissions");
public final JMenuItem viewManifest = new JMenuItem("View Manifest"); public final JMenuItem viewManifest = new JMenuItem("View Manifest");
public final JMenuItem changeClassFileVersions = new JMenuItem("Change ClassFile Versions");
//all of the settings main menu components //all of the settings main menu components
public final ButtonGroup apkConversionGroup = new ButtonGroup(); public final ButtonGroup apkConversionGroup = new ButtonGroup();
@ -259,7 +262,7 @@ public class MainViewerGUI extends JFrame
public MainViewerGUI() public MainViewerGUI()
{ {
setIconImages(Resources.iconList); setIconImages(IconResources.iconList);
setSize(new Dimension(800, 488)); setSize(new Dimension(800, 488));
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@ -405,6 +408,7 @@ public class MainViewerGUI extends JFrame
Configuration.rstaTheme = t; Configuration.rstaTheme = t;
item.setSelected(true); item.setSelected(true);
SettingsSerializer.saveSettingsAsync(); SettingsSerializer.saveSettingsAsync();
updateTabTheme();
}); });
rstaThemes.put(t, item); rstaThemes.put(t, item);
@ -431,7 +435,7 @@ public class MainViewerGUI extends JFrame
try try
{ {
theme.setLAF(); theme.setLAF();
SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer); updateTabTheme();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -600,6 +604,7 @@ public class MainViewerGUI extends JFrame
pluginsMainMenu.add(showAllStrings); pluginsMainMenu.add(showAllStrings);
pluginsMainMenu.add(replaceStrings); pluginsMainMenu.add(replaceStrings);
pluginsMainMenu.add(stackFramesRemover); pluginsMainMenu.add(stackFramesRemover);
pluginsMainMenu.add(changeClassFileVersions);
//allatori is disabled since they are just placeholders //allatori is disabled since they are just placeholders
//ZKM and ZStringArray decrypter are disabled until deobfuscation has been extended //ZKM and ZStringArray decrypter are disabled until deobfuscation has been extended
@ -621,6 +626,7 @@ public class MainViewerGUI extends JFrame
zStringArrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter())); zStringArrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter()));
viewAPKAndroidPermissions.addActionListener(arg0 -> PluginManager.runPlugin(new ViewAPKAndroidPermissions())); viewAPKAndroidPermissions.addActionListener(arg0 -> PluginManager.runPlugin(new ViewAPKAndroidPermissions()));
viewManifest.addActionListener(arg0 -> PluginManager.runPlugin(new ViewManifest())); viewManifest.addActionListener(arg0 -> PluginManager.runPlugin(new ViewManifest()));
changeClassFileVersions.addActionListener(arg0 -> PluginManager.runPlugin(new ChangeClassFileVersions()));
} }
public void buildObfuscateMenu() public void buildObfuscateMenu()
@ -888,5 +894,31 @@ public class MainViewerGUI extends JFrame
Configuration.deleteForeignLibraries = deleteForeignOutdatedLibs.isSelected(); Configuration.deleteForeignLibraries = deleteForeignOutdatedLibs.isSelected();
} }
public void updateTabTheme()
{
try
{
for(Component viewerComponent : BytecodeViewer.viewer.workPane.tabs.getComponents())
{
if(!(viewerComponent instanceof ResourceViewer))
continue;
ResourceViewer viewerResource = (ResourceViewer) viewerComponent;
if(!(viewerResource instanceof ClassViewer))
continue;
ClassViewer viewerClass = (ClassViewer) viewerResource;
Configuration.rstaTheme.apply(viewerClass.resourceViewPanel1.textArea);
Configuration.rstaTheme.apply(viewerClass.resourceViewPanel2.textArea);
Configuration.rstaTheme.apply(viewerClass.resourceViewPanel3.textArea);
}
SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public static final long serialVersionUID = 1851409230530948543L; public static final long serialVersionUID = 1851409230530948543L;
} }

View file

@ -184,7 +184,7 @@ public class WorkPaneMainComponent extends TranslatedVisibleComponent
{ {
if(resourceView instanceof ClassViewer) if(resourceView instanceof ClassViewer)
{ {
((ClassViewer)resourceView).startPaneUpdater(null); ((ClassViewer)resourceView).refresh(null);
} }
resourceView.workingName = workingName; resourceView.workingName = workingName;

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.FileViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.FileViewer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -30,18 +31,13 @@ public class WorkPaneRefresh implements Runnable
if(event != null && event.getSource() instanceof JButton) if(event != null && event.getSource() instanceof JButton)
src = (JButton) event.getSource(); src = (JButton) event.getSource();
final Component tabComp = BytecodeViewer.viewer.workPane.tabs.getSelectedComponent(); final ResourceViewer tabComp = (ResourceViewer) BytecodeViewer.viewer.workPane.tabs.getSelectedComponent();
if(tabComp == null) if(tabComp == null)
return; return;
BytecodeViewer.updateBusyStatus(true); BytecodeViewer.updateBusyStatus(true);
tabComp.refresh(src);
if (tabComp instanceof ClassViewer)
((ClassViewer) tabComp).startPaneUpdater(src);
else if (tabComp instanceof FileViewer)
((FileViewer) tabComp).refresh(src);
BytecodeViewer.updateBusyStatus(false); BytecodeViewer.updateBusyStatus(false);
} }
} }

View file

@ -88,7 +88,8 @@ public class ClassViewer extends ResourceViewer
}); });
} }
public void startPaneUpdater(final JButton button) @Override
public void refresh(final JButton button)
{ {
this.cn = container.getClassNode(cn.name); //update the classnode this.cn = container.getClassNode(cn.name); //update the classnode

View file

@ -122,13 +122,15 @@ public class FileViewer extends ResourceViewer
mainPanel.add(textArea.getScrollPane()); mainPanel.add(textArea.getScrollPane());
} }
@Override
public void refresh(JButton src) public void refresh(JButton src)
{ {
refreshTitle(); refreshTitle();
if (!canRefresh) if (!canRefresh)
{ {
src.setEnabled(true); if(src != null)
src.setEnabled(true);
return; return;
} }
@ -139,8 +141,9 @@ public class FileViewer extends ResourceViewer
JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER); JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
mainPanel.add(label, BorderLayout.CENTER); mainPanel.add(label, BorderLayout.CENTER);
mainPanel.updateUI(); mainPanel.updateUI();
src.setEnabled(true); if(src != null)
src.setEnabled(true);
} }
private static final long serialVersionUID = 6103372882168257164L; private static final long serialVersionUID = 6103372882168257164L;

View file

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer; package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer;
import javax.swing.JPanel; import javax.swing.*;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
@ -62,6 +63,9 @@ public abstract class ResourceViewer extends JPanel
return container.getBytes(name); return container.getBytes(name);
} }
public abstract void refresh(final JButton button);
/** /**
* Updates the tab's title * Updates the tab's title
*/ */

View file

@ -116,6 +116,16 @@ public class ResourceContainer
return this; return this;
} }
/**
* Updates this container's class node byte[] map
*/
public ResourceContainer updateClassNodeBytes()
{
resourceClassBytes.clear();
resourceClasses.forEach((s, cn) -> resourceClassBytes.put(s, ASMUtil.nodeToBytes(cn)));
return this;
}
/** /**
* Copy a resource container's resources into this container * Copy a resource container's resources into this container
*/ */