GP-3000 - Theme Cleanup

This commit is contained in:
dragonmacher 2023-02-09 15:22:54 -05:00
parent f022b9a4d5
commit 1fa08a6002
38 changed files with 324 additions and 177 deletions

View file

@ -159,14 +159,14 @@ color.fg.dialog.status.error = color.fg.error
color.fg.dialog.status.warning = orange
color.fg.dialog.status.normal = lightBlue
color.bg.currentline = rgb(40,40,56) // dark bluish gray
color.bg.currentline = #003366
color.bg.textfield.hint.invalid = maroon
color.bg.filterfield = color.bg.filtered
color.fg.filterfield = darkSlateGray
color.bg.selection = #284028 // greenish
color.bg.selection = #003333 // greenish
color.bg.highlight = #404028 // yellowish
color.bg.fieldpanel.selection.and.highlight = #344028 // yellow greenish

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View file

@ -268,9 +268,9 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
/**
* Overrides this method to ensure that the new foreground color is not
* a {@link GColorUIResource}. Some Look and Feels will ignore color values that extend
* {@link UIResource}, choosing instead their own custom painting behavior. By not using a
* {@link UIResource}, choosing instead their own custom painting behavior. By not using a
* UIResource, we prevent the Look and Feel from overriding this renderer's color value.
*
*
* @param fg the new foreground color
*/
@Override
@ -281,9 +281,9 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
/**
* Overrides this method to ensure that the new background color is not
* a {@link GColorUIResource}. Some Look and Feels will ignore color values that extend
* {@link UIResource}, choosing instead their own custom painting behavior. By not using a
* {@link UIResource}, choosing instead their own custom painting behavior. By not using a
* UIResource, we prevent the Look and Feel from overriding this renderer's color value.
*
*
* @param bg the new background color
*/
@Override

View file

@ -39,11 +39,11 @@ public interface GComponent {
}
/**
* Returns the current HTML rendering 'enable-ment' of this component.
*
* Returns the current HTML rendering enablement of this component.
*
* @return boolean, true if HTML rendering is allowed
*/
public default boolean getHTMLRenderingEnabled() {
public default boolean isHTMLRenderingEnabled() {
Object prop = ((JComponent) this).getClientProperty(HTML_DISABLE_STRING);
return prop == null || prop != Boolean.TRUE;
}
@ -66,7 +66,7 @@ public interface GComponent {
/**
* Sets the HTML rendering flag for the specified component.
*
*
* @param comp the thing
* @param enabled boolean, if true html rendering will be allowed
*/

View file

@ -51,13 +51,11 @@ public abstract class AbstractHtmlLabel extends JLabel
protected AbstractHtmlLabel() {
addPropertyChangeListener(this);
setHTMLRenderingEnabled(false); // disable parent html rendering so we can do our own
}
protected AbstractHtmlLabel(String text) {
super(text);
addPropertyChangeListener(this);
setHTMLRenderingEnabled(false); // disable parent html rendering so we can do our own
}
@Override
@ -82,7 +80,7 @@ public abstract class AbstractHtmlLabel extends JLabel
private void updateHtmlView() {
String text = getText();
if (text == null) {
if (text == null || !isHTMLRenderingEnabled()) {
putClientProperty(BasicHTML.propertyKey, null);
return;
}

View file

@ -207,7 +207,7 @@ public abstract class AbstractColumnConstraintEditor<T> implements ColumnConstra
* @return an HTML string suitable for a JLabel.
*/
protected final static String formatStatus(String message, boolean error) {
Color color = error ? Colors.ERROR : Colors.FOREGROUND;
Color color = error ? Colors.Messages.ERROR : Colors.FOREGROUND;
String messageWithFont = HTMLUtilities.setFont(message, color, 12);
String html = HTMLUtilities.wrapAsHTML(messageWithFont);
return html;

View file

@ -56,7 +56,7 @@ import ghidra.util.worker.PriorityWorker;
* Class for creating a JTree that supports filtering, threading, and a progress bar.
*/
public class GTree extends JPanel implements BusyListener, ThemeListener {
public class GTree extends JPanel implements BusyListener {
private static final Color BACKGROUND = new GColor("color.bg.tree");
private AutoScrollTree tree;
private GTreeModel model;
@ -93,6 +93,11 @@ public class GTree extends JPanel implements BusyListener, ThemeListener {
private JTreeMouseListenerDelegate mouseListenerDelegate;
private GTreeDragNDropHandler dragNDropHandler;
private boolean isFilteringEnabled = true;
private ThemeListener themeListener = e -> {
if (e.isLookAndFeelChanged()) {
model.fireNodeStructureChanged(getModelRoot());
}
};
private ThreadLocal<TaskMonitor> threadLocalMonitor = new ThreadLocal<>();
private PriorityWorker worker;
@ -135,7 +140,7 @@ public class GTree extends JPanel implements BusyListener, ThemeListener {
uniquePreferenceKey));
filterUpdateManager = new SwingUpdateManager(1000, 30000, () -> updateModelFilter());
Gui.addThemeListener(this);
Gui.addThemeListener(themeListener);
}
/**
@ -148,13 +153,6 @@ public class GTree extends JPanel implements BusyListener, ThemeListener {
threadLocalMonitor.set(monitor);
}
@Override
public void themeChanged(ThemeEvent event) {
if (event.isLookAndFeelChanged()) {
model.fireNodeStructureChanged(getModelRoot());
}
}
/**
* Returns the monitor in associated with the GTree for the calling thread. This method is
* designed to be used by slow loading nodes that are loading <b>off the Swing thread</b>. Some
@ -272,6 +270,8 @@ public class GTree extends JPanel implements BusyListener, ThemeListener {
realViewRootNode.disposeClones();
}
model.dispose();
Gui.removeThemeListener(themeListener);
}
public boolean isDisposed() {
@ -1091,17 +1091,17 @@ public class GTree extends JPanel implements BusyListener, ThemeListener {
Consumer<GTreeNode> consumer) {
/*
If the GTree were to use Java's CompletableStage API, then the code below
could be written thusly:
tree.getNewNode(modelParent, newName)
.thenCompose(newModelChild -> {
tree.ignoreFilter(newModelChild);
return tree.getNewNode(viewParent, newName);
))
.thenAccept(consumer);
*/
// ensure we operate on the model node which will always have the given child not the view