开发者

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?


[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)


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)


You get the local path with FILE.

Maybe you try something like this?

<?php
'127.0.0.1' == $_SERVER["REMOTE_ADDR"] and print __FILE__;
?>


Is integrating Eclipse with Xdebug an option? I've done this with TextMate so that generated error messages are clickable to take me to the correct line in the right file. (See this question for details).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜