define([
'components.dt/js/spi/creators/CreatorType'
], function (
CreatorType
) {
'use strict';
/**
* A creator is used to create new instances of component views. It is
* plugged-in into the Abcs system using the registration API
* ({@link components.dt/js/api/ComponentProviderRegistry ComponentProviderRegistry}).
*
* <p>This type of creator by default does not raise any UI when a component's
* view is creating, it expects the view is created immediately with
* default properties. If you want to raise a UI to tweak component's view
* creation, use one of UI creators:</p>
* <dl>
* <dt>{@link components.dt/js/spi/creators/PopupCreator PopupCreator}</dt>
* <dd>Raises a light-weight popup UI for modifying the view's properties
* and behaviour.</dd>
* </dl>
*
* <p>In order to add a creator for a new component create an object with methods
* described by {@link components.dt/js/spi/creators/Creator Creator}.
* The object must implement {@link components.dt/js/spi/creators/Creator#createView Creator.createView}
* method creating a view instance, {@link components.dt/js/spi/creators/Creator#getType Creator.getType}
* to specify the type of the creator and {@link components.dt/js/spi/creators/Creator#getOptions Creator.getOptions}
* to specify creator options.</p>
*
* @AbcsExtension stable
* @exports components.dt/js/spi/creators/Creator
* @constructor
* @private
* @see {@link components.dt/js/spi/creators/Creator#createView Creator.createView}
* @see {@link components.dt/js/api/ComponentFactory#createView ComponentFactory.createView}
* @version 16.3.5
* @example
* <caption>Example of a plain view creator</caption>
* define([
* 'components.dt/js/api/ComponentFactory',
* 'components.dt/js/spi/creators/CreatorType'
* ], function (ComponentFactory, CreatorType) {
*
* 'use strict';
*
* var MyCreator = function () {
* };
*
* MyCreator.prototype.getType = function () {
* return CreatorType.PLAIN;
* };
*
* MyCreator.prototype.createView = function (activePage, container, createContext) {
* var componentFactory = ComponentFactory.create(activePage);
* var properties = {
* text: createContext && createContext.text || 'Default Text'
* };
*
* var view = componentFactory.createView({
* type: 'org.my.myComponent',
* properties: properties,
* displayName: 'My Component'
* });
* return view;
* };
*
* MyCreator.prototype.getOptions = function () {
* return {
* // the creator is expected to create only one type of view: org.my.myComponent
* possibleGeneratedViewTypes: ['org.my.myComponent'],
* // min width of the component will be 2 columns
* minWidth: 2
* };
* };
*
* return MyCreator;
*
* });
*/
var Creator = function() {
AbcsLib.checkThis(this);
};
/**
* Creates a specific {@link pages.dt/js/api/View View} for the component.
* <p><strong>MUST</strong> be implemented.</p>
* <p>The main purpose of this method is to create a full working instance
* of a {@link pages.dt/js/api/View View} representing the top of your
* component hieararchy. You do not call its constructor directly but rather
* call the {@link components.dt/js/api/ComponentFactory#createView ComponentFactory.createView} factory
* method taking care of lots of things for you.</p>
* <p>See {@link components.dt/js/spi/creators/Creator Creator}
* for an example on how to implement this method.</p>
*
* @AbcsExtension stable
* @version 16.3.5
* @param {pages.dt/js/api/Page} activePage the current page the view is created for.
* @param {pages.dt/js/api/View|undefined} container parent container the view is about to be added into.
* <strong>May be</strong> <code>undefined</code>, when a standalone view is created,
* so do not heavily depend on it.
* @param {Object} createContext object with set of default properties used
* to create specific view instance with default properties or possibly even
* reconstruct an old view from a serialized context.
* @return {pages.dt/js/api/View} created View.
* @see {@link components.dt/js/api/ComponentFactory#createView ComponentFactory.createView}
*/
Creator.prototype.createView = function(/*activePage, container, createContext*/) {
throw new Error('Missing implementation.');
};
/**
* Specifies the type of the creator.
* <p>Every creator must specify its type (if it's a non-UI plain creator,
* a popup creator or another). Plain creators must return
* {@link components.dt/js/spi/creators/CreatorType.PLAIN CreatorType.PLAIN}
* type.</p>
*
* @AbcsExtension stable
* @version 16.3.5
* @returns {components.dt/js/spi/creators/CreatorType} creator type
*/
Creator.prototype.getType = function () {
return CreatorType.PLAIN;
};
/**
* Get the options which will be used by designer infrastructure.
*
* @AbcsExtension stable
* @version 16.3.5
* @returns {components.dt/js/spi/creators/Creator.CreatorOptions}
*/
Creator.prototype.getOptions = function () {
throw new Error('Missing implementation.');
};
/**
* Creator options registration object containing information about creator and created views.
* Returned from {@link components.dt/js/spi/creators/Creator#getOptions Creator.getOptions}
* method.
*
* @AbcsExtension stable
* @version 16.3.5
* @memberof components.dt/js/spi/creators/Creator
* @objectLiteral
*/
var CreatorOptions = function () {
};
/**
* Array of view types (or just one view type) which could be created by the creator.
*
* @AbcsExtension stable
* @version 16.3.5
* @type {String|String[]}
*/
CreatorOptions.prototype.possibleGeneratedViewTypes = '';
/**
* Minimal width of a component after drop in columns (1 - 12).
*
* @AbcsExtension stable
* @version 16.3.5
* @type {Number}
*/
CreatorOptions.prototype.minWidth = 1;
return Creator;
});