Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to react to change in AutoEditStrategyProvider
How to react to change in AutoEditStrategyProvider [message #719791] Mon, 29 August 2011 03:28 Go to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi,
In order to make auto edits controllable via a preference page, I
override the DefaultAutoEditStrategyProvider with my own implementation
and simply do not call the super version of the various configure
methods if that auto edit strategy is not wanted (as per what is set in
preferences).

This works fine with one exception; how do I affect already opened
editors? Right now, the user of my editor have to close and reopen the
editor for the settings to take effect.

Regards
- henrik
Re: How to react to change in AutoEditStrategyProvider [message #719822 is a reply to message #719791] Mon, 29 August 2011 06:28 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

I think the cleanest way would be to customize the strategies itself.
They should listen to preference changes and guard themselves if they
are disabled (e.g. like in
org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy.customizeDocumentCommand(IDocument,
DocumentCommand)

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 29.08.11 05:28, Henrik Lindberg wrote:
> Hi,
> In order to make auto edits controllable via a preference page, I
> override the DefaultAutoEditStrategyProvider with my own implementation
> and simply do not call the super version of the various configure
> methods if that auto edit strategy is not wanted (as per what is set in
> preferences).
>
> This works fine with one exception; how do I affect already opened
> editors? Right now, the user of my editor have to close and reopen the
> editor for the settings to take effect.
>
> Regards
> - henrik
Re: How to react to change in AutoEditStrategyProvider [message #719987 is a reply to message #719822] Mon, 29 August 2011 15:54 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Thanks Sebastian,
I ended up with a wrapper that checks for enablement before calling the
original customizeDocumentCommand. Works like a charm.

I anyone is interested, the code is (soon) at github cloudsmith/geppetto.

- henrik

On 8/29/11 8:28 AM, Sebastian Zarnekow wrote:
> Hi Henrik,
>
> I think the cleanest way would be to customize the strategies itself.
> They should listen to preference changes and guard themselves if they
> are disabled (e.g. like in
> org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy.customizeDocumentCommand(IDocument,
> DocumentCommand)
>
> Regards,
> Sebastian
Re: How to react to change in AutoEditStrategyProvider [message #720202 is a reply to message #719987] Tue, 30 August 2011 05:56 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

would you be willing to contribute a minimalist preference page for the
auto edit configuration to the framework?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 29.08.11 17:54, Henrik Lindberg wrote:
> Thanks Sebastian,
> I ended up with a wrapper that checks for enablement before calling the
> original customizeDocumentCommand. Works like a charm.
>
> I anyone is interested, the code is (soon) at github cloudsmith/geppetto.
>
> - henrik
>
> On 8/29/11 8:28 AM, Sebastian Zarnekow wrote:
>> Hi Henrik,
>>
>> I think the cleanest way would be to customize the strategies itself.
>> They should listen to preference changes and guard themselves if they
>> are disabled (e.g. like in
>> org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy.customizeDocumentCommand(IDocument,
>>
>> DocumentCommand)
>>
>> Regards,
>> Sebastian
>
Re: How to react to change in AutoEditStrategyProvider [message #720500 is a reply to message #720202] Tue, 30 August 2011 18:01 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 8/30/11 7:56 AM, Sebastian Zarnekow wrote:
> would you be willing to contribute a minimalist preference page for the
> auto edit configuration to the framework?

Sure - the one I have written is EPL and in Geppetto. The autoedit is
currently slightly intertwined with other puppet specific settings, so
needs a small tweak to be generalized.

My overriding AutoEditStrategy is not that pretty :) It would be better
to modify the DefaultAutoEditStrategyProvider and make it aware of the
wrapper - (or modify all the edit strategies and make them take an
enablement-function as argument. (That was too much work IMO, so hence
the uglier solution).

It is not that much code, maybe I can just edit and contribute it as
classes attached to a bugzilla? Or do you prefer some other way?

Regards
- henrik
Re: How to react to change in AutoEditStrategyProvider [message #720502 is a reply to message #720202] Tue, 30 August 2011 18:01 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 8/30/11 7:56 AM, Sebastian Zarnekow wrote:
> would you be willing to contribute a minimalist preference page for the
> auto edit configuration to the framework?

Sure - the one I have written is EPL and in Geppetto. The autoedit is
currently slightly intertwined with other puppet specific settings, so
needs a small tweak to be generalized.

My overriding AutoEditStrategy is not that pretty :) It would be better
to modify the DefaultAutoEditStrategyProvider and make it aware of the
wrapper - (or modify all the edit strategies and make them take an
enablement-function as argument. (That was too much work IMO, so hence
the uglier solution).

It is not that much code, maybe I can just edit and contribute it as
classes attached to a bugzilla? Or do you prefer some other way?

Regards
- henrik
Re: How to react to change in AutoEditStrategyProvider [message #720509 is a reply to message #720500] Tue, 30 August 2011 18:06 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

a simple patch attached to a feature request in the bugzilla would be great.

Thanks in advance,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 30.08.11 20:01, Henrik Lindberg wrote:
> On 8/30/11 7:56 AM, Sebastian Zarnekow wrote:
>> would you be willing to contribute a minimalist preference page for the
>> auto edit configuration to the framework?
>
> Sure - the one I have written is EPL and in Geppetto. The autoedit is
> currently slightly intertwined with other puppet specific settings, so
> needs a small tweak to be generalized.
>
> My overriding AutoEditStrategy is not that pretty :) It would be better
> to modify the DefaultAutoEditStrategyProvider and make it aware of the
> wrapper - (or modify all the edit strategies and make them take an
> enablement-function as argument. (That was too much work IMO, so hence
> the uglier solution).
>
> It is not that much code, maybe I can just edit and contribute it as
> classes attached to a bugzilla? Or do you prefer some other way?
>
> Regards
> - henrik
Re: How to react to change in AutoEditStrategyProvider [message #720511 is a reply to message #720500] Tue, 30 August 2011 18:06 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

a simple patch attached to a feature request in the bugzilla would be great.

Thanks in advance,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 30.08.11 20:01, Henrik Lindberg wrote:
> On 8/30/11 7:56 AM, Sebastian Zarnekow wrote:
>> would you be willing to contribute a minimalist preference page for the
>> auto edit configuration to the framework?
>
> Sure - the one I have written is EPL and in Geppetto. The autoedit is
> currently slightly intertwined with other puppet specific settings, so
> needs a small tweak to be generalized.
>
> My overriding AutoEditStrategy is not that pretty :) It would be better
> to modify the DefaultAutoEditStrategyProvider and make it aware of the
> wrapper - (or modify all the edit strategies and make them take an
> enablement-function as argument. (That was too much work IMO, so hence
> the uglier solution).
>
> It is not that much code, maybe I can just edit and contribute it as
> classes attached to a bugzilla? Or do you prefer some other way?
>
> Regards
> - henrik
Re: How to react to change in AutoEditStrategyProvider [message #720632 is a reply to message #720509] Wed, 31 August 2011 00:39 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 8/30/11 8:06 PM, Sebastian Zarnekow wrote:
> Hi Henrik,
>
> a simple patch attached to a feature request in the bugzilla would be
> great.
>
> Thanks in advance,
> Sebastian

https://bugs.eclipse.org/bugs/show_bug.cgi?id=356262

Attached the current version of the Geppetto code, and posted some ideas
about improvements in the issue.

Regards
- henrik
Previous Topic:How to update text in comments?
Next Topic:root model imports
Goto Forum:
  


Current Time: Sat Apr 27 02:37:33 GMT 2024

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

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

Back to the top