Bug 467278 - Allow to input information in a text editor without changing the underlying buffer
Summary: Allow to input information in a text editor without changing the underlying b...
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 17:36 EDT by Pascal Rapicault CLA
Modified: 2015-05-20 03:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Rapicault CLA 2015-05-13 17:36:52 EDT
Preamble. I'm starting an exploration which aims at allowing a user to input free form text into an existing editor (e.g. Java editor, C editor, etc.) and yet keep the editor main buffer clean, so that the syntax highlighting, and other features of the editor keep on working. 
The context for this is work in the new egerrit plugin, where we want to improve the presentation of comments. What we are aiming at is to allow for a user to be able to open a gerrit review and see the comments directly in the code (like you would see them in the gerrit web UI), and also directly comment in the code editor.

At this point, my predecessor has done some prototyping and managed to get something working by hacking things here and there in AbstractTextEditor and a few other classes. However we are not sure it is the best solution, and we would like to start a discussion on how this can be achieved (e.g. is there any existing concept which could be tweaked to achieve what we want). We are not asking for code, just for guidance / time.

Finally our goal is to have something for Neon.
Comment 1 Dani Megert CLA 2015-05-18 08:28:05 EDT
I know that others in the past wanted to do something like that. Therefore I would start by looking around for already existing solutions and whether they might be willing to contribute their code.

As for possible ways to implement this, two things come to mind on a quick brain scan:

1. Use folding/projection. Note though that the current implementation is only line based (see 114906).

2. Use Annotations. The code comments could be added via editable hover (not yet implemented), or maybe by implementing a custom IAnnotationPresentation. This would probably need some additions since currently it can only paint.
Comment 2 Pascal Rapicault CLA 2015-05-19 22:00:57 EDT
Thanks for the reply.

(In reply to Dani Megert from comment #1)
> I know that others in the past wanted to do something like that. Therefore I
> would start by looking around for already existing solutions and whether
> they might be willing to contribute their code.
    If you remember the name of the people who tried this in the past, it would be greatly appreciated.


> As for possible ways to implement this, two things come to mind on a quick
> brain scan:
> 
> 1. Use folding/projection. Note though that the current implementation is
> only line based (see 114906).
  In my perusing of the framework, I ran into the concept of ProjectionDocument, ProjectionMapping, etc. but I have not digged into it. Is that what you are talking about? Is there any doc or a small example using this functionality or do I have to look at the folding code from JDT?

> 2. Use Annotations. The code comments could be added via editable hover (not
> yet implemented), or maybe by implementing a custom IAnnotationPresentation.
> This would probably need some additions since currently it can only paint.
  The popup approach has been tried in the context of R4e but it was deemed to be not user friendly enough (popup hides content, by default they disappear when they lose focus, etc.) which is why we are looking into creating something where the comments of the review are directly integrated in the editor.
  Do you think IAnnotationPresentation could be extended to "inject" content into the buffer of the StyledText widget?
Comment 3 Dani Megert CLA 2015-05-20 03:27:07 EDT
(In reply to Pascal Rapicault from comment #2)
> Thanks for the reply.
> 
> (In reply to Dani Megert from comment #1)
> > I know that others in the past wanted to do something like that. Therefore I
> > would start by looking around for already existing solutions and whether
> > they might be willing to contribute their code.
>     If you remember the name of the people who tried this in the past, it
> would be greatly appreciated.

Sorry, I have no names. Search the eclipse.platform newsgroup and bugzilla.


> > 1. Use folding/projection. Note though that the current implementation is
> > only line based (see 114906).
>   In my perusing of the framework, I ran into the concept of
> ProjectionDocument, ProjectionMapping, etc. but I have not digged into it.
> Is that what you are talking about?

Yes.


> Is there any doc or a small example
> using this functionality or do I have to look at the folding code from JDT?

Take a look at this tutorial (with code examples):
https://www.eclipse.org/eclipse/platform-text/eclipseCon/2006/texteditorrecipes.zip


> > 2. Use Annotations. The code comments could be added via editable hover (not
> > yet implemented), or maybe by implementing a custom IAnnotationPresentation.
> > This would probably need some additions since currently it can only paint.
>   The popup approach has been tried in the context of R4e but it was deemed
> to be not user friendly enough (popup hides content, by default they
> disappear when they lose focus, etc.) which is why we are looking into
> creating something where the comments of the review are directly integrated
> in the editor.
>   Do you think IAnnotationPresentation could be extended to "inject" content
> into the buffer of the StyledText widget?

No.


Another possible solution could be to place the comments on the left (or right) of the editor. Similar to what you see in the compare editor.