Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assistant for Datatypes(Dynamic Content assist for datatypes)
Content assistant for Datatypes [message #695218] Mon, 11 July 2011 09:54 Go to next message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
hi all,
in my grammar i have a data type STROKE_STYLE:

STROKE_STYLE:
'"Solid"' | '"ShortDash"' | '"Short-Dot"' | '"ShortDashDot"' | "ShortDashDotDot"' | '"Dot"' | '"Dash"' |'"Long-Dash"' | '"DashDot"' |	'"LongDashDot"' | '"LongDashDotDot"' | '"none"';


and it is been used like this:
Stroke:
	'{'
	('"color"' ':' color=Color (',')?)?
	('"style"' ':' style=STROKE_STYLE (',')?)?
	('"width"' ':' width=NUMBER (',')?)?
	('"cap"' ':' cap=STROKE_CAP (',')?)?
	('"join"' ':' join=STROKE_JOIN (',')?)?
	'}';

now i wanted to provide content assistant for STROKE_STYLE,so i override the STROKE_STYLE function as follow:
@Override
	public void complete_STROKE_STYLE(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		acceptor.accept(createCompletionProposal("\"Solid\"", "Solid",null,context));
		acceptor.accept(createCompletionProposal("\"ShortDash\"", "ShortDash",null,context));
		acceptor.accept(createCompletionProposal("\"Short-Dot\"", "Short-Dot",null,context));
		acceptor.accept(createCompletionProposal("\"ShortDashDot\"", "ShortDashDot",null,context));
		acceptor.accept(createCompletionProposal("\"ShortDashDotDot\"", "ShortDashDotDot",null,context));
		acceptor.accept(createCompletionProposal("\"Dot\"", "Dot",null,context));
		acceptor.accept(createCompletionProposal("\"Dash\"", "Dash",null,context));
		acceptor.accept(createCompletionProposal("\"Long-Dash\"", "Long-Dash",null,context));
		acceptor.accept(createCompletionProposal("\"DashDot\"", "DashDot",null,context));
		acceptor.accept(createCompletionProposal("\"LongDashDot\"", "LongDashDot",null,context));
		acceptor.accept(createCompletionProposal("\"LongDashDotDot\"", "LongDashDotDot",null,context));
		acceptor.accept(createCompletionProposal("\"none\"", "none",null,context));
	}

But this is kind of hard coding the option in the content assistant,so i am looking for a more dynamic way of doing it,a way in which the content assist can directly refer to the values of the datatype...
i am not sure if thats possible or not...
if any one knows a way please share..
thanks in advance
Irfan

[Updated on: Mon, 11 July 2011 09:55]

Report message to a moderator

Re: Content assistant for Datatypes [message #695228 is a reply to message #695218] Mon, 11 July 2011 10:23 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

have not tried it, but an option might be that you inject the <MyDsl>GrammarAccess into your proposal provider. From that you may obtain the stroke style rule and iterate over the alternatives, creating the proposals "on the fly" without hard coding.

Alex
Re: Content assistant for Datatypes [message #695338 is a reply to message #695228] Mon, 11 July 2011 14:20 Go to previous message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
hi,
it would be great if you could provide some example for it.
thanks
irfan
Previous Topic:C# like #region Preprocessor
Next Topic:Reference to an external Ecore model (inside a plugin)
Goto Forum:
  


Current Time: Wed Oct 21 00:20:26 GMT 2020

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

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

Back to the top