Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using the reconciler programmatically
Using the reconciler programmatically [message #723681] Fri, 09 September 2011 06:59 Go to next message
Eclipse UserFriend
Hello,

what is the best way to use the reconciler of the xtext edior programmatically?

I have an action which should just switch background color of particular text areas in the xtext editor. What I tried to do is to use a boolean value in the semantic highlighting configuration class for switching betweeen options and the reconciler's refresh method to initiate an update in the editor, but i get a NullPointerException at

org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.refresh(HighlightingReconciler.java:243)

the code in the Action:
public class SetColorForBackgroundAction implements IWorkbenchWindowPulldownDelegate {
  @Inject
  private HighlightingReconciler reconciler;

  @Inject
  private SemanticHighlightingConfiguration conf;
  
  public void run(IAction action) {
    conf.setColorForBackground(true);
    reconciler.refresh();
  }
}


What is the best way to implement such functionality?

thanks in advance


Re: Using the reconciler programmatically [message #723713 is a reply to message #723681] Fri, 09 September 2011 08:21 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
AFAIK, there's an individual reconciler for each editor, so this won't
work. I haven't verified this, but I'd try to

- get the editor (store the page in the init() method of your IWWPD, and
go to the active page,...)
- access its source viewer
- invalidateTextPresentation()

Am 09.09.11 08:59, schrieb as:
> Hello,
>
> what is the best way to use the reconciler of the xtext edior
> programmatically?
>
> I have an action which should just switch background color of particular
> text areas in the xtext editor. What I tried to do is to use a boolean
> value in the semantic highlighting configuration class for switching
> betweeen options and the reconciler's refresh method to initiate an
> update in the editor, but i get a NullPointerException at
> org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.refresh(HighlightingReconciler.java:243)
>
>
> the code in the Action:
>
> public class SetColorForBackgroundAction implements
> IWorkbenchWindowPulldownDelegate {
> @Inject
> private HighlightingReconciler reconciler;
>
> @Inject
> private SemanticHighlightingConfiguration conf;
>
> public void run(IAction action) {
> conf.setColorForBackground(true);
> reconciler.refresh();
> }
> }
>
>
> What is the best way to implement such functionality?
>
> thanks in advance
>
>
>


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Using the reconciler programmatically [message #723763 is a reply to message #723681] Fri, 09 September 2011 11:39 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

I would simply change the preference for the color in the
IPreferenceStore and rely on the framework to refresh the visual
presentation accordingly.

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

On 09.09.11 08:59, as wrote:
> Hello,
>
> what is the best way to use the reconciler of the xtext edior
> programmatically?
>
> I have an action which should just switch background color of particular
> text areas in the xtext editor. What I tried to do is to use a boolean
> value in the semantic highlighting configuration class for switching
> betweeen options and the reconciler's refresh method to initiate an
> update in the editor, but i get a NullPointerException at
> org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.refresh(HighlightingReconciler.java:243)
>
>
> the code in the Action:
>
> public class SetColorForBackgroundAction implements
> IWorkbenchWindowPulldownDelegate {
> @Inject
> private HighlightingReconciler reconciler;
>
> @Inject
> private SemanticHighlightingConfiguration conf;
>
> public void run(IAction action) {
> conf.setColorForBackground(true);
> reconciler.refresh();
> }
> }
>
>
> What is the best way to implement such functionality?
>
> thanks in advance
>
>
>
Previous Topic:Using ModifyListener in XtextEditor
Next Topic:Xtext keyword with "%"
Goto Forum:
  


Current Time: Sat Apr 27 02:21:04 GMT 2024

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

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

Back to the top