Arrive 2 hours Early to Shanghai Train Station?
Since you'll need to wait in line at the ticket window to pick up the tickets you booked online, then I'd advise an hour before. Make sure you are waiting in the correct line as only one of the many ticket lines at the ticket counter is for picking up tickets booked online. 2 hours is overkill. If you already had tickets in hand then I'd go with Moondog's advice but since you don't you'll need more time.