Skip to main content


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 Go to next message
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.
Re: Hiding text in Editor [message #1700649 is a reply to message #890010] Mon, 06 July 2015 08:44 Go to previous message
Hasan Emre Kirmizi is currently offline Hasan Emre KirmiziFriend
Messages: 2
Registered: July 2015
Junior Member
Hi, I have a same problem now, I saw that you posted it in 2012, Did you solve the problem?
Previous Topic:Export Eclipse Plugin Jar through command Line is not working
Next Topic:OSGi (Equinox) going forward... or not?
Goto Forum:
  


Current Time: Thu Apr 25 21:30:09 GMT 2024

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

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

Back to the top