PropertiesActivator.js 1.6 KB

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