Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Hiding text in Editor(Hiding text in text editor, e.g. using ProjectionDocuments)
Hiding text in Editor [message #890010] Wed, 20 June 2012 14:51
Ali Pang is currently offline Ali PangFriend
Messages: 1
Registered: June 2012
Junior Member
Hey!

I'm trying to create an editor where I'm hiding certain patterns, e.g. I'd like to display the document

> VAR
>   Foo@1000 : ...


as

> VAR
>  Foo : ...


i.e. hiding the pattern @1000. This might appear multiple times within a line.

I've managed to get what I want using a ProjectionDocument, but this messes up my syntax highlighting etc (still appears, but with incorrect offsets.). I'm probably setting things up wrong. Are there any code examples of doing something similar somewhere?

To clarify, I do _not_ want this to behave as the java code folding, with expansion/collapsing. I'd simply like some text completely hidden from view.

Thanks for any help! My code so far has been to simply try to create an extension of FileDocumentProvider, but this appears not to be enough.

public class MyDocumentProvider extends FileDocumentProvider {

	protected IDocument createDocument(Object element) throws CoreException {
		
		IDocument document = super.createDocument(element);
		
		ProjectionDocumentManager pMan = new ProjectionDocumentManager();
		ProjectionDocument pDoc = (ProjectionDocument) pMan.createSlaveDocument(document);

		// just remove the first 10 characters for testing 
		try {
			pDoc.addMasterDocumentRange(10, document.getLength() - 10);
		} catch (BadLocationException e)
		{
			e.printStackTrace();
		}
		
		// set up scanners
		if (pDoc != null) {
			IDocumentPartitioner partitioner =
				new FastPartitioner(
					new MyPartitionScanner(),
					new String[] 
					{						
						MyPartitionScanner.COMMENT_CONTENT,
						MYPartitionScanner.STRING_CONTENT
					});
			partitioner.connect(pDoc);
			pDoc.setDocumentPartitioner(partitioner);
		}
				
		return pDoc;
	}
}


Any help on how to set this up properly much appreciated.
Previous Topic:RevisionInformation or ChangeInformation on LineNumberChangeRulerColumn
Next Topic:build plugin with command line
Goto Forum:
  


Current Time: Sat Nov 29 09:11:18 GMT 2014

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

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