Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340039

Summary: [Client]Make compare text model editable
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, eclipse.felipe, libingw, Silenio_Quarti, susan, Szymon.Brandys, tomasz.zarna
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=339439
Whiteboard:

Description libing wang CLA 2011-03-15 11:08:36 EDT
We need to enhance the current compare text model  in order to achieve the compare editor functionality .
The current text model is gap-based and read-only , extending the default editor text model.
The inline model will still remain read-only , providing a quick view of the file diff in the git status page.
The side-by-side will be improved to a editable level.
They are using the same model class with different line feeders , where inline uses a feeder to feed lines from diff string and the side by side is fed by dummy empty lines.
I am not completely sure is we should still use the gaps for editing but I will start to think about it.
I am linking this bug to 339439 , which is the main thread of M7 Git/Compare design.
Comment 1 libing wang CLA 2011-03-16 15:08:25 EDT
After discussing with Silenio ,  I will start with none-gap text model, which will be just the default model , and listen to the onChanged event to update the mapper.
In this way , it will behave the same way as desktop Eclipse does.
The gap model (dummy line ) model will still be used as the inline viewer inside the git status page.
Comment 2 libing wang CLA 2011-03-17 11:14:15 EDT
I've read some articles regarding HTML 5 canvas on IE8 , seems that http://code.google.com/p/explorercanvas/ can simulate the canvas but there are two thing I am concerned:
1.Is there legal issues?
2.The simulation seems to slow down the IE performance.   

More generally, I am not sure about the direction how we will use html 5 yet.
Comment 3 libing wang CLA 2011-03-22 15:16:28 EDT
I am making some progress to make the left side editor editable.
1. There is an html 5 canvas sitting in between the editors , which is using curves to map the diff between two blocks in the editors.
2.Editing (add , remove) lines on the left side dynamically change the reletive curves.
3.Clicking on the overview brings the proper diffs on both side 
4. The canvas works well on Chrome ,Fire Fox , IE9 and Safari. IE8 dosen't support html 5 canvas but there are some third party js code that can handle this. I am holding on for this now.

TODOs:
1.Scroll bar sync. will be tricky if we maitain two scroll bars .
2. Add more actions/commnads as page actions (next diff , previous diff , replace from right to left , etc)
3.I am waiting for the solution of 337647 in order to include all the functions as a real editor on the left side.
Comment 4 libing wang CLA 2011-03-28 13:09:33 EDT
I've created  https://bugs.eclipse.org/bugs/show_bug.cgi?id=341141 for the syntax highlighting merging to the diff highlighting. There is an workaround for this now but once 341141 is done we need to move onto that.
For TODO status from last comments:
1. Scroll bar sync.This is done by always syncing right to left when left is scrolled. I am not syncing the right to left when left is scrolled because I think this will give user more flexibilities.
But this policy is built on the fact that we do not provide a unique scroll bar as eclipse does.

2. Add more actions/commnads as page actions. Added "next diff" and "copy from left  to right " actions. more will be done ...

3.solution of 337647. I am consuming the new editorContainer now and it will evolve further when I am using it deeply.
Comment 5 Tomasz Zarna CLA 2011-03-29 12:12:39 EDT
How does bug 340439 relate to this one? Once you've managed to enable one side of the comparison to be edited you will still need to keep the other side read-only.
Comment 6 libing wang CLA 2011-03-29 14:50:49 EDT
(In reply to comment #5)
> How does bug 340439 relate to this one? Once you've managed to enable one side
> of the comparison to be edited you will still need to keep the other side
> read-only.

In compare editor , the right side is always read only. This can bee easily achieved by setting the read-only option to true when the editor instance is constructed.
If you are to use coding.html to show the commit in bug 340439 , we may want to put additional hash parameter and change the coding.js a little bit.
Comment 7 libing wang CLA 2011-03-29 14:53:31 EDT
planned  to add save , undo , redo commands. The rendering will be tricky because all the commands are rendered o nthe right end of the page action bar.
Created bug 341274 to address this.
Comment 8 libing wang CLA 2011-04-15 11:45:15 EDT
Mark this as fixed . All the functions is there .
I have a bug 342650 for adding undo/redo.
If we have other issues we should open new bugs for better tracking.