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

Bug 382492

Summary: Abstract explorer like in search/replace
Product: [ECD] Orion Reporter: Malgorzata Janczarska <malgorzata.tomczyk>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.5   
Target Milestone: 2.0 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 398967    
Bug Blocks: 382493    

Description Malgorzata Janczarska CLA 2012-06-13 09:12:06 EDT
The search/replace explorer could be useful in other places as well when we deal with lots of changes in files. The example is String Externalizer.
The new page should be made by only by creating:
1. Model - the structure of files that also returns the "replaced" version, also the list of changes
2. Renderer - what fields from the model should be rendered in what columns
3. Commands
The rest should be provided by the abstract explorer, including stuff like:
1. Selecting "checked/unchecked" hierarchically in tree (unchecking the parent should uncheck children, checking children should check parent)
2. Updating the compare view on the bottom
3. Scrolling to the given place in compare view when changing the selection of changes
4. Notifying when changes/files are checked/unchecked to update the potential "replaced file" contents.
Comment 1 libing wang CLA 2012-10-04 16:47:31 EDT
Triage in 2.0M1.
Comment 2 libing wang CLA 2013-01-23 16:17:52 EST
OK, finally I got off the hook of undojo stuff. Now trying to figure out a way to best suit Gosia's case.

Gosia, one thing to mention, the search explorer can handle regEx replace withot interfering the server.
If your case uses regEx, it will be simpler. At least the Model does not have to be exposed.
Comment 3 libing wang CLA 2013-01-23 17:54:51 EST
Gosia,  I was trying to debug the Externalizer but it hangs in nonnlsSearchUtil.js. I could not debug to the  searchExplorer level to see what kind of model is returned.

I read your code for a little bit, Here is my thought.
1. Regarding the model, you can create your own mode and pass it to the replace widget. You model basically has to follow this contract:  
a. 
You will have to provide several functions that is mandatory to the explorer and renderer.
There were a lot wrapper functions before in the model level, which I would like to put into some sort of internal helper functions.
By doing that, we will know what is exactly needed from a pure model point of view. And it should end up with very few functions that you have to implement.

b.
You will have to provide a getReplacedContent callback, which will be called 
whenever the first time a file is selected and compare view requires that.

c.
You will have to provide a writeIncrementalNewContent callback, which is the most important part of the replace widget. All the checked/unchecked flag is set back to the model by the widget. So this writeIncrementalNewContent  has to write the whole selected files and selected matches.

2. Regarding the renderer:
I think if we have enough info in the model, the render has to knwo what has to be rendered.

3.Regarding the command 
I am not quite sure what that means.
Comment 4 libing wang CLA 2013-01-23 17:56:45 EST
regarding the amount of changes, this might be an RC1 candidate. But lets see if we can make it in M2.
Comment 5 libing wang CLA 2013-01-24 11:57:29 EST
Given I still have some other minor bugs I will fix today, moving this to RC1.
Comment 7 libing wang CLA 2013-01-31 16:46:43 EST
fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e2a5666af7cfb3f6460f40f55661f97076e38b5a.

Now you only need to implement the searchModel. You get the renderer and explorer by free.
Please see searchModel.js and strExternalizerModel.js for API docs. Look for "requied function".
Comment 8 libing wang CLA 2013-02-04 15:15:09 EST
I made the final change on how the "write all replaced files" is called in a generic way.
By doing this, we discarded the previous complicated parameters.

Now the explorer only needs to call something like:

theModel.writeReplacedContents(reportList).then(function(){
    
   //Do report UI based on the filled up reportList.

});

As all the models (currently search or externalizer model) know what should be written by their own and just fill out the report list. The explorer takes care of  rendering the report generically.