mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 11:31:43 +00:00
Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-11-12-24'
This commit is contained in:
commit
bbbd1c677a
@ -39,25 +39,25 @@ import ghidra.util.exception.AssertException;
|
||||
*/
|
||||
public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldDataModel<DataType> {
|
||||
|
||||
private final DataTypeManager dtm; // preferred data type manager
|
||||
private final DataTypeManager preferredDtm; // preferred data type manager; may be null
|
||||
private final DataTypeManagerService dataTypeService;
|
||||
|
||||
public DataTypeDropDownSelectionDataModel(ServiceProvider serviceProvider) {
|
||||
this.dtm = null;
|
||||
this.preferredDtm = null;
|
||||
this.dataTypeService = getDataTypeService(serviceProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param dtm the preferred {@link DataTypeManager}. Data types that are found in multiple
|
||||
* data type managers will be pruned to just the ones already in the preferred data type
|
||||
* manager.
|
||||
* @param preferredDtm the preferred {@link DataTypeManager}. Data types that are found in
|
||||
* multiple data type managers will be pruned to just the ones already in the preferred data
|
||||
* type manager.
|
||||
* @param dataTypeService {@link DataTypeManagerService}
|
||||
*/
|
||||
public DataTypeDropDownSelectionDataModel(DataTypeManager dtm,
|
||||
public DataTypeDropDownSelectionDataModel(DataTypeManager preferredDtm,
|
||||
DataTypeManagerService dataTypeService) {
|
||||
this.dtm = dtm;
|
||||
this.preferredDtm = preferredDtm;
|
||||
this.dataTypeService = dataTypeService;
|
||||
}
|
||||
|
||||
@ -98,54 +98,64 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldData
|
||||
/**
|
||||
* Remove any unwanted data type items, like arrays.
|
||||
*/
|
||||
private List<DataType> filterDataTypeList(List<DataType> dataTypeList) {
|
||||
// build lookups for data types that are in the preferred dtm, but may have come from
|
||||
// another DTM. In the second step, duplicate data types will be omitted from the
|
||||
private List<DataType> filterDataTypeList(List<DataType> dtList) {
|
||||
// Build lookups for data types that are in the preferred dtm, but may have come from
|
||||
// another dtm. In the second step, duplicate data types will be omitted from the
|
||||
// final results, in favor of the data type that is already in the preferred dtm.
|
||||
Set<UniversalID> preferredUIDs = new HashSet<>();
|
||||
Set<UniversalID> preferredUids = new HashSet<>();
|
||||
Set<Class<?>> preferredBuiltins = new HashSet<>();
|
||||
for (DataType dt : dataTypeList) {
|
||||
DataType baseDT = DataTypeUtilities.getBaseDataType(dt);
|
||||
if (isFromPreferredDTM(baseDT)) {
|
||||
if (baseDT instanceof BuiltInDataType) {
|
||||
preferredBuiltins.add(baseDT.getClass());
|
||||
}
|
||||
else if (baseDT.getUniversalID() != null) {
|
||||
preferredUIDs.add(baseDT.getUniversalID());
|
||||
}
|
||||
for (DataType dt : dtList) {
|
||||
DataType baseDt = DataTypeUtilities.getBaseDataType(dt);
|
||||
if (!isFromPreferredDtm(baseDt)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (baseDt instanceof BuiltInDataType) {
|
||||
preferredBuiltins.add(baseDt.getClass());
|
||||
}
|
||||
else if (baseDt.getUniversalID() != null) {
|
||||
preferredUids.add(baseDt.getUniversalID());
|
||||
}
|
||||
}
|
||||
|
||||
List<DataType> matchingList = new ArrayList<>(dataTypeList.size());
|
||||
for (DataType dataType : dataTypeList) {
|
||||
if (dataType instanceof Array) {
|
||||
List<DataType> matchingList = new ArrayList<>(dtList.size());
|
||||
for (DataType dt : dtList) {
|
||||
if (dt instanceof Array) {
|
||||
continue;
|
||||
}
|
||||
DataType baseDT = DataTypeUtilities.getBaseDataType(dataType);
|
||||
if (dtm != null && !isFromPreferredDTM(baseDT)) {
|
||||
if (baseDT instanceof BuiltInDataType &&
|
||||
preferredBuiltins.contains(baseDT.getClass())) {
|
||||
DataType baseDt = DataTypeUtilities.getBaseDataType(dt);
|
||||
if (baseDt == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preferredDtm != null && !isFromPreferredDtm(baseDt)) {
|
||||
if (baseDt instanceof BuiltInDataType &&
|
||||
preferredBuiltins.contains(baseDt.getClass())) {
|
||||
continue;
|
||||
}
|
||||
if (baseDT.getUniversalID() != null &&
|
||||
preferredUIDs.contains(baseDT.getUniversalID())) {
|
||||
if (baseDt.getUniversalID() != null &&
|
||||
preferredUids.contains(baseDt.getUniversalID())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
matchingList.add(dataType);
|
||||
matchingList.add(dt);
|
||||
}
|
||||
|
||||
return matchingList;
|
||||
}
|
||||
|
||||
private boolean isFromPreferredDTM(DataType dt) {
|
||||
if (dtm != null) {
|
||||
DataTypeManager altDTM = dtm instanceof CompositeViewerDataTypeManager compDTM
|
||||
? compDTM.getOriginalDataTypeManager()
|
||||
private boolean isFromPreferredDtm(DataType dt) {
|
||||
if (dt == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preferredDtm != null) {
|
||||
DataTypeManager altDtm = preferredDtm instanceof CompositeViewerDataTypeManager compDtm
|
||||
? compDtm.getOriginalDataTypeManager()
|
||||
: null;
|
||||
DataTypeManager dtDTM = dt.getDataTypeManager();
|
||||
return dtDTM == dtm || dtDTM == altDTM;
|
||||
DataTypeManager dtDtm = dt.getDataTypeManager();
|
||||
return dtDtm == preferredDtm || dtDtm == altDtm;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -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.
|
||||
@ -181,6 +181,11 @@ public class StubThemeManager extends ThemeManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingAquaUI() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingNimbusUI() {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user