Merge branch 'master' of ssh://git.eclipse.org/gitroot/orion/org.eclipse.orion.client
diff --git a/bundles/org.eclipse.orion.client.ui/web/compare/compare2.html b/bundles/org.eclipse.orion.client.ui/web/compare/compare2.html
new file mode 100644
index 0000000..e7f3259
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.ui/web/compare/compare2.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+    <head>
+		<meta name="copyright" content="Copyright (c) IBM Corporation and others 2010, 2011." >
+		<meta http-equiv="Content-Language" content="en-us">
+		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+		<title>Compare</title>    
+		<link rel="stylesheet" type="text/css" href="compare.css" />
+		<script src="../requirejs/require.js"></script>
+		<script>
+		/*global require*/
+		require({
+			  baseUrl: '..',
+			  paths: {
+				  text: 'requirejs/text',
+				  i18n: 'requirejs/i18n',
+				  domReady: 'requirejs/domReady'	    
+			  }
+			});
+			require(["compare2.js"]);
+		</script>
+	</head>
+	<body id="orion-compare" class="orionPage">
+		<div class="content-fixedHeight">
+			<div class="fixedToolbarHolder mainpane">
+				<div class="mainToolbar toolComposite" id="pageToolbar"></div>
+				<div id="compareContainer" class="toolbarTarget">
+				</div>
+			</div>
+		</div>
+		<div class="footer-fixed-bottom footer" id="footer">
+		</div>
+	</body>	
+</html>
\ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/compare/compare2.js b/bundles/org.eclipse.orion.client.ui/web/compare/compare2.js
new file mode 100644
index 0000000..c7e6d64
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.ui/web/compare/compare2.js
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2011, 2012 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html),
+ * and the Eclipse Distribution License v1.0
+ * (http://www.eclipse.org/org/documents/edl-v10.html).
+ * 
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+/*global define document window */
+
+define(['orion/bootstrap', 'orion/status', 'orion/progress', 'orion/operationsClient', 'orion/commandRegistry', 'orion/fileClient', 'orion/searchClient', 'orion/globalCommands',
+		'orion/compare/compareCommands', 'orion/compare/resourceComparer', 'orion/widgets/themes/ThemePreferences', 'orion/widgets/themes/editor/ThemeData', 'orion/compare/compareUtils', 'orion/contentTypes', 'orion/PageUtil'],
+		function(mBootstrap, mStatus, mProgress, mOperationsClient, mCommandRegistry, mFileClient, mSearchClient, mGlobalCommands, mCompareCommands, mResourceComparer, mThemePreferences, mThemeData, mCompareUtils, mContentTypes, PageUtil) {
+	mBootstrap.startup().then(function(core) {
+		var serviceRegistry = core.serviceRegistry;
+		var preferences = core.preferences;
+		var commandService = new mCommandRegistry.CommandRegistry({ });
+		// File operations
+		var fileClient = new mFileClient.FileClient(serviceRegistry);
+		var contentTypeService = new mContentTypes.ContentTypeService(serviceRegistry);
+		var searcher = new mSearchClient.Searcher({
+			serviceRegistry: serviceRegistry, commandService: commandService, fileService: fileClient
+		});
+		var operationsClient = new mOperationsClient.OperationsClient(serviceRegistry);
+		var statusService = new mStatus.StatusReportingService(serviceRegistry, operationsClient, "statusPane", "notifications", "notificationArea"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+		var progressService = new mProgress.ProgressService(serviceRegistry, operationsClient, commandService);
+		var themePreferences = new mThemePreferences.ThemePreferences(preferences, new mThemeData.ThemeData());
+		themePreferences.apply();
+		mGlobalCommands.generateBanner("orion-compare", serviceRegistry, commandService, preferences, searcher); //$NON-NLS-0$
+		/*
+		var uiFactory = new mCompareFeatures.TwoWayCompareUIFactory({
+			parentDivID: "compareContainer", //$NON-NLS-0$
+			showTitle: true,
+			showLineStatus: true
+		});
+		uiFactory.buildUI();
+		*/
+		var diffProvider = new mResourceComparer.DefaultDiffProvider(serviceRegistry);
+		var cmdProvider = new mCompareCommands.CompareCommandFactory({commandService: commandService, commandSpanId: "pageNavigationActions"}); //$NON-NLS-0$
+		
+		var startWidget = function(){
+			var compareParams = PageUtil.matchResourceParameters();
+			var options = {
+				readonly: compareParams.readonly === "true", //$NON-NLS-0$
+				onPage: true,
+				generateLink: true,
+				hasConflicts: compareParams.conflict === "true", //$NON-NLS-0$
+				diffProvider: diffProvider,
+				resource: compareParams.resource,
+				compareTo: compareParams.compareTo
+			};
+			var viewOptions = {
+				parentDivId: "compareContainer", //$NON-NLS-0$
+				commandProvider: cmdProvider,
+				showTitle: true,
+				showLineStatus: true,
+				blockNumber: compareParams.block,
+				changeNumber: compareParams.change
+			};
+			var comparer = new mResourceComparer.ResourceComparer(serviceRegistry, commandService, options, viewOptions);
+			comparer.start();
+		};
+		startWidget();
+		// every time the user manually changes the hash, we need to reastart the compare widget.
+		window.addEventListener("hashchange", function() { //$NON-NLS-0$
+			startWidget();
+		}, false);		
+	});
+});
\ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/compare/builder/compare.js b/bundles/org.eclipse.orion.client.ui/web/orion/compare/builder/compare.js
index e2dab36..038785a 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/compare/builder/compare.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/compare/builder/compare.js
@@ -127,10 +127,10 @@
 				Deferred.all(promises, function(error) { return {_error: error}; }).then(function(results){
 					this.getCompareView().getWidget().options.oldFile.Content = results[0];
 					this.getCompareView().getWidget().options.newFile.Content = results[1];
-					this.getCompareView().getWidget().refresh();
+					this.getCompareView().getWidget().refresh(true);
 				}.bind(this));
 			} else {
-				this.getCompareView().getWidget().refresh();
+				this.getCompareView().getWidget().refresh(true);
 			}
 		}
 	};
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareCommands.js
index 1602d28..8668ab2 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareCommands.js
@@ -48,7 +48,7 @@
 				id: "orion.compare.copyToLeft", //$NON-NLS-0$
 				groupId: "orion.compareGroup", //$NON-NLS-0$
 				visibleWhen: function(item) {
-					return compareWidget.type === "twoWay"; //$NON-NLS-0$
+					return compareWidget.type === "twoWay" && compareWidget.options.newFile && !compareWidget.options.newFile.readonly; //$NON-NLS-0$
 				}.bind(this),
 				callback : function(data) {
 					data.items.copyToLeft();
@@ -60,7 +60,7 @@
 				id: "orion.compare.copyToRight", //$NON-NLS-0$
 				groupId: "orion.compareGroup", //$NON-NLS-0$
 				visibleWhen: function(item) {
-					return compareWidget.type === "twoWay"; //$NON-NLS-0$
+					return compareWidget.type === "twoWay" && compareWidget.options.oldFile && !compareWidget.options.oldFile.readonly; //$NON-NLS-0$
 				}.bind(this),
 				callback : function(data) {
 					data.items.copyToRight();
@@ -137,12 +137,8 @@
 			// Register command contributions
 			commandService.registerCommandContribution(commandSpanId, "orion.compare.toggle2Inline", 108); //$NON-NLS-0$
 			commandService.registerCommandContribution(commandSpanId, "orion.compare.toggle2TwoWay", 109); //$NON-NLS-0$
-			if (!compareWidget.options.newFile.readonly) {
-				commandService.registerCommandContribution(commandSpanId, "orion.compare.copyToLeft", 110, null, false, new mKeyBinding.KeyBinding(37/*left arrow key*/, true, false, true)); //$NON-NLS-0$
-			}
-			if (!compareWidget.options.oldFile.readonly) {
-				commandService.registerCommandContribution(commandSpanId, "orion.compare.copyToRight", 111, null, false, new mKeyBinding.KeyBinding(39/*left arrow key*/, true, false, true)); //$NON-NLS-0$
-			}
+			commandService.registerCommandContribution(commandSpanId, "orion.compare.copyToLeft", 110, null, false, new mKeyBinding.KeyBinding(37/*left arrow key*/, true, false, true)); //$NON-NLS-0$
+			commandService.registerCommandContribution(commandSpanId, "orion.compare.copyToRight", 111, null, false, new mKeyBinding.KeyBinding(39/*left arrow key*/, true, false, true)); //$NON-NLS-0$
 			commandService.registerCommandContribution(commandSpanId, "orion.compare.nextDiff", 112, null, false, new mKeyBinding.KeyBinding(40/*down arrow key*/, true)); //$NON-NLS-0$
 			commandService.registerCommandContribution(commandSpanId, "orion.compare.prevDiff", 113, null, false, new mKeyBinding.KeyBinding(38/*up arrow key*/, true)); //$NON-NLS-0$
 			if(compareWidget.options.wordLevelNav){
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareView.js b/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareView.js
index 7f5b008..c4cd71a 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareView.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/compare/compareView.js
@@ -146,10 +146,10 @@
 			return this;
 		},
 		
-		startup: function(onsave, onLoadContents){
+		startup: function(onLoadContents){
 			this.initEditors();
 			this._onLoadContents = onLoadContents;
-			this.refresh(onsave);
+			this.refresh(true);
 		}
 	};
 	return CompareView;
@@ -209,6 +209,10 @@
 		}.bind(this);
 	};
 	
+	TwoWayCompareView.prototype.getEditors = function(){
+		return this._editors;
+	};
+	
 	TwoWayCompareView.prototype.gotoDiff = function(lineNumber, offsetInTheLine, updateLeft){
 		var textView = updateLeft ? this._editors[1].getTextView() : this._editors[0].getTextView();
 		var offset = textView.getModel().getLineStart(lineNumber) + offsetInTheLine;
@@ -269,15 +273,18 @@
 			return view;
 		}.bind(this);
 		
+		var keyBindingFactory = fileOptions.keyBindingFactory;
 		//Create keybindings factory
-		var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) {
-			// Create keybindings for generic editing
-			var genericBindings = new mEditorFeatures.TextActions(editor, undoStack);
-			keyModeStack.push(genericBindings);
-			// create keybindings for source editing
-			var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist);
-			keyModeStack.push(codeBindings);
-		};
+		if(!keyBindingFactory) {
+			keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) {
+				// Create keybindings for generic editing
+				var genericBindings = new mEditorFeatures.TextActions(editor, undoStack);
+				keyModeStack.push(genericBindings);
+				// create keybindings for source editing
+				var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist);
+				keyModeStack.push(codeBindings);
+			};
+		}
 
 		//Create the status reporter if needed
 		var statusReporter = null;
@@ -376,16 +383,16 @@
 		}
 	};
 	
-	TwoWayCompareView.prototype.refresh = function(onsave){	
+	TwoWayCompareView.prototype.refresh = function(refreshEditors){	
 		var input = this.options.oldFile.Content;
 		var output = this.options.newFile.Content;
 		var diff = this.options.diffContent;
 		
 		var result;
 		if(output) {
-			result = this.parseMapper(input , output, diff , this.options.hasConflicts, true);
+			result = this.parseMapper(input , output, diff , this.options.hasConflicts);
 		} else {
-			result = this.parseMapper(input , output, diff , this.options.hasConflicts, onsave);
+			result = this.parseMapper(input , output, diff , this.options.hasConflicts);
 			output = result.output;
 		}
 		
@@ -393,10 +400,10 @@
 		var lFeeder = new mDiffTreeNavigator.TwoWayDiffBlockFeeder(this._editors[1].getTextView().getModel(), result.mapper, 0);
 		this._diffNavigator.initAll(this.options.charDiff ? "char" : "word", this._editors[0], this._editors[1], rFeeder, lFeeder, this._overviewRuler, this._curveRuler); //$NON-NLS-1$ //$NON-NLS-0$
 		this._curveRuler.init(result.mapper ,this._editors[1], this._editors[0], this._diffNavigator);
-		if(!onsave){
+		if(refreshEditors) {
 			this._editors[1].setInput(this.options.newFile.Name, null, output);
+			this._editors[0].setInput(this.options.oldFile.Name, null, input);
 		}
-		this._editors[0].setInput(this.options.oldFile.Name, null, input);
 		this._initSyntaxHighlighter([{fileName: this.options.newFile.Name, contentType: this.options.newFile.Type, editor: this._editors[1]},
 									 {fileName: this.options.oldFile.Name, contentType: this.options.oldFile.Type, editor: this._editors[0]}]);
 		this._highlightSyntax();
@@ -408,6 +415,15 @@
 		if(this._viewLoadedCounter === 2){
 			this._diffNavigator.gotoBlock(this.options.blockNumber-1, this.options.changeNumber-1);
 		}
+		
+		var newFileTitleNode = this._uiFactory.getTitleDiv(true);
+		var oldFileTitleNode = this._uiFactory.getTitleDiv(false);
+		if(oldFileTitleNode && newFileTitleNode){
+			lib.empty(oldFileTitleNode);
+			lib.empty(newFileTitleNode);
+			oldFileTitleNode.appendChild(document.createTextNode(this.options.oldFile.Name));
+			newFileTitleNode.appendChild(document.createTextNode(this.options.newFile.Name));
+		}
 		var leftViewHeight = this._editors[1].getTextView().getModel().getLineCount() * this._editors[1].getTextView().getLineHeight() + 5;
 		var rightViewHeight = this._editors[0].getTextView().getModel().getLineCount() * this._editors[0].getTextView().getLineHeight() +5;
 		return leftViewHeight > rightViewHeight ? leftViewHeight : rightViewHeight;
@@ -575,7 +591,7 @@
 	}
 	toggleableCompareView.prototype = {
 		startup: function(onLoadContents){
-			this._widget.startup(false, onLoadContents);
+			this._widget.startup(onLoadContents);
 		},
 		
 		toggle: function(){
@@ -591,7 +607,7 @@
 				this._widget = new exports.InlineCompareView(options);
 			}
 			this._widget.initEditors();
-			this._widget.refresh();
+			this._widget.refresh(true);
 		},
 		
 		getWidget: function() {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/compare/examples/demo.js b/bundles/org.eclipse.orion.client.ui/web/orion/compare/examples/demo.js
index 46f438a..60b5738 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/compare/examples/demo.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/compare/examples/demo.js
@@ -82,7 +82,7 @@
 			widget.options.oldFile.Name = "sampRight.js";
 			widget.options.newFile.Name = "sampleLeft.js";
 			widget.options.mapper = null;
-			compare.refresh();
+			compare.refresh(true);
 		}
 	}
 	function animateDiffs() {
@@ -101,7 +101,7 @@
 	function doCompare() {
 		var widget = compare.getCompareView().getWidget();
 		if(widget.type === "twoWay"){ //$NON-NLS-0$
-			var editors = widget._editors;
+			var editors = widget.getEditors();
 			var oldContents = editors[0].getTextView().getText();
 			var newContents = editors[1].getTextView().getText();
 			if(compareType === "byTwoContents"){ //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/compare/resourceComparer.js b/bundles/org.eclipse.orion.client.ui/web/orion/compare/resourceComparer.js
index 5720301..afe8c1c 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/compare/resourceComparer.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/compare/resourceComparer.js
@@ -12,8 +12,9 @@
 /*global define document console prompt window*/
 /*jslint forin:true regexp:false sub:true*/
 
-define(['orion/Deferred', 'orion/compare/diff-provider', 'orion/compare/compareView', 'orion/highlight', 'orion/fileClient'], 
-		function(Deferred, mDiffProvider, mCompareView, Highlight, mFileClient) {
+define(['i18n!orion/compare/nls/messages', 'require', 'orion/Deferred', 'orion/compare/diff-provider', 'orion/compare/compareView', 'orion/highlight', 
+		'orion/fileClient', 'orion/globalCommands', 'orion/searchAndReplace/textSearcher', 'orion/editorCommands', 'orion/editor/editorFeatures'], 
+		function(messages, require, Deferred, mDiffProvider, mCompareView, Highlight, mFileClient, mGlobalCommands, mSearcher, mEditorCommands, mEditorFeatures) {
 
 var exports = {};
 
@@ -51,7 +52,7 @@
 			Deferred.all([ that._getContentType(oldFileURL), that._getContentType(newFileURL)], function(error) { return {_error: error}; }).then(compareTwo);
 		},
 		
-		_resolveDiff: function(resource, compareTo, onlyDiff, errorCallback) {
+		_resolveDiff: function(resource, compareTo, errorCallback) {
 			if(compareTo){
 				this._resolveTwoFiles(compareTo, resource, errorCallback);
 			} else {
@@ -66,13 +67,7 @@
 					} else {
 						that._diffContent = jsonData;
 					}
-					if (onlyDiff){
-						that.callBack({ 
-							diffContent: that._diffContent
-						 });
-					} else {
-						that._resolveComplexFileURL(resource);
-					}
+					that._resolveComplexFileURL(resource);
 				}, errorCallback);
 			}
 		},
@@ -96,10 +91,10 @@
 			}, errorCallback);
 		},
 		
-		provide: function(resource, compareTo, onlyDiff, hasConflicts,callBack, errorCallBack) {
+		provide: function(resource, compareTo, hasConflicts,callBack, errorCallBack) {
 			this.callBack = callBack;
 			this._hasConflicts = hasConflicts;
-			this._resolveDiff(resource, compareTo, onlyDiff, errorCallBack);
+			this._resolveDiff(resource, compareTo, errorCallBack);
 		}
 	};
 	return DefaultDiffProvider;
@@ -118,9 +113,13 @@
 };
 
 exports.ResourceComparer = (function() {
-	function ResourceComparer (serviceRegistry, options, viewOptions) {
+	function ResourceComparer (serviceRegistry, commandRegistry, options, viewOptions) {
 		this._registry = serviceRegistry;
+		this._commandService = commandRegistry;
 		this._fileClient = new mFileClient.FileClient(serviceRegistry);
+		this._fileClient = new mFileClient.FileClient(serviceRegistry);
+		this._searchService = this._registry.getService("orion.core.search"); //$NON-NLS-0$
+		this._progress = this._registry.getService("orion.page.progress"); //$NON-NLS-0$
 		this.setOptions(options, true);
 		if(options.toggleable) {
 			this._compareView = new mCompareView.toggleableCompareView(options.type === "inline" ? "inline" : "twoWay", viewOptions);
@@ -130,9 +129,87 @@
 			this._compareView = new mCompareView.TwoWayCompareView(viewOptions);
 		}
 		if(!viewOptions.highlighters){
-			this._compareView.getWidget().setOptions({highlighters: [new CompareStyler(), new CompareStyler()]});
+			this._compareView.getWidget().setOptions({highlighters: [new CompareStyler(serviceRegistry), new CompareStyler(serviceRegistry)]});
+		}
+		if(!viewOptions.oldFile){
+			this._compareView.getWidget().setOptions({oldFile: {readonly: true}});
+		}
+		if(!viewOptions.newFile){
+			this._compareView.getWidget().setOptions({newFile: {readonly: options.readonly}});
+		}
+		var that = this;
+		this._inputManager = {
+			filePath: "",
+			getInput: function() {
+				return this.filePath;
+			},
+			
+			setDirty: function(dirty) {
+				mGlobalCommands.setDirtyIndicator(dirty);
+			},
+			
+			getFileMetadata: function() {
+				return this._fileMetadata;
+			},
+			
+			setInput: function(fileURI, editor) {
+				that._progress.progress(that._fileClient.read(fileURI, true), "Getting file metadata " + fileURI).then( //$NON-NLS-0$
+					function(metadata) {
+						this._fileMetadata = metadata;
+						this.setTitle(metadata.Location, metadata);
+					}.bind(this),
+					function(error) {
+						console.error("Error loading file metadata: " + error.message); //$NON-NLS-0$
+						this.setTitle(fileURI);
+					}.bind(this)
+				);
+				this.lastFilePath = fileURI;
+			},
+			
+			setTitle : function(title, /*optional*/ metadata) {
+				var name;
+				if (metadata) {
+					name = metadata.Name;
+				}
+				mGlobalCommands.setPageTarget({task: messages["Compare"], name: name, target: metadata,
+							serviceRegistry: serviceRegistry, commandService: that._commandService,
+							searchService: that._searchService, fileService: that._fileClient});
+				if (title.charAt(0) === '*') { //$NON-NLS-0$
+					mGlobalCommands.setDirtyIndicator(true);
+					name = title.substring(1);
+				} else {
+					mGlobalCommands.setDirtyIndicator(false);
+				} 
+			},
+			
+			afterSave: function(){
+				var editors = that._compareView.getWidget().getEditors();
+				var newContents = editors[1].getTextView().getText();
+				that._compareView.getWidget().options.newFile.Content = newContents;
+				that._compareView.getWidget().refresh();
+			}
+		};
+		if(!options.readonly && !options.toggleable && this._compareView.getWidget().type === "twoWay") { //$NON-NLS-0$
+			var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) {
+				var localSearcher = new mSearcher.TextSearcher(editor, that._commandService, undoStack);
+				var commandGenerator = new mEditorCommands.EditorCommandFactory(that._registry, that._commandService,that._fileClient , that._inputManager, "pageActions", false, "pageNavigationActions", localSearcher); //$NON-NLS-1$ //$NON-NLS-0$
+				commandGenerator.generateEditorCommands(editor);
+				var genericBindings = new mEditorFeatures.TextActions(editor, undoStack);
+				keyModeStack.push(genericBindings);
+				// create keybindings for source editing
+				var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist);
+				keyModeStack.push(codeBindings);
+			};
+			this._compareView.getWidget().options.newFile.keyBindingFactory = keyBindingFactory;
 		}
 		this._compareView.getWidget().initEditors();
+		if(!options.readonly && !options.toggleable && this._compareView.getWidget().type === "twoWay") { //$NON-NLS-0$
+			var editors = this._compareView.getWidget().getEditors();
+			//right side editor
+			editors[1].addEventListener("DirtyChanged", function(evt) { //$NON-NLS-0$
+				this._inputManager.setDirty(editors[1].isDirty());
+			}.bind(this));
+		}
 	}
 	ResourceComparer.prototype = {
 		_clearOptions: function(){
@@ -160,14 +237,22 @@
 			that.options.diffProvider.provide(that.options.resource, that.options.compareTo, that.options.hasConflicts, function(diffParam){
 				that._compareView.getWidget().setOptions(diffParam);
 				var viewOptions = that._compareView.getWidget().options;
+				viewOptions.oldFile.readonly = true;
+				if(that.options.readonly) {
+					viewOptions.newFile.readonly = true;
+				}
 				if(that.options.callback){
 					that.options.callback(viewOptions.oldFile.Name, viewOptions.newFile.Name);
 				}
 				var filesToLoad = ( viewOptions.diffContent ? [viewOptions.oldFile/*, viewOptions.newFile*/] : [viewOptions.oldFile, viewOptions.newFile]); 
 				that.getFilesContents(filesToLoad).then( function(){
-					var viewHeight = this._compareView.getWidget().setEditor();
-					if(this._onLoadContents){
-						this._onLoadContents(viewHeight);
+					var viewHeight = that._compareView.getWidget().refresh(true);
+					if(!that.options.readonly && !that.options.toggleable && that._compareView.getWidget().type === "twoWay") { //$NON-NLS-0$
+						this._inputManager.filePath = that._compareView.getWidget().options.newFile.URL;
+						that._inputManager.setInput(viewOptions.newFile.URL , that._compareView.getWidget().getEditors()[1]);
+					}
+					if(that._onLoadContents){
+						that._onLoadContents(viewHeight);
 					}
 				}.bind(that));
 			}, that.options.errorCallback);
@@ -195,7 +280,7 @@
 		        }.bind(this)
 			);
 	    },
-		compose: function(onLoadContents){
+		start: function(onLoadContents){
 			this._onLoadContents = onLoadContents;
 			if(this.options.resource){
 				this.resolveDiffByProvider();