summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelijahe <elijahe@ca.ibm.com>2015-01-14 17:35:02 -0500
committerJohn Arthorne <John_Arthorne@ca.ibm.com>2015-01-14 20:01:31 -0500
commitb82a1abb480fa547b6c71fd2ce9e10b3cfa52b19 (patch)
tree568bc4015dd21c2ab38b10f025f6a4cc65d2077f
parentd4fc80d7f40794d2be540b65e2216d0c4dfe046f (diff)
downloadorg.eclipse.orion.client-origin/stable_20150113.zip
org.eclipse.orion.client-origin/stable_20150113.tar.gz
org.eclipse.orion.client-origin/stable_20150113.tar.bz2
Modified initialization of RunBar to support waiting for the completion of asynchronous eventsorigin/stable_20150113
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/customGlobalCommands.js9
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js1
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/project-nav.js17
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/projects/RunBar.js57
4 files changed, 57 insertions, 27 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/customGlobalCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/customGlobalCommands.js
index 60a56d9..3b46251 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/customGlobalCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/customGlobalCommands.js
@@ -10,11 +10,12 @@
******************************************************************************/
/*eslint-env browser, amd*/
-define(['orion/widgets/projects/RunBar'],
-function(mRunBar){
+define(['orion/Deferred', 'orion/widgets/projects/RunBar'],
+function(Deferred, mRunBar){
function createRunBar(options) {
- return new mRunBar.RunBar({
+ var runBarDeferred = new Deferred();
+ var runBar = new mRunBar.RunBar({
parentNode: options.parentNode,
projectExplorer: options.projectExplorer,
serviceRegistry: options.serviceRegistry,
@@ -24,6 +25,8 @@ function(mRunBar){
projectClient: options.projectClient,
progressService: options.progressService
});
+ runBarDeferred.resolve(runBar);
+ return runBarDeferred;
}
return {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js
index 9c2c480..e665635 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js
@@ -1369,7 +1369,6 @@ define(['require', 'i18n!orion/navigate/nls/messages', 'orion/webui/littlelib',
},
visibleWhen: function(item) {
- if(projectCommandUtils.hideAllDeployCommands) return false;
if (!(command.showCommand == undefined || command.showCommand)) return false;
item = explorer.treeRoot;
if(!item.Project || !item.children || item.children.length === 0){
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/project-nav.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/project-nav.js
index 39ac6dd..95e7825 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/project-nav.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/project-nav.js
@@ -199,14 +199,11 @@ define([
this.projectClient.getProjectLaunchConfigurations(this.treeRoot.Project).then(function(launchConfigurations){
doUpdateForLaunchConfigurations.apply(this, [launchConfigurations, selections]);
- if (this._runBar) {
- this._runBar.setLaunchConfigurations(launchConfigurations);
- }
if(!this.launchConfigurationListener){
var _self = this;
this.launchConfigurationDispatcher = ProjectCommands.getLaunchConfigurationDispatcher();
this.launchConfigurationListener = function(event){
- if(event.type === "changedVisibility"){
+ if(event.type === "changedVisibility"){ //$NON-NLS-0$
_self.updateCommands.apply(_self, selections);
} if(event.type === "changedDefault"){ //$NON-NLS-0$
return;
@@ -297,7 +294,7 @@ define([
var runBarParent = menuBar.runBarNode;
lib.empty(runBarParent);
- this._runBar = mCustomGlobalCommands.createRunBar({
+ mCustomGlobalCommands.createRunBar({
parentNode: runBarParent,
projectExplorer: this,
serviceRegistry: this.serviceRegistry,
@@ -306,9 +303,13 @@ define([
projectCommands: ProjectCommands,
projectClient: this.projectClient,
progressService: this.progressService
- });
-
- this.setRunBarVisible(true);
+ }).then(function(runBar){
+ if (runBar) {
+ // runBar successfully created, stash it and make it visible
+ this._runBar = runBar;
+ this.setRunBarVisible(true);
+ }
+ }.bind(this));
}
});
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/projects/RunBar.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/projects/RunBar.js
index 8bd6c9a..5c0a389 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/projects/RunBar.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/projects/RunBar.js
@@ -96,11 +96,22 @@ define([
this._setNodeTooltip(this._appLink, messages["openAppTooltip"]); //$NON-NLS-0$
this._disableLink(this._appLink);
+ if (this._projectExplorer.treeRoot && this._projectExplorer.treeRoot.Project) {
+ this.loadLaunchConfigurations(this._projectExplorer.treeRoot.Project);
+ } else {
+ // the Project has not yet been fully loaded into the explorer, wait until that happens
+ this._projectExplorer.addEventListener("rootChanged", function(event){ //$NON-NLS-0$
+ var root = event.root;
+ if (root && root.Project) {
+ this.loadLaunchConfigurations(root.Project);
+ }
+ }.bind(this));
+ }
} else {
throw new Error("this._domNode is null"); //$NON-NLS-0$
}
},
-
+
_createLaunchConfigurationsDropdown: function() {
this._launchConfigurationsWrapper = lib.$(".launchConfigurationsWrapper", this._domNode); //$NON-NLS-0$
this._cachedLaunchConfigurations = {};
@@ -162,11 +173,12 @@ define([
dropdownMenuItemSpan.classList.add("addNewMenuItem"); //$NON-NLS-0$
var defaultDeployCommand = this._projectCommands.getDeployProjectCommands(this._commandRegistry)[0];
-
- this._commandRegistry.registerCommandContribution(createNewItem.id, defaultDeployCommand.id, 1); //$NON-NLS-0$
- domNodeWrapperList = [];
- this._commandRegistry.renderCommands(createNewItem.id, dropdownMenuItemSpan, this._projectExplorer.treeRoot, this, "button", null, domNodeWrapperList); //$NON-NLS-0$
- domNodeWrapperList[0].domNode.textContent = messages["createNew"]; //$NON-NLS-0$
+ if (defaultDeployCommand) {
+ this._commandRegistry.registerCommandContribution(createNewItem.id, defaultDeployCommand.id, 1); //$NON-NLS-0$
+ domNodeWrapperList = [];
+ this._commandRegistry.renderCommands(createNewItem.id, dropdownMenuItemSpan, this._projectExplorer.treeRoot, this, "button", null, domNodeWrapperList); //$NON-NLS-0$
+ domNodeWrapperList[0].domNode.textContent = messages["createNew"]; //$NON-NLS-0$
+ }
}
}.bind(this);
@@ -196,15 +208,19 @@ define([
destroy: function() {
// destroy tooltips
- this._undestroyedTooltips.forEach(function(tooltip){
- tooltip.destroy();
- }, this);
- this._undestroyedTooltips = null;
+ if (this._undestroyedTooltips) {
+ this._undestroyedTooltips.forEach(function(tooltip){
+ tooltip.destroy();
+ }, this);
+ this._undestroyedTooltips = null;
+ }
// remove event listeners
- this._launchConfigurationEventTypes.forEach(function(eventType) {
- this._launchConfigurationDispatcher.removeEventListener(eventType, this._boundLaunchConfigurationListener);
- }, this);
+ if (this._launchConfigurationEventTypes) {
+ this._launchConfigurationEventTypes.forEach(function(eventType) {
+ this._launchConfigurationDispatcher.removeEventListener(eventType, this._boundLaunchConfigurationListener);
+ }, this);
+ }
if (this._playButton) {
this._playButton.removeEventListener("click", this._boundPlayButtonListener); //$NON-NLS-0$
@@ -424,7 +440,18 @@ define([
this._setText(this._appInfoSpan, "(" + appInfoText.toLocaleLowerCase() + ")"); //$NON-NLS-1$ //$NON-NLS-0$
}
},
-
+
+ /**
+ * Get launch configurations from the specified project and load them into this run bar.
+ *
+ * @param[in] {Object} project The project from which to load the launch configurations
+ */
+ loadLaunchConfigurations: function (project) {
+ this._projectClient.getProjectLaunchConfigurations(project).then(function(launchConfigurations){
+ this._setLaunchConfigurations(launchConfigurations);
+ }.bind(this));
+ },
+
/**
* Sets the list of launch configurations to be used by this run bar.
* This method may be called more than once. Any previously cached
@@ -432,7 +459,7 @@ define([
*
* @param {Array} launchConfigurations An array of launch configurations
*/
- setLaunchConfigurations: function(launchConfigurations) {
+ _setLaunchConfigurations: function(launchConfigurations) {
this._enableControl(this._launchConfigurationsWrapper);
this._menuItemsCache = []; //reset the cached launch configuration dropdown menu items
this._cacheLaunchConfigurations(launchConfigurations);