1

I am running Eclipse Che v6.18.1 in Google Chrome on MacBook Pro OS v10.10.5 (Yosemite). Eclipse Che workspace runs in a Docker container.

How can I open a new browser tab (in the same browser window as Eclipse Che) from within a Python code executed in Eclipse Che?

So not a new Google Chrome instance from within a Docker container (much too slow) but a new tab in already existing browser window on the host machine.

In Eclipse Che it is possible to preview an HTML file in the project Workspace (right-click => Preview). Then the HTML file opens in the next tab to the Eclipse Che IDE. How could I use that feature from within a Python code to open a new browser tab?

Tony
  • 7,767
  • 2
  • 22
  • 51

3 Answers3

0

Are you trying to open a preview window similar to the sample nodejs Yeoman application? Or are you trying to open a new tab from the source code in someone's browser?

If it's the latter, then I do not think it is possible (or a good idea!) - Che does not run in a security context that will allow it to instruct the browser to open a new tab or window.

Dave Neary
  • 297
  • 1
  • 4
  • Ideally, I would like that Python script opens a locally generated HTML file (inside the WS) in the same browser that I use for Che IDE. In Che it is possible to preview HTML files in the project WS. How could I use that feature from within a Python code? – Tony Mar 18 '19 at 13:27
  • Is it sufficient to provide users with a link that they will click to open the generated HTML file? – Dave Neary Mar 20 '19 at 13:39
  • No. I would like to open a new Terminal in Eclipse Che workspace and run a Python script that will generate an HTML file and open it in the same browser window as Eclipse Che. – Tony Mar 20 '19 at 14:04
  • You can certainly run a script in the terminal - and once the HTML file is generated, it will be a file in your project like any other. I think the "Preview" link is how we serve static HTML pages from a project, but I am not sure how to do it (I would also like to do this FWIW). – Dave Neary Mar 21 '19 at 20:43
0

[che6] You can't really open the preview url from the python code. But you can create a Che command that would run the python code AND show the preview url. Details here: https://www.eclipse.org/che/docs/che-6/commands-ide-macro.html

sunix
  • 323
  • 1
  • 3
  • 8
  • Thanks for helping. The referenced page, however, doesn't contain any examples. What is not clear to me is: **What is the correct syntax inside the command to refer to the HTML file inside a WS and start the preview?** When I put “${server.wsagent/http}/project/file/test/test.html” in the **Preview URL** pane then I can open this URL in Browser for preview (“Preview:” in Terminal or “Previews” in the right-upper corner) However, if I put the same macro in the **Command Line** pane I get an error “No such file or directory”. So I am not able to create a command to open that file for preview. – Tony Mar 21 '19 at 20:29
  • Also: **How can I refer from the Python script to the command I saved in my WS?** I was searching on my host machine but also entered the WS via bash and I can't find a file with that name. When I do “echo ${editor.current.file.path}” I get “/projects/commands/custom/run_test” but I can not open it for viewing or run with Python. – Tony Mar 21 '19 at 20:29
  • Like already stated: I can easily construct and put a link to a file in the Preview URL pane (then click "preview" header in Terminal and open a file when running the command) but I cannot use the same syntax for the Command Line pane. I know the content of both panes is stored together as one command but i don't know how and where. Basically I don't want to run entire command, just that part of a command from the Preview URL pane. What is the correct way to do that? – Tony Mar 27 '19 at 13:54
0

According to Eclipse Che developers this functionality is currently not available in Eclipse Che. There is always user interaction required for this. See this GitHub post.

Tony
  • 7,767
  • 2
  • 22
  • 51