8
|
1 define([
|
|
2 "dojo/_base/declare",
|
|
3 "implab/safe",
|
|
4 "implab/components/ActivationController",
|
|
5 "./ToolType" ],
|
|
6
|
|
7 function(declare, safe, ActivationController, ToolType) {
|
|
8 return declare([ ActivationController ], {
|
|
9 _stack : null,
|
|
10 _tools : null,
|
|
11
|
|
12 constructor : function() {
|
|
13 this._stack = new Array();
|
|
14 this._tools = new Array();
|
|
15 },
|
|
16
|
|
17 activate : function(tool) {
|
|
18 safe.argumentNotNull(tool, "tool");
|
|
19
|
|
20 var me = this, current = me.getCurrent();
|
|
21
|
|
22 return this.inherited(arguments).then(function(success) {
|
|
23 if (success) {
|
|
24 if (tool.toolType == ToolType.Oneshot && current)
|
|
25 me._stack.push(current);
|
|
26 else
|
|
27 me._stack = [];
|
|
28 }
|
|
29 return success;
|
|
30 });
|
|
31 },
|
|
32
|
|
33 deactivate : function() {
|
|
34 var me = this;
|
|
35 return me.inherited(arguments).then(function(success) {
|
|
36 if (success && me._stack.length)
|
|
37 return me.activate(me._stack.pop());
|
|
38
|
|
39 return success;
|
|
40 });
|
|
41 }
|
|
42 });
|
|
43 }); |