Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF Parsley » Loading Resource via Filechooser(Loading Resource via Filechooser)
Loading Resource via Filechooser [message #1783761] Fri, 16 March 2018 16:27 Go to next message
Dominik Nickl is currently offline Dominik NicklFriend
Messages: 5
Registered: February 2018
Junior Member
Hi again
I am trying to add a Filechooser to my EMF Parsley Project
I've tried it like this
configurator {
		resourceURI {
			TreeformSaveableTreeFormView -> {
				val fc = new FileChooser(null, SWT.NONE);
				return URI.createFileURI(sd.open() as String);
			}
		}
	}

and hoped it would just open the dialog, but that's not the case.
So now I don't realy know how I should implement it.
Re: Loading Resource via Filechooser [message #1783845 is a reply to message #1783761] Mon, 19 March 2018 10:21 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1751
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

do you get any specific error?
you pass null as the shell to file chooser I guess, is that supposed to work in FileChooser?

Note that this use case hasn't been taken into consideration at the moment.
Re: Loading Resource via Filechooser [message #1784473 is a reply to message #1783845] Wed, 28 March 2018 11:17 Go to previous messageGo to next message
Dominik Nickl is currently offline Dominik NicklFriend
Messages: 5
Registered: February 2018
Junior Member
I don't get any Error
null should work with the FileChooser, but even if i pass a new Shell i don't get any responses
Re: Loading Resource via Filechooser [message #1784784 is a reply to message #1784473] Wed, 04 April 2018 07:42 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1751
Registered: July 2009
Location: Firenze, Italy
Senior Member
nothing in the "Error Log" view?
Re: Loading Resource via Filechooser [message #1784804 is a reply to message #1784784] Wed, 04 April 2018 10:10 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1751
Registered: July 2009
Location: Firenze, Italy
Senior Member
By the way, where does FileChooser come from?
Note that you assign it to "fc" but then you call open on "sd"...
Re: Loading Resource via Filechooser [message #1784806 is a reply to message #1784804] Wed, 04 April 2018 10:14 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1751
Registered: July 2009
Location: Firenze, Italy
Senior Member
I've just tried with org.eclipse.swt.widgets.FileDialog:

configurator {
		resourceURI {
			TreeformSaveableTreeFormView -> {
				val fc = new FileDialog(site.shell, SWT.OPEN);
				val result = fc.open();
				return URI.createFileURI(result);
			}
		}
...


and this works out of the box, as expected: the first time you open the view the dialog shows up
Re: Loading Resource via Filechooser [message #1785116 is a reply to message #1784806] Mon, 09 April 2018 16:34 Go to previous messageGo to next message
Dominik Nickl is currently offline Dominik NicklFriend
Messages: 5
Registered: February 2018
Junior Member
That worked for me too
thanks

What does the site reference to?
Re: Loading Resource via Filechooser [message #1785329 is a reply to message #1785116] Thu, 12 April 2018 14:58 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1751
Registered: July 2009
Location: Firenze, Italy
Senior Member
That is the syntactic sugar from Xbase (the Java-like expression language the Parsley DSL is based on): it stands for getSite().getShell() : the code block is passed a paremeter "it" of the same type of the type before the arrow (in this example, TreeformSaveableTreeFormView), that can be used in the block. "it" can always be used as an implicit receiver (like "this"). Summarizing, "site.shell" is the short form of "it.getSite().getShell()" (and getSite() comes from the fact that a View has such a method).
Previous Topic:Calling a method on Button Push
Next Topic:Can not change int attribute
Goto Forum:
  


Current Time: Sun Nov 18 01:17:31 GMT 2018

Powered by FUDForum. Page generated in 0.03223 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top