Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a local file in Eclipse from the web

Right now, when I notice a problem on a page on my PHP web site, I have to look at the URL, mentally deduce what file is responsible for displaying that page, then navigate the Eclipse PDT file tree to open that file. This is annoying and uses brain power that could have been applied to solving the issue instead.

I would like my PHP web site to display on every page a link that I could click to automatically open the correct file in Eclipse.

I can easily compute the complete absolute path for the file I need to open (for example, open C:/xampp/htdocs/controllers/Foo/Bar.php when visiting /foo/bar), and I can make sure that Eclipse is currently open with the correct project loaded, but I'm stuck on how I can have Firefox/Chrome/IE tell Eclipse to open that specific file.

Edit

I'm going along the way of a data: URI, by adding a link to my file that contains the name of the file, with an unusual MIME type.

<a href="data:link/php;base64,IkM6XHhhb[snip]GhwIgo=">
  View controller
</a>

The base64-encoded content is the absolute path to the file on my computer. When I click the link, Firefox lets me bind the content type to a new application, so I chose a batch file I wrote myself:

for /f "delims=" %%i in (%1) do (
  notepad.exe "%%i"
)

This works. Now, I would like the file to be opened in the already opened window of Eclipse. What do I have to replace notepad.exe with in the above batch?

like image 259
Victor Nicollet Avatar asked Mar 26 '10 09:03

Victor Nicollet


People also ask

How do I search and open files in Eclipse?

The Eclipse search dialog box allows you to search for files that contain a literal or a character pattern in the entire workspace, a set of projects, a specific project or folders selects in the package explorer view. Clicking on the Search menu and selecting Search or File or Java. Clicking Ctrl + H.


2 Answers

[pathtoeclipse]\eclipsec.exe -name Eclipse --launcher.openFile [fullpathtoyourfilehere]

I am not sure if it works with Galileo (i am on Helios)

Further reading: https://bugs.eclipse.org/bugs/show_bug.cgi?id=4922 (it is a long, long story)

like image 119
ts. Avatar answered Sep 22 '22 22:09

ts.


I've tried similar things in the past, but this isn't as easy as it should be. The end result was always that Firefox would need an extension to execute a local file (I never found one that would do the job), and IE won't do it at all any more (save, maybe, for some complicated proprietary VBScript/WScript).

I see two workarounds to do this:

  1. A function that displays the file path on your page in a big fat dialog window, making it easy to copy and paste into the Windows + R "Execute" Dialog

  2. Alternatively, registering a custom Protocol (e.g. eclipse://) in your operating system, and tying that protocol to Eclipse. This is a pretty great way actually, I haven't tried this yet but definitely will in the next project I need this. Mozillazine: Register protocol (see the .reg file example)

like image 26
Pekka Avatar answered Sep 24 '22 22:09

Pekka