@Override
	protected boolean isEnabledForContext(ProgramLocationActionContext context) {
		Data cursorData = DataUtilities.getDataAtLocation(context.getLocation());
		return cursorData != null &&
			(cursorData.getNumComponents() > 0 || cursorData.getParent() != null);
	}
Action for toggling the expanded/collapsed state of an single expandable data element.  This
action works for both top level structures and structures inside other structures.  Also,
if invoked on any data element inside a structure, it will collapse the immediate parent
of that element.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/actions/ToggleExpandCollapseDataAction.java