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 |
irfan 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
|
|
| | |
Goto Forum:
Current Time: Thu Apr 18 09:41:15 GMT 2024
Powered by FUDForum. Page generated in 0.02188 seconds
|