From your question, I understand that you want to add the button to the Page Tab in the Ribbon whenever a particular WebPart is added to the page.
You can do this with the JavaScript Client Object Model: http://msdn.microsoft.com/en-us/library/hh185004
Here is a list of all Locations where the Button can be added: http://msdn.microsoft.com/en-us/library/bb802730
If you want to go the Server Side way, you can add the Ribbon button like this: http://sp365.co.uk/2011/09/programmatically-add-ribbon-custom-action-to-an-existing-list/
Also, I would like to mention that there is an awesome Library on Codeplex for adding ribbon buttons: http://spribbon.codeplex.com/