I would recommend having the house painted first, especially if the ceilings are being painted / sprayed.
While it may come down to when you can get a painting contractor or hardwood floor contractor in to work on your house.
Essentially, having it painted first, then floors installed will make sure that any overspray / paint drips won't end up on your new hardwood floor. Even if the painters put down mats / protection down on the floor, it is bound to get messed up by mini drops of paint spray, ladders, etc. It can be a huge pain to try to get overspray off tile or hardwood floors, even if the paint is water soluble.
That being said, the hardwood floor installers will likely mess up your newly painted walls when installing new hard wood floors. You will likely need to clean the walls off of floor dust and touch up the walls with paint after your hardwood floors are installed. If you don't want to do this, then make sure you include in your contract with your hardwood floor installer to fix any drywall / paint issues that they cause when installing the floors. I would take before and after pictures, so you can make sure they correct any problems.