GP-6475 follow up on datatype merge action to only popup on supported

datatypes.
This commit is contained in:
ghidragon
2026-02-23 13:11:29 -05:00
parent 41e7ac82ed
commit 90dcf26dfd
2 changed files with 14 additions and 6 deletions
@@ -57,12 +57,6 @@ public class MergeDataTypeAction extends DockingAction {
setHelpLocation(new HelpLocation("DataTypeManagerPlugin", "merge_datatypes"));
}
@Override
public boolean isAddToPopup(ActionContext context) {
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
return node instanceof DataTypeNode;
}
@Override
public boolean isEnabledForContext(ActionContext context) {
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
@@ -75,6 +69,10 @@ public class MergeDataTypeAction extends DockingAction {
}
DataType dataType = dtNode.getDataType();
if (!DataTypeUtilities.supportsMerge(dataType)) {
return false;
}
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
// for now, only allow merging on program datatypes.
@@ -1105,7 +1105,17 @@ public class DataTypeUtilities {
public static boolean equalsIgnoreConflict(String name1, String name2) {
return getNameWithoutConflict(name1).equals(getNameWithoutConflict(name2));
}
/**
* Returns true if there is a {@link DataTypeMerger} that can handle the given datatype. Currently, only structures
* unions, and enums are supported.
* @param dataType the dataType to check
* @return true if there is support for merging that dataType
*/
public static boolean supportsMerge(DataType dataType) {
return dataType instanceof Composite || dataType instanceof Enum;
}
/**
* Convenience method for getting the appropriate datatype merger or throwing an exception
* if the two datatypes are not eligible to be merged.