Skip to content

Commit daabec6

Browse files
committed
Merge remote-tracking branch
'origin/GP-3684-dragonmacher-filter-description-2' into patch (Closes NationalSecurityAgency#5614)
2 parents d39caa5 + aa7cfa6 commit daabec6

File tree

2 files changed

+27
-70
lines changed

2 files changed

+27
-70
lines changed

Ghidra/Framework/Docking/src/main/java/docking/widgets/AbstractGCellRenderer.java

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import javax.swing.JComponent;
2222
import javax.swing.border.Border;
2323
import javax.swing.plaf.UIResource;
24+
import javax.swing.plaf.basic.BasicHTML;
25+
import javax.swing.table.DefaultTableCellRenderer;
2426

2527
import docking.widgets.label.GDHtmlLabel;
2628
import generic.theme.GColor;
@@ -174,17 +176,13 @@ protected Color getUneditableForegroundColor(boolean isSelected) {
174176
return isSelected ? Tables.UNEDITABLE_SELECTED : Tables.UNEDITABLE_UNSELECTED;
175177
}
176178

177-
// ==================================================================================================
179+
//==================================================================================================
178180
// Methods overridden for performance reasons (see DefaultTableCellRenderer &
179181
// DefaultListCellRenderer)
180182
//==================================================================================================
181183

182184
/**
183-
* Overridden for performance reasons.
184-
* See the <a href="#override">Implementation Note</a>
185-
* for more information.
186-
*
187-
* @since 1.5
185+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
188186
*/
189187
@Override
190188
public void invalidate() {
@@ -196,78 +194,63 @@ protected void superValidate() {
196194
}
197195

198196
/**
199-
* Overridden for performance reasons.
200-
* See the <a href="#override">Implementation Note</a>
201-
* for more information.
197+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
202198
*/
203199
@Override
204200
public void validate() {
205201
// stub
206202
}
207203

208204
/**
209-
* Overridden for performance reasons.
210-
* See the <a href="#override">Implementation Note</a>
211-
* for more information.
205+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
212206
*/
213207
@Override
214208
public void revalidate() {
215209
// stub
216210
}
217211

218212
/**
219-
* Overridden for performance reasons.
220-
* See the <a href="#override">Implementation Note</a>
221-
* for more information.
213+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
222214
*/
223215
@Override
224216
public void repaint(long tm, int x, int y, int width, int height) {
225217
// stub
226218
}
227219

228220
/**
229-
* Overridden for performance reasons.
230-
* See the <a href="#override">Implementation Note</a>
231-
* for more information.
221+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
232222
*/
233223
@Override
234224
public void repaint(Rectangle r) {
235225
// stub
236226
}
237227

238228
/**
239-
* Overridden for performance reasons.
240-
* See the <a href="#override">Implementation Note</a>
241-
* for more information.
242-
*
243-
* @since 1.5
229+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
244230
*/
245231
@Override
246232
public void repaint() {
247233
// stub
248234
}
249235

250236
/**
251-
* Overridden for performance reasons.
252-
* See the <a href="#override">Implementation Note</a>
253-
* for more information.
237+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
254238
*/
255239
@Override
256-
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
257-
if (propertyName.equals("text") || propertyName.equals("labelFor") ||
258-
propertyName.equals("displayedMnemonic") ||
259-
((propertyName.equals("font") || propertyName.equals("foreground")) &&
260-
oldValue != newValue &&
261-
getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
262-
263-
super.firePropertyChange(propertyName, oldValue, newValue);
240+
protected void firePropertyChange(String property, Object oldValue, Object newValue) {
241+
if (property.equals("text") || property.equals("labelFor") ||
242+
property.equals("displayedMnemonic") || property.equals("html")) {
243+
super.firePropertyChange(property, oldValue, newValue);
244+
}
245+
else if (getClientProperty(BasicHTML.propertyKey) != null) {
246+
if (property.equals("font") || property.equals("foreground")) {
247+
super.firePropertyChange(property, oldValue, newValue);
248+
}
264249
}
265250
}
266251

267252
/**
268-
* Overridden for performance reasons.
269-
* See the <a href="#override">Implementation Note</a>
270-
* for more information.
253+
* See {@link DefaultTableCellRenderer} class header javadoc for more info.
271254
*/
272255
@Override
273256
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {

Ghidra/Framework/Docking/src/main/java/docking/widgets/list/GListCellRenderer.java

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,8 +15,7 @@
1515
*/
1616
package docking.widgets.list;
1717

18-
import java.awt.*;
19-
import java.util.List;
18+
import java.awt.Component;
2019
import java.util.function.Function;
2120

2221
import javax.swing.*;
@@ -38,7 +37,7 @@ public class GListCellRenderer<E> extends AbstractGCellRenderer implements ListC
3837
* <p>
3938
* Use this if you only need to provide a way to get the string value from the type being shown
4039
* in the list.
41-
*
40+
*
4241
* @param cellToTextMappingFunction a function that maps your custom type to a string value
4342
* @return new GListCellRenderer instance
4443
*/
@@ -75,6 +74,7 @@ public Component getListCellRendererComponent(JList<? extends E> list, E value,
7574
boolean isSelected, boolean hasFocus) {
7675

7776
setText(getItemText(value));
77+
7878
setHorizontalAlignment(
7979
value instanceof Number ? SwingConstants.RIGHT : SwingConstants.LEFT);
8080
ListModel<? extends E> model = list.getModel();
@@ -83,14 +83,13 @@ public Component getListCellRendererComponent(JList<? extends E> list, E value,
8383
if (isSelected) {
8484
setForeground(list.getSelectionForeground());
8585
setBackground(list.getSelectionBackground());
86-
setOpaque(true);
8786
}
8887
else {
8988
setForegroundColor(list, model, value);
9089

9190
JList.DropLocation dropLocation = list.getDropLocation();
9291
// @formatter:off
93-
boolean isDropRow = (dropLocation != null &&
92+
boolean isDropRow = (dropLocation != null &&
9493
dropLocation.isInsert() &&
9594
dropLocation.getIndex() == index);
9695
// @formatter:on
@@ -103,6 +102,7 @@ public Component getListCellRendererComponent(JList<? extends E> list, E value,
103102
}
104103

105104
setBorder(hasFocus ? focusBorder : noFocusBorder);
105+
106106
return this;
107107
}
108108

@@ -114,30 +114,4 @@ protected void setForegroundColor(JList<? extends E> list, ListModel<? extends E
114114
protected void configureFont(JList<? extends E> list, ListModel<? extends E> model, int index) {
115115
setFont(defaultFont);
116116
}
117-
118-
/**
119-
* Returns the width, height necessary to display the largest element in this list.
120-
* <p>
121-
* Useful for setting a JList's fixed cell width and height to the actual necessary size.
122-
* <p>
123-
* NOTE: the items and the renderer must be in plain text mode, not HTML rendering mode.
124-
*
125-
* @param list the JList that uses this cell renderer
126-
* @param items the items to measure
127-
* @param minWidth the minimum width that can be returned
128-
* @param minHeight the minimum height that can be returned
129-
* @return a new Dimension containing a width and height value necessary to display the largest
130-
* element in the list
131-
*/
132-
public Dimension computePlainTextListCellDimensions(JList<? extends E> list, List<E> items,
133-
int minWidth, int minHeight) {
134-
configureFont(list, list.getModel(), 0);
135-
FontMetrics metrics = getFontMetrics(getFont());
136-
int maxWidth = minWidth;
137-
for (E item : items) {
138-
String text = getItemText(item).toString();
139-
maxWidth = Math.max(maxWidth, metrics.stringWidth(text));
140-
}
141-
return new Dimension(maxWidth, Math.max(metrics.getHeight(), minHeight));
142-
}
143117
}

0 commit comments

Comments
 (0)