UNPKG

1.66 kBJavaScriptView Raw
1'use strict';
2
3var DEFAULT_PRIORITY = 1000;
4
5
6/**
7 * A component that decides upon the visibility / editable
8 * state of properties in the properties panel.
9 *
10 * Implementors must subclass this component and override
11 * {@link PropertiesActivator#isEntryVisible} and
12 * {@link PropertiesActivator#isPropertyEditable} to provide
13 * custom behavior.
14 *
15 * @class
16 * @constructor
17 *
18 * @param {EventBus} eventBus
19 * @param {Number} [priority] at which priority to hook into the activation
20 */
21function PropertiesActivator(eventBus, priority) {
22 var self = this;
23
24 priority = priority || DEFAULT_PRIORITY;
25
26 eventBus.on('propertiesPanel.isEntryVisible', priority, function(e) {
27 return self.isEntryVisible(e.entry, e.element);
28 });
29
30 eventBus.on('propertiesPanel.isPropertyEditable', priority, function(e) {
31 return self.isPropertyEditable(e.entry, e.propertyName, e.element);
32 });
33}
34
35PropertiesActivator.$inject = [ 'eventBus' ];
36
37module.exports = PropertiesActivator;
38
39
40/**
41 * Should the given entry be visible for the specified element.
42 *
43 * @method PropertiesActivator#isEntryVisible
44 *
45 * @param {EntryDescriptor} entry
46 * @param {ModdleElement} element
47 *
48 * @returns {Boolean}
49 */
50PropertiesActivator.prototype.isEntryVisible = function(entry, element) {
51 return true;
52};
53
54/**
55 * Should the given property be editable for the specified element
56 *
57 * @method PropertiesActivator#isPropertyEditable
58 *
59 * @param {EntryDescriptor} entry
60 * @param {String} propertyName
61 * @param {ModdleElement} element
62 *
63 * @returns {Boolean}
64 */
65PropertiesActivator.prototype.isPropertyEditable = function(entry, propertyName, element) {
66 return true;
67};
\No newline at end of file