diff --git a/src/adapter/bundle.js b/src/adapter/bundle.js index 914028cf0d..9893fe39a7 100644 --- a/src/adapter/bundle.js +++ b/src/adapter/bundle.js @@ -26,14 +26,16 @@ define([ './directives/MCTView', './services/Instantiate', './capabilities/APICapabilityDecorator', - './policies/AdapterCompositionPolicy' + './policies/AdapterCompositionPolicy', + './runs/AlternateCompositionInitializer' ], function ( legacyRegistry, ActionDialogDecorator, MCTView, Instantiate, APICapabilityDecorator, - AdapterCompositionPolicy + AdapterCompositionPolicy, + AlternateCompositionInitializer ) { legacyRegistry.register('src/adapter', { "extensions": { @@ -82,6 +84,12 @@ define([ depends: [ "openmct" ] } ], + runs: [ + { + implementation: AlternateCompositionInitializer, + depends: ["openmct"] + } + ], licenses: [ { "name": "almond", diff --git a/src/adapter/capabilities/AlternateCompositionCapability.js b/src/adapter/capabilities/AlternateCompositionCapability.js index b84a42cc85..9845ba376b 100644 --- a/src/adapter/capabilities/AlternateCompositionCapability.js +++ b/src/adapter/capabilities/AlternateCompositionCapability.js @@ -26,7 +26,6 @@ define([ '../../api/objects/object-utils' ], function (objectUtils) { - function AlternateCompositionCapability($injector, domainObject) { this.domainObject = domainObject; this.getDependencies = function () { @@ -98,7 +97,9 @@ define([ }; AlternateCompositionCapability.appliesTo = function (model) { - return true; + // Will get replaced by a runs exception to properly + // bind to running openmct instance + return false; }; return AlternateCompositionCapability; diff --git a/src/adapter/runs/AlternateCompositionInitializer.js b/src/adapter/runs/AlternateCompositionInitializer.js new file mode 100644 index 0000000000..77bc1866cd --- /dev/null +++ b/src/adapter/runs/AlternateCompositionInitializer.js @@ -0,0 +1,36 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2016, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +define([ + '../capabilities/AlternateCompositionCapability' +], function (AlternateCompositionCapability) { + // Present to work around the need for openmct to be used + // from AlternateCompositionCapability.appliesTo, even though it + // cannot be injected. + function AlternateCompositionInitializer(openmct) { + AlternateCompositionCapability.appliesTo = function (model) { + return !!openmct.composition.get(model); + }; + } + + return AlternateCompositionCapability; +}); diff --git a/src/api/composition/CompositionAPI.js b/src/api/composition/CompositionAPI.js index 265602ea67..31073bd956 100644 --- a/src/api/composition/CompositionAPI.js +++ b/src/api/composition/CompositionAPI.js @@ -70,7 +70,7 @@ define([ */ CompositionAPI.prototype.get = function (domainObject) { var provider = _.find(this.registry, function (p) { - return p.appliesTo(object); + return p.appliesTo(domainObject); }); if (!provider) {