Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Remove gaps from the blanked name
Remove gaps from the blanked name [message #1058600] Tue, 14 May 2013 14:18 Go to next message
junior developer is currently offline junior developerFriend
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 #1058626 is a reply to message #1058600] Tue, 14 May 2013 15:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
http://www.eclipse.org/forums/index.php/m/1027868/?srch=AbstractEditStrategy#msg_1027868

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Remove gaps from the blanked name [message #1058701 is a reply to message #1058626] Tue, 14 May 2013 18:02 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

Thank you for help

Best regards.
Re: Remove gaps from the blanked name [message #1058853 is a reply to message #1058626] Wed, 15 May 2013 12:15 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
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:02
http://www.eclipse.org/forums/index.php/m/1027868/?srch=AbstractEditStrategy#msg_1027868
Re: Remove gaps from the blanked name [message #1058856 is a reply to message #1058853] Wed, 15 May 2013 12:26 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sorry i dont have the time to do the digging for you

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Single quotation marks consumed incorrectly
Next Topic:A Rule with a list of rules where all entrys are allowed once
Goto Forum:
  


Current Time: Thu Apr 25 07:40:41 GMT 2024

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

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

Back to the top