mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch
'origin/GP-94_dragonmacher_PR-2214_astrelsky_GnuDemangler' (fixes #2214)
This commit is contained in:
commit
ed1580f4f9
15 changed files with 750 additions and 501 deletions
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,38 +15,26 @@
|
|||
*/
|
||||
package ghidra.framework.options;
|
||||
|
||||
import ghidra.util.Msg;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public class EnumEditor extends PropertyEditorSupport {
|
||||
|
||||
private Enum<?> value;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see java.beans.PropertyEditor#setValue(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object o) {
|
||||
value = (Enum<?>) o;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see java.beans.PropertyEditor#getValue()
|
||||
*/
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see java.beans.PropertyEditor#getTags()
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
|
||||
|
@ -85,28 +72,20 @@ public class EnumEditor extends PropertyEditorSupport {
|
|||
return new Enum<?>[] { value };
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see java.beans.PropertyEditor#getAsText()
|
||||
*/
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see java.beans.PropertyEditor#setAsText(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(String s) {
|
||||
|
||||
try {
|
||||
Method m = value.getClass().getMethod("values");
|
||||
Enum<?>[] enums = (Enum<?>[]) m.invoke(null);
|
||||
for (int i = 0; i < enums.length; i++) {
|
||||
if (s.equals(enums[i].toString())) {
|
||||
value = enums[i];
|
||||
for (Enum<?> enum1 : enums) {
|
||||
if (s.equals(enum1.toString())) {
|
||||
value = enum1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,19 +16,19 @@
|
|||
package ghidra.framework.options;
|
||||
|
||||
// Support for PropertyEditors that use tags.
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.beans.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
/**
|
||||
* An implementation of a PropertyComponent that is represented as a
|
||||
* combo box.
|
||||
*/
|
||||
public class PropertySelector extends JComboBox implements ItemListener {
|
||||
public class PropertySelector extends JComboBox<String> implements ItemListener {
|
||||
|
||||
private PropertyEditor editor;
|
||||
private PropertyEditor propertyEditor;
|
||||
private boolean notifyEditorOfChanges = true;
|
||||
|
||||
/**
|
||||
|
@ -38,22 +37,23 @@ public class PropertySelector extends JComboBox implements ItemListener {
|
|||
* changes in the combo box
|
||||
*/
|
||||
public PropertySelector(PropertyEditor pe) {
|
||||
editor = pe;
|
||||
String tags[] = editor.getTags();
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
addItem(tags[i]);
|
||||
propertyEditor = pe;
|
||||
String tags[] = propertyEditor.getTags();
|
||||
for (String tag : tags) {
|
||||
addItem(tag);
|
||||
}
|
||||
|
||||
setSelectedIndex(0);
|
||||
|
||||
// This is a no-op if the getAsText is not a tag that we set from getTags() above
|
||||
setSelectedItem(editor.getAsText());
|
||||
setSelectedItem(propertyEditor.getAsText());
|
||||
addItemListener(this);
|
||||
invalidate();
|
||||
|
||||
editor.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
propertyEditor.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String value = editor.getAsText();
|
||||
String value = propertyEditor.getAsText();
|
||||
if (!value.equals(getSelectedItem())) {
|
||||
notifyEditorOfChanges = false;
|
||||
try {
|
||||
|
@ -67,14 +67,15 @@ public class PropertySelector extends JComboBox implements ItemListener {
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
||||
*/
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent evt) {
|
||||
if (notifyEditorOfChanges) {
|
||||
String s = (String) getSelectedItem();
|
||||
editor.setAsText(s);
|
||||
if (!notifyEditorOfChanges) {
|
||||
return;
|
||||
}
|
||||
|
||||
String s = (String) getSelectedItem();
|
||||
if (s != null) {
|
||||
propertyEditor.setAsText(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue