diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json
index 3dfc0c0447..359f8d22a5 100644
--- a/platform/commonUI/general/bundle.json
+++ b/platform/commonUI/general/bundle.json
@@ -151,6 +151,12 @@
{
"key": "tree",
"templateUrl": "templates/tree.html",
+ "type": "root",
+ "priority": "preferred"
+ },
+ {
+ "key": "tree",
+ "templateUrl": "templates/subtree.html",
"uses": [ "composition" ]
},
{
diff --git a/platform/commonUI/general/res/templates/subtree.html b/platform/commonUI/general/res/templates/subtree.html
new file mode 100644
index 0000000000..92eb25ef7a
--- /dev/null
+++ b/platform/commonUI/general/res/templates/subtree.html
@@ -0,0 +1,14 @@
+
+ -
+
+
+ Loading...
+
+
+ -
+
+
+
+
diff --git a/platform/commonUI/general/res/templates/tree.html b/platform/commonUI/general/res/templates/tree.html
index 92eb25ef7a..445d554222 100644
--- a/platform/commonUI/general/res/templates/tree.html
+++ b/platform/commonUI/general/res/templates/tree.html
@@ -1,13 +1,7 @@
- -
-
-
- Loading...
-
-
- -
+
-
diff --git a/platform/core/src/models/RootModelProvider.js b/platform/core/src/models/RootModelProvider.js
index 6e6e59e417..f819f94dd4 100644
--- a/platform/core/src/models/RootModelProvider.js
+++ b/platform/core/src/models/RootModelProvider.js
@@ -28,6 +28,7 @@ define(
function addRoot(models) {
models.ROOT = {
name: "The root object",
+ type: "root",
composition: ids
};
return models;
diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js
index 1cecf7a981..bfc5ec3b64 100644
--- a/platform/representation/src/MCTRepresentation.js
+++ b/platform/representation/src/MCTRepresentation.js
@@ -32,25 +32,43 @@ define(
* @param {ViewDefinition[]} views an array of view extensions
*/
function MCTRepresentation(representations, views, representers, $q, $log) {
- var pathMap = {},
- representationMap = {},
+ var representationMap = {},
gestureMap = {};
// Assemble all representations and views
// The distinction between views and representations is
// not important her (view is-a representation)
representations.concat(views).forEach(function (representation) {
- var path = [
+ var key = representation.key;
+
+ // Store the representation
+ representationMap[key] = representationMap[key] || [];
+ representationMap[representation.key].push(representation);
+ });
+
+ // Get a path to a representation
+ function getPath(representation) {
+ return [
representation.bundle.path,
representation.bundle.resources,
representation.templateUrl
].join("/");
+ }
- // Consider allowing multiple templates with the same key
- pathMap[representation.key] = path;
- representationMap[representation.key] = representation;
- });
-
+ // Look up a matching representation for this domain object
+ function lookup(key, domainObject) {
+ var candidates = representationMap[key] || [],
+ type,
+ i;
+ // Filter candidates by object type
+ for (i = 0; i < candidates.length; i += 1) {
+ type = candidates[i].type;
+ if (!type || !domainObject ||
+ domainObject.getCapability('type').instanceOf(type)) {
+ return candidates[i];
+ }
+ }
+ }
function link($scope, element, attrs) {
var activeRepresenters = representers.map(function (Representer) {
@@ -89,8 +107,8 @@ define(
// as appropriate for current representation key and
// domain object.
function refresh() {
- var representation = representationMap[$scope.key],
- domainObject = $scope.domainObject,
+ var domainObject = $scope.domainObject,
+ representation = lookup($scope.key, domainObject),
uses = ((representation || {}).uses || []),
gestureKeys = ((representation || {}).gestures || []);
@@ -100,7 +118,7 @@ define(
// Look up the actual template path, pass it to ng-include
// via the "inclusion" field
- $scope.inclusion = pathMap[$scope.key];
+ $scope.inclusion = representation && getPath(representation);
// Any existing gestures are no longer valid; release them.
activeRepresenters.forEach(function (activeRepresenter) {