How do I add a button to the editor (with a custom script)?

Hey dear XWiki-Community,

I have written a velocity-script I want my users to be able to use. However, I dont want them to copy my script to the source editor, but to use a button in the optical editor.
The editor page I have read and I have already been able to add a button to the toolbar which inserts a macro.
But as described above, I want to add a button which opens a dialogue in which the user can put a text. The text then should be put in the middle of my script and all of it inserted into the page which is being edited.
How can I achieve that? Do I have to write a macro in java?