From cbcc9dcadaf62b3b0aef380f022bf6c365785627 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Thu, 2 Feb 2012 10:36:05 -0800
Subject: Tree Controller - Initial add
---
js/controllers/tree-controller.js | 219 ++++++++++++++++++++++++++++++++++++++
1 file changed, 219 insertions(+)
create mode 100644 js/controllers/tree-controller.js
diff --git a/js/controllers/tree-controller.js b/js/controllers/tree-controller.js
new file mode 100644
index 00000000..45e4c4ba
--- /dev/null
+++ b/js/controllers/tree-controller.js
@@ -0,0 +1,219 @@
+/*
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
+ contentProvider
property for a TreeView object.
+ @class module:montage/ui/controller/tree-controller.TreeController
+ @classdesc
+ @extends module:montage/ui/controller/object-controller.ObjectController
+*/
+var TreeController = exports.TreeController = Montage.create(ObjectController, /** @lends module:montage/ui/controller/tree-controller.TreeController# */ {
+
+ rootKey : {
+ value: null
+ },
+
+ branchKey : {
+ value: 'children'
+ },
+
+ _root : {
+ value : null
+ },
+ root : {
+ get: function() {
+ return this._root;
+ },
+ set: function(value) {
+ this._root = value;
+
+ this.initArrayControllers();
+ }
+ },
+
+ rootController: {
+ value: null
+ },
+
+ initArrayControllers : {
+ value: function() {
+ var self = this;
+
+ ///// Declare function to initialize controller for each node
+ ///// that is a branch
+
+ function initController(array, depth) {
+ var controller = Montage.create(ArrayController, {
+ content : { value: array },
+ delegate : { value: self },
+ isSelectionEnabled : { value: true }});
+
+ if(depth === 0) {
+ self.rootController = controller;
+ }
+
+ self.branchControllers.push({
+ depth : depth,
+ controller : controller
+
+ });
+ }
+
+ ///// Recursive function that finds all branch nodes and initializes
+ ///// an array controller
+
+ function walk(node, init, depth) {
+ var children = node[self.branchKey];
+
+ if(children) {
+ //init(children, depth);
+
+ children.forEach(function(child) {
+ walk(child, init, ++depth);
+ });
+
+ node['treeNodeType'] = 'branch';
+ } else {
+ node['treeNodeType'] = 'leaf';
+ }
+ }
+
+ walk(this._root, initController, 0);
+
+ }
+ },
+
+ /**
+ @private
+ */
+ _selectedIndexes: {
+ value: null,
+ enumerable: false
+ },
+
+ /**
+ Description TODO
+ @type {Function}
+ @default null
+ */
+ selectedIndexes: {
+ get: function() {
+
+ },
+ set: function(value) {
+
+ }
+ },
+
+ lazyLoad : {
+ value: false
+ },
+
+ branchControllers: {
+ value: []
+ },
+
+ addBranchController : {
+ value: function(controller) {
+ if(this.delegate) {
+ controller.delegate = this.delegate;
+ }
+
+ this.branchControllers.push(controller);
+ }
+ },
+
+ /**
+ @private
+ */
+ _content: {
+ enumerable: false,
+ value: null
+ },
+ /**
+ The content managed by the TreeController.
+ @type {Function}
+ @default {String} null
+ */
+ content: {
+ get: function() {
+ return this._content;
+ },
+ set: function(value) {
+ if (this._content === value) {
+ return;
+ }
+
+ this._content = value;
+
+ //TODO for right now assume that any content change invalidates the selection completely; we'll need to address this of course
+ this.selectedObjects = null;
+
+ if (this.rootKey) {
+ if (value[this.rootKey]) {
+ this.root = value[this.rootKey];
+ } else {
+ console.log('No root key found in content data');
+ }
+ } else {
+ this.root = value;
+ }
+
+
+ }
+ },
+
+ addObjects : {
+ value: function() {
+
+ var objects = Array.prototype.slice.call(arguments),
+ i,
+ objectCount = objects.length,
+ selectedContentIndexes, firstIndex;
+
+ for (i = 0; i < objectCount; i++) {
+ this.content.push(objects[i]);
+ }
+
+ if (this.selectObjectsOnAddition) {
+ selectedContentIndexes = [];
+ firstIndex = this.content.length-objectCount;
+ for (i = 0; i < objectCount; i++) {
+ selectedContentIndexes[i] = firstIndex++;
+ }
+ this.selectedContentIndexes = selectedContentIndexes;
+ this.selectedObjects = objects;
+ }
+
+ if (this.clearFilterFunctionOnAddition) {
+ this.filterFunction = null;
+ }
+
+ if (this.automaticallyOrganizeObjects) {
+ this.organizeObjects();
+ }
+
+ }
+ },
+
+ insertChildBefore : { value : function() {} },
+
+ insertChildAfter : { value : function() {} }
+
+
+
+});
--
cgit v1.2.3
From 5c5f4eabdc4befe3fb6da44bc8ad5fef20642f21 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Thu, 2 Feb 2012 14:58:21 -0800
Subject: Tree Controller - Clean out unused code
---
js/controllers/tree-controller.js | 48 ++++++---------------------------------
1 file changed, 7 insertions(+), 41 deletions(-)
diff --git a/js/controllers/tree-controller.js b/js/controllers/tree-controller.js
index 45e4c4ba..2b2e910c 100644
--- a/js/controllers/tree-controller.js
+++ b/js/controllers/tree-controller.js
@@ -53,37 +53,15 @@ var TreeController = exports.TreeController = Montage.create(ObjectController, /
value: function() {
var self = this;
- ///// Declare function to initialize controller for each node
- ///// that is a branch
-
- function initController(array, depth) {
- var controller = Montage.create(ArrayController, {
- content : { value: array },
- delegate : { value: self },
- isSelectionEnabled : { value: true }});
-
- if(depth === 0) {
- self.rootController = controller;
- }
-
- self.branchControllers.push({
- depth : depth,
- controller : controller
-
- });
- }
-
///// Recursive function that finds all branch nodes and initializes
- ///// an array controller
+ ///// sets the tree node type to "branch" or "leaf"
function walk(node, init, depth) {
- var children = node[self.branchKey];
-
- if(children) {
- //init(children, depth);
+ var branch = node[self.branchKey];
- children.forEach(function(child) {
- walk(child, init, ++depth);
+ if(branch) {
+ branch.forEach(function(node) {
+ walk(node, init, ++depth);
});
node['treeNodeType'] = 'branch';
@@ -92,7 +70,7 @@ var TreeController = exports.TreeController = Montage.create(ObjectController, /
}
}
- walk(this._root, initController, 0);
+ walk(this._root, 0);
}
},
@@ -119,10 +97,6 @@ var TreeController = exports.TreeController = Montage.create(ObjectController, /
}
},
- lazyLoad : {
- value: false
- },
-
branchControllers: {
value: []
},
@@ -160,7 +134,6 @@ var TreeController = exports.TreeController = Montage.create(ObjectController, /
this._content = value;
- //TODO for right now assume that any content change invalidates the selection completely; we'll need to address this of course
this.selectedObjects = null;
if (this.rootKey) {
@@ -173,7 +146,6 @@ var TreeController = exports.TreeController = Montage.create(ObjectController, /
this.root = value;
}
-
}
},
@@ -208,12 +180,6 @@ var TreeController = exports.TreeController = Montage.create(ObjectController, /
}
}
- },
-
- insertChildBefore : { value : function() {} },
-
- insertChildAfter : { value : function() {} }
-
-
+ }
});
--
cgit v1.2.3
From 984d65c818969ea3bef57ade9cbf5fc50d9a2316 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Mon, 6 Feb 2012 11:43:01 -0800
Subject: Tree Components - Adding the tree components
---
js/components/treeview/branch.reel/branch.css | 16 +++
js/components/treeview/branch.reel/branch.html | 142 ++++++++++++++++++++
js/components/treeview/branch.reel/branch.js | 48 +++++++
js/components/treeview/leaf.reel/leaf.css | 4 +
js/components/treeview/leaf.reel/leaf.html | 38 ++++++
js/components/treeview/leaf.reel/leaf.js | 44 +++++++
.../treeview/ninja-branch.reel/ninja-branch.css | 34 +++++
.../treeview/ninja-branch.reel/ninja-branch.html | 145 +++++++++++++++++++++
.../treeview/ninja-branch.reel/ninja-branch.js | 131 +++++++++++++++++++
.../treeview/ninja-leaf.reel/ninja-leaf.css | 22 ++++
.../treeview/ninja-leaf.reel/ninja-leaf.html | 38 ++++++
.../treeview/ninja-leaf.reel/ninja-leaf.js | 41 ++++++
js/components/treeview/tree-node.js | 103 +++++++++++++++
js/components/treeview/treeview.reel/treeview.css | 3 +
js/components/treeview/treeview.reel/treeview.html | 50 +++++++
js/components/treeview/treeview.reel/treeview.js | 129 ++++++++++++++++++
16 files changed, 988 insertions(+)
create mode 100644 js/components/treeview/branch.reel/branch.css
create mode 100644 js/components/treeview/branch.reel/branch.html
create mode 100644 js/components/treeview/branch.reel/branch.js
create mode 100644 js/components/treeview/leaf.reel/leaf.css
create mode 100644 js/components/treeview/leaf.reel/leaf.html
create mode 100644 js/components/treeview/leaf.reel/leaf.js
create mode 100644 js/components/treeview/ninja-branch.reel/ninja-branch.css
create mode 100644 js/components/treeview/ninja-branch.reel/ninja-branch.html
create mode 100644 js/components/treeview/ninja-branch.reel/ninja-branch.js
create mode 100644 js/components/treeview/ninja-leaf.reel/ninja-leaf.css
create mode 100644 js/components/treeview/ninja-leaf.reel/ninja-leaf.html
create mode 100644 js/components/treeview/ninja-leaf.reel/ninja-leaf.js
create mode 100644 js/components/treeview/tree-node.js
create mode 100644 js/components/treeview/treeview.reel/treeview.css
create mode 100644 js/components/treeview/treeview.reel/treeview.html
create mode 100644 js/components/treeview/treeview.reel/treeview.js
diff --git a/js/components/treeview/branch.reel/branch.css b/js/components/treeview/branch.reel/branch.css
new file mode 100644
index 00000000..5998e0f0
--- /dev/null
+++ b/js/components/treeview/branch.reel/branch.css
@@ -0,0 +1,16 @@
+.treeRoot > .branch > ul {
+ margin-top: 0;
+}
+.branch > .branch-label {
+ font-weight: bold;
+ cursor: pointer;
+}
+.branch ul {
+ list-style: none;
+}
+.branch ul {
+ padding-left: 30px;
+}
+.branch .collapse {
+ display: none;
+}
\ No newline at end of file
diff --git a/js/components/treeview/branch.reel/branch.html b/js/components/treeview/branch.reel/branch.html
new file mode 100644
index 00000000..31a4cf18
--- /dev/null
+++ b/js/components/treeview/branch.reel/branch.html
@@ -0,0 +1,142 @@
+
+
+
contentProvider
property for a TreeView object.
+ @class module:montage/ui/controller/tree-controller.TreeController
+ @classdesc
+ @extends module:montage/ui/controller/object-controller.ObjectController
+*/
+var TreeController = exports.TreeController = Montage.create(ObjectController, /** @lends module:montage/ui/controller/tree-controller.TreeController# */ {
+
+ rootKey : {
+ value: null
+ },
+
+ branchKey : {
+ value: 'children'
+ },
+
+ _root : {
+ value : null
+ },
+ root : {
+ get: function() {
+ return this._root;
+ },
+ set: function(value) {
+ this._root = value;
+
+ this.initArrayControllers();
+ }
+ },
+
+ rootController: {
+ value: null
+ },
+
+ initArrayControllers : {
+ value: function() {
+ var self = this;
+
+ ///// Recursive function that finds all branch nodes and initializes
+ ///// sets the tree node type to "branch" or "leaf"
+
+ function walk(node, init, depth) {
+ var branch = node[self.branchKey];
+
+ if(branch) {
+ branch.forEach(function(node) {
+ walk(node, init, ++depth);
+ });
+
+ node['treeNodeType'] = 'branch';
+ } else {
+ node['treeNodeType'] = 'leaf';
+ }
+ }
+
+ walk(this._root, 0);
+
+ }
+ },
+
+ /**
+ @private
+ */
+ _selectedIndexes: {
+ value: null,
+ enumerable: false
+ },
+
+ /**
+ Description TODO
+ @type {Function}
+ @default null
+ */
+ selectedIndexes: {
+ get: function() {
+ return this._selectedIndexes;
+ },
+ set: function(value) {
+ this._selectedIndexes = value;
+ }
+ },
+
+ branchControllers: {
+ value: []
+ },
+
+ addBranchController : {
+ value: function(controller) {
+ if(this.delegate) {
+ controller.delegate = this.delegate;
+ }
+
+ this.branchControllers.push(controller);
+ }
+ },
+
+ /**
+ @private
+ */
+ _content: {
+ enumerable: false,
+ value: null
+ },
+ /**
+ The content managed by the TreeController.
+ @type {Function}
+ @default {String} null
+ */
+ content: {
+ get: function() {
+ return this._content;
+ },
+ set: function(value) {
+ if (this._content === value) {
+ return;
+ }
+
+ this._content = value;
+
+ this.selectedObjects = null;
+
+ if (this.rootKey) {
+ if (value[this.rootKey]) {
+ this.root = value[this.rootKey];
+ } else {
+ console.log('No root key found in content data');
+ }
+ } else {
+ this.root = value;
+ }
+
+ }
+ },
+
+ addObjects : {
+ value: function() {
+
+ var objects = Array.prototype.slice.call(arguments),
+ i,
+ objectCount = objects.length,
+ selectedContentIndexes, firstIndex;
+
+ for (i = 0; i < objectCount; i++) {
+ this.content.push(objects[i]);
+ }
+
+ if (this.selectObjectsOnAddition) {
+ selectedContentIndexes = [];
+ firstIndex = this.content.length-objectCount;
+ for (i = 0; i < objectCount; i++) {
+ selectedContentIndexes[i] = firstIndex++;
+ }
+ this.selectedContentIndexes = selectedContentIndexes;
+ this.selectedObjects = objects;
+ }
+
+ if (this.clearFilterFunctionOnAddition) {
+ this.filterFunction = null;
+ }
+
+ if (this.automaticallyOrganizeObjects) {
+ this.organizeObjects();
+ }
+
+ }
+ }
+
+});
--
cgit v1.2.3
From fa036c22a3f1e4862a121f478eb227f52578f8a0 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Mon, 6 Feb 2012 16:41:15 -0800
Subject: Attempt to fix initialization bug for snap-manager
---
js/helper-classes/3D/snap-manager.js | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 8819f637..3af7d8cf 100644
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -9,14 +9,13 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
// Class to do hit testing of objects in the html page
///////////////////////////////////////////////////////////////////////
var Montage = require("montage/core/core").Montage,
- Component = require("montage/ui/component").Component;
-
-var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils;
-var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
-var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils;
-var HitRecord = require("js/helper-classes/3D/hit-record").HitRecord;
-var Snap2DRecord = require("js/helper-classes/3D/snap-2d-record").Snap2DRecord;
-var NJUtils = require("js/lib/NJUtils").NJUtils;
+ Component = require("montage/ui/component").Component,
+ viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
+ vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
+ drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils,
+ HitRecord = require("js/helper-classes/3D/hit-record").HitRecord,
+ Snap2DRecord = require("js/helper-classes/3D/snap-2d-record").Snap2DRecord,
+ NJUtils = require("js/lib/NJUtils").NJUtils;
var SnapManager = exports.SnapManager = Montage.create(Component, {
///////////////////////////////////////////////////////////////////////
--
cgit v1.2.3