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

Bug 382104

Summary: String externalizer shows only one editor in compare view.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ken_walker, malgorzata.tomczyk
Version: 0.5Flags: malgorzata.tomczyk: review+
Target Milestone: 0.5 RC2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
the new patch after review none

Description libing wang CLA 2012-06-08 09:46:45 EDT
Tested on RC1 build.
Steps(chrome 20.0.1132.27 beta-m)

1.In navigator, select git bundle and use string externalize action
2.In the externalize page all results showed OK but the comapre view only show one editor.
Comment 1 Malgorzata Janczarska CLA 2012-06-08 09:56:22 EDT
(In reply to comment #0)
> 2.In the externalize page all results showed OK but the comapre view only show
> one editor.

Looks like a performance issue. The second editor show after a while and then it just starts working.
Comment 2 Ken Walker CLA 2012-06-08 10:02:44 EDT
If you resize the window it shows up
Comment 3 Malgorzata Janczarska CLA 2012-06-08 10:03:42 EDT
(In reply to comment #1)
> (In reply to comment #0)
> > 2.In the externalize page all results showed OK but the comapre view only show
> > one editor.
> 
> Looks like a performance issue. The second editor show after a while and then
> it just starts working.

Sorry, I was wrong. It's not time that makes the two sides of the compare appear. It's resizing the browser window. Looks like a problem with rendering.
Comment 4 Malgorzata Janczarska CLA 2012-06-08 10:25:20 EDT
Assigning to Libing as this looks like a problem in compare editor (the right side of the compare is only a file contents, so it's hard to do it wrong), but I will help to investigate why this problem occurs in externalizer, but doesn't occur it any other place like this. This is also Chrome only.
We have a simple walkaround, so this is not a blocker. I'm assigning it to RC2, because RC1 is today.
Comment 5 Ken Walker CLA 2012-06-08 10:37:04 EDT
Not Chrome only, happens in Safari and Firefox for me too
Comment 6 libing wang CLA 2012-06-13 09:55:31 EDT
Here is the patch diff --git a/bundles/org.eclipse.orion.client.core/web/orion/compare/compare-features.js b/bundles/org.eclipse.orion.client.core/web/orion/compare/compare-features.js
index 1624138..c8b10e9 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/compare/compare-features.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/compare/compare-features.js
@@ -10,7 +10,7 @@
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
 
-define(['i18n!orion/compare/nls/messages', 'dojo', 'dijit', 'dijit/layout/ContentPane', 'dijit/layout/BorderContainer'], function(messages, dojo, dijit) {
+define(['i18n!orion/compare/nls/messages', 'orion/util', 'dojo', 'dijit', 'dijit/layout/ContentPane', 'dijit/layout/BorderContainer'], function(messages, mUtil, dojo, dijit) {
 
 
 var orion = orion || {};
@@ -157,6 +157,7 @@
 			topWidget.addChild(leftB);
 			topWidget.addChild(rightB);
 			topWidget.startup();
+			mUtil.forceLayout(this._parentDivID);
 		},
 		
 		destroy: function(){
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/searchExplorer.js b/bundles/org.eclipse.orion.client.core/web/orion/searchExplorer.js
index 3dbdad6..7612304 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/searchExplorer.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/searchExplorer.js
@@ -1120,7 +1120,6 @@
 			dojo.when(fType, function(fType) {
 				var options = {
 					readonly: true,
-					onPage: true,
 					hasConflicts: false,
 					newFile: {
 						Name: fileItem.location,
diff --git a/bundles/org.eclipse.orion.client.core/web/stringexternalizer/searchExplorer.js b/bundles/org.eclipse.orion.client.core/web/stringexternalizer/searchExplorer.js
index 238355b..322da9a 100644
--- a/bundles/org.eclipse.orion.client.core/web/stringexternalizer/searchExplorer.js
+++ b/bundles/org.eclipse.orion.client.core/web/stringexternalizer/searchExplorer.js
@@ -36,7 +36,7 @@
 	SearchResultModel.prototype.sameFile = function(prevSelection, curSelection){
 		if(!prevSelection)
 			return false;
-		return (prevSelection.Location || prevSelection.parent.Location) === (curSelection.Location || curSelection.parent.Location);
+		return (prevSelection.Location || prevSelection.fileClone.Location) === (curSelection.Location || curSelection.fileClone.Location);
 	};
 	
 	SearchResultModel.prototype.fileModel = function(model){
@@ -71,7 +71,8 @@
 			}
 			for(var j=0; j<this._listRoot.children[i].nonnls.length; j++){
 				this._listRoot.children[i].nonnls[j].type = "detail"; //$NON-NLS-0$
-				this._listRoot.children[i].nonnls[j].parent = fileClone;
+				this._listRoot.children[i].nonnls[j].parent = this._listRoot.children[i];//.parent is reserved for tree visitor
+				this._listRoot.children[i].nonnls[j].fileClone = fileClone;
 				this._listRoot.children[i].nonnls[j].parentNum = i;
 				this._listRoot.children[i].nonnls[j].checked = true;
 			}
@@ -103,7 +104,7 @@
 				// remove all non valid chars to make a dom id. 
 				result = result.replace(/[^\.\:\-\_0-9A-Za-z]/g, "");				
 			} else {
-				result = this.getId(item.parent);
+				result = this.getId(item.fileClone);
 				result += item.lineNum;
 				result += item.character;
 			}
@@ -137,7 +138,9 @@
 		} else if (parentItem.type === "detail") { //$NON-NLS-0$
 			onComplete([]);
 		} else if (parentItem.type === "file") { //$NON-NLS-0$
-			 onComplete(parentItem.nonnls);
+			parentItem.children = parentItem.nonnls;//Tree iterator (visitor) requires .children property. But this will be improved in the future without requiring this property.
+			                                        //Addressed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=380687#c2.
+			onComplete(parentItem.nonnls);
 		} else {
 			onComplete([]);
 		}
@@ -625,33 +628,34 @@
 				var options = {
 					readonly: true,
 					hasConflicts: false,
-					baseFile: {
+					newFile: {
 						Name: fileItem.Location,
 						Type: fType,
 						Content: fileItem.contents
 					},
-					newFile: {
+					baseFile: {
 						Name: fileItem.Location,
 						Type: fType,
 						Content: fileItem.checked ? mNonnlsSearchUtil.replaceNls(fileItem.contents, fileItem.nonnls, that.config) : fileItem.contents
 					}
 				};
+				
 				if(!that.twoWayCompareContainer){
 					that.uiFactoryCompare = new mCompareFeatures.TwoWayCompareUIFactory({
 						parentDivID: uiFactory.getCompareDivID(),
 						showTitle: true,
-						leftTitle: dojo.string.substitute(messages["Replaced File (${0})"], [fileItem.Name]),
-						rightTitle: dojo.string.substitute(messages["Original File (${0})"], [fileItem.Name]),
+						rightTitle: dojo.string.substitute(messages["Replaced File (${0})"], [fileItem.Name]),
+						leftTitle: dojo.string.substitute(messages["Original File (${0})"], [fileItem.Name]),
 						showLineStatus: false
 					});
 					that.uiFactoryCompare.buildUI();
 					that.twoWayCompareContainer = new mCompareContainer.TwoWayCompareContainer(that.registry, uiFactory.getCompareDivID(), that.uiFactoryCompare, options);
 					that.twoWayCompareContainer.startup();
 				} else {
-					dojo.empty(that.uiFactoryCompare.getTitleDivId(true));
-					dojo.place(document.createTextNode(dojo.string.substitute(messages['Replaced File (${0})'], [fileItem.Name])), that.uiFactoryCompare.getTitleDivId(true), "only"); //$NON-NLS-1$
 					dojo.empty(that.uiFactoryCompare.getTitleDivId());
-					dojo.place(document.createTextNode(dojo.string.substitute(messages['Original File (${0})'], [fileItem.Name])), that.uiFactoryCompare.getTitleDivId(), "only"); //$NON-NLS-1$
+					dojo.place(document.createTextNode(dojo.string.substitute(messages['Replaced File (${0})'], [fileItem.Name])), that.uiFactoryCompare.getTitleDivId(), "only"); //$NON-NLS-1$
+					dojo.empty(that.uiFactoryCompare.getTitleDivId(true));
+					dojo.place(document.createTextNode(dojo.string.substitute(messages['Original File (${0})'], [fileItem.Name])), that.uiFactoryCompare.getTitleDivId(true), "only"); //$NON-NLS-1$
 					that.twoWayCompareContainer.setOptions(options);
 					that.twoWayCompareContainer.setEditor();
 				}
Comment 7 libing wang CLA 2012-06-13 09:55:56 EDT
Gosia, could you review it?
Comment 8 libing wang CLA 2012-06-13 11:07:31 EDT
Created attachment 217288 [details]
the new patch after review
Comment 9 Malgorzata Janczarska CLA 2012-06-13 11:51:41 EDT
(In reply to comment #8)
> Created attachment 217288 [details]
> the new patch after review

You can remove those lines from searchExplorer:
			//clone object without children
			var fileClone = {};
			for(var op in this._listRoot.children[i]){
				if(op!=="nonnls") //$NON-NLS-0$
					fileClone[op] = this._listRoot.children[i][op];
			}

Creating the fileClone is no longer needed, because fileClone is no longer used. Apart from that everything works fine.