diff options
author | Nivesh Rajbhandari | 2012-02-03 15:09:54 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-03 15:09:54 -0800 |
commit | d7ad2659d7ef8d0fffbb1cba8218061ebd516dd0 (patch) | |
tree | efd2d3b7077fedfbf6234a92a223fee7a9a89244 | |
parent | 130c1d3bfeedfc50ab3481c7d8c2e83af224feac (diff) | |
download | ninja-d7ad2659d7ef8d0fffbb1cba8218061ebd516dd0.tar.gz |
Handle delete of multiple objects. Also, have deletion go through the mediator so elementDeleted event is fired for SnapManager, DrawUtils, etc. to clean up after deleted element(s).
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rw-r--r-- | js/helper-classes/3D/draw-utils.js | 7 | ||||
-rw-r--r-- | js/mediators/element-mediator.js | 14 | ||||
-rw-r--r-- | js/stage/layout.js | 17 |
3 files changed, 21 insertions, 17 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 08a27618..c07391db 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -110,6 +110,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
110 | 110 | ||
111 | this.eventManager.addEventListener("elementAdded", this, false); | 111 | this.eventManager.addEventListener("elementAdded", this, false); |
112 | this.eventManager.addEventListener("elementDeleted", this, false); | 112 | this.eventManager.addEventListener("elementDeleted", this, false); |
113 | this.eventManager.addEventListener("deleteSelection", this, false); | ||
113 | this.eventManager.addEventListener("elementChange", this, false); | 114 | this.eventManager.addEventListener("elementChange", this, false); |
114 | } | 115 | } |
115 | }, | 116 | }, |
@@ -127,6 +128,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
127 | } | 128 | } |
128 | }, | 129 | }, |
129 | 130 | ||
131 | handleDeleteSelection: { | ||
132 | value: function(event) { | ||
133 | this.drawWorkingPlane(); | ||
134 | } | ||
135 | }, | ||
136 | |||
130 | _shouldUpdatePlanes: { | 137 | _shouldUpdatePlanes: { |
131 | value: function(props) { | 138 | value: function(props) { |
132 | if(!props) | 139 | if(!props) |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index b2bc5355..992ac620 100644 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -44,12 +44,16 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
44 | this.deleteDelegate.handleDelete(); | 44 | this.deleteDelegate.handleDelete(); |
45 | } else { | 45 | } else { |
46 | // Add the Undo/Redo | 46 | // Add the Undo/Redo |
47 | var els = []; | 47 | var els = [], |
48 | len = this.application.ninja.selectedElements.length; | ||
48 | 49 | ||
49 | if(this.application.ninja.selectedElements.length > 0) { | 50 | if(len) { |
50 | for(var i=0, item; item = this.application.ninja.selectedElements[i]; i++) { | 51 | for(var i = 0; i<len; i++) |
51 | ElementController.removeElement(item._element); | 52 | { |
52 | els.push(item._element); | 53 | els.push(this.application.ninja.selectedElements[i]); |
54 | } | ||
55 | for(i=0; i<len; i++) { | ||
56 | this._removeElement(els[i]._element); | ||
53 | } | 57 | } |
54 | 58 | ||
55 | NJevent( "deleteSelection", els ); | 59 | NJevent( "deleteSelection", els ); |
diff --git a/js/stage/layout.js b/js/stage/layout.js index c369fc30..1a491210 100644 --- a/js/stage/layout.js +++ b/js/stage/layout.js | |||
@@ -58,7 +58,7 @@ exports.Layout = Montage.create(Component, { | |||
58 | 58 | ||
59 | this.eventManager.addEventListener("selectionChange", this, false); | 59 | this.eventManager.addEventListener("selectionChange", this, false); |
60 | 60 | ||
61 | this.eventManager.addEventListener("deleteSelection", this, true); | 61 | this.eventManager.addEventListener("deleteSelection", this, false); |
62 | 62 | ||
63 | // this.addEventListener("change@stage.appModel.layoutView", this.handleLayoutView, false); | 63 | // this.addEventListener("change@stage.appModel.layoutView", this.handleLayoutView, false); |
64 | 64 | ||
@@ -83,21 +83,14 @@ exports.Layout = Montage.create(Component, { | |||
83 | handleElementDeleted: { | 83 | handleElementDeleted: { |
84 | value: function(event) { | 84 | value: function(event) { |
85 | this.domTree.splice(this.domTree.indexOf(event.detail), 1); | 85 | this.domTree.splice(this.domTree.indexOf(event.detail), 1); |
86 | |||
87 | this.draw(); | ||
88 | this.draw3DInfo(false); | ||
89 | } | 86 | } |
90 | }, | 87 | }, |
91 | 88 | ||
92 | captureDeleteSelection: { | 89 | // Redraw stage only once after all deletion is completed |
90 | handleDeleteSelection: { | ||
93 | value: function(event) { | 91 | value: function(event) { |
94 | //this.redrawDocument(); | 92 | this.draw(); |
95 | 93 | this.draw3DInfo(false); | |
96 | var len = event.detail.length; | ||
97 | for(var i = 0; i < len ; i++) { | ||
98 | this.domTree.splice(this.domTree.indexOf(event.detail[i]),1); | ||
99 | } | ||
100 | |||
101 | } | 94 | } |
102 | }, | 95 | }, |
103 | 96 | ||