Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customizable formatting
Customizable formatting [message #1176567] Fri, 08 November 2013 12:15 Go to next message
Siber Just Siber is currently offline Siber Just SiberFriend
Messages: 6
Registered: October 2013
Junior Member
Hi everyone,
I've implemented some formatting rules in the provided extension of AbstractFormatter. Now my goal is to make it customizable by user. I've created a property page just with a check-box, and in the configureFormatting(FormattingConfig c) I check the corresponding property value for the checkbox and setNoLinewrap or singe linewrap based on the check result.
In debug I can see that property value is read correctly (if there is a tick - true and setLinewrap is executed, otherwise setNoLineWrap).

The problem is that property change has its effect only for the first two times - after I start eclipse with my editor and after first change of the property. Can somebody give a hint why is it so and what should I change to make it normal real-time adjustment without a need to restart eclipse?

Thanks in advance!
Re: Customizable formatting [message #1176583 is a reply to message #1176567] Fri, 08 November 2013 12:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

have a look at org.eclipse.xtext.formatting.impl.FormattingConfig.
maybe you can null the once stored config.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Customizable formatting [message #1176601 is a reply to message #1176583] Fri, 08 November 2013 12:37 Go to previous messageGo to next message
Siber Just Siber is currently offline Siber Just SiberFriend
Messages: 6
Registered: October 2013
Junior Member
I tried to null it, but it didn't help. What I did is created my own AbstractFormatter and from that one I inherit my XTend formatter.

In AbstractFormatter I did only one change from:
	protected synchronized FormattingConfig getConfig() {
		if (config.config == null) {
			config.config = createFormattingConfig();	
		        configureFormatting(config.config);
		}
		return config.config;
	}

to:
	protected synchronized FormattingConfig getConfig() {
		if (config.config == null) {
			config.config = createFormattingConfig();	
		}
		configureFormatting(config.config);
		return config.config;
	}

It didn't help as well.

Then I tried to also create it everytime:
	protected synchronized FormattingConfig getConfig() {
		if (config.config == null) {

		}
		config.config = createFormattingConfig();	
		configureFormatting(config.config);
		return config.config;
	}

Didn't help. Seems like problem is actually not even in formatter
Re: Customizable formatting [message #1176618 is a reply to message #1176601] Fri, 08 November 2013 12:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what does debugging say. is the formatter asked for a config? see org.eclipse.xtext.ui.editor.formatting.ContentFormatterFactory.FormattingUnitOfWork


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Customizable formatting [message #1176624 is a reply to message #1176618] Fri, 08 November 2013 12:58 Go to previous message
Siber Just Siber is currently offline Siber Just SiberFriend
Messages: 6
Registered: October 2013
Junior Member
Hi,
Yes it is asked for the config, config is assigned according to the new property value but after the second try content (edited source) is not changed anymore, i.e it keeps formatting style from the second try.

[Updated on: Fri, 08 November 2013 13:15]

Report message to a moderator

Previous Topic:How to I force a re-validation of all xtext resources in a given project/workspace
Next Topic:Default value of String
Goto Forum:
  


Current Time: Thu Apr 18 11:09:12 GMT 2024

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

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

Back to the top