Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » AbstractTextEditor: how to refresh the whole document partition
AbstractTextEditor: how to refresh the whole document partition [message #539988] Mon, 14 June 2010 10:12 Go to next message
BLANC Philippe is currently offline BLANC Philippe
Messages: 89
Registered: July 2009
Member
Hello,
I'm developing a custom AbstractTextEditor using syntax highlighting.
My text is splitted in several partitions. Some partitions directly depends on the line position.
For any user modification, only one partition is recalculated (according modification location). I would like recalculate all the document partitions after any modification.

I thought about two ways to do that:
- implement a custom PresentationReconciler... but I don't know what to override.
- find a way to refresh the document after any user modification.

Thank you for your help.

Best regards,

Philippe

[Updated on: Mon, 14 June 2010 10:21]

Report message to a moderator

Re: AbstractTextEditor: how to refresh the whole document partition [message #540001 is a reply to message #539988] Mon, 14 June 2010 10:23 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
BLANC Philippe wrote:
> Hello,
> I'm developing a custom AbstractTextEditor using syntax highlighting.
> My text is splitted in several partitions. Some partitions directly
> depends on the line position.
> For any user modification, only one partition is recalculated
> (according modification location). I would like recalculate all the
> document partitions after any modification.
>
> I thought two ways to do that:
> - implement a custom PresentationReconciler... but I don't know
> what to override.
See
org.eclipse.jface.text.rules.DefaultDamagerRepairer.getDamag eRegion(ITypedRegion,
DocumentEvent, boolean). You can return a region that covers the whole
document (or just a partition).

Dani
> - find a way to refresh the document after any user modification.
>
> Thank you for your help.
>
> Best regards,
>
> Philippe
Re: AbstractTextEditor: how to refresh the whole document partition [message #540027 is a reply to message #540001] Mon, 14 June 2010 11:59 Go to previous messageGo to next message
BLANC Philippe is currently offline BLANC Philippe
Messages: 89
Registered: July 2009
Member
Hello Dani,

I've already try this solution, but it seems that only the modified partition is recalculated...

Here is my code:

public class MyDamager extends DefaultDamagerRepairer{

	public MyDamager(ITokenScanner scanner) {
		super(scanner);
	}

	@Override
	public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e,
			boolean documentPartitioningChanged) {
		return new Region(0, e.getDocument().getLength());
	}

}
Re: AbstractTextEditor: how to refresh the whole document partition [message #540199 is a reply to message #540027] Tue, 15 June 2010 07:04 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
BLANC Philippe wrote:
> Hello Dani,
>
> I've already try this solution, but it seems that only the modified
> partition is recalculated...
I think it should work assuming that your damage repairer is used for
the whole document. It should then call
createPresentation(TextPresentation, ITypedRegion) on your rapairer for
each partition.

Dani
>
> Here is my code:
>
>
> public class MyDamager extends DefaultDamagerRepairer{
>
> public MyDamager(ITokenScanner scanner) {
> super(scanner);
> }
>
> @Override
> public IRegion getDamageRegion(ITypedRegion partition,
> DocumentEvent e,
> boolean documentPartitioningChanged) {
> return new Region(0, e.getDocument().getLength());
> }
>
> }
>
Re: AbstractTextEditor: how to refresh the whole document partition [message #540308 is a reply to message #540199] Tue, 15 June 2010 11:13 Go to previous message
BLANC Philippe is currently offline BLANC Philippe
Messages: 89
Registered: July 2009
Member
Hello,
I found a solution.
Actually, the main stuff is done before the calls of the methods DefaultDamagerRepairer.getDamagedRegion and PresentationReconciler.createPresentation.

After user modification, the method AbstractDocument.updateDocumentStructure is called. This methods aims to recalculate the Positions (in other words, partitions) of the document according the user modification location.

So, I have created my own Document with the following code:

public static class MyDocument extends Document{

		@Override
		protected void updateDocumentStructures(DocumentEvent event) {
			event.fOffset = 0;
			event.fLength = event.fDocument.getLength();
			super.updateDocumentStructures(event);
		}
		
}


However, I think that this modification limits the advantages of the damager/repairer use...

Regards,

Philippe
Previous Topic:IWorkspaceRunnable on root waiting for its own lock (?)
Next Topic:Is it possible to access the current workspace name and set this to a variable?
Goto Forum:
  


Current Time: Fri Aug 29 06:30:59 EDT 2014

Powered by FUDForum. Page generated in 0.01993 seconds