orbisgis / orbisrcp

Repository for all RCP plugins, features and repositories.
GNU Lesser General Public License v3.0
0 stars 4 forks source link

Groovy output browser #82

Open SPalominos opened 2 years ago

SPalominos commented 2 years ago

Add an output browser for groovy, which is passed to the script into the bindings.

The browser is shown using the menu windows/shows view/other, and in the popup open other/Groovy Output Browser. For now, only one single browser can be shown.

An handler for this browser is pass through the script bindings under the name browser. This handler has the setText(String) methods because it should call Display.getCurrent().asyncExec(...) in order to update the SWT composite in the good thread.

An example of non working Demat script (the browser is not able to find the vega javascripts, so @ebocher if you want to fix it...)

@GrabResolver(name='orbisgis', root='https://oss.sonatype.org/content/repositories/snapshots')
@Grab(group='org.orbisgis', module='demat', version='0.0.7-SNAPSHOT')

import static org.orbisgis.demat.Plot.*
def chart = Chart(Data([
                ["a": "A", "b": 28], ["a": "B", "b": 55], ["a": "C", "b": 43],
                ["a": "D", "b": 91], ["a": "E", "b": 81], ["a": "F", "b": 53],
                ["a": "G", "b": 19], ["a": "H", "b": 87], ["a": "I", "b": 52]])).mark_bar().
                encode(X("a").nominal(), Y("b").quantitative())
chart.show()

def file = new File("/tmp/tempChart.html")
chart.save(file, true) 
browser.setText(file.text)
ebocher commented 2 years ago

That's very interesting. I'll look on it. Thanks a lot