In Economics there are a number of sub-menus: Industry, Mining etc. I suggest the rather drastic step of either removing or "greying out" the options with no relevant actions. So if there are no Shipyards on a planet or an asteroid you can not chose Shipyard or Shipyard task on that body.
I think this could be applied to Shipyard, Shipyard Tasks, Research, GU training, Stockpiles and Ancient Constructs.