Skip to main content


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 14:12 Go to next message
BLANC Philippe is currently offline BLANC PhilippeFriend
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 14: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 14:23 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
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 15:59 Go to previous messageGo to next message
BLANC Philippe is currently offline BLANC PhilippeFriend
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 11:04 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
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 15:13 Go to previous message
BLANC Philippe is currently offline BLANC PhilippeFriend
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 Mar 29 12:22:33 GMT 2024

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

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

Back to the top