Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to open a project/file browser for a importURI content assist?
How to open a project/file browser for a importURI content assist? [message #848681] Wed, 18 April 2012 13:30 Go to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi,

I would like to open a generic project/file browser in importURI content assist for users to select the file to be imported.

could someone point me how to do this?

regards,

Cristiano
Re: How to open a project/file browser for a importURI content assist? [message #848869 is a reply to message #848681] Wed, 18 April 2012 16:53 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
I've found this article: http://zarnekow.blogspot.com.br/2011/06/customizing-content-assist-with-xtext.html

I'll investigate if I can use that same approach to open a file browser dialog.
Re: How to open a project/file browser for a importURI content assist? [message #848883 is a reply to message #848869] Wed, 18 April 2012 17:08 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Yes, that should work.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 18.04.12 18:53, schrieb Cristiano Gaviao:
> I've found this article:
> http://zarnekow.blogspot.com.br/2011/06/customizing-content-assist-with-xtext.html
>
>
> I'll investigate if I can use that same approach to open a file browser
> dialog.
Re: How to open a project/file browser for a importURI content assist? [message #850077 is a reply to message #848883] Thu, 19 April 2012 18:42 Go to previous message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Yep, the same approach have worked. Thanks Sebastian !
This is the method that I had to modify:

	public void completeImport_ImportURI(EObject model, Assignment assignment,
			final ContentAssistContext context,
			ICompletionProposalAcceptor acceptor) {

		ConfigurableCompletionProposal pickModelFile = (ConfigurableCompletionProposal) createCompletionProposal(
				"Pick a model file...", context);
		if (pickModelFile != null) {
			pickModelFile.setTextApplier(new ReplacementTextApplier() {

				@Override
				public String getActualReplacementString(
						ConfigurableCompletionProposal proposal) {
					Display display = context.getViewer().getTextWidget()
							.getDisplay();

					FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(
							display.getActiveShell(), false, ResourcesPlugin
									.getWorkspace().getRoot(), IResource.FILE);
					dialog.setBlockOnOpen(true);
					dialog.setInitialPattern("*.riskModel");
					dialog.setMessage("Choose the model file that you want to have access in this model.");
					dialog.setTitle("Model Selection");
					dialog.open();

					File result = (File) dialog.getResult()[0];

					return "\"" + result.getLocationURI() + "\"";
				}
			});
			acceptor.accept(pickModelFile);
		}
	}
Previous Topic:Validation errors in Xpand template for project wizard
Next Topic:Check for syntax errors before formatting.
Goto Forum:
  


Current Time: Thu Mar 28 09:14:03 GMT 2024

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

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

Back to the top