summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalgorzata Janczarska <malgorzata.tomczyk@pl.ibm.com>2013-12-06 15:17:03 +0100
committerMalgorzata Janczarska <malgorzata.tomczyk@pl.ibm.com>2013-12-06 15:17:03 +0100
commit2473f347699766f052a7a9e25451c39827264e36 (patch)
tree3fed5c07726db6da2f1ca9d6f95abfd166664db4
parentf7f614a65533f84db86cbddbaca02fdc16164c8d (diff)
downloadorg.eclipse.orion.client-origin/Bug423062.zip
org.eclipse.orion.client-origin/Bug423062.tar.gz
org.eclipse.orion.client-origin/Bug423062.tar.bz2
Bug 423062 - [Project] Start/stop deployed applicationorigin/Bug423062
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js48
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/projects/projectEditor.js31
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/section.js11
3 files changed, 83 insertions, 7 deletions
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 fc9ddaa..73e3c3d 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js
@@ -298,7 +298,53 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/comm
}
});
commandService.addCommand(checkStateCommand);
-
+
+ function createStartStopCommand(start){
+ var stopApplicationCommand = new mCommands.Command({
+ name: start ? "Start" :"Stop",
+ tooltip: start ? "Start application" : "Stop application",
+ id: start ? "orion.launchConfiguration.startApp" : "orion.launchConfiguration.stopApp", //$NON-NLS-0$
+ imageClass: start ? "core-sprite-start" : "core-sprite-stop",
+ callback: function(data) {
+ var item = forceSingleItem(data.items);
+
+ data.oldParams = item.params;
+
+ var func = arguments.callee;
+ var params = handleParamsInCommand(func, data, start? "Start application" : "Stop application");
+ if(!params){
+ return;
+ }
+
+ projectClient.getProjectDelpoyService(item.ServiceId).then(function(service){
+ if(service && (start ? service.start : service.stop)){
+ (start ? service.start : service.stop)(params).then(function(result){
+ item.status = result;
+ if(sharedLaunchConfigurationDispatcher){
+ sharedLaunchConfigurationDispatcher.dispatchEvent({type: "changeState", newValue: item });
+ }
+ }, function(error){
+ if(error.Retry){
+ data.parameters = getCommandParameters(error.Retry.parameters, error.Retry.optionalParameters);
+ data.oldParams = params;
+ commandService.collectParameters(data);
+ } else {
+ errorHandler(error);
+ }
+ });
+ }
+ });
+ },
+ visibleWhen: function(items) {
+ var item = forceSingleItem(items);
+ return item.ServiceId && item.Name && item.status && (start ? item.status.Running===false : item.status.Running===true);
+ }
+ });
+ commandService.addCommand(stopApplicationCommand);
+ }
+
+ createStartStopCommand(true);
+ createStartStopCommand(false);
};
/**
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectEditor.js b/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectEditor.js
index 6270aa4..869a344 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectEditor.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectEditor.js
@@ -413,6 +413,32 @@ define(['orion/URITemplate', 'orion/webui/littlelib', 'orion/Deferred', 'orion/o
};
+ function LaunchConfigurationExplorer(serviceRegistry, selection, renderer, commandRegistry, launchConfigurationActions){
+ mExplorer.Explorer.apply(this, arguments);
+ this.actionScopeId = launchConfigurationActions;
+ this.selectionActions = "LaunchConfigurationExplorerSelectionActions";
+ this.actionsSections = [this.selectionActions];
+ }
+
+ LaunchConfigurationExplorer.prototype = Object.create(mExplorer.Explorer.prototype);
+
+ objects.mixin(LaunchConfigurationExplorer.prototype, /** @lends orion.Explorer.prototype */ {
+ registerCommands: function(){
+ this.commandService.registerCommandContribution(this.selectionActions, "orion.launchConfiguration.startApp", 1);
+ this.commandService.registerCommandContribution(this.selectionActions, "orion.launchConfiguration.stopApp", 2);
+ },
+ updateCommands: function(selections){
+ this.selectionActionsNode = lib.node(this.selectionActions);
+ lib.empty(this.selectionActionsNode);
+ this.commandService.renderCommands(this.selectionActions, this.selectionActionsNode, selections, this, "tool");
+ },
+ load: function(parent, project, configurations, projectClient){
+ this.createTree(parent, new LaunchConfigurationModel(project, configurations, projectClient), {indent: '8px'});
+ this.loaded();
+ },
+ constructor: LaunchConfigurationExplorer
+ });
+
function ProjectEditor(options){
this.serviceRegistry = options.serviceRegistry;
this.fileClient = options.fileClient;
@@ -606,10 +632,9 @@ define(['orion/URITemplate', 'orion/webui/littlelib', 'orion/Deferred', 'orion/o
actionScopeId: this.launchConfigurationActions,
projectClient: this.projectClient
}, this);
- var launchConfigurationExplorer = new mExplorer.Explorer(this.serviceRegistry, null, launchConfigurationRenderer, this.commandRegistry);
- launchConfigurationExplorer.actionScopeId = this.launchConfigurationActions;
+ var launchConfigurationExplorer = new LaunchConfigurationExplorer(this.serviceRegistry, null, launchConfigurationRenderer, this.commandRegistry, this.launchConfigurationActions);
launchConfigurationSection.embedExplorer(launchConfigurationExplorer, launchConfigurationParent);
- launchConfigurationExplorer.createTree(launchConfigurationParent, new LaunchConfigurationModel(this.projectData, configurations, this.projectClient), {indent: '8px'});
+ launchConfigurationExplorer.load(launchConfigurationParent, this.projectData, configurations, this.projectClient);
},
launchConfigurationChanged: function(event){
if(!this.configurations){
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/section.js b/bundles/org.eclipse.orion.client.ui/web/orion/section.js
index 10df6fe..b86371d 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/section.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/section.js
@@ -279,14 +279,19 @@ define(['orion/webui/littlelib', 'orion/selection', 'orion/commandRegistry', 'or
loaded: function(){
var self = this;
if(!this.selection){
- this.selection = new Selection.Selection(this.serviceRegistry, this.parent.id + "Selection"); //$NON-NLS-0$
+ this.selection = new Selection.Selection(this.serviceRegistry || this.registry, this.parent.id + "Selection"); //$NON-NLS-0$
this.selection.addEventListener("selectionChanged", function(event) { //$NON-NLS-0$
self.updateCommands(event.selections);
});
}
- this.registerCommands().then(function() {
+ var commandsRegistered = this.registerCommands();
+ if(!commandsRegistered || !commandsRegistered.then){
self.updateCommands();
- });
+ } else {
+ commandsRegistered.then(function() {
+ self.updateCommands();
+ });
+ }
}
});
if(explorer.renderer){