diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java index 118520e443..53b39223f5 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/datatype/DataTypeDropDownSelectionDataModel.java @@ -39,25 +39,25 @@ import ghidra.util.exception.AssertException; */ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldDataModel { - 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 filterDataTypeList(List 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 filterDataTypeList(List 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 preferredUIDs = new HashSet<>(); + Set preferredUids = new HashSet<>(); Set> 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 matchingList = new ArrayList<>(dataTypeList.size()); - for (DataType dataType : dataTypeList) { - if (dataType instanceof Array) { + List 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; } diff --git a/Ghidra/Framework/Gui/src/main/java/generic/theme/StubThemeManager.java b/Ghidra/Framework/Gui/src/main/java/generic/theme/StubThemeManager.java index 0138a91aba..02f823954f 100644 --- a/Ghidra/Framework/Gui/src/main/java/generic/theme/StubThemeManager.java +++ b/Ghidra/Framework/Gui/src/main/java/generic/theme/StubThemeManager.java @@ -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;