Remove gaps from the blanked name [message #1058600] |
Tue, 14 May 2013 14:18 |
junior developer Messages: 354 Registered: January 2013 |
Senior Member |
|
|
Hi all ,
I want to remove gaps from the name.if a user enter a name such as : Web home web ,home web is a ID .I want to write a code for this issue with DefaultAutoEditStrategyProvider
How can I do this.I want to : user enter" { " blanked name triped with code and shows such as homeweb.
If the user enter
Web home web {
when entered "{"
home web changed with homeweb.User show "homeweb "
Must I use auto complete for this problem ?
Best regards ,
[Updated on: Tue, 14 May 2013 14:30] Report message to a moderator
|
|
|
|
|
Re: Remove gaps from the blanked name [message #1058853 is a reply to message #1058626] |
Wed, 15 May 2013 12:15 |
junior developer Messages: 354 Registered: January 2013 |
Senior Member |
|
|
Hi Christian ,
I tried this method :
but,my problem is not solved ,I con not understand: if ( command.text.length() == 0 || command.text.charAt(0) > ' ') return; hence,this method checks all keywords.I want to keyword's name .I must get keywords name :
such as below example :if the user enter Web ww w ,Iwant to take "ww w" and fix it automatically.
SiteCollection ss {
guID="guID"
Web ww w
}
}
public class MyDslEditStrategyProvider extends DefaultAutoEditStrategyProvider {
@Inject
Provider<IGrammarAccess> iGrammar;
private Set<String> kwds;
@Override
protected void configure(IEditStrategyAcceptor acceptor) {
kwds = GrammarUtil.getAllKeywords(iGrammar.get().getGrammar());
IAutoEditStrategy strategy = new IAutoEditStrategy() {
@Override
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
if ( command.text.length() == 0 || command.text.charAt(0) > ' ') return;
IRegion reg = ((XtextDocument) document).getLastDamage();
try {
String token = document.get(reg.getOffset(), reg.getLength());
String uToken = token.toUpperCase();
if ( uToken.equals(token) || !kwds.contains(uToken) ) return;
document.replace(reg.getOffset(), reg.getLength(), uToken);
} catch (Exception e) {}
}
};
acceptor.accept(strategy, IDocument.DEFAULT_CONTENT_TYPE);
super.configure(acceptor);
}
}
Christian Dietrich wrote on Tue, 14 May 2013 11:02http://www.eclipse.org/forums/index.php/m/1027868/?srch=AbstractEditStrategy#msg_1027868
|
|
|
|
Powered by
FUDForum. Page generated in 0.03096 seconds