Update settings without needing to refresh

This commit is contained in:
Konloch 2021-06-26 05:26:12 -07:00
parent 05c6148ff5
commit e25d6179f3
4 changed files with 32 additions and 16 deletions

View file

@ -20,6 +20,7 @@ import the.bytecode.club.bytecodeviewer.api.ClassNodeLoader;
import the.bytecode.club.bytecodeviewer.compilers.Compilers; import the.bytecode.club.bytecodeviewer.compilers.Compilers;
import the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent; import the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourcePanelCompileMode; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourcePanelCompileMode;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane; import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane;
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI; import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
@ -27,6 +28,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.RunOptions;
import the.bytecode.club.bytecodeviewer.gui.resourcesearch.SearchBoxPane; import the.bytecode.club.bytecodeviewer.gui.resourcesearch.SearchBoxPane;
import the.bytecode.club.bytecodeviewer.gui.components.SystemErrConsole; import the.bytecode.club.bytecodeviewer.gui.components.SystemErrConsole;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.WorkPaneMainComponent; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.WorkPaneMainComponent;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager; import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
import the.bytecode.club.bytecodeviewer.util.*; import the.bytecode.club.bytecodeviewer.util.*;
@ -71,6 +73,8 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
* http://the.bytecode.club * http://the.bytecode.club
* *
* TODO BUGS: * TODO BUGS:
* + Removing a tab disrupts the tab order
* Tab index orders need to be recounted on removal probably
* + Last selected directory isn't set on most file chooser dialogues * + Last selected directory isn't set on most file chooser dialogues
* + Synchronized scrolling is broken * + Synchronized scrolling is broken
* + Spam-clicking the refresh button will cause the swing thread to deadlock (Quickly opening resources used to also do this) * + Spam-clicking the refresh button will cause the swing thread to deadlock (Quickly opening resources used to also do this)
@ -600,6 +604,15 @@ public class BytecodeViewer
while (!tempF.exists()) // keep making dirs while (!tempF.exists()) // keep making dirs
tempF.mkdir(); tempF.mkdir();
} }
public static void refreshAllTabTitles()
{
for(int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
{
ResourceViewer viewer = ((TabbedPane) BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i)).resource;
viewer.refreshTitle();
}
}
/** /**
* Checks the hotkeys * Checks the hotkeys

View file

@ -544,10 +544,12 @@ public class MainViewerGUI extends JFrame
showFileInTabTitle.addActionListener(arg0 -> { showFileInTabTitle.addActionListener(arg0 -> {
Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected(); Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
Settings.saveSettings(); Settings.saveSettings();
BytecodeViewer.refreshAllTabTitles();
}); });
simplifyNameInTabTitle.addActionListener(arg0 -> { simplifyNameInTabTitle.addActionListener(arg0 -> {
Configuration.simplifiedTabNames = BytecodeViewer.viewer.simplifyNameInTabTitle.isSelected(); Configuration.simplifiedTabNames = BytecodeViewer.viewer.simplifyNameInTabTitle.isSelected();
Settings.saveSettings(); Settings.saveSettings();
BytecodeViewer.refreshAllTabTitles();
}); });
} }

View file

@ -14,6 +14,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.gui.components.ButtonHoverAnimation; import the.bytecode.club.bytecodeviewer.gui.components.ButtonHoverAnimation;
import the.bytecode.club.bytecodeviewer.gui.components.MaxWidthJLabel; import the.bytecode.club.bytecodeviewer.gui.components.MaxWidthJLabel;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.MouseClickedListener; import the.bytecode.club.bytecodeviewer.gui.components.listeners.MouseClickedListener;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import the.bytecode.club.bytecodeviewer.gui.util.DelayTabbedPaneThread; import the.bytecode.club.bytecodeviewer.gui.util.DelayTabbedPaneThread;
/*************************************************************************** /***************************************************************************
@ -48,18 +49,20 @@ public class TabbedPane extends JPanel
private long startedDragging = 0; private long startedDragging = 0;
public final String tabName; public final String tabName;
public final String fileContainerName; public final String fileContainerName;
public final ResourceViewer resource;
private static long lastMouseClick = System.currentTimeMillis(); private static long lastMouseClick = System.currentTimeMillis();
public final static MouseListener buttonHoverAnimation = new ButtonHoverAnimation(); public final static MouseListener buttonHoverAnimation = new ButtonHoverAnimation();
public static final Color BLANK_COLOR = new Color(0, 0, 0, 0); public static final Color BLANK_COLOR = new Color(0, 0, 0, 0);
public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName, String name, final JTabbedPane existingTabs) public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName, String name, final JTabbedPane existingTabs, ResourceViewer resource)
{ {
// unset default FlowLayout' gaps // unset default FlowLayout' gaps
super(new FlowLayout(FlowLayout.LEFT, 0, 0)); super(new FlowLayout(FlowLayout.LEFT, 0, 0));
this.tabName = name; this.tabName = name;
this.fileContainerName = fileContainerName; this.fileContainerName = fileContainerName;
this.resource = resource;
if (existingTabs == null) if (existingTabs == null)
throw new NullPointerException("TabbedPane is null"); throw new NullPointerException("TabbedPane is null");

View file

@ -14,13 +14,11 @@ import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent; import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
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 the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.FileContainer;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU; import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU;
@ -164,16 +162,16 @@ public class WorkPaneMainComponent extends VisibleComponent
if (!workingOn.containsKey(workingName)) if (!workingOn.containsKey(workingName))
{ {
final ClassViewer tabComp = new ClassViewer(container, name, cn, workingName); final ClassViewer resourceView = new ClassViewer(container, name, cn, workingName);
tabs.add(tabComp); tabs.add(resourceView);
final int tabIndex = tabs.indexOfComponent(tabComp); final int tabIndex = tabs.indexOfComponent(resourceView);
workingOn.put(workingName, tabIndex); workingOn.put(workingName, tabIndex);
TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs); TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs, resourceView);
tabComp.tabbedPane = tabbedPane; resourceView.tabbedPane = tabbedPane;
tabs.setTabComponentAt(tabIndex, tabbedPane); tabs.setTabComponentAt(tabIndex, tabbedPane);
tabs.setSelectedIndex(tabIndex); tabs.setSelectedIndex(tabIndex);
tabComp.refreshTitle(); resourceView.refreshTitle();
} }
else else
{ {
@ -196,16 +194,16 @@ public class WorkPaneMainComponent extends VisibleComponent
if (!workingOn.containsKey(workingName)) if (!workingOn.containsKey(workingName))
{ {
final FileViewer tabComp = new FileViewer(container, name, contents, workingName); final FileViewer resourceView = new FileViewer(container, name, contents, workingName);
tabs.add(tabComp); tabs.add(resourceView);
final int tabIndex = tabs.indexOfComponent(tabComp); final int tabIndex = tabs.indexOfComponent(resourceView);
workingOn.put(workingName, tabIndex); workingOn.put(workingName, tabIndex);
TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs); TabbedPane tabbedPane = new TabbedPane(tabIndex, workingName, container.name, name, tabs, resourceView);
tabComp.tabbedPane = tabbedPane; resourceView.tabbedPane = tabbedPane;
tabs.setTabComponentAt(tabIndex, tabbedPane); tabs.setTabComponentAt(tabIndex, tabbedPane);
tabs.setSelectedIndex(tabIndex); tabs.setSelectedIndex(tabIndex);
tabComp.refreshTitle(); resourceView.refreshTitle();
} }
else else
{ {