Regarding deep space missions, like the Rosetta mission, how much of the journey to the final destination is pre-programmed vs. recalculated on the fly? For the Rosetta example, was the whole sequence of gravity assists (and burns to align the trajectory in order to do the assists) pre-programmed, or was the trajectory recalculated after every maneuver? Could the whole journey be executed in a "hands off" fashion (not counting the other various stuff that needs to be done during the journey like doing science, telemetry checks etc., just the trajectory planning and maneuver execution)?
The journey to the destination is about always completely pre-planned. All the gravity assists, close fly-bys, and so on, are planned before launch - and often long before the probe design is completed, as often the requirements of the trajectory influence design considerations: ability to hibernate, delta-V of the engines, tolerance to heat if the probe is to get assists from Venus, equipment to pick science specific from given targets-of-opportunity (asteroid flybys), and all equipment lifetime, as the trajectory means trip time.
This doesn't mean the probe can do everything fully autonomously.
In the mission plan, there are events of "course adjustment". Each maneuver, like a gravity assist, departure burn, or plane change is performed with a certain error. At these distances, a couple milliseconds of error at departure burn will mean hundreds of kilometers of error at the destination. After a maneuver was performed, the deviation from planned trajectory is determined. Parameters of the corrective burn are established, and the probe performs the maneuver at the pre-planned location and time, but according to parameters that were obtained only after the maneuver that introduced the error.