Friday, February 5, 2010

CopyTo...Pastebin (and others) Plug-In for Eclipse

I am currently working on a small Plug-In that some of you might find useful (especially if you are hanging out in IRC a lot). The plugin allows you to select resources, classes or methods in Java projects and posts them to your favorite pastebin. After that it provides the URL of the pastebin entry in your clipboard so you can easily send it to others. This little video demonstrates this: Some pastebins allow the user to specify additional options when posting. This will be covered when the user helds down the "CTRL" while selecting the menu entry. A dialog is then display where the user can adjust such options. Likewise he could change the content type of the pasted text, if the automatic detection failed. The Plug-In will be released under EPL 1.0 and the source will be up at github. Now, if anyone of you have a nicer name for the Plug-In, I would like to replace the rather generic "CopyTo" (Pasty?). The Plug-In is very easily extensible with new pastebin providers. In fact all current providers are supplied via Fragement-Bundles that basically just add their menuContribution the the CopyTo menu. There is support for the usual redirect based pastebins, as well as ones that send back JSON. Additional response handlers can be easily plugged in (SOAP *yikes*) and additional JSON helpers, that extract the new location URL component from a JSON response are queried using the Eclipse IAdapterManager. Currently there is only support for copying JDT elements (Classes, Methods) but other sources of "Copyable" content can be also plugged in via Adapters. I also plan to provide a "History" view of pastes that allows you to copy the URL again into the clipboard at any time.


  1. Hi Phil, your blog layout is a little bit to narrow to see the right part of the screenshot / video...

  2. I use both Eclipse and pastebin in the lectures of introductory course for objekts using Java, and look forward to trying it out! When do you have a downloadable/installable version available?

  3. If I may make a suggestion, instead of doing that in a popup menu, add a button to the main toolbar. You can use dropdown button similar to Run/Debug buttons. From the implementation point of view, you can simply request current selection from the selection service.

    Also, it would be neat if you could make paste web sites configurable, e.g. using simple url format with macro substitution, like${text}&user=test

  4. @Peter: Yes I know... Blogger platform just has no useful, floating layouts. Or maybe you know a better one?

    @Hallvard: There is (was) already a version available. But it had dependencies on 3.6 Eclipse. I will build a new one that uses 3.4 as target on the weekend and publish the update site url.

    @Eugene: Privet :) Good idea. I will also add a dropdown button. I have already an entry in the "Edit" menu and unfortunately contributing to the popup menu or a usual menu differs. Basically one would have to register the menuContribution with "menu:" as well with "popup:" locations. That's a legacy issue. I address that currently in the code and just add an AbstractContributionFactory an fill it with "menu:" contributions myself. Adding the toolbar button with dropdown menu will be easy therefore, as no contribution has to be changed.
    Also, as you suggested I already use the IStringVariableManager (which is unfortunately not very dynamic) to replace text in the url.

    The copyto command serialized looks like this:

    And the variables one can use are by default:

    Of course each contribution can define its own static or dynamic variables and provide configuration of those variables in a preference page, as well as directly before the contribution is called (if you hold down the CTRL key).

    For a sample contribution for checkout:

  5. Hi Philipp,

    Nice. Just a minor UI change please : contribute your "Copy to" menu in the group where copy and paste actions are.



  6. @Mariot: I was about to. Unfortunately I got sidetracked by the issue that one contribution cannot make its contributions to the the main menu as well as the popup menu (different target URIs). I will move it again (since I have my own workaround in place now) to sit right under "Copy".