aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Bendkowski2012-08-30 11:53:13 (EDT)
committerSzymon Brandys2012-08-30 11:53:13 (EDT)
commitf8728dfae75ec8dfe0ab4439186d4279d1fb7253 (patch)
tree143a3ee718e522787bdfa75923721f42401e0351
parent88df45b81dcc0b2918b41908a692fc778a04d8ce (diff)
downloadorg.eclipse.orion.client-f8728dfae75ec8dfe0ab4439186d4279d1fb7253.zip
org.eclipse.orion.client-f8728dfae75ec8dfe0ab4439186d4279d1fb7253.tar.gz
org.eclipse.orion.client-f8728dfae75ec8dfe0ab4439186d4279d1fb7253.tar.bz2
Bug 369604 - hard to find branches in the "see all branches" list squash
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/section.js3
-rw-r--r--bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js4
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js29
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/widgets/FilterSearchBox.js102
4 files changed, 133 insertions, 5 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/section.js b/bundles/org.eclipse.orion.client.core/web/orion/section.js
index 6f3ee18..e95ff7a 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/section.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/section.js
@@ -84,6 +84,9 @@ define(['dojo', 'orion/selection', 'orion/commands', 'orion/commonHTMLFragments'
this._progressNode = dojo.create( "div", { id: options.id + "Progress", "class": "sectionProgress sectionTitle layoutLeft", innerHTML: "..."}, this.domNode ); //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
this._progressNode.style.visibility = "hidden"; //$NON-NLS-0$
+ // add filter search box
+ dojo.create("div", {"id" : options.id + "FilterSearchBox"}, this.domNode);
+
this._toolActionsNode = dojo.create( "div", { id: options.id + "ToolActionsArea", "class":"layoutRight sectionActions"}, this.domNode ); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
this.actionsNode = dojo.create( "div", { id: options.id + "ActionArea", "class":"layoutRight sectionActions"}, this.domNode ); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
this.selectionNode = dojo.create( "div", { id: options.id + "SelectionArea", "class":"layoutRight sectionActions"}, this.domNode ); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js
index 489c600..2ac6bef 100644
--- a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js
+++ b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js
@@ -345,7 +345,9 @@ define({
"Change..." : "Change...",
"Merge Squash": "Merge Squash",
"Squash the content of the branch to the index" : "Squash the content of the branch to the index",
- "Local Branch Name:" : "Local Branch Name:",
+ "Local Branch Name:" : "Local Branch Name:",
+ "Filter items" : "Filter items",
+ "Filter remote branches" : "Filter remote branches",
"Paste link in email or IM" : "Paste link in email or IM",
"Show Commit in GitHub" : "Show Commit in GitHub",
"Show Repository in GitHub" : "Show Repository in GitHub",
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js
index 65e3166..3ab0922 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitRepositoryExplorer.js
@@ -11,8 +11,8 @@
/*global define dijit console document Image */
-define(['i18n!git/nls/gitmessages', 'require', 'dojo', 'orion/commands', 'orion/section', 'orion/dynamicContent', 'orion/util', 'orion/PageUtil', 'orion/globalCommands', 'orion/git/gitCommands', 'orion/git/widgets/CommitTooltipDialog'],
- function(messages, require, dojo, mCommands, mSection, mDynamicContent, mUtil, PageUtil, mGlobalCommands, mGitCommands) {
+define(['i18n!git/nls/gitmessages', 'require', 'dojo', 'orion/commands', 'orion/section', 'orion/dynamicContent', 'orion/git/widgets/FilterSearchBox', 'orion/util', 'orion/PageUtil', 'orion/globalCommands', 'orion/git/gitCommands', 'orion/git/widgets/CommitTooltipDialog'],
+ function(messages, require, dojo, mCommands, mSection, mDynamicContent, mFilterSearchBox, mUtil, PageUtil, mGlobalCommands, mGitCommands) {
var exports = {};
exports.GitRepositoryExplorer = (function() {
@@ -623,7 +623,7 @@ exports.GitRepositoryExplorer = (function() {
);
};
- GitRepositoryExplorer.prototype.displayRemoteBranches2 = function(titleWrapper, remotes, repository, deferred, anyRemoteBranch){
+ GitRepositoryExplorer.prototype.displayRemoteBranches2 = function(titleWrapper, remotes, repository, deferred, anyRemoteBranch, previousRemoteBranches){
var that = this;
if (deferred == null)
deferred = new dojo.Deferred();
@@ -636,7 +636,28 @@ exports.GitRepositoryExplorer = (function() {
remoteBranches[i].Repository = repository;
that.renderRemoteBranch(remoteBranches[i], i);
}
- that.displayRemoteBranches2(titleWrapper, remotes.slice(1), repository, deferred, (anyRemoteBranch || (remoteBranches.length > 0)));
+
+ //concat with previous branches to get full list for the search box
+ if(previousRemoteBranches){
+ remoteBranches = previousRemoteBranches.concat(remoteBranches);
+ }
+
+ if(remotes.length === 1){
+ //add filter/search box after all branches are rendered
+ var remoteBranchesSearchBox = new mFilterSearchBox.FilterSearchBox({
+ items : remoteBranches,
+ renderItem : function(branch){
+ that.renderRemoteBranch.bind(that)(branch);
+ },
+ sectionId : "remoteBranchSection",
+ itemNode : "remoteBranchNode",
+ placeHolder : messages["Filter remote branches"]
+ });
+
+ remoteBranchesSearchBox.render();
+ }
+
+ that.displayRemoteBranches2(titleWrapper, remotes.slice(1), repository, deferred, (anyRemoteBranch || (remoteBranches.length > 0)), remoteBranches);
}, function () {
}
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/FilterSearchBox.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/FilterSearchBox.js
new file mode 100644
index 0000000..7d1e9cf
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/FilterSearchBox.js
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+ define(['i18n!git/nls/gitmessages', 'dojo', 'dijit', 'dojo/store/Memory', 'dojo/data/ObjectStore', 'dijit/form/ComboBox'],
+ function(messages, dojo, dijit, Memory, ObjectStore, ComboBox){
+
+ /**
+ * Filtering search box widget
+ * @param options.items [required] loaded items to be filtered
+ * @param options.renderItem [required] function(item) which renders the item
+ * @param options.sectionId [required] section id in which the filter search box is rendered
+ * @param options.itemNode [required] node in which filtered items are rendered
+ * @param options.filterAttr [optional] unique property after which items are filtered (default: Name)
+ * @param options.placeHolder [optional] filter search box placeholder (default: externalized Filter items)
+ */
+ function FilterSearchBox(options){
+ if(!options) { throw new Error("Missing argument: options"); }
+
+ this._items = options.items;
+ this._renderItem = options.renderItem;
+ this._id = options.sectionId + "FilterSearchBox";
+ this._itemNode = options.itemNode;
+
+ //optional parameters
+ if(options.filterAttr) { this._filterAttr = options.filterAttr; }
+ else { this._filterAttr = "Name"; }
+
+ if(options.placeHolder) { this._placeHolder = options.placeHolder; }
+ else { this._placeHolder = messages["Filter items"]; }
+ }
+
+ FilterSearchBox.prototype = {
+
+ /**
+ * Cleans the view by deleting all of the rendered items
+ **/
+ _cleanup : function(){
+ dojo.empty(this._itemNode);
+ },
+
+ /**
+ * Renders the search box into the view
+ */
+ render : function(){
+ if(dijit.byId(this._id)){
+ return;
+ }
+
+ var that = this;
+
+ // create a store based on the given items
+ var store = new Memory({
+ idProperty : this._filterAttr, //$NON-NLS-0$
+ data : that._items
+ });
+
+ var select = new ComboBox({
+ name: that._id,
+ placeHolder: that._placeHolder,
+ store: new ObjectStore({objectStore : store}),
+ searchAttr : that._filterAttr, //$NON-NLS-0$
+ highlightMatch : "all", //$NON-NLS-0$
+ queryExpr : "*${0}*", //$NON-NLS-0$
+ autoComplete : false,
+ style : { width : "280px" }
+ }, that._id);
+
+ dojo.connect(select, "onChange", function(){
+ var exp = new RegExp(select.get('displayedValue'), 'i'); //$NON-NLS-0$
+
+ //clean the view
+ that._cleanup();
+
+ setTimeout(function(){
+ //filter items
+ store.query(function(item){
+ return item[that._filterAttr].match(exp);
+ }).forEach(function(item){
+ //render matched item
+ that._renderItem(item);
+ });}, 1);
+ });
+
+ //update widget
+ select.startup();
+ }
+ };
+
+ //add constructor
+ FilterSearchBox.prototype.constructor = FilterSearchBox;
+
+ return {
+ FilterSearchBox : FilterSearchBox
+ };
+ }); \ No newline at end of file