Make theme changes also affect components that are not in UI tree.
This commit is contained in:
parent
fb4a15f0c3
commit
b52c194fd1
|
@ -8,7 +8,8 @@ import com.github.weisj.darklaf.theme.IntelliJTheme;
|
|||
import com.github.weisj.darklaf.theme.OneDarkTheme;
|
||||
import com.github.weisj.darklaf.theme.SolarizedDarkTheme;
|
||||
import com.github.weisj.darklaf.theme.SolarizedLightTheme;
|
||||
import java.awt.Dialog;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
@ -175,4 +176,14 @@ public enum LAFTheme
|
|||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that theme changes also affect components that are not in the UI tree.
|
||||
*/
|
||||
public static void registerThemeUpdate(Component... components) {
|
||||
LafManager.registerInitTask((t, p) -> SwingUtilities.invokeLater(() -> {
|
||||
for (Component component : components)
|
||||
SwingUtilities.updateComponentTreeUI(component);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.objectweb.asm.tree.InsnList;
|
|||
import org.objectweb.asm.tree.LdcInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
|
||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||
|
@ -53,6 +54,7 @@ public class LDCSearch implements SearchPanel
|
|||
{
|
||||
searchText = new JTextField("");
|
||||
searchText.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||
LAFTheme.registerThemeUpdate(searchText);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,6 +65,7 @@ public class LDCSearch implements SearchPanel
|
|||
myPanel = new JPanel(new GridLayout(1, 2));
|
||||
myPanel.add(new TranslatedJLabel("Search String: ", TranslatedComponents.SEARCH_STRING));
|
||||
myPanel.add(searchText);
|
||||
LAFTheme.registerThemeUpdate(myPanel);
|
||||
}
|
||||
|
||||
return myPanel;
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.objectweb.asm.Type;
|
|||
import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
|
||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||
|
@ -46,6 +47,7 @@ public class MemberWithAnnotationSearch implements SearchPanel {
|
|||
public MemberWithAnnotationSearch() {
|
||||
annotation = new JTextField("");
|
||||
annotation.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||
LAFTheme.registerThemeUpdate(annotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,6 +56,7 @@ public class MemberWithAnnotationSearch implements SearchPanel {
|
|||
myPanel = new JPanel(new GridLayout(1, 2));
|
||||
myPanel.add(new TranslatedJLabel("Annotation name: ", TranslatedComponents.ANNOTATION_NAME));
|
||||
myPanel.add(annotation);
|
||||
LAFTheme.registerThemeUpdate(myPanel);
|
||||
}
|
||||
|
||||
return myPanel;
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package the.bytecode.club.bytecodeviewer.searching.impl;
|
||||
|
||||
import com.github.weisj.darklaf.LafManager;
|
||||
import eu.bibl.banalysis.asm.desc.OpcodeInfo;
|
||||
import java.awt.GridLayout;
|
||||
import java.util.Iterator;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
|
||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||
|
@ -59,6 +61,8 @@ public class MethodCallSearch implements SearchPanel
|
|||
mName.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||
mDesc = new JTextField("");
|
||||
mDesc.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||
|
||||
LAFTheme.registerThemeUpdate(mOwner, mName, mDesc);
|
||||
}
|
||||
|
||||
public JPanel getPanel()
|
||||
|
@ -72,24 +76,25 @@ public class MethodCallSearch implements SearchPanel
|
|||
myPanel.add(mName);
|
||||
myPanel.add(new TranslatedJLabel("Desc: ", TranslatedComponents.DESC));
|
||||
myPanel.add(mDesc);
|
||||
LAFTheme.registerThemeUpdate(myPanel);
|
||||
}
|
||||
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact)
|
||||
{
|
||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||
|
||||
|
||||
String searchOwner = mOwner.getText();
|
||||
if (searchOwner.isEmpty())
|
||||
searchOwner = null;
|
||||
|
||||
|
||||
String searchName = mName.getText();
|
||||
if (searchName.isEmpty())
|
||||
searchName = null;
|
||||
|
||||
|
||||
String searchDesc = mDesc.getText();
|
||||
if (searchDesc.isEmpty())
|
||||
searchDesc = null;
|
||||
|
@ -104,10 +109,10 @@ public class MethodCallSearch implements SearchPanel
|
|||
if (insnNode instanceof MethodInsnNode)
|
||||
{
|
||||
final MethodInsnNode min = (MethodInsnNode) insnNode;
|
||||
|
||||
|
||||
if (searchName == null && searchOwner == null && searchDesc == null)
|
||||
continue;
|
||||
|
||||
|
||||
if (exact)
|
||||
{
|
||||
if (searchName != null && !searchName.equals(min.name))
|
||||
|
@ -126,13 +131,13 @@ public class MethodCallSearch implements SearchPanel
|
|||
if (searchDesc != null && !min.desc.contains(searchDesc))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
found(container, resourceWorkingName, node, method, insnNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void found(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, final MethodNode method, final AbstractInsnNode insnNode)
|
||||
{
|
||||
BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.objectweb.asm.Type;
|
|||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
|
||||
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||
import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent;
|
||||
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||
|
@ -54,6 +55,8 @@ public class RegexSearch implements SearchPanel
|
|||
{
|
||||
searchText = new JTextField("");
|
||||
searchText.addKeyListener(EnterKeyEvent.SINGLETON);
|
||||
|
||||
LAFTheme.registerThemeUpdate(searchText);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,6 +67,7 @@ public class RegexSearch implements SearchPanel
|
|||
myPanel = new JPanel(new GridLayout(1, 2));
|
||||
myPanel.add(new TranslatedJLabel("Search Regex: ", TranslatedComponents.SEARCH_REGEX));
|
||||
myPanel.add(searchText);
|
||||
LAFTheme.registerThemeUpdate(myPanel);
|
||||
}
|
||||
|
||||
return myPanel;
|
||||
|
|
Loading…
Reference in New Issue