1 | ;
|
2 |
|
3 | var 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 | */
|
21 | function PropertiesActivator(eventBus, priority) {
|
22 | var self = this;
|
23 |
|
24 | priority = priority || DEFAULT_PRIORITY;
|
25 |
|
26 | eventBus.on('propertiesPanel.isEntryVisible', priority, function(context) {
|
27 | var element = context.element,
|
28 | entry = context.entry,
|
29 | group = context.group,
|
30 | tab = context.tab;
|
31 |
|
32 | return self.isEntryVisible(element, entry, group, tab);
|
33 | });
|
34 |
|
35 | eventBus.on('propertiesPanel.isPropertyEditable', priority, function(context) {
|
36 | var element = context.element,
|
37 | entry = context.entry,
|
38 | group = context.group,
|
39 | propertyName = context.propertyName,
|
40 | tab = context.tab;
|
41 |
|
42 | return self.isPropertyEditable(propertyName, element, entry, group, tab);
|
43 | });
|
44 | }
|
45 |
|
46 | PropertiesActivator.$inject = [ 'eventBus' ];
|
47 |
|
48 | module.exports = PropertiesActivator;
|
49 |
|
50 |
|
51 | /**
|
52 | * Should the given entry be visible for the specified element.
|
53 | *
|
54 | * @method PropertiesActivator#isEntryVisible
|
55 | *
|
56 | * @param {ModdleElement} element
|
57 | * @param {Object} entry
|
58 | * @param {Object} group
|
59 | * @param {Object} tab
|
60 | *
|
61 | * @returns {boolean}
|
62 | */
|
63 | PropertiesActivator.prototype.isEntryVisible = function(element, entry, group, tab) {
|
64 | return true;
|
65 | };
|
66 |
|
67 | /**
|
68 | * Should the given property be editable for the specified element
|
69 | *
|
70 | * @method PropertiesActivator#isPropertyEditable
|
71 | *
|
72 | * @param {string} propertyName
|
73 | * @param {ModdleElement} element
|
74 | * @param {Object} entry
|
75 | * @param {Object} group
|
76 | * @param {Object} tab
|
77 | *
|
78 | * @returns {boolean}
|
79 | */
|
80 | PropertiesActivator.prototype.isPropertyEditable = function(propertyName, element, entry, group, tab) {
|
81 | return true;
|
82 | }; |
\ | No newline at end of file |