mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
Merge remote-tracking branch
'origin/GP-3764-dragonmacher-data-types-filter-fix--SQUASHED' (Closes #5685)
This commit is contained in:
commit
4b075086c2
@ -327,6 +327,13 @@
|
||||
fields of <TT>Enum</TT> names and values, and <TT>Function</TT> parameter data types and
|
||||
names. You may turn this feature off if you find that your search yields too many results
|
||||
for data types that have common names, such as <TT>byte</TT>.</P>
|
||||
|
||||
<A name="Filter_Name_Only"></A>
|
||||
<P>The <B>Filter on Name Only</B> action, when toggled on, will trigger the
|
||||
filter field to search only using data type names. When toggled off, filtering will
|
||||
be done using the display text of the node, which may include additional information, such
|
||||
as an associated archive.
|
||||
</P>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H2><A name="conflict_mode"></A>Data Type Conflict Resolution Mode</H2>
|
||||
|
@ -94,7 +94,9 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
||||
private ToggleDockingAction filterPointersAction;
|
||||
private ToggleDockingAction previewWindowAction;
|
||||
private ToggleDockingAction includeDataMembersInSearchAction;
|
||||
private FilterOnNameOnlyAction filterOnNameOnlyAction;
|
||||
private boolean includeDataMembersInFilter;
|
||||
private boolean filterOnNameOnly;
|
||||
|
||||
public DataTypesProvider(DataTypeManagerPlugin plugin, String providerName) {
|
||||
this(plugin, providerName, false);
|
||||
@ -199,6 +201,9 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
||||
includeDataMembersInSearchAction = new IncludeDataTypesInFilterAction(plugin, this, "5");
|
||||
addLocalAction(includeDataMembersInSearchAction);
|
||||
|
||||
filterOnNameOnlyAction = new FilterOnNameOnlyAction(plugin, this, "6");
|
||||
addLocalAction(filterOnNameOnlyAction);
|
||||
|
||||
addLocalAction(new ApplyFunctionDataTypesAction(plugin)); // Tree
|
||||
addLocalAction(new CaptureFunctionDataTypesAction(plugin)); // Tree
|
||||
addLocalAction(new SetFavoriteDataTypeAction(plugin)); // Data Type
|
||||
@ -820,23 +825,24 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
||||
return selectedDataTypes;
|
||||
}
|
||||
|
||||
// this is a callback from the action--we need this to prevent callbacks, as the other
|
||||
// version of this method will update the action, which would trigger a callback
|
||||
// this is called from the action
|
||||
public void setIncludeDataTypeMembersInFilterCallback(boolean newValue) {
|
||||
includeDataMembersInFilter = newValue;
|
||||
archiveGTree.setIncludeDataTypeMembersInSearch(includeDataMembersInFilter);
|
||||
archiveGTree.updateDataTransformer(this);
|
||||
}
|
||||
|
||||
// this is called from the action
|
||||
public void setFilterOnNameOnlyCallback(boolean newValue) {
|
||||
filterOnNameOnly = newValue;
|
||||
archiveGTree.updateDataTransformer(this);
|
||||
}
|
||||
|
||||
public void setIncludeDataTypeMembersInFilter(boolean newValue) {
|
||||
includeDataMembersInFilter = newValue;
|
||||
archiveGTree.setIncludeDataTypeMembersInSearch(includeDataMembersInFilter);
|
||||
includeDataMembersInSearchAction.setSelected(newValue);
|
||||
}
|
||||
|
||||
// make sure the action is in sync
|
||||
ToggleDockingAction action = includeDataMembersInSearchAction;
|
||||
boolean selected = action.isSelected();
|
||||
if (selected != includeDataMembersInFilter) {
|
||||
action.setSelected(includeDataMembersInFilter);
|
||||
}
|
||||
public void setFilterOnNameOnly(boolean newValue) {
|
||||
filterOnNameOnlyAction.setSelected(newValue);
|
||||
}
|
||||
|
||||
public void setFilteringArrays(boolean b) {
|
||||
@ -847,10 +853,14 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
||||
archiveGTree.enablePointerFilter(b);
|
||||
}
|
||||
|
||||
boolean includeDataMembersInSearch() {
|
||||
public boolean isIncludeDataMembersInSearch() {
|
||||
return includeDataMembersInFilter;
|
||||
}
|
||||
|
||||
public boolean isFilterOnNameOnly() {
|
||||
return filterOnNameOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return splitPane;
|
||||
@ -978,4 +988,5 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
||||
navigationHistory.add(new DataTypeUrl(dt));
|
||||
contextChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.core.datamgr;
|
||||
|
||||
import docking.action.MenuData;
|
||||
import docking.action.ToggleDockingAction;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
/**
|
||||
* Allows user to filter on only the data type name. When off, all information returned by
|
||||
* {@link GTreeNode#getDisplayText()} is used for filtering.
|
||||
*/
|
||||
public class FilterOnNameOnlyAction extends ToggleDockingAction {
|
||||
|
||||
private final DataTypesProvider provider;
|
||||
|
||||
public FilterOnNameOnlyAction(DataTypeManagerPlugin plugin, DataTypesProvider provider,
|
||||
String menuSubGroup) {
|
||||
super("Filter on Name Only", plugin.getName());
|
||||
this.provider = provider;
|
||||
|
||||
setMenuBarData(new MenuData(new String[] { "Filter on Name Only" }, null, "VeryLast",
|
||||
MenuData.NO_MNEMONIC, menuSubGroup));
|
||||
setDescription("Selected indicates to use only the data type name when filtering.");
|
||||
|
||||
setEnabled(true);
|
||||
setSelected(false); // default to off!
|
||||
|
||||
setHelpLocation(new HelpLocation("DataTypeManagerPlugin", "Filter_Name_Only"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean newValue) {
|
||||
if (isSelected() == newValue) {
|
||||
return;
|
||||
}
|
||||
super.setSelected(newValue);
|
||||
provider.setFilterOnNameOnlyCallback(newValue);
|
||||
}
|
||||
}
|
@ -43,6 +43,9 @@ public class IncludeDataTypesInFilterAction extends ToggleDockingAction {
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean newValue) {
|
||||
if (isSelected() == newValue) {
|
||||
return;
|
||||
}
|
||||
super.setSelected(newValue);
|
||||
provider.setIncludeDataTypeMembersInFilterCallback(newValue);
|
||||
}
|
||||
|
@ -158,9 +158,21 @@ public class DataTypeArchiveGTree extends GTree {
|
||||
reloadTree();
|
||||
}
|
||||
|
||||
public void setIncludeDataTypeMembersInSearch(boolean includeDataTypes) {
|
||||
setDataTransformer(
|
||||
includeDataTypes ? new DataTypeTransformer() : new DefaultGTreeDataTransformer());
|
||||
public void updateDataTransformer(DataTypesProvider provider) {
|
||||
|
||||
boolean includeMembers = provider.isIncludeDataMembersInSearch();
|
||||
boolean filterOnNameOnly = provider.isFilterOnNameOnly();
|
||||
|
||||
DefaultDtTreeDataTransformer transformer;
|
||||
if (includeMembers) {
|
||||
transformer = new DataTypeTransformer(filterOnNameOnly);
|
||||
}
|
||||
else {
|
||||
transformer = new DefaultDtTreeDataTransformer(filterOnNameOnly);
|
||||
}
|
||||
|
||||
setDataTransformer(transformer);
|
||||
|
||||
reloadTree();
|
||||
}
|
||||
|
||||
@ -249,7 +261,28 @@ public class DataTypeArchiveGTree extends GTree {
|
||||
// Inner Classes
|
||||
//==================================================================================================
|
||||
|
||||
private class DataTypeTransformer extends DefaultGTreeDataTransformer {
|
||||
private class DefaultDtTreeDataTransformer extends DefaultGTreeDataTransformer {
|
||||
|
||||
private boolean filterOnNameOnly;
|
||||
|
||||
DefaultDtTreeDataTransformer(boolean filterOnNameOnly) {
|
||||
this.filterOnNameOnly = filterOnNameOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toString(GTreeNode node) {
|
||||
if (filterOnNameOnly) {
|
||||
return node.getName(); // the node name is the type name
|
||||
}
|
||||
return super.toString(node);
|
||||
}
|
||||
}
|
||||
|
||||
private class DataTypeTransformer extends DefaultDtTreeDataTransformer {
|
||||
|
||||
DataTypeTransformer(boolean filterOnNameOnly) {
|
||||
super(filterOnNameOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> transform(GTreeNode node) {
|
||||
|
@ -24,7 +24,7 @@ import ghidra.util.FilterTransformer;
|
||||
public class DefaultGTreeDataTransformer implements FilterTransformer<GTreeNode> {
|
||||
private ThreadLocal<List<String>> localizedResults = new ThreadLocal<List<String>>() {
|
||||
@Override
|
||||
protected java.util.List<String> initialValue() {
|
||||
protected List<String> initialValue() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
};
|
||||
@ -33,7 +33,11 @@ public class DefaultGTreeDataTransformer implements FilterTransformer<GTreeNode>
|
||||
public List<String> transform(GTreeNode node) {
|
||||
List<String> results = localizedResults.get();
|
||||
results.clear();
|
||||
results.add(node.getDisplayText());
|
||||
results.add(toString(node));
|
||||
return results;
|
||||
}
|
||||
|
||||
protected String toString(GTreeNode node) {
|
||||
return node.getDisplayText();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user