summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPiotr Janik2011-05-26 06:05:12 (EDT)
committer Szymon Brandys2011-05-26 06:05:12 (EDT)
commit2367135fa2ba1810ec5feff5f515b5be67858886 (patch)
tree4ec35233bd59acb4a6d70a6c6f5367d8bbc0c534
parent68ca93944d74170857fc0b81d2b1804730f85a69 (diff)
downloadorg.eclipse.orion.client-2367135fa2ba1810ec5feff5f515b5be67858886.zip
org.eclipse.orion.client-2367135fa2ba1810ec5feff5f515b5be67858886.tar.gz
org.eclipse.orion.client-2367135fa2ba1810ec5feff5f515b5be67858886.tar.bz2
bug 344215 - [client][git] Missing functionality: manage remotes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=344215
-rw-r--r--bundles/org.eclipse.orion.client.git/static/js/git-clone/git-clone.js2
-rw-r--r--bundles/org.eclipse.orion.client.git/static/js/gitClient.js40
-rw-r--r--bundles/org.eclipse.orion.client.git/static/js/gitCommands.js45
-rw-r--r--bundles/org.eclipse.orion.client.git/static/js/widgets/AddRemoteDialog.js39
-rw-r--r--bundles/org.eclipse.orion.client.git/static/js/widgets/templates/AddRemoteDialog.html36
5 files changed, 162 insertions, 0 deletions
diff --git a/bundles/org.eclipse.orion.client.git/static/js/git-clone/git-clone.js b/bundles/org.eclipse.orion.client.git/static/js/git-clone/git-clone.js
index bdec6c9..6e2c259 100644
--- a/bundles/org.eclipse.orion.client.git/static/js/git-clone/git-clone.js
+++ b/bundles/org.eclipse.orion.client.git/static/js/git-clone/git-clone.js
@@ -44,6 +44,8 @@ dojo.addOnLoad(function(){
commandService.registerCommandContribution("eclipse.checkoutBranch", 2);
commandService.registerCommandContribution("eclipse.addBranch", 2);
commandService.registerCommandContribution("eclipse.removeBranch", 2);
+ commandService.registerCommandContribution("eclipse.addRemote", 2);
+ commandService.registerCommandContribution("eclipse.removeRemote", 2);
commandService.registerCommandContribution("eclipse.openGitLog", 2);
commandService.registerCommandContribution("eclipse.orion.git.fetch", 2);
commandService.registerCommandContribution("eclipse.orion.git.merge", 2);
diff --git a/bundles/org.eclipse.orion.client.git/static/js/gitClient.js b/bundles/org.eclipse.orion.client.git/static/js/gitClient.js
index 4cea9c0..d2e1a04 100644
--- a/bundles/org.eclipse.orion.client.git/static/js/gitClient.js
+++ b/bundles/org.eclipse.orion.client.git/static/js/gitClient.js
@@ -380,6 +380,46 @@ eclipse.GitService = (function() {
console.error("HTTP status code: ", ioArgs.xhr.status);
}
});
+ },
+ addRemote : function(gitRemoteParentURI, remoteName, remoteURI) {
+ var service = this;
+ return dojo.xhrPost({
+ url : gitRemoteParentURI,
+ headers : {
+ "Orion-Version" : "1"
+ },
+ putData : dojo.toJson({
+ "Remote" : remoteName,
+ "RemoteURI" : remoteURI
+ }),
+ handleAs : "json",
+ timeout : 5000,
+ load : function(jsonData, secondArg) {
+ return jsonData;
+ },
+ error : function(error, ioArgs) {
+ handleGetAuthenticationError(this, ioArgs);
+ console.error("HTTP status code: ", ioArgs.xhr.status);
+ }
+ });
+ },
+ removeRemote : function(gitRemoteURI) {
+ var service = this;
+ return dojo.xhrDelete({
+ url : gitRemoteURI,
+ headers : {
+ "Orion-Version" : "1"
+ },
+ handleAs : "json",
+ timeout : 5000,
+ load : function(jsonData, secondArg) {
+ return jsonData;
+ },
+ error : function(error, ioArgs) {
+ handleGetAuthenticationError(this, ioArgs);
+ console.error("HTTP status code: ", ioArgs.xhr.status);
+ }
+ });
},
doGitLog : function(gitLogURI, onLoad) {
var service = this;
diff --git a/bundles/org.eclipse.orion.client.git/static/js/gitCommands.js b/bundles/org.eclipse.orion.client.git/static/js/gitCommands.js
index 2b4aa68..0c30cc5 100644
--- a/bundles/org.eclipse.orion.client.git/static/js/gitCommands.js
+++ b/bundles/org.eclipse.orion.client.git/static/js/gitCommands.js
@@ -25,6 +25,7 @@ eclipse.gitCommandUtils = eclipse.gitCommandUtils || {};
dojo.require("widgets.CloneGitRepositoryDialog");
dojo.require("widgets.InitGitRepositoryDialog");
+dojo.require("widgets.AddRemoteDialog");
dojo.require("widgets.GitCredentialsDialog");
//this function is just a closure for the global "doOnce" flag
@@ -293,6 +294,50 @@ dojo.require("widgets.GitCredentialsDialog");
);
commandService.addCommand(removeBranchCommand, "object");
+ var addRemoteCommand = new eclipse.Command({
+ name: "Add Remote",
+ image: "/images/add_obj.gif",
+ id: "eclipse.addRemote",
+ callback : function(item) {
+ var dialog = new widgets.AddRemoteDialog({
+ func : function(remote, remoteURI){
+ serviceRegistry.getService("orion.git.provider").then(function(gitService) {
+ gitService.addRemote(item.Location, remote, remoteURI).then(
+ function() {
+ dojo.hitch(explorer, explorer.changedItem)(item);
+ });
+ });
+ }
+ });
+ dialog.startup();
+ dialog.show();
+ },
+ visibleWhen: function(item) {
+ return item.GroupNode && item.Name === "Remote";
+ }}
+ );
+ commandService.addCommand(addRemoteCommand, "object");
+
+ var removeRemoteCommand = new eclipse.Command({
+ name: "Remove Remote",
+ image: "/images/remove.gif",
+ id: "eclipse.removeRemote",
+ callback: function(item) {
+ serviceRegistry.getService("orion.git.provider").then(
+ function(service) {
+ service.removeRemote(item.Location).then(
+ function(){
+ dojo.hitch(explorer, explorer.changedItem)(item.parent);
+ });
+ }
+ );
+ },
+ visibleWhen: function(item) {
+ return item.Type === "Remote";
+ }}
+ );
+ commandService.addCommand(removeRemoteCommand, "object");
+
var openGitLog = new eclipse.Command({
name : "Show Git Log",
id : "eclipse.openGitLog",
diff --git a/bundles/org.eclipse.orion.client.git/static/js/widgets/AddRemoteDialog.js b/bundles/org.eclipse.orion.client.git/static/js/widgets/AddRemoteDialog.js
new file mode 100644
index 0000000..46c354a
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.git/static/js/widgets/AddRemoteDialog.js
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 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 dojo dijit widgets*/
+dojo.provide("widgets.AddRemoteDialog");
+
+dojo.require("dijit.Dialog");
+dojo.require("widgets._OrionDialogMixin");
+
+/**
+ * @param options {{
+ * func: function
+ * }}
+ */
+dojo.declare("widgets.AddRemoteDialog", [dijit.Dialog, widgets._OrionDialogMixin], {
+ widgetsInTemplate: true,
+ templateString: dojo.cache("widgets", "templates/AddRemoteDialog.html"),
+
+ constructor : function() {
+ this.inherited(arguments);
+ this.options = arguments[0] || {};
+ },
+ postMixInProperties : function() {
+ this.inherited(arguments);
+ this.title = "Add Remote";
+ this.gitRemoteLabelText = "Remote Name:";
+ this.gitRemoteURILabelText = "Remote URI:";
+ },
+ execute: function() {
+ this.options.func(this.gitRemote.value, this.gitRemoteURI.value);
+ }
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.git/static/js/widgets/templates/AddRemoteDialog.html b/bundles/org.eclipse.orion.client.git/static/js/widgets/templates/AddRemoteDialog.html
new file mode 100644
index 0000000..dc2b49e
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.git/static/js/widgets/templates/AddRemoteDialog.html
@@ -0,0 +1,36 @@
+<div class="dijitDialog" tabindex="-1" waiRole="dialog" waiState="labelledby-${id}_title">
+ <div dojoAttachPoint="titleBar" class="dijitDialogTitleBar">
+ <span dojoAttachPoint="titleNode" class="dijitDialogTitle" id="${id}_title"></span>
+ <span dojoAttachPoint="closeButtonNode" class="dijitDialogCloseIcon" dojoAttachEvent="onclick: onCancel" title="${buttonCancel}">
+ <span dojoAttachPoint="closeText" class="closeText" title="${buttonCancel}">x</span>
+ </span>
+ </div>
+ <div dojoAttachPoint="containerNode" class="dijitDialogPaneContent">
+ <!-- Actual content here -->
+ <div style="display: table">
+ <div style="display: table-row">
+ <div style="display: table-cell; padding: 5">
+ <label dojoAttachPoint="gitRemoteLabel" for="${id}_gitRemote" style="padding-right: 10">${gitRemoteLabelText}</label>
+ </div>
+ <div style="display: table-cell; padding: 5; width: 40em; text-align: left;">
+ <input dojoAttachPoint="gitRemote" id="${id}_gitRemote" style="display: inline-block; width: 98%;" value="">
+ </div>
+ </div>
+ <div style="display: table-row">
+ <div style="display: table-cell; padding: 5">
+ <label dojoAttachPoint="gitRemoteURILabel" for="${id}_gitRemoteURI" style="padding-right: 10">${gitRemoteURILabelText}</label>
+ </div>
+ <div style="display: table-cell; padding: 5; width: 40em; text-align: left;">
+ <input dojoAttachPoint="gitRemoteURI" id="${id}_gitRemoteURI" style="display: inline-block; width: 98%;" value="">
+ </div>
+ </div>
+ <div style="display: table-row">
+ <div style="display: table-cell; padding: 5"></div>
+ <div style="display: table-cell; padding: 5">
+ <button dojoAttachPoint="cloneItemButton" dojoType="dijit.form.Button" type="submit" value="OK" style="padding: 20 0 10 0; float: right; clear: both;">OK
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+</div> \ No newline at end of file