Skip to content

Instantly share code, notes, and snippets.

@kritzikratzi
Created September 23, 2011 20:52
Show Gist options
  • Save kritzikratzi/1238410 to your computer and use it in GitHub Desktop.
Save kritzikratzi/1238410 to your computer and use it in GitHub Desktop.
97 simple steps to get a working eclipse url handler for play in mac os

I really like those links to be clickable from my web-browser, I also really love eclipse.

Here's how you make them play together:

1/97: Modify your application.config

Look for the play.editor option and modify it.

play.editor=playclipse://open?url=file://%s&line=%s

Add an error somewhere and verify that the new link shows up.

2/97: Create the applescript

Fire up AppleScript-Editor and copy&paste this in a new window

on open location uri
	tell application "Eclipse"
		set i1 to offset of "?url=" in uri
		set i2 to offset of "&line=" in uri
		set i3 to the length of uri
		set myfile to text (i1 + 12) through (i2 - 1) of uri
		set myline to text (i2 + 6) through i3 of uri
		activate
		open myfile
		tell application "System Events"
			keystroke "l" using {command down}
			keystroke myline
			key code 36
		end tell
	end tell
end open location

Use the "save as" function (yep, this app still has save as, even in lion) and save it as an application package to a location of your choice. I put mine to /Applications/Play/ where i also keep all my play versions.

After that: close the applescript editor again.

3/97: Modify the application package

Now navigate to the script-application you just created, right click on it, navigate to Contents/Info.plist, open that in a text editor and insert CFBundleIdentifier and CFBundleURLTypes as shown below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleIdentifier</key>
	<string>play.EclipseLauncher</string>
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>playclipse</string>
			</array>
			<key>CFBundleURLName</key>
			<string>LocalCommand</string>
		</dict>
	</array>
---- the rest of the file stays like it was --- 

Save the plist file, then double-click the script-application. Nothing should happen.

At this point it should already work in Safari. Try it out: playclipse://open?url=file:///Users/some-file-some-where&line=1

4/97: Make it work in google chrome

First close google chrome. Now open the file ~/Library/Application Support/Google/Chrome/Local State in your favourite text editor.

Search for excluded_schemes and add playclipse:false, like so:

[...]
"nntp": true,
"playclipse": false,
[...]

Save the file. Launch google chrome, test it out. Everything should work now.

The next steps

This wasn't easy enough, bang your head against the table 93 times!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment