aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Luong2013-06-12 11:40:02 (EDT)
committerMalgorzata Janczarska2013-06-12 12:38:25 (EDT)
commit3dbb8cea6547859e9ff43d3118ad0f71e6bac86c (patch)
tree8d772cdba456e568b1b5dfae2e85bbcb274b2b00
parent142929e8097ca8d03ca502a46860b40bf56a3cd4 (diff)
downloadorg.eclipse.orion.client-3dbb8cea6547859e9ff43d3118ad0f71e6bac86c.zip
org.eclipse.orion.client-3dbb8cea6547859e9ff43d3118ad0f71e6bac86c.tar.gz
org.eclipse.orion.client-3dbb8cea6547859e9ff43d3118ad0f71e6bac86c.tar.bz2
Bug 410530 - Remove delay in rendering of the compare widget and
stage/unstage buttons in git status and git commit explorer Conflicts: bundles/org.eclipse.orion.client.git/web/orion/git/gitStatusExplorer.js
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js40
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitCommitExplorer.js1027
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitStatusExplorer.js1884
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/util.js6
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/compare/compareView.js8
5 files changed, 1480 insertions, 1485 deletions
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
index 343f99f..7b6a799 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
@@ -9,7 +9,7 @@
* Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
-/*globals window document define confirm URL*/
+/*globals window document define confirm URL console*/
/*jslint nomen:false sub:true forin:false laxbreak:true eqeqeq:false*/
define(['i18n!git/nls/gitmessages', 'require', 'orion/Deferred', 'orion/i18nUtil', 'orion/webui/littlelib', 'orion/commands', 'orion/commandRegistry', 'orion/git/util', 'orion/compare/compareUtils', 'orion/git/gitPreferenceStorage', 'orion/git/gitConfigPreference',
@@ -109,7 +109,7 @@ var exports = {};
var progress = serviceRegistry.getService("orion.page.progress"); //$NON-NLS-0$
progress.removeOperation(options.failedOperation);
}
- func({ knownHosts: options.knownHosts, gitSshUsername: credentials.gitSshUsername, gitSshPassword: credentials.gitSshPassword, gitPrivateKey: credentials.gitPrivateKey, gitPassphrase: credentials.gitPassphrase}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ func({knownHosts: options.knownHosts, gitSshUsername: credentials.gitSshUsername, gitSshPassword: credentials.gitSshPassword, gitPrivateKey: credentials.gitPrivateKey, gitPassphrase: credentials.gitPassphrase}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
return;
}
@@ -273,12 +273,12 @@ var exports = {};
gitSshPassword : sshPassword
}).then(
function(){
- triggerCallback({ gitSshUsername: sshUser, gitSshPassword: sshPassword, gitPrivateKey: "", gitPassphrase: ""}); //$NON-NLS-0$
+ triggerCallback({gitSshUsername: sshUser, gitSshPassword: sshPassword, gitPrivateKey: "", gitPassphrase: ""}); //$NON-NLS-0$
}
);
return;
} else {
- triggerCallback({ gitSshUsername: sshUser, gitSshPassword: sshPassword, gitPrivateKey: "", gitPassphrase: ""}); //$NON-NLS-0$
+ triggerCallback({gitSshUsername: sshUser, gitSshPassword: sshPassword, gitPrivateKey: "", gitPassphrase: ""}); //$NON-NLS-0$
return;
}
}
@@ -1855,9 +1855,10 @@ var exports = {};
var orionHome = PageLinks.getOrionHome();
var url = sshCheck(clone.Children[0].GitUrl);
var reviewRequestUrl = orionHome + "/git/reviewRequest.html#" + url + "_" + item.Name;
- var dialog = new mReviewRequest.ReviewRequestDialog({ title : messages["Contribution Review Request"],
- url : reviewRequestUrl,
- func : sendNotificationFunction
+ var dialog = new mReviewRequest.ReviewRequestDialog({
+ title : messages["Contribution Review Request"],
+ url : reviewRequestUrl,
+ func : sendNotificationFunction
});
dialog.show();
}, displayErrorOnStatus);
@@ -2064,7 +2065,7 @@ var exports = {};
var gitConfigPreference = new GitConfigPreference(serviceRegistry);
serviceRegistry.getService("orion.page.message").setProgressMessage("Your project is being set up. This may take a minute...");
- gitConfigPreference.getConfig().then( function(userInfo){
+ gitConfigPreference.getConfig().then(function(userInfo){
var deferred = progress.progress(gitService.cloneGitRepository(name, gitUrl, path, explorer.defaultPath, options.gitSshUsername, options.gitSshPassword, options.knownHosts, //$NON-NLS-0$
options.gitPrivateKey, options.gitPassphrase, userInfo), "Cloning repository " + name);
deferred.then(function(jsonData, secondArg) {
@@ -2086,9 +2087,9 @@ var exports = {};
}
});
}
- )
+ );
}
- )
+ );
}, func, messages['Clone Git Repository']);
}, function(jsonData, secondArg) {
exports.handleProgressServiceResponse(jsonData, options, serviceRegistry, function() {}, func, messages['Clone Git Repository']);
@@ -2118,7 +2119,7 @@ var exports = {};
console.info("Folder project is used");
}
}
- )
+ );
} else {
console.info("Folder project is used");
}
@@ -2148,7 +2149,7 @@ var exports = {};
exports.getDefaultSshOptions(serviceRegistry).then(function(options) {
var func = arguments.callee;
var gitConfigPreference = new GitConfigPreference(serviceRegistry);
- gitConfigPreference.getConfig().then( function(userInfo){
+ gitConfigPreference.getConfig().then(function(userInfo){
var deferred = progress.progress(gitService.cloneGitRepository(name, gitUrl, path, explorer.defaultPath, options.gitSshUsername, options.gitSshPassword, options.knownHosts, //$NON-NLS-0$
options.gitPrivateKey, options.gitPassphrase, userInfo), "Cloning repository " + name);
serviceRegistry.getService("orion.page.message").createProgressMonitor(deferred,
@@ -2197,7 +2198,7 @@ var exports = {};
exports.getDefaultSshOptions(serviceRegistry).then(function(options) {
var func = arguments.callee;
var gitConfigPreference = new GitConfigPreference(serviceRegistry);
- gitConfigPreference.getConfig().then( function(userInfo){
+ gitConfigPreference.getConfig().then(function(userInfo){
var deferred = progress.progress(gitService.cloneGitRepository(name, gitUrl, path, explorer.defaultPath, options.gitSshUsername, options.gitSshPassword, options.knownHosts, //$NON-NLS-0$
options.gitPrivateKey, options.gitPassphrase, userInfo), "Cloning git repository " + name);
serviceRegistry.getService("orion.page.message").createProgressMonitor(deferred,
@@ -2365,7 +2366,7 @@ var exports = {};
exports.getDefaultSshOptions(serviceRegistry).then(function(options){
var func = arguments.callee;
var gitConfigPreference = new GitConfigPreference(serviceRegistry);
- gitConfigPreference.getConfig().then( function(userInfo){
+ gitConfigPreference.getConfig().then(function(userInfo){
var deferred = progress.progress(gitService.cloneGitRepository(name, gitUrl, path, explorer.defaultPath, null, null, null, null, null, userInfo), messages["Initializing repository: "] + name); //$NON-NLS-0$
serviceRegistry.getService("orion.page.message").createProgressMonitor(deferred,
messages["Initializing repository: "] + name);
@@ -2589,7 +2590,7 @@ var exports = {};
);
} else {
var paths = [];
- for ( var i = 0; i < items.length; i++) {
+ for (var i = 0; i < items.length; i++) {
paths[i] = items[i].name;
}
@@ -2643,7 +2644,7 @@ var exports = {};
);
} else {
var paths = [];
- for ( var i = 0; i < items.length; i++) {
+ for (var i = 0; i < items.length; i++) {
paths[i] = items[i].name;
}
@@ -2791,7 +2792,7 @@ var exports = {};
var progress = serviceRegistry.getService("orion.page.progress"); //$NON-NLS-0$
var paths = [];
- for ( var i = 0; i < items.length; i++) {
+ for (var i = 0; i < items.length; i++) {
paths[i] = items[i].name;
}
@@ -2941,11 +2942,10 @@ var exports = {};
});
commandService.addCommand(rebaseAbortCommand);
-
-
-
};
}());
+
return exports;
+
});
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommitExplorer.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommitExplorer.js
index 4a35f73..17b2c7f 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommitExplorer.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommitExplorer.js
@@ -1,513 +1,514 @@
-/*******************************************************************************
- * @license Copyright (c) 2011, 2013 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 window console document Image */
-
-define(
- [ 'require', 'i18n!git/nls/gitmessages', 'orion/section', 'orion/explorers/explorer', 'orion/PageUtil', 'orion/i18nUtil', 'orion/webui/littlelib',
- 'orion/globalCommands', 'orion/git/gitCommands', 'orion/git/util', 'orion/Deferred', 'orion/webui/tooltip' ],
- function(require, messages, mSection, mExplorer, PageUtil, i18nUtil, lib, mGlobalCommands, mGitCommands, mGitUtil, Deferred, Tooltip) {
- var exports = {};
-
- exports.GitCommitExplorer = (function() {
-
- /**
- * Creates a new Git commit explorer.
- *
- * @class Git commit explorer
- * @name orion.git.GitCommitExplorer
- * @param registry
- * @param commandService
- * @param linkService
- * @param selection
- * @param parentId
- * @param toolbarId
- * @param sectionToolsId
- * @param actionScopeId
- */
- function GitCommitExplorer(registry, commandService, linkService, selection, parentId, toolbarId, selectionToolsId, actionScopeId) {
- this.parentId = parentId;
- this.registry = registry;
- this.commandService = commandService;
- this.linkService = linkService;
- this.selection = selection;
- this.parentId = parentId;
- this.toolbarId = toolbarId;
- this.selectionToolsId = selectionToolsId;
- this.checkbox = false;
- this.actionScopeId = actionScopeId;
- mExplorer.createExplorerCommands(commandService);
- }
-
- GitCommitExplorer.prototype.handleError = function(error) {
- var display = {};
- display.Severity = "Error"; //$NON-NLS-0$
- display.HTML = false;
- try {
- var resp = JSON.parse(error.responseText);
- display.Message = resp.DetailedMessage ? resp.DetailedMessage : resp.Message;
- } catch (Exception) {
- display.Message = error.message;
- }
- this.registry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$
-
- if (error.status === 404) {
- this.initTitleBar();
- this.displayCommit();
- }
- };
-
- GitCommitExplorer.prototype.changedItem = function(parent, children) {
- this.redisplay();
- };
-
- GitCommitExplorer.prototype.redisplay = function() {
- var pageParams = PageUtil.matchResourceParameters();
- this.display(pageParams.resource);
- };
-
- GitCommitExplorer.prototype.display = function(location) {
- var that = this;
- var progressService = this.registry.getService("orion.page.progress"); //$NON-NLS-0$
-
- progressService
- .showWhile(this.registry.getService("orion.git.provider").getGitClone(location), "Getting repository details").then( //$NON-NLS-0$
- function(resp) {
- if (resp.Children.length === 0) {
- that.initTitleBar();
- that.displayCommit();
- } else if (resp.Children.length === 1 && resp.Children[0].Type === "Commit") { //$NON-NLS-0$
- var commits = resp.Children;
-
- progressService
- .progress(
- that.registry.getService("orion.git.provider").getGitClone(resp.CloneLocation), "Getting repository details " + resp.Name).then( //$NON-NLS-0$
- function(resp) {
- var repositories = resp.Children;
- that.initTitleBar(commits[0], repositories[0]);
- that.displayCommit(commits[0]);
- that.displayTags(commits[0]);
- that.displayDiffs(commits[0]);
-
- commits[0].CloneLocation = repositories[0].Location;
-
- // render commands
- mGitCommands.updateNavTools(that.registry, that.commandService, that, "pageActions", "selectionTools", commits[0]); //$NON-NLS-1$ //$NON-NLS-0$
- }, function(error) {
- that.handleError(error);
- });
- }
- }, function(error) {
- that.handleError(error);
- });
- };
-
- GitCommitExplorer.prototype.initTitleBar = function(commit, repository) {
- var that = this;
- var item = {};
-
- commit.GitUrl = repository.GitUrl;
- commit.ContentLocation = repository.ContentLocation;
-
- if (commit) {
- item = {};
- item.Name = commit.Name;
- item.Parents = [];
- item.Parents[0] = {};
- item.Parents[0].Name = repository.Name;
- item.Parents[0].Location = repository.Location;
- item.Parents[0].ChildrenLocation = repository.Location;
- item.Parents[1] = {};
- item.Parents[1].Name = messages["Repositories"];
- }
- mGlobalCommands.setPageTarget({ task : "Commit",
- target : commit,
- breadcrumbTarget : item,
- makeBreadcrumbLink : function(seg, location) {
- seg.href = require.toUrl("git/git-repository.html") + (location ? "#" + location : ""); //$NON-NLS-0$
- },
- serviceRegistry : that.registry,
- commandService : that.commandService
- });
- };
-
- GitCommitExplorer.prototype.displayCommit = function(commit) {
-
- var tableNode = lib.node('table'); //$NON-NLS-0$
- lib.empty(tableNode);
-
- if (!commit) {
- var titleWrapper = new mSection.Section(tableNode, { id : "commitSection", //$NON-NLS-0$
- title : messages["No Commits"],
- iconClass : "core-sprite-file" //$NON-NLS-0$
- });
- return;
- }
-
- var contentParent = document.createElement("div");
- contentParent.className = "sectionTable";
- tableNode.appendChild(contentParent);
-
- var commitNode = document.createElement("div");
- commitNode.className = "mainPadding";
- commitNode.id = "commitNode";
- contentParent.appendChild(commitNode);
-
- var detailsView = document.createElement("div");
- detailsView.className = "sectionTableItem";
- commitNode.appendChild(detailsView);
-
- var commitMessages = this._splitCommitMessage(commit.Message);
-
- var mainCommitMessage = document.createElement("div");
- mainCommitMessage.style.paddingBottom = "15px";
- this.registry.getService("orion.core.textlink").addLinks(commitMessages[0], mainCommitMessage); //$NON-NLS-0$
- detailsView.appendChild(mainCommitMessage);
-
- if (commitMessages[1] !== null) {
- var secondaryCommitMessage = document.createElement("pre");
- secondaryCommitMessage.style.paddingBottom = "15px";
- secondaryCommitMessage.style.marginTop = "0px";
- this.registry.getService("orion.core.textlink").addLinks(commitMessages[1], secondaryCommitMessage); //$NON-NLS-0$
- detailsView.appendChild(secondaryCommitMessage);
- }
-
- var commitName = document.createElement("div");
- commitName.appendChild(document.createTextNode(i18nUtil.formatMessage(messages["commit: 0"], commit.Name)));
- detailsView.appendChild(commitName);
-
- if (commit.Parents && commit.Parents.length > 0) {
- var parentCommitName = document.createElement("div");
- parentCommitName.style.paddingBottom = "15px";
- var parentCommitLink = document.createElement("a");
- parentCommitLink.className = "pnavlinkonpage";
- parentCommitLink.href = require.toUrl("git/git-commit.html#") + commit.Parents[0].Location + "?page=1&pageSize=1";
- parentCommitLink.textContent = i18nUtil.formatMessage(messages["parent: 0"], commit.Parents[0].Name);
- parentCommitName.appendChild(parentCommitLink);
- detailsView.appendChild(parentCommitName);
- }
-
- if (commit.AuthorImage) {
- var authorImage = document.createElement("div");
- authorImage.style['float'] = "left";
- var image = new Image();
- image.src = commit.AuthorImage;
- image.name = commit.AuthorName;
- image.className = "git-author-icon-small";
- authorImage.appendChild(image);
- detailsView.appendChild(authorImage);
- }
-
- var author = document.createElement("div");
-
- var authorName = document.createElement("div");
- authorName.appendChild(document.createTextNode(i18nUtil.formatMessage(messages["authored by 0 (1) on 2"], commit.AuthorName,
- commit.AuthorEmail, new Date(commit.Time).toLocaleString())));
- author.appendChild(authorName);
-
- var committerName = document.createElement("div");
- committerName.appendChild(document.createTextNode(i18nUtil.formatMessage(messages["committed by 0 (1)"], commit.CommitterName,
- commit.CommitterEmail)));
- author.appendChild(committerName);
-
- detailsView.appendChild(author);
- };
-
- GitCommitExplorer.prototype._splitCommitMessage = function(commitMessage) {
- var cut = false;
- var mainMessageMaxLength = 100;
-
- var commitMessage0 = commitMessage.split(/(\r?\n|$)/)[0].trim();
- if (commitMessage0.length > mainMessageMaxLength) {
- var cutPoint = commitMessage0.indexOf(" ", mainMessageMaxLength - 10); //$NON-NLS-0$
- commitMessage0 = commitMessage0.substring(0, (cutPoint !== -1 ? cutPoint : mainMessageMaxLength));
- cut = true;
- }
- ;
-
- var commitMessage1 = commitMessage.substring(commitMessage0.length + 1, commitMessage.length).trim();
- if (commitMessage1.length > 0) {
- commitMessage1 = (cut ? "..." + commitMessage1 : commitMessage1); //$NON-NLS-0$
- } else {
- commitMessage1 = null;
- }
-
- commitMessage0 += (cut ? "..." : ""); //$NON-NLS-0$
-
- return [ commitMessage0, commitMessage1 ];
- };
-
- // Git tags
-
- GitCommitExplorer.prototype.displayTags = function(commit) {
- var tags = commit.Tags;
-
- var tableNode = lib.node('table'); //$NON-NLS-0$
-
- var titleWrapper = new mSection.Section(tableNode, { id : "tagSection", //$NON-NLS-0$
- title : ((tags && tags.length > 0) ? messages["Tags:"] : messages["No Tags"]),
- iconClass : [ "gitImageSprite", "git-sprite-tag" ], //$NON-NLS-1$ //$NON-NLS-0$
- slideout : true,
- content : '<div id="tagNode"></div>', //$NON-NLS-0$
- canHide : true,
- preferenceService : this.registry.getService("orion.core.preference") //$NON-NLS-0$
- });
-
- this.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.addTag", 100); //$NON-NLS-0$
- this.commandService.renderCommands(titleWrapper.actionsNode.id, titleWrapper.actionsNode, commit, this, "button"); //$NON-NLS-0$
-
- if (!tags && tags.length > 0)
- return;
-
- for ( var i = 0; (i < tags.length && i < 10); i++) {
- this.renderTag(tags[i]);
- }
- };
-
- GitCommitExplorer.prototype.renderTag = function(tag) {
- var tagNode = lib.node("tagNode"); //$NON-NLS-0$
-
- var sectionItem = document.createElement("div");
- sectionItem.className = "sectionTableItem";
- tagNode.appendChild(sectionItem);
-
- var horizontalBox = document.createElement("div");
- horizontalBox.className = "sectionTableItem";
- sectionItem.appendChild(horizontalBox);
-
- var detailsView = document.createElement("div");
- detailsView.className = "stretch";
- horizontalBox.appendChild(detailsView);
-
- var title = document.createElement("span");
- title.textContent = tag.Name;
- detailsView.appendChild(title);
-
- var actionsArea = document.createElement("div");
- actionsArea.className = "sectionTableItemActions";
- horizontalBox.appendChild(actionsArea);
-
- this.commandService.renderCommands(this.actionScopeId, actionsArea, tag, this, "tool", false); //$NON-NLS-0$
- };
-
- // Git diffs
-
- GitCommitExplorer.prototype.displayDiffs = function(commit) {
-
- var that = this;
-
- var diffs = commit.Diffs;
-
- var tableNode = lib.node('table'); //$NON-NLS-0$
-
- var section = new mSection.Section(tableNode, { id : "diffSection", //$NON-NLS-0$
- title : messages["Diffs"],
- content : '<div id="diffNode"></div>', //$NON-NLS-0$
- canHide : true,
- preferenceService : this.registry.getService("orion.core.preference") //$NON-NLS-0$
- });
-
- this.commandService.registerCommandContribution(section.actionsNode.id, "orion.explorer.expandAll", 100); //$NON-NLS-1$ //$NON-NLS-0$
- this.commandService.registerCommandContribution(section.actionsNode.id, "orion.explorer.collapseAll", 200); //$NON-NLS-1$ //$NON-NLS-0$
-
- var sectionItemActionScopeId = "diffSectionItemActionArea"; //$NON-NLS-0$
-
- var DiffModel = (function() {
- function DiffModel() {
- }
-
- DiffModel.prototype = { destroy : function() {
- },
- getRoot : function(onItem) {
- onItem(diffs);
- },
- getChildren : function(parentItem, onComplete) {
- if (parentItem instanceof Array && parentItem.length > 0) {
- onComplete(parentItem);
- } else if (parentItem.Type === "Diff") {
- if (!parentItem.children) {// lazy creation,
- // this is required
- // for selection
- // model to be able
- // to trverse into
- // children
- parentItem.children = [];
- parentItem.children.push({ parent : parentItem,
- DiffLocation : parentItem.DiffLocation
- }); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- }
- onComplete(parentItem.children); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- // onComplete([{parent: parentItem}]);
- // //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- } else {
- onComplete([]);
- }
- },
- getId : function(/* item */item) {
- if (item instanceof Array && item.length > 0) {
- return "diffRoot"; //$NON-NLS-0$
- } else if (item.Type === "Diff") {
- return "diff" + item.DiffLocation; //$NON-NLS-0$
- } else {
- return "diffWidget" + item.DiffLocation; //$NON-NLS-0$
- }
- }
- };
-
- return DiffModel;
- }());
-
- var DiffRenderer = (function() {
- function DiffRenderer(options, explorer) {
- this._init(options);
- this.options = options;
- this.explorer = explorer;
- this.registry = options.registry;
- }
-
- DiffRenderer.prototype = new mExplorer.SelectionRenderer();
-
- DiffRenderer.prototype.getCellElement = function(col_no, item, tableRow) {
- switch (col_no) {
- case 0:
- if (item.Type === "Diff") {
- var td = document.createElement("td"); //$NON-NLS-0$
-
- var div = document.createElement("div"); //$NON-NLS-0$
- div.className = "sectionTableItem"; //$NON-NLS-0$
- td.appendChild(div);
-
- var path = item.OldPath;
- var sprite = "git-sprite-file"; //$NON-NLS-0$
- var tooltip = messages["Diffs"]; //$NON-NLS-0$
- if (item.ChangeType === "ADD") { //$NON-NLS-0$
- path = item.NewPath;
- sprite = "git-sprite-addition"; //$NON-NLS-0$
- tooltip = messages["Addition"]; //$NON-NLS-0$
- } else if (item.ChangeType === "DELETE") { //$NON-NLS-0$
- sprite = "git-sprite-removal"; //$NON-NLS-0$
- tooltip = messages["Deletion"]; //$NON-NLS-0$
- }
-
- this.getExpandImage(tableRow, div);
-
- var icon = document.createElement("span"); //$NON-NLS-0$
- icon.className = sprite;
- icon.classList.add("gitImageSprite");
- icon.commandTooltip = new Tooltip.Tooltip({
- node: icon,
- text: tooltip,
- position: ["above", "below", "right", "left"] //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- });
- div.appendChild(icon);
-
- var itemLabel = document.createElement("span"); //$NON-NLS-0$
- itemLabel.className = "gitMainDescription"; //$NON-NLS-0$
- itemLabel.textContent = path;
- div.appendChild(itemLabel);
-
- return td;
- } else {
- var td = document.createElement("td"); //$NON-NLS-0$
- td.colSpan = 2;
-
- var div = document.createElement("div"); //$NON-NLS-0$
- div.className = "sectionTableItem"; //$NON-NLS-0$
- td.appendChild(div);
-
- var actionsWrapper = document.createElement("div"); //$NON-NLS-0$
- actionsWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
- div.appendChild(actionsWrapper);
-
- var diffActionWrapper = document.createElement("span"); //$NON-NLS-0$
- diffActionWrapper.id = "diff" + item.parent.DiffLocation + "DiffActionWrapper"; //$NON-NLS-0$
- actionsWrapper.appendChild(diffActionWrapper);
-
- var compareWidgetActionWrapper = document.createElement("span"); //$NON-NLS-0$
- compareWidgetActionWrapper.id = "diff" + item.parent.DiffLocation + "CompareWidgetActionWrapper"; //$NON-NLS-0$
- actionsWrapper.appendChild(compareWidgetActionWrapper);
-
- var diffContainer = document.createElement("div"); //$NON-NLS-0$
- diffContainer.id = "diffArea_" + item.parent.DiffLocation; //$NON-NLS-0$
- diffContainer.style.height = "420px";
- diffContainer.style.border = "1px solid lightgray";
- diffContainer.style.overflow = "hidden";
- div.appendChild(diffContainer);
-
- var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
- window.setTimeout(function() {
- mGitUtil.createCompareWidget(that.registry,
- that.commandService,
- item.parent.DiffLocation,
- false,
- "diffArea_" + item.parent.DiffLocation, //$NON-NLS-0$
- compareWidgetActionWrapper.id,
- false, //editableInComparePage
- {
- navGridHolder : navGridHolder,
- additionalCmdRender : function(gridHolder) {
- that.commandService.destroy(diffActionWrapper.id);
- that.commandService.renderCommands(
- "itemLevelCommands", diffActionWrapper.id, item.parent, that, "tool", false, gridHolder); //$NON-NLS-0$
- },
- before : true
- }
- );
- }, 500);
- return td;
- }
- break;
- }
- };
-
- return DiffRenderer;
- }());
-
- var DiffNavigator = (function() {
- function DiffNavigator(registry, selection, parentId, actionScopeId) {
- this.registry = registry;
- this.checkbox = false;
- this.parentId = parentId;
- this.selection = selection;
- this.actionScopeId = actionScopeId;
- this.renderer = new DiffRenderer({ registry : this.registry,
- actionScopeId : sectionItemActionScopeId,
- cachePrefix : "DiffNavigator", checkbox : false}, this); //$NON-NLS-0$
- this.createTree(this.parentId, new DiffModel(), {/*
- * selectionPolicy:
- * "cursorOnly"
- */});
- }
-
- DiffNavigator.prototype = new mExplorer.Explorer();
-
- // provide to the selection model that if a row is
- // selectable
- DiffNavigator.prototype.isRowSelectable = function(modelItem) {
- return false;
- };
- // provide to the expandAll/collapseAll commands
- DiffNavigator.prototype.getItemCount = function() {
- return diffs.length;
- };
-
- return DiffNavigator;
- }());
-
- var diffnavigator = new DiffNavigator(this.registry, null, "diffNode", sectionItemActionScopeId); //$NON-NLS-0$
- this.commandService.renderCommands(section.actionsNode.id, section.actionsNode.id, diffnavigator, diffnavigator, "button"); //$NON-NLS-0$
- };
-
- return GitCommitExplorer;
- }());
-
- return exports;
- }); // end of define
+/*******************************************************************************
+ * @license Copyright (c) 2011, 2013 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 window console document Image */
+
+define(
+ [ 'require', 'i18n!git/nls/gitmessages', 'orion/section', 'orion/explorers/explorer', 'orion/PageUtil', 'orion/i18nUtil', 'orion/webui/littlelib',
+ 'orion/globalCommands', 'orion/git/gitCommands', 'orion/git/util', 'orion/Deferred', 'orion/webui/tooltip' ],
+ function(require, messages, mSection, mExplorer, PageUtil, i18nUtil, lib, mGlobalCommands, mGitCommands, mGitUtil, Deferred, Tooltip) {
+ var exports = {};
+
+ exports.GitCommitExplorer = (function() {
+
+ /**
+ * Creates a new Git commit explorer.
+ *
+ * @class Git commit explorer
+ * @name orion.git.GitCommitExplorer
+ * @param registry
+ * @param commandService
+ * @param linkService
+ * @param selection
+ * @param parentId
+ * @param toolbarId
+ * @param sectionToolsId
+ * @param actionScopeId
+ */
+ function GitCommitExplorer(registry, commandService, linkService, selection, parentId, toolbarId, selectionToolsId, actionScopeId) {
+ this.parentId = parentId;
+ this.registry = registry;
+ this.commandService = commandService;
+ this.linkService = linkService;
+ this.selection = selection;
+ this.parentId = parentId;
+ this.toolbarId = toolbarId;
+ this.selectionToolsId = selectionToolsId;
+ this.checkbox = false;
+ this.actionScopeId = actionScopeId;
+ mExplorer.createExplorerCommands(commandService);
+ }
+
+ GitCommitExplorer.prototype.handleError = function(error) {
+ var display = {};
+ display.Severity = "Error"; //$NON-NLS-0$
+ display.HTML = false;
+ try {
+ var resp = JSON.parse(error.responseText);
+ display.Message = resp.DetailedMessage ? resp.DetailedMessage : resp.Message;
+ } catch (Exception) {
+ display.Message = error.message;
+ }
+ this.registry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$
+
+ if (error.status === 404) {
+ this.initTitleBar();
+ this.displayCommit();
+ }
+ };
+
+ GitCommitExplorer.prototype.changedItem = function(parent, children) {
+ this.redisplay();
+ };
+
+ GitCommitExplorer.prototype.redisplay = function() {
+ var pageParams = PageUtil.matchResourceParameters();
+ this.display(pageParams.resource);
+ };
+
+ GitCommitExplorer.prototype.display = function(location) {
+ var that = this;
+ var progressService = this.registry.getService("orion.page.progress"); //$NON-NLS-0$
+
+ progressService
+ .showWhile(this.registry.getService("orion.git.provider").getGitClone(location), "Getting repository details").then( //$NON-NLS-0$
+ function(resp) {
+ if (resp.Children.length === 0) {
+ that.initTitleBar();
+ that.displayCommit();
+ } else if (resp.Children.length === 1 && resp.Children[0].Type === "Commit") { //$NON-NLS-0$
+ var commits = resp.Children;
+
+ progressService
+ .progress(
+ that.registry.getService("orion.git.provider").getGitClone(resp.CloneLocation), "Getting repository details " + resp.Name).then( //$NON-NLS-0$
+ function(resp) {
+ var repositories = resp.Children;
+ that.initTitleBar(commits[0], repositories[0]);
+ that.displayCommit(commits[0]);
+ that.displayTags(commits[0]);
+ that.displayDiffs(commits[0]);
+
+ commits[0].CloneLocation = repositories[0].Location;
+
+ // render commands
+ mGitCommands.updateNavTools(that.registry, that.commandService, that, "pageActions", "selectionTools", commits[0]); //$NON-NLS-1$ //$NON-NLS-0$
+ }, function(error) {
+ that.handleError(error);
+ });
+ }
+ }, function(error) {
+ that.handleError(error);
+ });
+ };
+
+ GitCommitExplorer.prototype.initTitleBar = function(commit, repository) {
+ var that = this;
+ var item = {};
+
+ commit.GitUrl = repository.GitUrl;
+ commit.ContentLocation = repository.ContentLocation;
+
+ if (commit) {
+ item = {};
+ item.Name = commit.Name;
+ item.Parents = [];
+ item.Parents[0] = {};
+ item.Parents[0].Name = repository.Name;
+ item.Parents[0].Location = repository.Location;
+ item.Parents[0].ChildrenLocation = repository.Location;
+ item.Parents[1] = {};
+ item.Parents[1].Name = messages["Repositories"];
+ }
+ mGlobalCommands.setPageTarget({ task : "Commit",
+ target : commit,
+ breadcrumbTarget : item,
+ makeBreadcrumbLink : function(seg, location) {
+ seg.href = require.toUrl("git/git-repository.html") + (location ? "#" + location : ""); //$NON-NLS-0$
+ },
+ serviceRegistry : that.registry,
+ commandService : that.commandService
+ });
+ };
+
+ GitCommitExplorer.prototype.displayCommit = function(commit) {
+
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+ lib.empty(tableNode);
+
+ if (!commit) {
+ var titleWrapper = new mSection.Section(tableNode, { id : "commitSection", //$NON-NLS-0$
+ title : messages["No Commits"],
+ iconClass : "core-sprite-file" //$NON-NLS-0$
+ });
+ return;
+ }
+
+ var contentParent = document.createElement("div");
+ contentParent.className = "sectionTable";
+ tableNode.appendChild(contentParent);
+
+ var commitNode = document.createElement("div");
+ commitNode.className = "mainPadding";
+ commitNode.id = "commitNode";
+ contentParent.appendChild(commitNode);
+
+ var detailsView = document.createElement("div");
+ detailsView.className = "sectionTableItem";
+ commitNode.appendChild(detailsView);
+
+ var commitMessages = this._splitCommitMessage(commit.Message);
+
+ var mainCommitMessage = document.createElement("div");
+ mainCommitMessage.style.paddingBottom = "15px";
+ this.registry.getService("orion.core.textlink").addLinks(commitMessages[0], mainCommitMessage); //$NON-NLS-0$
+ detailsView.appendChild(mainCommitMessage);
+
+ if (commitMessages[1] !== null) {
+ var secondaryCommitMessage = document.createElement("pre");
+ secondaryCommitMessage.style.paddingBottom = "15px";
+ secondaryCommitMessage.style.marginTop = "0px";
+ this.registry.getService("orion.core.textlink").addLinks(commitMessages[1], secondaryCommitMessage); //$NON-NLS-0$
+ detailsView.appendChild(secondaryCommitMessage);
+ }
+
+ var commitName = document.createElement("div");
+ commitName.appendChild(document.createTextNode(i18nUtil.formatMessage(messages["commit: 0"], commit.Name)));
+ detailsView.appendChild(commitName);
+
+ if (commit.Parents && commit.Parents.length > 0) {
+ var parentCommitName = document.createElement("div");
+ parentCommitName.style.paddingBottom = "15px";
+ var parentCommitLink = document.createElement("a");
+ parentCommitLink.className = "pnavlinkonpage";
+ parentCommitLink.href = require.toUrl("git/git-commit.html#") + commit.Parents[0].Location + "?page=1&pageSize=1";
+ parentCommitLink.textContent = i18nUtil.formatMessage(messages["parent: 0"], commit.Parents[0].Name);
+ parentCommitName.appendChild(parentCommitLink);
+ detailsView.appendChild(parentCommitName);
+ }
+
+ if (commit.AuthorImage) {
+ var authorImage = document.createElement("div");
+ authorImage.style['float'] = "left";
+ var image = new Image();
+ image.src = commit.AuthorImage;
+ image.name = commit.AuthorName;
+ image.className = "git-author-icon-small";
+ authorImage.appendChild(image);
+ detailsView.appendChild(authorImage);
+ }
+
+ var author = document.createElement("div");
+
+ var authorName = document.createElement("div");
+ authorName.appendChild(document.createTextNode(i18nUtil.formatMessage(messages["authored by 0 (1) on 2"], commit.AuthorName,
+ commit.AuthorEmail, new Date(commit.Time).toLocaleString())));
+ author.appendChild(authorName);
+
+ var committerName = document.createElement("div");
+ committerName.appendChild(document.createTextNode(i18nUtil.formatMessage(messages["committed by 0 (1)"], commit.CommitterName,
+ commit.CommitterEmail)));
+ author.appendChild(committerName);
+
+ detailsView.appendChild(author);
+ };
+
+ GitCommitExplorer.prototype._splitCommitMessage = function(commitMessage) {
+ var cut = false;
+ var mainMessageMaxLength = 100;
+
+ var commitMessage0 = commitMessage.split(/(\r?\n|$)/)[0].trim();
+ if (commitMessage0.length > mainMessageMaxLength) {
+ var cutPoint = commitMessage0.indexOf(" ", mainMessageMaxLength - 10); //$NON-NLS-0$
+ commitMessage0 = commitMessage0.substring(0, (cutPoint !== -1 ? cutPoint : mainMessageMaxLength));
+ cut = true;
+ }
+ ;
+
+ var commitMessage1 = commitMessage.substring(commitMessage0.length + 1, commitMessage.length).trim();
+ if (commitMessage1.length > 0) {
+ commitMessage1 = (cut ? "..." + commitMessage1 : commitMessage1); //$NON-NLS-0$
+ } else {
+ commitMessage1 = null;
+ }
+
+ commitMessage0 += (cut ? "..." : ""); //$NON-NLS-0$
+
+ return [ commitMessage0, commitMessage1 ];
+ };
+
+ // Git tags
+
+ GitCommitExplorer.prototype.displayTags = function(commit) {
+ var tags = commit.Tags;
+
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+
+ var titleWrapper = new mSection.Section(tableNode, { id : "tagSection", //$NON-NLS-0$
+ title : ((tags && tags.length > 0) ? messages["Tags:"] : messages["No Tags"]),
+ iconClass : [ "gitImageSprite", "git-sprite-tag" ], //$NON-NLS-1$ //$NON-NLS-0$
+ slideout : true,
+ content : '<div id="tagNode"></div>', //$NON-NLS-0$
+ canHide : true,
+ preferenceService : this.registry.getService("orion.core.preference") //$NON-NLS-0$
+ });
+
+ this.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.addTag", 100); //$NON-NLS-0$
+ this.commandService.renderCommands(titleWrapper.actionsNode.id, titleWrapper.actionsNode, commit, this, "button"); //$NON-NLS-0$
+
+ if (!tags && tags.length > 0)
+ return;
+
+ for ( var i = 0; (i < tags.length && i < 10); i++) {
+ this.renderTag(tags[i]);
+ }
+ };
+
+ GitCommitExplorer.prototype.renderTag = function(tag) {
+ var tagNode = lib.node("tagNode"); //$NON-NLS-0$
+
+ var sectionItem = document.createElement("div");
+ sectionItem.className = "sectionTableItem";
+ tagNode.appendChild(sectionItem);
+
+ var horizontalBox = document.createElement("div");
+ horizontalBox.className = "sectionTableItem";
+ sectionItem.appendChild(horizontalBox);
+
+ var detailsView = document.createElement("div");
+ detailsView.className = "stretch";
+ horizontalBox.appendChild(detailsView);
+
+ var title = document.createElement("span");
+ title.textContent = tag.Name;
+ detailsView.appendChild(title);
+
+ var actionsArea = document.createElement("div");
+ actionsArea.className = "sectionTableItemActions";
+ horizontalBox.appendChild(actionsArea);
+
+ this.commandService.renderCommands(this.actionScopeId, actionsArea, tag, this, "tool", false); //$NON-NLS-0$
+ };
+
+ // Git diffs
+
+ GitCommitExplorer.prototype.displayDiffs = function(commit) {
+
+ var that = this;
+
+ var diffs = commit.Diffs;
+
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+
+ var section = new mSection.Section(tableNode, { id : "diffSection", //$NON-NLS-0$
+ title : messages["Diffs"],
+ content : '<div id="diffNode"></div>', //$NON-NLS-0$
+ canHide : true,
+ preferenceService : this.registry.getService("orion.core.preference") //$NON-NLS-0$
+ });
+
+ this.commandService.registerCommandContribution(section.actionsNode.id, "orion.explorer.expandAll", 100); //$NON-NLS-1$ //$NON-NLS-0$
+ this.commandService.registerCommandContribution(section.actionsNode.id, "orion.explorer.collapseAll", 200); //$NON-NLS-1$ //$NON-NLS-0$
+
+ var sectionItemActionScopeId = "diffSectionItemActionArea"; //$NON-NLS-0$
+
+ var DiffModel = (function() {
+ function DiffModel() {
+ }
+
+ DiffModel.prototype = { destroy : function() {
+ },
+ getRoot : function(onItem) {
+ onItem(diffs);
+ },
+ getChildren : function(parentItem, onComplete) {
+ if (parentItem instanceof Array && parentItem.length > 0) {
+ onComplete(parentItem);
+ } else if (parentItem.Type === "Diff") {
+ if (!parentItem.children) {// lazy creation,
+ // this is required
+ // for selection
+ // model to be able
+ // to trverse into
+ // children
+ parentItem.children = [];
+ parentItem.children.push({ parent : parentItem,
+ DiffLocation : parentItem.DiffLocation
+ }); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ onComplete(parentItem.children); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ // onComplete([{parent: parentItem}]);
+ // //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ } else {
+ onComplete([]);
+ }
+ },
+ getId : function(/* item */item) {
+ if (item instanceof Array && item.length > 0) {
+ return "diffRoot"; //$NON-NLS-0$
+ } else if (item.Type === "Diff") {
+ return "diff" + item.DiffLocation; //$NON-NLS-0$
+ } else {
+ return "diffWidget" + item.DiffLocation; //$NON-NLS-0$
+ }
+ }
+ };
+
+ return DiffModel;
+ }());
+
+ var DiffRenderer = (function() {
+ function DiffRenderer(options, explorer) {
+ this._init(options);
+ this.options = options;
+ this.explorer = explorer;
+ this.registry = options.registry;
+ }
+
+ DiffRenderer.prototype = new mExplorer.SelectionRenderer();
+
+ DiffRenderer.prototype.getCellElement = function(col_no, item, tableRow) {
+ switch (col_no) {
+ case 0:
+ if (item.Type === "Diff") {
+ var td = document.createElement("td"); //$NON-NLS-0$
+
+ var div = document.createElement("div"); //$NON-NLS-0$
+ div.className = "sectionTableItem"; //$NON-NLS-0$
+ td.appendChild(div);
+
+ var path = item.OldPath;
+ var sprite = "git-sprite-file"; //$NON-NLS-0$
+ var tooltip = messages["Diffs"]; //$NON-NLS-0$
+ if (item.ChangeType === "ADD") { //$NON-NLS-0$
+ path = item.NewPath;
+ sprite = "git-sprite-addition"; //$NON-NLS-0$
+ tooltip = messages["Addition"]; //$NON-NLS-0$
+ } else if (item.ChangeType === "DELETE") { //$NON-NLS-0$
+ sprite = "git-sprite-removal"; //$NON-NLS-0$
+ tooltip = messages["Deletion"]; //$NON-NLS-0$
+ }
+
+ this.getExpandImage(tableRow, div);
+
+ var icon = document.createElement("span"); //$NON-NLS-0$
+ icon.className = sprite;
+ icon.classList.add("gitImageSprite");
+ icon.commandTooltip = new Tooltip.Tooltip({
+ node: icon,
+ text: tooltip,
+ position: ["above", "below", "right", "left"] //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ });
+ div.appendChild(icon);
+
+ var itemLabel = document.createElement("span"); //$NON-NLS-0$
+ itemLabel.className = "gitMainDescription"; //$NON-NLS-0$
+ itemLabel.textContent = path;
+ div.appendChild(itemLabel);
+
+ return td;
+ } else {
+ var td = document.createElement("td"); //$NON-NLS-0$
+ td.colSpan = 2;
+
+ var div = document.createElement("div"); //$NON-NLS-0$
+ div.className = "sectionTableItem"; //$NON-NLS-0$
+ td.appendChild(div);
+
+ var actionsWrapper = document.createElement("div"); //$NON-NLS-0$
+ actionsWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
+ div.appendChild(actionsWrapper);
+
+ var diffActionWrapper = document.createElement("span"); //$NON-NLS-0$
+ diffActionWrapper.id = "diff" + item.parent.DiffLocation + "DiffActionWrapper"; //$NON-NLS-0$
+ actionsWrapper.appendChild(diffActionWrapper);
+
+ var compareWidgetActionWrapper = document.createElement("span"); //$NON-NLS-0$
+ compareWidgetActionWrapper.id = "diff" + item.parent.DiffLocation + "CompareWidgetActionWrapper"; //$NON-NLS-0$
+ actionsWrapper.appendChild(compareWidgetActionWrapper);
+
+ var diffContainer = document.createElement("div"); //$NON-NLS-0$
+ diffContainer.id = "diffArea_" + item.parent.DiffLocation; //$NON-NLS-0$
+ diffContainer.style.height = "420px";
+ diffContainer.style.border = "1px solid lightgray";
+ diffContainer.style.overflow = "hidden";
+ div.appendChild(diffContainer);
+
+ var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
+
+ mGitUtil.createCompareWidget(
+ that.registry,
+ that.commandService,
+ item.parent.DiffLocation,
+ false,
+ diffContainer,
+ compareWidgetActionWrapper.id,
+ false, //editableInComparePage
+ {
+ navGridHolder : navGridHolder,
+ additionalCmdRender : function(gridHolder) {
+ that.commandService.destroy(diffActionWrapper.id);
+ that.commandService.renderCommands(
+ "itemLevelCommands", diffActionWrapper.id, item.parent, that, "tool", false, gridHolder); //$NON-NLS-0$
+ },
+ before : true
+ }
+ );
+
+ return td;
+ }
+ break;
+ }
+ };
+
+ return DiffRenderer;
+ }());
+
+ var DiffNavigator = (function() {
+ function DiffNavigator(registry, selection, parentId, actionScopeId) {
+ this.registry = registry;
+ this.checkbox = false;
+ this.parentId = parentId;
+ this.selection = selection;
+ this.actionScopeId = actionScopeId;
+ this.renderer = new DiffRenderer({ registry : this.registry,
+ actionScopeId : sectionItemActionScopeId,
+ cachePrefix : "DiffNavigator", checkbox : false}, this); //$NON-NLS-0$
+ this.createTree(this.parentId, new DiffModel(), {/*
+ * selectionPolicy:
+ * "cursorOnly"
+ */});
+ }
+
+ DiffNavigator.prototype = new mExplorer.Explorer();
+
+ // provide to the selection model that if a row is
+ // selectable
+ DiffNavigator.prototype.isRowSelectable = function(modelItem) {
+ return false;
+ };
+ // provide to the expandAll/collapseAll commands
+ DiffNavigator.prototype.getItemCount = function() {
+ return diffs.length;
+ };
+
+ return DiffNavigator;
+ }());
+
+ var diffnavigator = new DiffNavigator(this.registry, null, "diffNode", sectionItemActionScopeId); //$NON-NLS-0$
+ this.commandService.renderCommands(section.actionsNode.id, section.actionsNode.id, diffnavigator, diffnavigator, "button"); //$NON-NLS-0$
+ };
+
+ return GitCommitExplorer;
+ }());
+
+ return exports;
+ }); // end of define
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitStatusExplorer.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitStatusExplorer.js
index aafddd0..9286c31 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitStatusExplorer.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitStatusExplorer.js
@@ -1,949 +1,943 @@
-/*******************************************************************************
- * @license Copyright (c) 2012, 2013 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 Image*/
-define(['require', 'i18n!git/nls/gitmessages', 'orion/explorers/explorer', 'orion/selection', 'orion/section', 'orion/PageUtil', 'orion/webui/littlelib',
- 'orion/i18nUtil', 'orion/globalCommands', 'orion/git/util', 'orion/git/gitCommands', 'orion/Deferred', 'orion/git/widgets/CommitTooltipDialog',
- 'orion/webui/tooltip'],
- function(require, messages, mExplorer, mSelection, mSection, PageUtil, lib, i18nUtil, mGlobalCommands, mGitUtil, mGitCommands,
- Deferred, mCommitTooltip, Tooltip) {
-
- var exports = {};
- var conflictTypeStr = "Conflicting"; //$NON-NLS-0$
-
- function isConflict(type) {
- return type === conflictTypeStr;
- }
-
- var GitStatusModel = (function() {
- function GitStatusModel() {
- this.selectedFileId = undefined;
- this.selectedItem = undefined;
- this.interestedUnstagedGroup = [ "Missing", "Modified", "Untracked", "Conflicting" ]; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- this.interestedStagedGroup = [ "Added", "Changed", "Removed" ]; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- this.conflictPatterns = [
- [ "Both", "Modified", "Added", "Changed", "Missing" ], [ "RemoteDelete", "Untracked", "Removed" ], [ "LocalDelete", "Modified", "Added", "Missing" ] ]; //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- this.conflictType = "Conflicting"; //$NON-NLS-0$
-
- this.statusTypeMap = {
- "Missing" : { imageClass: "gitImageSprite git-sprite-removal", tooltip: messages['Unstaged removal'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- "Removed" : { imageClass: "gitImageSprite git-sprite-removal", tooltip: messages['Staged removal'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- "Modified" : { imageClass: "gitImageSprite git-sprite-file", tooltip: messages['Unstaged change'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- "Changed" : { imageClass: "gitImageSprite git-sprite-file", tooltip: messages['Staged change'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- "Untracked" : { imageClass: "gitImageSprite git-sprite-addition", tooltip: messages["Unstaged addition"] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- "Added" : { imageClass: "gitImageSprite git-sprite-addition", tooltip: messages["Staged addition"] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- "Conflicting" : { imageClass: "gitImageSprite git-sprite-conflict-file", tooltip: messages['Conflicting'] } //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- };
- }
-
- GitStatusModel.prototype = {
- destroy: function() {},
-
- interestedCategory: function() {},
-
- init: function(jsonData) {
- this.items = jsonData;
- },
-
- getModelType: function(groupItem, groupName) {
- return groupName;
- },
-
- _markConflict: function(conflictPattern) {
- // if git status server API response a file with "Modified"
- // ,"Added", "Changed","Missing" states , we treat it as a
- // conflicting file
- // And we add additional attribute to that groupItem :
- // groupItem.Conflicting = true;
- var baseGroup = this.getGroupData(conflictPattern[1]);
- if (!baseGroup)
- return;
- for (var i = 0; i < baseGroup.length; i++) {
- if (baseGroup[i].Conflicting)
- continue;
- var fileLocation = baseGroup[i].Location;
- var itemsInDetectGroup = [];
-
- for (var j = 2; j < conflictPattern.length; j++) {
- var groupName = conflictPattern[j];
- var groupData = this.getGroupData(groupName);
- if (!groupData)
- continue;
- var item = this._findSameFile(fileLocation, groupData);
- if (item) {
- itemsInDetectGroup.push(item);
- } else {
- continue;
- }
- }
-
- // we have the same file at "Modified" ,"Added",
- // "Changed","Missing" groups
- if (itemsInDetectGroup.length === (conflictPattern.length - 2)) {
- baseGroup[i].Conflicting = conflictPattern[0];
- for (var k = 0; k < itemsInDetectGroup.length; k++) {
- itemsInDetectGroup[k].Conflicting = "Hide"; //$NON-NLS-0$
- }
- }
- }
- },
-
- _findSameFile: function(fileLocation, groupData) {
- for (var j = 0; j < groupData.length; j++) {
- if (groupData[j].Conflicting)
- continue;
- if (fileLocation === groupData[j].Location)
- return groupData[j];
- }
- return undefined;
- },
-
- getGroupData: function(groupName) {
- return this.items[groupName];
- },
-
- isStaged: function(type) {
- for (var i = 0; i < this.interestedStagedGroup.length; i++) {
- if (type === this.interestedStagedGroup[i]) {
- return true;
- }
- }
- return false;
- },
-
- getClass: function(type) {
- return this.statusTypeMap[type].imageClass;
- },
-
- getTooltip: function(type) {
- return this.statusTypeMap[type].tooltip;
- }
- };
-
- return GitStatusModel;
- }());
-
- exports.GitStatusExplorer = (function() {
- /**
- * Creates a new Git status explorer.
- *
- * @class Git status explorer
- * @name orion.git.GitStatusExplorer
- * @param registry
- * @param commandService
- * @param linkService
- * @param selection
- * @param parentId
- * @param toolbarId
- * @param selectionToolsId
- * @param actionScopeId
- */
- function GitStatusExplorer(registry, commandService, linkService, selection, parentId, toolbarId, selectionToolsId, actionScopeId) {
- this.parentId = parentId;
- this.registry = registry;
- this.commandService = commandService;
- this.linkService = linkService;
- this.selection = selection;
- this.parentId = parentId;
- this.toolbarId = toolbarId;
- this.selectionToolsId = selectionToolsId;
- this.checkbox = false;
- this.actionScopeId = actionScopeId;
- mExplorer.createExplorerCommands(commandService);
- }
-
- GitStatusExplorer.prototype.handleError = function(error) {
- var display = {};
- display.Severity = "Error"; //$NON-NLS-0$
- display.HTML = false;
- try {
- var resp = JSON.parse(error.responseText);
- display.Message = resp.DetailedMessage ? resp.DetailedMessage : resp.Message;
- } catch (Exception) {
- display.Message = error.message;
- }
- this.registry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$
-
- if (error.status === 404) {
- this.initTitleBar();
- this.displayCommit();
- }
- };
-
- GitStatusExplorer.prototype.changedItem = function(parent, children) {
- this.redisplay();
- };
-
- GitStatusExplorer.prototype.redisplay = function() {
- var pageParams = PageUtil.matchResourceParameters();
- this.display(pageParams.resource);
- };
-
- GitStatusExplorer.prototype.display = function(location) {
- var that = this;
- var progressService = this.registry.getService("orion.page.progress"); //$NON-NLS-0$
-
- progressService
- .progress(this.registry.getService("orion.git.provider").getGitStatus(location), messages['Loading...']).then( //$NON-NLS-0$
- function(resp) {
- if (resp.Type === "Status") { //$NON-NLS-0$
- var status = resp;
- that._model = new GitStatusModel();
- that._model.init(status);
-
- progressService
- .progress(
- that.registry.getService("orion.git.provider").getGitClone(status.CloneLocation), "Getting repository information").then( //$NON-NLS-0$
- function(resp) {
- var repositories = resp.Children;
-
- progressService
- .progress(
- that.registry
- .getService("orion.git.provider").getGitCloneConfig(repositories[0].ConfigLocation), "Getting repository configuration ", repositories[0].Name).then( //$NON-NLS-0$
- function(resp) {
- var config = resp.Children;
-
- status.Clone = repositories[0];
- status.Clone.Config = [];
-
- for (var i = 0; i < config.length; i++) {
- if (config[i].Key === "user.name" || config[i].Key === "user.email") //$NON-NLS-1$ //$NON-NLS-0$
- status.Clone.Config.push(config[i]);
- }
-
- var tableNode = lib.node('table'); //$NON-NLS-0$
- lib.empty(tableNode);
- that.initTitleBar(status, repositories[0]);
- that.displayUnstaged(status, repositories[0]);
- that.displayStaged(status, repositories[0]);
- that.displayCommits(repositories[0]);
-
- // render
- // commands
- mGitCommands.updateNavTools(that.registry, that.commandService, that,
- "pageActions", "selectionTools", status); //$NON-NLS-1$ //$NON-NLS-0$
- }, function(error) {
- that.handleError(error);
- });
- }, function(error) {
- that.handleError(error);
- });
- }
- }, function(error) {
- that.handleError(error);
- });
- };
-
- GitStatusExplorer.prototype.initTitleBar = function(status, repository) {
- var item = {};
-
- // TODO add info about branch or detached
- item.Name = messages["Status"] + ((status.RepositoryState && status.RepositoryState.indexOf("REBASING") !== -1) ? messages[" (Rebase in Progress)"] : ""); //$NON-NLS-1$
- item.Parents = [];
- item.Parents[0] = {};
- item.Parents[0].Name = repository.Name;
- item.Parents[0].Location = repository.Location;
- item.Parents[0].ChildrenLocation = repository.Location;
- item.Parents[1] = {};
- item.Parents[1].Name = "Repositories"; //$NON-NLS-0$
-
- mGlobalCommands.setPageTarget({
- task : messages["Status"],
- target : repository,
- breadcrumbTarget : item,
- makeBreadcrumbLink : function(seg, location) {
- seg.href = require.toUrl("git/git-repository.html") + (location ? "#" + location : ""); //$NON-NLS-0$
- },
- serviceRegistry : this.registry,
- commandService : this.commandService
- });
- };
-
- // helpers
-
- GitStatusExplorer.prototype._sortBlock = function(interestedGroup) {
- var retValue = [];
- for (var i = 0; i < interestedGroup.length; i++) {
- var groupName = interestedGroup[i];
- var groupData = this._model.getGroupData(groupName);
- if (!groupData)
- continue;
- for (var j = 0; j < groupData.length; j++) {
- var renderType = this._model.getModelType(groupData[j], groupName);
- if (renderType) {
- retValue.push({
- name : groupData[j].Name,
- type : renderType,
- location : groupData[j].Location,
- path : groupData[j].Path,
- commitURI : groupData[j].Git.CommitLocation,
- indexURI : groupData[j].Git.IndexLocation,
- diffURI : groupData[j].Git.DiffLocation,
- CloneLocation : this._model.items.CloneLocation,
- conflicting : isConflict(renderType)
- });
- }
- }
- }
- retValue.sort(function(a, b) {
- var n1 = a.name && a.name.toLowerCase();
- var n2 = b.name && b.name.toLowerCase();
- if (n1 < n2) {
- return -1;
- }
- if (n1 > n2) {
- return 1;
- }
- return 0;
- });
- return retValue;
- };
-
- // Git unstaged changes
-
- GitStatusExplorer.prototype.displayUnstaged = function(status, repository) {
- var that = this;
- var unstagedSortedChanges = this._sortBlock(this._model.interestedUnstagedGroup);
- var tableNode = lib.node('table'); //$NON-NLS-0$
- var unstagedSection = new mSection.Section(tableNode, {
- id : "unstagedSection", //$NON-NLS-0$
- title : unstagedSortedChanges.length > 0 ? messages['Unstaged'] : messages["No Unstaged Changes"],
- content : '<div id="unstagedNode"></div>', //$NON-NLS-0$
- canHide : true,
- onExpandCollapse : function(isExpanded, section) {
- that.commandService.destroy(section.selectionNode);
- if (isExpanded) {
- that.commandService.renderCommands(section.selectionNode.id, section.selectionNode, null, that, "button", { "Clone" : repository}); //$NON-NLS-1$ //$NON-NLS-0$
- }
- }
- });
-
- this.commandService.registerCommandContribution(unstagedSection.actionsNode.id, "orion.explorer.expandAll", 200); //$NON-NLS-1$ //$NON-NLS-0$
- this.commandService.registerCommandContribution(unstagedSection.actionsNode.id, "orion.explorer.collapseAll", 300); //$NON-NLS-1$ //$NON-NLS-0$
-
- this.commandService.registerCommandContribution(unstagedSection.selectionNode.id, "eclipse.orion.git.showPatchCommand", 100); //$NON-NLS-0$
- this.commandService.registerCommandContribution(unstagedSection.selectionNode.id, "eclipse.orion.git.stageCommand", 200); //$NON-NLS-0$
- this.commandService.registerCommandContribution(unstagedSection.selectionNode.id, "eclipse.orion.git.checkoutCommand", 300); //$NON-NLS-0$
-
- if (!this.unstagedOnce) {
- if (!this.unstagedSelection) {
- this.unstagedSelection = new mSelection.Selection(this.registry, "orion.unstagedSection.selection"); //$NON-NLS-0$
- this.commandService.registerSelectionService(unstagedSection.selectionNode.id, this.unstagedSelection);
- }
-
- this.registry.getService("orion.unstagedSection.selection").addEventListener("selectionChanged", function(event) { //$NON-NLS-1$ //$NON-NLS-0$
- var selectionTools = lib.node(unstagedSection.selectionNode.id);
- if (selectionTools) {
- that.commandService.destroy(selectionTools);
- that.commandService.renderCommands(unstagedSection.selectionNode.id, selectionTools, event.selections, that,
- "button", { "Clone" : repository }); //$NON-NLS-1$ //$NON-NLS-0$
- }
- });
- this.unstagedOnce = true;
- }
-
- this.commandService.registerCommandContribution("DefaultActionWrapper", "eclipse.orion.git.stageCommand", 100); //$NON-NLS-1$ //$NON-NLS-0$
-
- var UnstagedModel = (function() {
- function UnstagedModel() {}
-
- UnstagedModel.prototype = {
- destroy : function() {},
-
- getRoot : function(onItem) {
- onItem(unstagedSortedChanges);
- },
-
- getChildren : function(parentItem, onComplete) {
- if (parentItem instanceof Array && parentItem.length > 0) {
- onComplete(parentItem);
- } else if (mGitUtil.isChange(parentItem)) {
- if (!parentItem.children) {// lazy creation,
- // this is required
- // for selection
- // model to be able
- // to traverse into
- // children
- parentItem.children = [];
- parentItem.children.push({ "diffUri" : parentItem.diffURI, "Type" : "Diff", parent : parentItem}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- }
- onComplete(parentItem.children); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- } else {
- onComplete([]);
- }
- },
-
- getId : function(/* item */item) {
- if (item instanceof Array && item.length > 0) {
- return "unstagedRoot"; //$NON-NLS-0$
- } else if (mGitUtil.isChange(item)) {
- return "unstaged" + item.name; //$NON-NLS-0$
- } else {
- return "unstaged" + item.diffUri; //$NON-NLS-0$
- }
- }
- };
-
- return UnstagedModel;
- }());
-
- var UnstagedRenderer = (function() {
- function UnstagedRenderer(options, explorer) {
- this._init(options);
- this.options = options;
- this.explorer = explorer;
- this.registry = options.registry;
- }
-
- UnstagedRenderer.prototype = new mExplorer.SelectionRenderer();
-
- UnstagedRenderer.prototype.getCellElement = function(col_no, item, tableRow) {
- switch (col_no) {
- case 0:
- if (mGitUtil.isChange(item)) {
- var td = document.createElement("td"); //$NON-NLS-0$
- var div = document.createElement("div"); //$NON-NLS-0$
- div.className = "sectionTableItem"; //$NON-NLS-0$
- td.appendChild(div);
-
- this.getExpandImage(tableRow, div);
-
- var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
-
- var diffActionWrapper = document.createElement("span"); //$NON-NLS-0$
- diffActionWrapper.id = "unstaged" + item.name + "DiffActionWrapper"; //$NON-NLS-0$
- diffActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
- div.appendChild(diffActionWrapper);
-
- window.setTimeout(function() {
- that.commandService.destroy(diffActionWrapper.id);
- that.commandService.renderCommands(
- "DefaultActionWrapper", diffActionWrapper.id, item, that, "tool", null, navGridHolder); //$NON-NLS-1$ //$NON-NLS-0$
- }, 300);
-
+/*******************************************************************************
+ * @license Copyright (c) 2012, 2013 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 Image*/
+define(['require', 'i18n!git/nls/gitmessages', 'orion/explorers/explorer', 'orion/selection', 'orion/section', 'orion/PageUtil', 'orion/webui/littlelib',
+ 'orion/i18nUtil', 'orion/globalCommands', 'orion/git/util', 'orion/git/gitCommands', 'orion/Deferred', 'orion/git/widgets/CommitTooltipDialog',
+ 'orion/webui/tooltip'],
+ function(require, messages, mExplorer, mSelection, mSection, PageUtil, lib, i18nUtil, mGlobalCommands, mGitUtil, mGitCommands,
+ Deferred, mCommitTooltip, Tooltip) {
+
+ var exports = {};
+ var conflictTypeStr = "Conflicting"; //$NON-NLS-0$
+
+ function isConflict(type) {
+ return type === conflictTypeStr;
+ }
+
+ var GitStatusModel = (function() {
+ function GitStatusModel() {
+ this.selectedFileId = undefined;
+ this.selectedItem = undefined;
+ this.interestedUnstagedGroup = [ "Missing", "Modified", "Untracked", "Conflicting" ]; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ this.interestedStagedGroup = [ "Added", "Changed", "Removed" ]; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ this.conflictPatterns = [
+ [ "Both", "Modified", "Added", "Changed", "Missing" ], [ "RemoteDelete", "Untracked", "Removed" ], [ "LocalDelete", "Modified", "Added", "Missing" ] ]; //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ this.conflictType = "Conflicting"; //$NON-NLS-0$
+
+ this.statusTypeMap = {
+ "Missing" : { imageClass: "gitImageSprite git-sprite-removal", tooltip: messages['Unstaged removal'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ "Removed" : { imageClass: "gitImageSprite git-sprite-removal", tooltip: messages['Staged removal'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ "Modified" : { imageClass: "gitImageSprite git-sprite-file", tooltip: messages['Unstaged change'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ "Changed" : { imageClass: "gitImageSprite git-sprite-file", tooltip: messages['Staged change'] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ "Untracked" : { imageClass: "gitImageSprite git-sprite-addition", tooltip: messages["Unstaged addition"] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ "Added" : { imageClass: "gitImageSprite git-sprite-addition", tooltip: messages["Staged addition"] }, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ "Conflicting" : { imageClass: "gitImageSprite git-sprite-conflict-file", tooltip: messages['Conflicting'] } //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ };
+ }
+
+ GitStatusModel.prototype = {
+ destroy: function() {},
+
+ interestedCategory: function() {},
+
+ init: function(jsonData) {
+ this.items = jsonData;
+ },
+
+ getModelType: function(groupItem, groupName) {
+ return groupName;
+ },
+
+ _markConflict: function(conflictPattern) {
+ // if git status server API response a file with "Modified"
+ // ,"Added", "Changed","Missing" states , we treat it as a
+ // conflicting file
+ // And we add additional attribute to that groupItem :
+ // groupItem.Conflicting = true;
+ var baseGroup = this.getGroupData(conflictPattern[1]);
+ if (!baseGroup)
+ return;
+ for (var i = 0; i < baseGroup.length; i++) {
+ if (baseGroup[i].Conflicting)
+ continue;
+ var fileLocation = baseGroup[i].Location;
+ var itemsInDetectGroup = [];
+
+ for (var j = 2; j < conflictPattern.length; j++) {
+ var groupName = conflictPattern[j];
+ var groupData = this.getGroupData(groupName);
+ if (!groupData)
+ continue;
+ var item = this._findSameFile(fileLocation, groupData);
+ if (item) {
+ itemsInDetectGroup.push(item);
+ } else {
+ continue;
+ }
+ }
+
+ // we have the same file at "Modified" ,"Added",
+ // "Changed","Missing" groups
+ if (itemsInDetectGroup.length === (conflictPattern.length - 2)) {
+ baseGroup[i].Conflicting = conflictPattern[0];
+ for (var k = 0; k < itemsInDetectGroup.length; k++) {
+ itemsInDetectGroup[k].Conflicting = "Hide"; //$NON-NLS-0$
+ }
+ }
+ }
+ },
+
+ _findSameFile: function(fileLocation, groupData) {
+ for (var j = 0; j < groupData.length; j++) {
+ if (groupData[j].Conflicting)
+ continue;
+ if (fileLocation === groupData[j].Location)
+ return groupData[j];
+ }
+ return undefined;
+ },
+
+ getGroupData: function(groupName) {
+ return this.items[groupName];
+ },
+
+ isStaged: function(type) {
+ for (var i = 0; i < this.interestedStagedGroup.length; i++) {
+ if (type === this.interestedStagedGroup[i]) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ getClass: function(type) {
+ return this.statusTypeMap[type].imageClass;
+ },
+
+ getTooltip: function(type) {
+ return this.statusTypeMap[type].tooltip;
+ }
+ };
+
+ return GitStatusModel;
+ }());
+
+ exports.GitStatusExplorer = (function() {
+ /**
+ * Creates a new Git status explorer.
+ *
+ * @class Git status explorer
+ * @name orion.git.GitStatusExplorer
+ * @param registry
+ * @param commandService
+ * @param linkService
+ * @param selection
+ * @param parentId
+ * @param toolbarId
+ * @param selectionToolsId
+ * @param actionScopeId
+ */
+ function GitStatusExplorer(registry, commandService, linkService, selection, parentId, toolbarId, selectionToolsId, actionScopeId) {
+ this.parentId = parentId;
+ this.registry = registry;
+ this.commandService = commandService;
+ this.linkService = linkService;
+ this.selection = selection;
+ this.parentId = parentId;
+ this.toolbarId = toolbarId;
+ this.selectionToolsId = selectionToolsId;
+ this.checkbox = false;
+ this.actionScopeId = actionScopeId;
+ mExplorer.createExplorerCommands(commandService);
+ }
+
+ GitStatusExplorer.prototype.handleError = function(error) {
+ var display = {};
+ display.Severity = "Error"; //$NON-NLS-0$
+ display.HTML = false;
+ try {
+ var resp = JSON.parse(error.responseText);
+ display.Message = resp.DetailedMessage ? resp.DetailedMessage : resp.Message;
+ } catch (Exception) {
+ display.Message = error.message;
+ }
+ this.registry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$
+
+ if (error.status === 404) {
+ this.initTitleBar();
+ this.displayCommit();
+ }
+ };
+
+ GitStatusExplorer.prototype.changedItem = function(parent, children) {
+ this.redisplay();
+ };
+
+ GitStatusExplorer.prototype.redisplay = function() {
+ var pageParams = PageUtil.matchResourceParameters();
+ this.display(pageParams.resource);
+ };
+
+ GitStatusExplorer.prototype.display = function(location) {
+ var that = this;
+ var progressService = this.registry.getService("orion.page.progress"); //$NON-NLS-0$
+
+ progressService
+ .progress(this.registry.getService("orion.git.provider").getGitStatus(location), messages['Loading...']).then( //$NON-NLS-0$
+ function(resp) {
+ if (resp.Type === "Status") { //$NON-NLS-0$
+ var status = resp;
+ that._model = new GitStatusModel();
+ that._model.init(status);
+
+ progressService
+ .progress(
+ that.registry.getService("orion.git.provider").getGitClone(status.CloneLocation), "Getting repository information").then( //$NON-NLS-0$
+ function(resp) {
+ var repositories = resp.Children;
+
+ progressService
+ .progress(
+ that.registry
+ .getService("orion.git.provider").getGitCloneConfig(repositories[0].ConfigLocation), "Getting repository configuration ", repositories[0].Name).then( //$NON-NLS-0$
+ function(resp) {
+ var config = resp.Children;
+
+ status.Clone = repositories[0];
+ status.Clone.Config = [];
+
+ for (var i = 0; i < config.length; i++) {
+ if (config[i].Key === "user.name" || config[i].Key === "user.email") //$NON-NLS-1$ //$NON-NLS-0$
+ status.Clone.Config.push(config[i]);
+ }
+
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+ lib.empty(tableNode);
+ that.initTitleBar(status, repositories[0]);
+ that.displayUnstaged(status, repositories[0]);
+ that.displayStaged(status, repositories[0]);
+ that.displayCommits(repositories[0]);
+
+ // render
+ // commands
+ mGitCommands.updateNavTools(that.registry, that.commandService, that,
+ "pageActions", "selectionTools", status); //$NON-NLS-1$ //$NON-NLS-0$
+ }, function(error) {
+ that.handleError(error);
+ });
+ }, function(error) {
+ that.handleError(error);
+ });
+ }
+ }, function(error) {
+ that.handleError(error);
+ });
+ };
+
+ GitStatusExplorer.prototype.initTitleBar = function(status, repository) {
+ var item = {};
+
+ // TODO add info about branch or detached
+ item.Name = messages["Status"] + ((status.RepositoryState && status.RepositoryState.indexOf("REBASING") !== -1) ? messages[" (Rebase in Progress)"] : ""); //$NON-NLS-1$
+ item.Parents = [];
+ item.Parents[0] = {};
+ item.Parents[0].Name = repository.Name;
+ item.Parents[0].Location = repository.Location;
+ item.Parents[0].ChildrenLocation = repository.Location;
+ item.Parents[1] = {};
+ item.Parents[1].Name = "Repositories"; //$NON-NLS-0$
+
+ mGlobalCommands.setPageTarget({
+ task : messages["Status"],
+ target : repository,
+ breadcrumbTarget : item,
+ makeBreadcrumbLink : function(seg, location) {
+ seg.href = require.toUrl("git/git-repository.html") + (location ? "#" + location : ""); //$NON-NLS-0$
+ },
+ serviceRegistry : this.registry,
+ commandService : this.commandService
+ });
+ };
+
+ // helpers
+
+ GitStatusExplorer.prototype._sortBlock = function(interestedGroup) {
+ var retValue = [];
+ for (var i = 0; i < interestedGroup.length; i++) {
+ var groupName = interestedGroup[i];
+ var groupData = this._model.getGroupData(groupName);
+ if (!groupData)
+ continue;
+ for (var j = 0; j < groupData.length; j++) {
+ var renderType = this._model.getModelType(groupData[j], groupName);
+ if (renderType) {
+ retValue.push({
+ name : groupData[j].Name,
+ type : renderType,
+ location : groupData[j].Location,
+ path : groupData[j].Path,
+ commitURI : groupData[j].Git.CommitLocation,
+ indexURI : groupData[j].Git.IndexLocation,
+ diffURI : groupData[j].Git.DiffLocation,
+ CloneLocation : this._model.items.CloneLocation,
+ conflicting : isConflict(renderType)
+ });
+ }
+ }
+ }
+ retValue.sort(function(a, b) {
+ var n1 = a.name && a.name.toLowerCase();
+ var n2 = b.name && b.name.toLowerCase();
+ if (n1 < n2) {
+ return -1;
+ }
+ if (n1 > n2) {
+ return 1;
+ }
+ return 0;
+ });
+ return retValue;
+ };
+
+ // Git unstaged changes
+
+ GitStatusExplorer.prototype.displayUnstaged = function(status, repository) {
+ var that = this;
+ var unstagedSortedChanges = this._sortBlock(this._model.interestedUnstagedGroup);
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+ var unstagedSection = new mSection.Section(tableNode, {
+ id : "unstagedSection", //$NON-NLS-0$
+ title : unstagedSortedChanges.length > 0 ? messages['Unstaged'] : messages["No Unstaged Changes"],
+ content : '<div id="unstagedNode"></div>', //$NON-NLS-0$
+ canHide : true,
+ onExpandCollapse : function(isExpanded, section) {
+ that.commandService.destroy(section.selectionNode);
+ if (isExpanded) {
+ that.commandService.renderCommands(section.selectionNode.id, section.selectionNode, null, that, "button", {"Clone" : repository}); //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ }
+ });
+
+ this.commandService.registerCommandContribution(unstagedSection.actionsNode.id, "orion.explorer.expandAll", 200); //$NON-NLS-1$ //$NON-NLS-0$
+ this.commandService.registerCommandContribution(unstagedSection.actionsNode.id, "orion.explorer.collapseAll", 300); //$NON-NLS-1$ //$NON-NLS-0$
+
+ this.commandService.registerCommandContribution(unstagedSection.selectionNode.id, "eclipse.orion.git.showPatchCommand", 100); //$NON-NLS-0$
+ this.commandService.registerCommandContribution(unstagedSection.selectionNode.id, "eclipse.orion.git.stageCommand", 200); //$NON-NLS-0$
+ this.commandService.registerCommandContribution(unstagedSection.selectionNode.id, "eclipse.orion.git.checkoutCommand", 300); //$NON-NLS-0$
+
+ if (!this.unstagedOnce) {
+ if (!this.unstagedSelection) {
+ this.unstagedSelection = new mSelection.Selection(this.registry, "orion.unstagedSection.selection"); //$NON-NLS-0$
+ this.commandService.registerSelectionService(unstagedSection.selectionNode.id, this.unstagedSelection);
+ }
+
+ this.registry.getService("orion.unstagedSection.selection").addEventListener("selectionChanged", function(event) { //$NON-NLS-1$ //$NON-NLS-0$
+ var selectionTools = lib.node(unstagedSection.selectionNode.id);
+ if (selectionTools) {
+ that.commandService.destroy(selectionTools);
+ that.commandService.renderCommands(unstagedSection.selectionNode.id, selectionTools, event.selections, that,
+ "button", {"Clone" : repository}); //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ });
+ this.unstagedOnce = true;
+ }
+
+ this.commandService.registerCommandContribution("DefaultActionWrapper", "eclipse.orion.git.stageCommand", 100); //$NON-NLS-1$ //$NON-NLS-0$
+
+ var UnstagedModel = (function() {
+ function UnstagedModel() {}
+
+ UnstagedModel.prototype = {
+ destroy : function() {},
+
+ getRoot : function(onItem) {
+ onItem(unstagedSortedChanges);
+ },
+
+ getChildren : function(parentItem, onComplete) {
+ if (parentItem instanceof Array && parentItem.length > 0) {
+ onComplete(parentItem);
+ } else if (mGitUtil.isChange(parentItem)) {
+ if (!parentItem.children) {// lazy creation,
+ // this is required
+ // for selection
+ // model to be able
+ // to traverse into
+ // children
+ parentItem.children = [];
+ parentItem.children.push({ "diffUri" : parentItem.diffURI, "Type" : "Diff", parent : parentItem}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ onComplete(parentItem.children); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ } else {
+ onComplete([]);
+ }
+ },
+
+ getId : function(/* item */item) {
+ if (item instanceof Array && item.length > 0) {
+ return "unstagedRoot"; //$NON-NLS-0$
+ } else if (mGitUtil.isChange(item)) {
+ return "unstaged" + item.name; //$NON-NLS-0$
+ } else {
+ return "unstaged" + item.diffUri; //$NON-NLS-0$
+ }
+ }
+ };
+
+ return UnstagedModel;
+ }());
+
+ var UnstagedRenderer = (function() {
+ function UnstagedRenderer(options, explorer) {
+ this._init(options);
+ this.options = options;
+ this.explorer = explorer;
+ this.registry = options.registry;
+ }
+
+ UnstagedRenderer.prototype = new mExplorer.SelectionRenderer();
+
+ UnstagedRenderer.prototype.getCellElement = function(col_no, item, tableRow) {
+ switch (col_no) {
+ case 0:
+ if (mGitUtil.isChange(item)) {
+ var td = document.createElement("td"); //$NON-NLS-0$
+ var div = document.createElement("div"); //$NON-NLS-0$
+ div.className = "sectionTableItem"; //$NON-NLS-0$
+ td.appendChild(div);
+
+ this.getExpandImage(tableRow, div);
+
+ var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
+
+ var diffActionWrapper = document.createElement("span"); //$NON-NLS-0$
+ diffActionWrapper.id = "unstaged" + item.name + "DiffActionWrapper"; //$NON-NLS-0$
+ diffActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
+ div.appendChild(diffActionWrapper);
+
+ that.commandService.destroy(diffActionWrapper);
+ that.commandService.renderCommands(
+ "DefaultActionWrapper", diffActionWrapper, item, that, "tool", null, navGridHolder); //$NON-NLS-1$ //$NON-NLS-0$
+
var icon = document.createElement("span"); //$NON-NLS-0$
- icon.className = that._model.getClass(item.type);
- icon.commandTooltip = new Tooltip.Tooltip({
- node: icon,
- text: that._model.getTooltip(item.type),
- position: ["above", "below", "right", "left"] //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ icon.className = that._model.getClass(item.type);
+ icon.commandTooltip = new Tooltip.Tooltip({
+ node: icon,
+ text: that._model.getTooltip(item.type),
+ position: ["above", "below", "right", "left"] //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
});
- div.appendChild(icon);
-
- var itemLabel = document.createElement("span"); //$NON-NLS-0$
- itemLabel.textContent = item.name;
- div.appendChild(itemLabel);
-
- return td;
- } else {
- var td = document.createElement("td"); //$NON-NLS-0$
- td.colSpan = 2;
-
- var div = document.createElement("div"); //$NON-NLS-0$
- div.className = "sectionTableItem"; //$NON-NLS-0$
- td.appendChild(div);
-
- var compareWidgetActionWrapper = document.createElement("div"); //$NON-NLS-0$
- compareWidgetActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
- compareWidgetActionWrapper.id = "unstaged" + item.parent.name + "CompareWidgetActionWrapper"; //$NON-NLS-1$ //$NON-NLS-0$
- div.appendChild(compareWidgetActionWrapper);
-
- var diffContainer = document.createElement("div"); //$NON-NLS-0$
- diffContainer.id = "diffArea_" + item.diffUri; //$NON-NLS-0$
- diffContainer.style.height = "420px"; //$NON-NLS-0$
- diffContainer.style.border = "1px solid lightgray"; //$NON-NLS-0$
- diffContainer.style.overflow = "hidden"; //$NON-NLS-0$
- div.appendChild(diffContainer);
-
- var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
- window.setTimeout(function() {
- mGitUtil.createCompareWidget(
- that.registry,
- that.commandService,
- item.diffUri,
- isConflict(item.parent.type),
- "diffArea_" + item.diffUri, //$NON-NLS-0$
- compareWidgetActionWrapper.id,
- true, //editableInComparePage
- {navGridHolder: navGridHolder} //gridRenderer
- );
- }, 300);
-
- return td;
- }
-
- break;
- }
- };
-
- return UnstagedRenderer;
- }());
-
- var UnstagedNavigator = (function() {
- function UnstagedNavigator(registry, selection, parentId, actionScopeId) {
- this.registry = registry;
- this.checkbox = false;
- this.parentId = parentId;
- this.selection = selection;
- this.actionScopeId = actionScopeId;
- this.renderer = new UnstagedRenderer({ registry : this.registry,/*
- * actionScopeId:
- * sectionItemActionScopeId,
- */
- cachePrefix : "UnstagedNavigator", checkbox : false}, this); //$NON-NLS-0$
- this.createTree(this.parentId, new UnstagedModel(), { setFocus : true
- });
- }
-
- UnstagedNavigator.prototype = new mExplorer.Explorer();
-
- // provide to the selection model that if a row is
- // selectable
- UnstagedNavigator.prototype.isRowSelectable = function(modelItem) {
- return mGitUtil.isChange(modelItem);
- };
- // provide to the expandAll/collapseAll commands
- UnstagedNavigator.prototype.getItemCount = function() {
- return unstagedSortedChanges.length;
- };
- return UnstagedNavigator;
- }());
-
- var unstagedNavigator = new UnstagedNavigator(this.registry, this.unstagedSelection, "unstagedNode" /*
- * ,
- * sectionItemActionScopeId
- */); //$NON-NLS-0$
- this.commandService.renderCommands(unstagedSection.actionsNode.id, unstagedSection.actionsNode.id, unstagedNavigator, unstagedNavigator,
- "button"); //$NON-NLS-0$
- };
-
- // Git staged changes
-
- GitStatusExplorer.prototype.displayStaged = function(status, repository) {
- var that = this;
- var stagedSortedChanges = this._sortBlock(this._model.interestedStagedGroup);
- var tableNode = lib.node('table'); //$NON-NLS-0$
- var stagedSection = new mSection.Section(tableNode, {
- id : "stagedSection", //$NON-NLS-0$
- title : stagedSortedChanges.length > 0 ? messages['Staged'] : messages["No Staged Changes"],
- content : '<div id="stagedNode"></div>', //$NON-NLS-0$
- slideout : true,
- canHide : true,
- onExpandCollapse : function(isExpanded, section) {
- that.commandService.destroy(section.selectionNode);
- if (isExpanded) {
- that.commandService.renderCommands(section.selectionNode.id, section.selectionNode, null, that, "button", { "Clone" : repository}); //$NON-NLS-0$ //$NON-NLS-1$
- }
- }
- });
-
- this.commandService.registerCommandContribution(stagedSection.actionsNode.id, "eclipse.orion.git.commitCommand", 100); //$NON-NLS-0$
- this.commandService.registerCommandContribution(stagedSection.actionsNode.id, "orion.explorer.expandAll", 200); //$NON-NLS-0$
- this.commandService.registerCommandContribution(stagedSection.actionsNode.id, "orion.explorer.collapseAll", 300); //$NON-NLS-0$
- this.commandService.registerCommandContribution(stagedSection.selectionNode.id, "eclipse.orion.git.unstageCommand", 100); //$NON-NLS-0$
-
- if (!this.stagedOnce) {
- if (!this.stagedSelection) {
- this.stagedSelection = new mSelection.Selection(this.registry, "orion.stagedSection.selection"); //$NON-NLS-0$
- this.commandService.registerSelectionService(stagedSection.selectionNode.id, this.stagedSelection);
- }
-
- this.registry.getService("orion.stagedSection.selection").addEventListener("selectionChanged", function(event) { //$NON-NLS-1$ //$NON-NLS-0$
- var selectionTools = lib.node(stagedSection.selectionNode.id);
- if (selectionTools) {
- that.commandService.destroy(selectionTools);
- that.commandService.renderCommands(stagedSection.selectionNode.id, selectionTools, event.selections, that,
- "button", { "Clone" : repository}); //$NON-NLS-1$ //$NON-NLS-0$
- }
- });
- this.stagedOnce = true;
- }
-
- this.commandService.registerCommandContribution("DefaultActionWrapper", "eclipse.orion.git.unstageCommand", 100); //$NON-NLS-1$ //$NON-NLS-0$
-
- var StagedModel = (function() {
- function StagedModel() {}
-
- StagedModel.prototype = {
- destroy : function() {},
-
- getRoot : function(onItem) {
- onItem(stagedSortedChanges);
- },
-
- getChildren : function(parentItem, onComplete) {
- if (parentItem instanceof Array && parentItem.length > 0) {
- onComplete(parentItem);
- } else if (mGitUtil.isChange(parentItem)) {
- if (!parentItem.children) {// lazy creation,
- // this is required
- // for selection
- // model to be able
- // to trverse into
- // children
- parentItem.children = [];
- parentItem.children.push({ "diffUri" : parentItem.diffURI, "Type" : "Diff", parent : parentItem});//$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- }
- onComplete(parentItem.children);
- } else {
- onComplete([]);
- }
- },
-
- getId : function(/* item */item) {
- if (item instanceof Array && item.length > 0) {
- return "stagedRoot"; //$NON-NLS-0$
- } else if (mGitUtil.isChange(item)) {
- return "staged" + item.name; //$NON-NLS-0$
- } else {
- return "staged" + item.diffUri; //$NON-NLS-0$
- }
- }
- };
-
- return StagedModel;
- }());
-
- var StagedRenderer = (function() {
- function StagedRenderer(options, explorer) {
- this._init(options);
- this.options = options;
- this.explorer = explorer;
- this.registry = options.registry;
- }
-
- StagedRenderer.prototype = new mExplorer.SelectionRenderer();
-
- StagedRenderer.prototype.getCellElement = function(col_no, item, tableRow) {
- switch (col_no) {
- case 0:
- if (mGitUtil.isChange(item)) {
- var td = document.createElement("td"); //$NON-NLS-0$
- var div = document.createElement("div"); //$NON-NLS-0$
- div.className = "sectionTableItem"; //$NON-NLS-0$
- td.appendChild(div);
-
- this.getExpandImage(tableRow, div);
-
- var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
-
- var diffActionWrapper = document.createElement("span"); //$NON-NLS-0$
- diffActionWrapper.id = "staged" + item.name + "DiffActionWrapper"; //$NON-NLS-0$
- diffActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
- div.appendChild(diffActionWrapper);
-
- window.setTimeout(function() {
- that.commandService.destroy(diffActionWrapper.id);
- that.commandService.renderCommands(
- "DefaultActionWrapper", diffActionWrapper.id, item, that, "tool", null, navGridHolder); //$NON-NLS-1$ //$NON-NLS-0$
- }, 300);
-
+ div.appendChild(icon);
+
+ var itemLabel = document.createElement("span"); //$NON-NLS-0$
+ itemLabel.textContent = item.name;
+ div.appendChild(itemLabel);
+
+ return td;
+ } else {
+ // render the compare widget
+ var td = document.createElement("td"); //$NON-NLS-0$
+ td.colSpan = 2;
+
+ var div = document.createElement("div"); //$NON-NLS-0$
+ div.className = "sectionTableItem"; //$NON-NLS-0$
+ td.appendChild(div);
+
+ var compareWidgetActionWrapper = document.createElement("div"); //$NON-NLS-0$
+ compareWidgetActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
+ compareWidgetActionWrapper.id = "unstaged" + item.parent.name + "CompareWidgetActionWrapper"; //$NON-NLS-1$ //$NON-NLS-0$
+ div.appendChild(compareWidgetActionWrapper);
+
+ var diffContainer = document.createElement("div"); //$NON-NLS-0$
+ diffContainer.id = "diffArea_" + item.diffUri; //$NON-NLS-0$
+ diffContainer.style.height = "420px"; //$NON-NLS-0$
+ diffContainer.style.border = "1px solid lightgray"; //$NON-NLS-0$
+ diffContainer.style.overflow = "hidden"; //$NON-NLS-0$
+ div.appendChild(diffContainer);
+
+ var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
+ mGitUtil.createCompareWidget(
+ that.registry,
+ that.commandService,
+ item.diffUri,
+ isConflict(item.parent.type),
+ diffContainer,
+ compareWidgetActionWrapper.id,
+ true, //editableInComparePage
+ {navGridHolder: navGridHolder} //gridRenderer
+ );
+
+ return td;
+ }
+
+ break;
+ }
+ };
+
+ return UnstagedRenderer;
+ }());
+
+ var UnstagedNavigator = (function() {
+ function UnstagedNavigator(registry, selection, parentId, actionScopeId) {
+ this.registry = registry;
+ this.checkbox = false;
+ this.parentId = parentId;
+ this.selection = selection;
+ this.actionScopeId = actionScopeId;
+ this.renderer = new UnstagedRenderer({ registry : this.registry,/*
+ * actionScopeId:
+ * sectionItemActionScopeId,
+ */
+ cachePrefix : "UnstagedNavigator", checkbox : false}, this); //$NON-NLS-0$
+ this.createTree(this.parentId, new UnstagedModel(), { setFocus : true
+ });
+ }
+
+ UnstagedNavigator.prototype = new mExplorer.Explorer();
+
+ // provide to the selection model that if a row is
+ // selectable
+ UnstagedNavigator.prototype.isRowSelectable = function(modelItem) {
+ return mGitUtil.isChange(modelItem);
+ };
+ // provide to the expandAll/collapseAll commands
+ UnstagedNavigator.prototype.getItemCount = function() {
+ return unstagedSortedChanges.length;
+ };
+ return UnstagedNavigator;
+ }());
+
+ var unstagedNavigator = new UnstagedNavigator(this.registry, this.unstagedSelection, "unstagedNode" /*
+ * ,
+ * sectionItemActionScopeId
+ */); //$NON-NLS-0$
+ this.commandService.renderCommands(unstagedSection.actionsNode.id, unstagedSection.actionsNode.id, unstagedNavigator, unstagedNavigator,
+ "button"); //$NON-NLS-0$
+ };
+
+ // Git staged changes
+
+ GitStatusExplorer.prototype.displayStaged = function(status, repository) {
+ var that = this;
+ var stagedSortedChanges = this._sortBlock(this._model.interestedStagedGroup);
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+ var stagedSection = new mSection.Section(tableNode, {
+ id : "stagedSection", //$NON-NLS-0$
+ title : stagedSortedChanges.length > 0 ? messages['Staged'] : messages["No Staged Changes"],
+ content : '<div id="stagedNode"></div>', //$NON-NLS-0$
+ slideout : true,
+ canHide : true,
+ onExpandCollapse : function(isExpanded, section) {
+ that.commandService.destroy(section.selectionNode);
+ if (isExpanded) {
+ that.commandService.renderCommands(section.selectionNode.id, section.selectionNode, null, that, "button", { "Clone" : repository}); //$NON-NLS-0$ //$NON-NLS-1$
+ }
+ }
+ });
+
+ this.commandService.registerCommandContribution(stagedSection.actionsNode.id, "eclipse.orion.git.commitCommand", 100); //$NON-NLS-0$
+ this.commandService.registerCommandContribution(stagedSection.actionsNode.id, "orion.explorer.expandAll", 200); //$NON-NLS-0$
+ this.commandService.registerCommandContribution(stagedSection.actionsNode.id, "orion.explorer.collapseAll", 300); //$NON-NLS-0$
+ this.commandService.registerCommandContribution(stagedSection.selectionNode.id, "eclipse.orion.git.unstageCommand", 100); //$NON-NLS-0$
+
+ if (!this.stagedOnce) {
+ if (!this.stagedSelection) {
+ this.stagedSelection = new mSelection.Selection(this.registry, "orion.stagedSection.selection"); //$NON-NLS-0$
+ this.commandService.registerSelectionService(stagedSection.selectionNode.id, this.stagedSelection);
+ }
+
+ this.registry.getService("orion.stagedSection.selection").addEventListener("selectionChanged", function(event) { //$NON-NLS-1$ //$NON-NLS-0$
+ var selectionTools = lib.node(stagedSection.selectionNode.id);
+ if (selectionTools) {
+ that.commandService.destroy(selectionTools);
+ that.commandService.renderCommands(stagedSection.selectionNode.id, selectionTools, event.selections, that,
+ "button", {"Clone" : repository}); //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ });
+ this.stagedOnce = true;
+ }
+
+ this.commandService.registerCommandContribution("DefaultActionWrapper", "eclipse.orion.git.unstageCommand", 100); //$NON-NLS-1$ //$NON-NLS-0$
+
+ var StagedModel = (function() {
+ function StagedModel() {}
+
+ StagedModel.prototype = {
+ destroy : function() {},
+
+ getRoot : function(onItem) {
+ onItem(stagedSortedChanges);
+ },
+
+ getChildren : function(parentItem, onComplete) {
+ if (parentItem instanceof Array && parentItem.length > 0) {
+ onComplete(parentItem);
+ } else if (mGitUtil.isChange(parentItem)) {
+ if (!parentItem.children) {// lazy creation,
+ // this is required
+ // for selection
+ // model to be able
+ // to trverse into
+ // children
+ parentItem.children = [];
+ parentItem.children.push({ "diffUri" : parentItem.diffURI, "Type" : "Diff", parent : parentItem});//$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ onComplete(parentItem.children);
+ } else {
+ onComplete([]);
+ }
+ },
+
+ getId : function(/* item */item) {
+ if (item instanceof Array && item.length > 0) {
+ return "stagedRoot"; //$NON-NLS-0$
+ } else if (mGitUtil.isChange(item)) {
+ return "staged" + item.name; //$NON-NLS-0$
+ } else {
+ return "staged" + item.diffUri; //$NON-NLS-0$
+ }
+ }
+ };
+
+ return StagedModel;
+ }());
+
+ var StagedRenderer = (function() {
+ function StagedRenderer(options, explorer) {
+ this._init(options);
+ this.options = options;
+ this.explorer = explorer;
+ this.registry = options.registry;
+ }
+
+ StagedRenderer.prototype = new mExplorer.SelectionRenderer();
+
+ StagedRenderer.prototype.getCellElement = function(col_no, item, tableRow) {
+ switch (col_no) {
+ case 0:
+ if (mGitUtil.isChange(item)) {
+ var td = document.createElement("td"); //$NON-NLS-0$
+ var div = document.createElement("div"); //$NON-NLS-0$
+ div.className = "sectionTableItem"; //$NON-NLS-0$
+ td.appendChild(div);
+
+ this.getExpandImage(tableRow, div);
+
+ var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
+
+ var diffActionWrapper = document.createElement("span"); //$NON-NLS-0$
+ diffActionWrapper.id = "staged" + item.name + "DiffActionWrapper"; //$NON-NLS-0$
+ diffActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
+ div.appendChild(diffActionWrapper);
+
+ that.commandService.destroy(diffActionWrapper);
+ that.commandService.renderCommands(
+ "DefaultActionWrapper", diffActionWrapper, item, that, "tool", null, navGridHolder); //$NON-NLS-1$ //$NON-NLS-0$
+
var icon = document.createElement("span"); //$NON-NLS-0$
- icon.className = that._model.getClass(item.type);
- icon.commandTooltip = new Tooltip.Tooltip({
- node: icon,
- text: that._model.getTooltip(item.type),
- position: ["above", "below", "right", "left"] //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ icon.className = that._model.getClass(item.type);
+ icon.commandTooltip = new Tooltip.Tooltip({
+ node: icon,
+ text: that._model.getTooltip(item.type),
+ position: ["above", "below", "right", "left"] //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
});
- div.appendChild(icon);
-
- var itemLabel = document.createElement("span"); //$NON-NLS-0$
- itemLabel.textContent = item.name;
- div.appendChild(itemLabel);
-
- return td;
- } else {
- var td = document.createElement("td"); //$NON-NLS-0$
- td.colSpan = 2;
-
- var div = document.createElement("div"); //$NON-NLS-0$
- div.className = "sectionTableItem"; //$NON-NLS-0$
- td.appendChild(div);
-
- var compareWidgetActionWrapper = document.createElement("div"); //$NON-NLS-0$
- compareWidgetActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
- compareWidgetActionWrapper.id = "staged" + item.parent.name + "CompareWidgetActionWrapper"; //$NON-NLS-1$ //$NON-NLS-0$
- div.appendChild(compareWidgetActionWrapper);
-
- var diffContainer = document.createElement("div"); //$NON-NLS-0$
- diffContainer.id = "diffArea_" + item.diffUri; //$NON-NLS-0$
- diffContainer.style.height = "420px"; //$NON-NLS-0$
- diffContainer.style.border = "1px solid lightgray"; //$NON-NLS-0$
- diffContainer.style.overflow = "hidden"; //$NON-NLS-0$
- div.appendChild(diffContainer);
-
- var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
- var hasConflict = isConflict(item.parent.type);
- window.setTimeout(function() {
- mGitUtil.createCompareWidget(
- that.registry,
- that.commandService,
- item.diffUri,
- isConflict(item.parent.type),
- "diffArea_" + item.diffUri, //$NON-NLS-0$
- compareWidgetActionWrapper.id,
- false, //editableInComparePage
- {navGridHolder: navGridHolder} //gridRenderer
- );
- }, 500);
-
- return td;
- }
-
- break;
- }
- };
-
- return StagedRenderer;
- }());
-
- var StagedNavigator = (function() {
- function StagedNavigator(registry, selection, parentId, actionScopeId) {
- this.registry = registry;
- this.checkbox = false;
- this.parentId = parentId;
- this.status = status;
- this.selection = selection;
- this.actionScopeId = actionScopeId;
- this.renderer = new StagedRenderer({ registry : this.registry, /*
- * actionScopeId:
- * sectionItemActionScopeId,
- */
- cachePrefix : "StagedNavigator", checkbox : false}, this); //$NON-NLS-0$
- this.createTree(this.parentId, new StagedModel());
- }
-
- StagedNavigator.prototype = new mExplorer.Explorer();
-
- // provide to the selection model that if a row is
- // selectable
- StagedNavigator.prototype.isRowSelectable = function(modelItem) {
- return mGitUtil.isChange(modelItem);
- };
- // provide to the expandAll/collapseAll commands
- StagedNavigator.prototype.getItemCount = function() {
- return stagedSortedChanges.length;
- };
- return StagedNavigator;
- }());
-
- var stagedNavigator = new StagedNavigator(this.registry, this.stagedSelection, "stagedNode" /*
- * ,
- * sectionItemActionScopeId
- */); //$NON-NLS-0$
- this.commandService.renderCommands(stagedSection.actionsNode.id, stagedSection.actionsNode.id, stagedNavigator, stagedNavigator, "button"); //$NON-NLS-0$
- };
-
- // Git commits
-
- GitStatusExplorer.prototype.displayCommits = function(repository) {
- var that = this;
- var tableNode = lib.node('table'); //$NON-NLS-0$
- var titleWrapper = new mSection.Section(tableNode, {
- id : "commitSection", //$NON-NLS-0$
- title : messages['Commits'],
- content : '<div id="commitNode" class="mainPadding"></div>', //$NON-NLS-0$
- slideout : true,
- canHide : true,
- preferenceService : this.registry.getService("orion.core.preference") //$NON-NLS-0$
- });
-
- var progress = titleWrapper.createProgressMonitor();
-
- progress.begin(messages['Getting current branch']);
- this.registry
- .getService("orion.page.progress").progress(this.registry.getService("orion.git.provider").getGitBranch(repository.BranchLocation), "Getting current branch " + repository.Name).then( //$NON-NLS-0$
- function(resp) {
- var branches = resp.Children;
- var currentBranch;
- for (var i = 0; i < branches.length; i++) {
- if (branches[i].Current) {
- currentBranch = branches[i];
- break;
- }
- }
-
- if (!currentBranch){
- progress.done();
- return;
- }
-
- var tracksRemoteBranch = (currentBranch.RemoteLocation.length === 1 && currentBranch.RemoteLocation[0].Children.length === 1);
-
- titleWrapper.setTitle(i18nUtil.formatMessage(messages["Commits for \"${0}\" branch"], currentBranch.Name));
- that.commandService.destroy(titleWrapper.actionsNode.id);
- that.commandService.registerCommandContribution(titleWrapper.actionsNode.id,
- "eclipse.orion.git.repositories.viewAllCommand", 10); //$NON-NLS-0$
- that.commandService.renderCommands(
- titleWrapper.actionsNode.id,
- titleWrapper.actionsNode.id,
- { "ViewAllLink" : "git/git-log.html#" + currentBranch.CommitLocation + "?page=1",
- "ViewAllLabel" : messages['See Full Log'],
- "ViewAllTooltip" : messages["See the full log"]
- }, that, "button"); //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
-
- if (tracksRemoteBranch) {
- that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.fetch", 100); //$NON-NLS-0$
- that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.merge", 100); //$NON-NLS-0$
- that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.rebase", 100); //$NON-NLS-0$
- that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.resetIndex", 100); //$NON-NLS-0$
- that.commandService.renderCommands(titleWrapper.actionsNode.id, titleWrapper.actionsNode.id,
- currentBranch.RemoteLocation[0].Children[0], that, "button"); //$NON-NLS-0$
- }
-
- that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.push", 100); //$NON-NLS-0$
- that.commandService.renderCommands(titleWrapper.actionsNode.id, titleWrapper.actionsNode.id, currentBranch, that,
- "button"); //$NON-NLS-0$
-
- if (currentBranch.RemoteLocation[0] === null) {
- progress.done();
- that.renderNoCommit();
- return;
- }
-
- progress.worked(i18nUtil.formatMessage(messages['Getting commits for \"${0}\" branch'], currentBranch.Name));
-
- if (tracksRemoteBranch && currentBranch.RemoteLocation[0].Children[0].CommitLocation) {
- that.registry
- .getService("orion.page.progress")
- .progress(
- that.registry.getService("orion.git.provider").getLog(
- currentBranch.RemoteLocation[0].Children[0].CommitLocation + "?page=1&pageSize=20", "HEAD"),
- i18nUtil.formatMessage(messages['Getting commits for \"${0}\" branch'], currentBranch.Name)).then( //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- function(resp) {
- progress.worked(messages['Rendering commits']);
-
- var commitsCount = resp.Children.length;
-
- for (var i = 0; i < resp.Children.length; i++) {
- that.renderCommit(resp.Children[i], true, i);
- }
-
- progress.worked(messages['Getting outgoing commits']);
- that.registry
- .getService("orion.page.progress").progress(that.registry.getService("orion.git.provider").getLog(currentBranch.CommitLocation + "?page=1&pageSize=20", currentBranch.RemoteLocation[0].Children[0].Id), messages['Getting outgoing commits']).then( //$NON-NLS-1$ //$NON-NLS-0$
- function(resp) {
- progress.worked(messages['Rendering commits']);
- for (var i = 0; i < resp.Children.length; i++) {
- that.renderCommit(resp.Children[i], false, i + commitsCount);
- }
-
- commitsCount = commitsCount + resp.Children.length;
-
- if (commitsCount === 0) {
- that.renderNoCommit();
- }
-
- progress.done();
- }, function(error) {
- progress.done(error);
- });
- }, function(error) {
- progress.done(error);
- });
- } else {
- that.registry.getService("orion.page.progress").progress(
- that.registry.getService("orion.git.provider").doGitLog(currentBranch.CommitLocation + "?page=1&pageSize=20"),
- i18nUtil.formatMessage(messages['Getting commits for \"${0}\" branch'], currentBranch.Name)).then( //$NON-NLS-1$ //$NON-NLS-0$
- function(resp) {
- progress.worked(messages['Rendering commits']);
- for (var i = 0; i < resp.Children.length; i++) {
- that.renderCommit(resp.Children[i], true, i);
- }
-
- if (resp.Children.length === 0) {
- that.renderNoCommit();
- }
-
- progress.done();
- }, function(error) {
- progress.done(error);
- }
- );
- }
- });
- };
-
- GitStatusExplorer.prototype.renderNoCommit = function() {
- var commitNode = lib.node("commitNode"); //$NON-NLS-0$
- commitNode.innerHTML = ""; //$NON-NLS-0$
- var sectionItem = document.createElement("div"); //$NON-NLS-0$
- sectionItem.className = "sectionTableItem"; //$NON-NLS-0$
- commitNode.appendChild(sectionItem);
-
- var detailsView = document.createElement("div"); //$NON-NLS-0$
- detailsView.className = "stretch"; //$NON-NLS-0$
- sectionItem.appendChild(detailsView);
-
- var title = document.createElement("div"); //$NON-NLS-0$
- title.appendChild(document.createTextNode(messages['The branch is up to date.']));
- detailsView.appendChild(title);
-
- var description = document.createElement("div"); //$NON-NLS-0$
- description.appendChild(document.createTextNode(messages['You have no outgoing or incoming commits.']));
- detailsView.appendChild(description);
- };
-
- GitStatusExplorer.prototype.renderCommit = function(commit, outgoing, index) {
- var commitNode = lib.node("commitNode"); //$NON-NLS-0$
- commitNode.innerHTML = ""; //$NON-NLS-0$
- var sectionItem = document.createElement("div"); //$NON-NLS-0$
- sectionItem.className = "sectionTableItem lightTreeTableRow"; //$NON-NLS-0$
- commitNode.appendChild(sectionItem);
-
- var horizontalBox = document.createElement("div"); //$NON-NLS-0$
- horizontalBox.className = "sectionTableItem"; //$NON-NLS-0$
- horizontalBox.style.overflow = "hidden"; //$NON-NLS-0$
- sectionItem.appendChild(horizontalBox);
-
- var imgSpriteName = (outgoing ? "git-sprite-outgoing_commit" : "git-sprite-incoming_commit"); //$NON-NLS-1$ //$NON-NLS-0$
-
- var direction = document.createElement("span"); //$NON-NLS-0$
- direction.className = "sectionIcon gitImageSprite " + imgSpriteName; //$NON-NLS-0$
- horizontalBox.appendChild(direction);
-
- if (commit.AuthorImage) {
- var authorImage = document.createElement("div"); //$NON-NLS-0$
- authorImage.style['float'] = "left"; //$NON-NLS-0$
- var image = new Image();
- image.src = commit.AuthorImage;
- image.name = commit.AuthorName;
- image.className = "git-author-icon"; //$NON-NLS-0$
- authorImage.appendChild(image);
- horizontalBox.appendChild(authorImage);
- }
-
- var detailsView = document.createElement("div"); //$NON-NLS-0$
- detailsView.className = "stretch"; //$NON-NLS-0$
- horizontalBox.appendChild(detailsView);
-
- var titleLink = document.createElement("a"); //$NON-NLS-0$
- titleLink.className = "navlinkonpage"; //$NON-NLS-0$
- titleLink.href = require.toUrl("git/git-commit.html#") + commit.Location + "?page=1&pageSize=1"; //$NON-NLS-1$ //$NON-NLS-0$
- titleLink.textContent = commit.Message;
- detailsView.appendChild(titleLink);
-
- new mCommitTooltip.CommitTooltipDialog({commit: commit, triggerNode: titleLink});
-
- var d = document.createElement("div"); //$NON-NLS-0$
- detailsView.appendChild(d);
-
- var description = document.createElement("span"); //$NON-NLS-0$
- description.textContent = " (SHA " + commit.Name + ") by " + commit.AuthorName //$NON-NLS-1$ //$NON-NLS-0$
- + " on " + new Date(commit.Time).toLocaleString(); //$NON-NLS-0$
- detailsView.appendChild(description);
- };
-
- return GitStatusExplorer;
- }());
-
- return exports;
-}); // end of define
+ div.appendChild(icon);
+
+ var itemLabel = document.createElement("span"); //$NON-NLS-0$
+ itemLabel.textContent = item.name;
+ div.appendChild(itemLabel);
+
+ return td;
+ } else {
+ // render the compare widget
+ var td = document.createElement("td"); //$NON-NLS-0$
+ td.colSpan = 2;
+
+ var div = document.createElement("div"); //$NON-NLS-0$
+ div.className = "sectionTableItem"; //$NON-NLS-0$
+ td.appendChild(div);
+
+ var compareWidgetActionWrapper = document.createElement("div"); //$NON-NLS-0$
+ compareWidgetActionWrapper.className = "sectionExplorerActions"; //$NON-NLS-0$
+ compareWidgetActionWrapper.id = "staged" + item.parent.name + "CompareWidgetActionWrapper"; //$NON-NLS-1$ //$NON-NLS-0$
+ div.appendChild(compareWidgetActionWrapper);
+
+ var diffContainer = document.createElement("div"); //$NON-NLS-0$
+ diffContainer.id = "diffArea_" + item.diffUri; //$NON-NLS-0$
+ diffContainer.style.height = "420px"; //$NON-NLS-0$
+ diffContainer.style.border = "1px solid lightgray"; //$NON-NLS-0$
+ diffContainer.style.overflow = "hidden"; //$NON-NLS-0$
+ div.appendChild(diffContainer);
+
+ var navGridHolder = this.explorer.getNavDict() ? this.explorer.getNavDict().getGridNavHolder(item, true) : null;
+ var hasConflict = isConflict(item.parent.type);
+ mGitUtil.createCompareWidget(
+ that.registry,
+ that.commandService,
+ item.diffUri,
+ isConflict(item.parent.type),
+ diffContainer,
+ compareWidgetActionWrapper.id,
+ false, //editableInComparePage
+ {navGridHolder: navGridHolder} //gridRenderer
+ );
+
+ return td;
+ }
+
+ break;
+ }
+ };
+
+ return StagedRenderer;
+ }());
+
+ var StagedNavigator = (function() {
+ function StagedNavigator(registry, selection, parentId, actionScopeId) {
+ this.registry = registry;
+ this.checkbox = false;
+ this.parentId = parentId;
+ this.status = status;
+ this.selection = selection;
+ this.actionScopeId = actionScopeId;
+ this.renderer = new StagedRenderer({ registry : this.registry, /*
+ * actionScopeId:
+ * sectionItemActionScopeId,
+ */
+ cachePrefix : "StagedNavigator", checkbox : false}, this); //$NON-NLS-0$
+ this.createTree(this.parentId, new StagedModel());
+ }
+
+ StagedNavigator.prototype = new mExplorer.Explorer();
+
+ // provide to the selection model that if a row is
+ // selectable
+ StagedNavigator.prototype.isRowSelectable = function(modelItem) {
+ return mGitUtil.isChange(modelItem);
+ };
+ // provide to the expandAll/collapseAll commands
+ StagedNavigator.prototype.getItemCount = function() {
+ return stagedSortedChanges.length;
+ };
+ return StagedNavigator;
+ }());
+
+ var stagedNavigator = new StagedNavigator(this.registry, this.stagedSelection, "stagedNode" /*
+ * ,
+ * sectionItemActionScopeId
+ */); //$NON-NLS-0$
+ this.commandService.renderCommands(stagedSection.actionsNode.id, stagedSection.actionsNode.id, stagedNavigator, stagedNavigator, "button"); //$NON-NLS-0$
+ };
+
+ // Git commits
+
+ GitStatusExplorer.prototype.displayCommits = function(repository) {
+ var that = this;
+ var tableNode = lib.node('table'); //$NON-NLS-0$
+ var titleWrapper = new mSection.Section(tableNode, {
+ id : "commitSection", //$NON-NLS-0$
+ title : messages['Commits'],
+ content : '<div id="commitNode" class="mainPadding"></div>', //$NON-NLS-0$
+ slideout : true,
+ canHide : true,
+ preferenceService : this.registry.getService("orion.core.preference") //$NON-NLS-0$
+ });
+
+ var progress = titleWrapper.createProgressMonitor();
+
+ progress.begin(messages['Getting current branch']);
+ this.registry
+ .getService("orion.page.progress").progress(this.registry.getService("orion.git.provider").getGitBranch(repository.BranchLocation), "Getting current branch " + repository.Name).then( //$NON-NLS-0$
+ function(resp) {
+ var branches = resp.Children;
+ var currentBranch;
+ for (var i = 0; i < branches.length; i++) {
+ if (branches[i].Current) {
+ currentBranch = branches[i];
+ break;
+ }
+ }
+
+ if (!currentBranch){
+ progress.done();
+ return;
+ }
+
+ var tracksRemoteBranch = (currentBranch.RemoteLocation.length === 1 && currentBranch.RemoteLocation[0].Children.length === 1);
+
+ titleWrapper.setTitle(i18nUtil.formatMessage(messages["Commits for \"${0}\" branch"], currentBranch.Name));
+ that.commandService.destroy(titleWrapper.actionsNode.id);
+ that.commandService.registerCommandContribution(titleWrapper.actionsNode.id,
+ "eclipse.orion.git.repositories.viewAllCommand", 10); //$NON-NLS-0$
+ that.commandService.renderCommands(
+ titleWrapper.actionsNode.id,
+ titleWrapper.actionsNode.id,
+ { "ViewAllLink" : "git/git-log.html#" + currentBranch.CommitLocation + "?page=1",
+ "ViewAllLabel" : messages['See Full Log'],
+ "ViewAllTooltip" : messages["See the full log"]
+ }, that, "button"); //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+
+ if (tracksRemoteBranch) {
+ that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.fetch", 100); //$NON-NLS-0$
+ that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.merge", 100); //$NON-NLS-0$
+ that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.rebase", 100); //$NON-NLS-0$
+ that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.resetIndex", 100); //$NON-NLS-0$
+ that.commandService.renderCommands(titleWrapper.actionsNode.id, titleWrapper.actionsNode.id,
+ currentBranch.RemoteLocation[0].Children[0], that, "button"); //$NON-NLS-0$
+ }
+
+ that.commandService.registerCommandContribution(titleWrapper.actionsNode.id, "eclipse.orion.git.push", 100); //$NON-NLS-0$
+ that.commandService.renderCommands(titleWrapper.actionsNode.id, titleWrapper.actionsNode.id, currentBranch, that,
+ "button"); //$NON-NLS-0$
+
+ if (currentBranch.RemoteLocation[0] === null) {
+ progress.done();
+ that.renderNoCommit();
+ return;
+ }
+
+ progress.worked(i18nUtil.formatMessage(messages['Getting commits for \"${0}\" branch'], currentBranch.Name));
+
+ if (tracksRemoteBranch && currentBranch.RemoteLocation[0].Children[0].CommitLocation) {
+ that.registry
+ .getService("orion.page.progress")
+ .progress(
+ that.registry.getService("orion.git.provider").getLog(
+ currentBranch.RemoteLocation[0].Children[0].CommitLocation + "?page=1&pageSize=20", "HEAD"),
+ i18nUtil.formatMessage(messages['Getting commits for \"${0}\" branch'], currentBranch.Name)).then( //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ function(resp) {
+ progress.worked(messages['Rendering commits']);
+
+ var commitsCount = resp.Children.length;
+
+ for (var i = 0; i < resp.Children.length; i++) {
+ that.renderCommit(resp.Children[i], true, i);
+ }
+
+ progress.worked(messages['Getting outgoing commits']);
+ that.registry
+ .getService("orion.page.progress").progress(that.registry.getService("orion.git.provider").getLog(currentBranch.CommitLocation + "?page=1&pageSize=20", currentBranch.RemoteLocation[0].Children[0].Id), messages['Getting outgoing commits']).then( //$NON-NLS-1$ //$NON-NLS-0$
+ function(resp) {
+ progress.worked(messages['Rendering commits']);
+ for (var i = 0; i < resp.Children.length; i++) {
+ that.renderCommit(resp.Children[i], false, i + commitsCount);
+ }
+
+ commitsCount = commitsCount + resp.Children.length;
+
+ if (commitsCount === 0) {
+ that.renderNoCommit();
+ }
+
+ progress.done();
+ }, function(error) {
+ progress.done(error);
+ });
+ }, function(error) {
+ progress.done(error);
+ });
+ } else {
+ that.registry.getService("orion.page.progress").progress(
+ that.registry.getService("orion.git.provider").doGitLog(currentBranch.CommitLocation + "?page=1&pageSize=20"),
+ i18nUtil.formatMessage(messages['Getting commits for \"${0}\" branch'], currentBranch.Name)).then( //$NON-NLS-1$ //$NON-NLS-0$
+ function(resp) {
+ progress.worked(messages['Rendering commits']);
+ for (var i = 0; i < resp.Children.length; i++) {
+ that.renderCommit(resp.Children[i], true, i);
+ }
+
+ if (resp.Children.length === 0) {
+ that.renderNoCommit();
+ }
+
+ progress.done();
+ }, function(error) {
+ progress.done(error);
+ }
+ );
+ }
+ });
+ };
+
+ GitStatusExplorer.prototype.renderNoCommit = function() {
+ var commitNode = lib.node("commitNode"); //$NON-NLS-0$
+ commitNode.innerHTML = ""; //$NON-NLS-0$
+ var sectionItem = document.createElement("div"); //$NON-NLS-0$
+ sectionItem.className = "sectionTableItem"; //$NON-NLS-0$
+ commitNode.appendChild(sectionItem);
+
+ var detailsView = document.createElement("div"); //$NON-NLS-0$
+ detailsView.className = "stretch"; //$NON-NLS-0$
+ sectionItem.appendChild(detailsView);
+
+ var title = document.createElement("div"); //$NON-NLS-0$
+ title.appendChild(document.createTextNode(messages['The branch is up to date.']));
+ detailsView.appendChild(title);
+
+ var description = document.createElement("div"); //$NON-NLS-0$
+ description.appendChild(document.createTextNode(messages['You have no outgoing or incoming commits.']));
+ detailsView.appendChild(description);
+ };
+
+ GitStatusExplorer.prototype.renderCommit = function(commit, outgoing, index) {
+ var commitNode = lib.node("commitNode"); //$NON-NLS-0$
+ commitNode.innerHTML = ""; //$NON-NLS-0$
+ var sectionItem = document.createElement("div"); //$NON-NLS-0$
+ sectionItem.className = "sectionTableItem lightTreeTableRow"; //$NON-NLS-0$
+ commitNode.appendChild(sectionItem);
+
+ var horizontalBox = document.createElement("div"); //$NON-NLS-0$
+ horizontalBox.className = "sectionTableItem"; //$NON-NLS-0$
+ horizontalBox.style.overflow = "hidden"; //$NON-NLS-0$
+ sectionItem.appendChild(horizontalBox);
+
+ var imgSpriteName = (outgoing ? "git-sprite-outgoing_commit" : "git-sprite-incoming_commit"); //$NON-NLS-1$ //$NON-NLS-0$
+
+ var direction = document.createElement("span"); //$NON-NLS-0$
+ direction.className = "sectionIcon gitImageSprite " + imgSpriteName; //$NON-NLS-0$
+ horizontalBox.appendChild(direction);
+
+ if (commit.AuthorImage) {
+ var authorImage = document.createElement("div"); //$NON-NLS-0$
+ authorImage.style['float'] = "left"; //$NON-NLS-0$
+ var image = new Image();
+ image.src = commit.AuthorImage;
+ image.name = commit.AuthorName;
+ image.className = "git-author-icon"; //$NON-NLS-0$
+ authorImage.appendChild(image);
+ horizontalBox.appendChild(authorImage);
+ }
+
+ var detailsView = document.createElement("div"); //$NON-NLS-0$
+ detailsView.className = "stretch"; //$NON-NLS-0$
+ horizontalBox.appendChild(detailsView);
+
+ var titleLink = document.createElement("a"); //$NON-NLS-0$
+ titleLink.className = "navlinkonpage"; //$NON-NLS-0$
+ titleLink.href = require.toUrl("git/git-commit.html#") + commit.Location + "?page=1&pageSize=1"; //$NON-NLS-1$ //$NON-NLS-0$
+ titleLink.textContent = commit.Message;
+ detailsView.appendChild(titleLink);
+
+ new mCommitTooltip.CommitTooltipDialog({commit: commit, triggerNode: titleLink});
+
+ var d = document.createElement("div"); //$NON-NLS-0$
+ detailsView.appendChild(d);
+
+ var description = document.createElement("span"); //$NON-NLS-0$
+ description.textContent = " (SHA " + commit.Name + ") by " + commit.AuthorName //$NON-NLS-1$ //$NON-NLS-0$
+ + " on " + new Date(commit.Time).toLocaleString(); //$NON-NLS-0$
+ detailsView.appendChild(description);
+ };
+
+ return GitStatusExplorer;
+ }());
+
+ return exports;
+}); // end of define
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/util.js b/bundles/org.eclipse.orion.client.git/web/orion/git/util.js
index 397c0b1..d0ec7de 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/util.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/util.js
@@ -68,10 +68,10 @@ define(['i18n!git/nls/gitmessages', 'orion/compare/compareCommands', 'orion/comp
* Create an embedded toggleable compare widget inside a given DIV.
* @param {Object} serviceRegistry The serviceRegistry.
* @param {Object} commandService The commandService.
- * @param {Sting} resoure The URL string of the complex URL which will be resolved by a diff provider into two file URLs and the unified diff.
+ * @param {String} resoure The URL string of the complex URL which will be resolved by a diff provider into two file URLs and the unified diff.
* @param {Boolean} hasConflicts The flag to indicate if the compare contains conflicts.
- * @param {Sting} parentDivId The id of the DIV that holds the compare widget.
- * @param {Sting} commandSpanId The id of the DIV where all the commands of the compare view are rendered. "Open in compare page", "toggle", "navigate diff" commands will be rendered.
+ * @param {Object} parentDivId The DIV node or string id of the DIV that holds the compare widget.
+ * @param {String} commandSpanId The id of the DIV where all the commands of the compare view are rendered. "Open in compare page", "toggle", "navigate diff" commands will be rendered.
* @param {Boolean} editableInComparePage The flag to indicate if opening compage will be editable on the left side. Default is false. Optional.
* @param {Object} gridRenderer If all the commands have to be rendered as grids, especially inside a row of Orion explorer, this has to be provided. Optional.
* @param {String} compareTo Optional. If the resource parameter is a simple file URL then this can be used as the second file URI to compare with.
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 e76c5db..b8d7538 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
@@ -532,14 +532,14 @@ exports.TwoWayCompareView = (function() {
* @name orion.compare.TwoWayCompareView
*/
exports.InlineCompareView = (function() {
- function InlineCompareView(options ) {
+ function InlineCompareView(options) {
this.setOptions(options, true);
this._diffNavigator = new mDiffTreeNavigator.DiffTreeNavigator("word"); //$NON-NLS-0$
this.type = "inline"; //$NON-NLS-0$
if(this.options.commandProvider){
this.options.commandProvider.initCommands(this);
}
- this._editorDivId = this.options.parentDivId;
+ this._editorDiv = this.options.parentDivId;
}
InlineCompareView.prototype = new exports.CompareView();
@@ -577,7 +577,7 @@ exports.InlineCompareView = (function() {
};
InlineCompareView.prototype.initEditors = function(initString){
- var parentDiv = lib.node(this._editorDivId);
+ var parentDiv = lib.node(this._editorDiv);
var textViewFactory = function(){
var textView = new mTextView.TextView({
parent: parentDiv,
@@ -682,7 +682,7 @@ exports.InlineCompareView = (function() {
* @name orion.compare.toggleableCompareView
*/
exports.toggleableCompareView = (function() {
- function toggleableCompareView(startWith, options ) {
+ function toggleableCompareView(startWith, options) {
if(options){
options.toggler = this;
}