@openui5/sap.ui.table 1.134.0 → 1.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/THIRDPARTY.txt +2 -2
  2. package/package.json +3 -3
  3. package/src/sap/ui/table/.library +1 -1
  4. package/src/sap/ui/table/AnalyticalColumn.js +1 -1
  5. package/src/sap/ui/table/AnalyticalColumnMenu.js +1 -1
  6. package/src/sap/ui/table/AnalyticalTable.js +3 -3
  7. package/src/sap/ui/table/Column.js +1 -1
  8. package/src/sap/ui/table/ColumnMenu.js +1 -1
  9. package/src/sap/ui/table/CreationRow.js +1 -1
  10. package/src/sap/ui/table/Row.js +21 -21
  11. package/src/sap/ui/table/RowAction.js +1 -1
  12. package/src/sap/ui/table/RowActionItem.js +1 -1
  13. package/src/sap/ui/table/RowSettings.js +1 -1
  14. package/src/sap/ui/table/Table.js +70 -112
  15. package/src/sap/ui/table/TablePersoController.js +1 -1
  16. package/src/sap/ui/table/TableRenderer.js +3 -5
  17. package/src/sap/ui/table/TreeTable.js +1 -1
  18. package/src/sap/ui/table/extensions/Accessibility.js +3 -4
  19. package/src/sap/ui/table/extensions/AccessibilityRender.js +2 -3
  20. package/src/sap/ui/table/extensions/DragAndDrop.js +1 -1
  21. package/src/sap/ui/table/extensions/ExtensionBase.js +1 -1
  22. package/src/sap/ui/table/extensions/Keyboard.js +1 -1
  23. package/src/sap/ui/table/extensions/KeyboardDelegate.js +2 -3
  24. package/src/sap/ui/table/extensions/Pointer.js +3 -5
  25. package/src/sap/ui/table/extensions/Scrolling.js +1 -1
  26. package/src/sap/ui/table/extensions/ScrollingIOS.js +1 -1
  27. package/src/sap/ui/table/extensions/Synchronization.js +1 -1
  28. package/src/sap/ui/table/library.js +11 -35
  29. package/src/sap/ui/table/menus/AnalyticalTableContextMenu.js +1 -1
  30. package/src/sap/ui/table/menus/ColumnHeaderMenuAdapter.js +1 -1
  31. package/src/sap/ui/table/menus/ContextMenu.js +1 -1
  32. package/src/sap/ui/table/menus/MobileColumnHeaderMenuAdapter.js +1 -1
  33. package/src/sap/ui/table/messagebundle_bg.properties +1 -1
  34. package/src/sap/ui/table/plugins/BindingSelection.js +33 -33
  35. package/src/sap/ui/table/plugins/MultiSelectionPlugin.js +37 -31
  36. package/src/sap/ui/table/plugins/ODataV4Selection.js +132 -69
  37. package/src/sap/ui/table/plugins/PluginBase.js +52 -139
  38. package/src/sap/ui/table/plugins/SelectionMode.js +35 -0
  39. package/src/sap/ui/table/plugins/SelectionModelSelection.js +28 -35
  40. package/src/sap/ui/table/plugins/SelectionPlugin.js +34 -35
  41. package/src/sap/ui/table/plugins/V4Aggregation.js +30 -37
  42. package/src/sap/ui/table/rowmodes/Auto.js +1 -1
  43. package/src/sap/ui/table/rowmodes/Fixed.js +1 -1
  44. package/src/sap/ui/table/rowmodes/Interactive.js +1 -1
  45. package/src/sap/ui/table/rowmodes/RowMode.js +1 -3
  46. package/src/sap/ui/table/rowmodes/Variable.js +1 -1
  47. package/src/sap/ui/table/themes/base/Cell.less +54 -42
  48. package/src/sap/ui/table/themes/base/CreationRow.less +10 -8
  49. package/src/sap/ui/table/themes/base/DragDrop.less +34 -31
  50. package/src/sap/ui/table/themes/base/Grouping.less +23 -14
  51. package/src/sap/ui/table/themes/base/Row.less +6 -6
  52. package/src/sap/ui/table/themes/base/RowAction.less +2 -2
  53. package/src/sap/ui/table/themes/base/RowHighlight.less +15 -15
  54. package/src/sap/ui/table/themes/base/RowSelection.less +13 -8
  55. package/src/sap/ui/table/themes/base/Scrolling.less +73 -25
  56. package/src/sap/ui/table/themes/base/Table.less +63 -46
  57. package/src/sap/ui/table/themes/base/library.source.less +3 -3
  58. package/src/sap/ui/table/utils/TableUtils.js +2 -3
  59. package/src/sap/ui/table/utils/_BindingUtils.js +1 -1
  60. package/src/sap/ui/table/utils/_ColumnUtils.js +1 -1
  61. package/src/sap/ui/table/utils/_GroupingUtils.js +1 -1
  62. package/src/sap/ui/table/utils/_HookUtils.js +1 -1
  63. package/src/sap/ui/table/utils/_MenuUtils.js +1 -1
@@ -5,38 +5,48 @@
5
5
  */
6
6
  sap.ui.define([
7
7
  "./SelectionPlugin",
8
+ "./SelectionMode",
8
9
  "./PluginBase",
9
10
  "../library",
10
11
  "../utils/TableUtils",
11
12
  "sap/ui/core/Icon",
12
- "sap/ui/core/IconPool",
13
- "sap/base/Log"
13
+ "sap/ui/core/IconPool"
14
14
  ], function(
15
15
  SelectionPlugin,
16
+ SelectionMode,
16
17
  PluginBase,
17
18
  library,
18
19
  TableUtils,
19
20
  Icon,
20
- IconPool,
21
- Log
21
+ IconPool
22
22
  ) {
23
23
  "use strict";
24
24
 
25
- const SelectionMode = library.plugins.SelectionMode;
26
- const TableSelectionMode = library.SelectionMode;
27
25
  const _private = TableUtils.createWeakMapFacade();
28
26
 
29
27
  /**
30
- * Constructs an instance of sap.ui.table.plugins.ODataV4Selection.
31
- * TODO: works only with an odata v4 model etc.
32
- *
33
28
  * @class
29
+ * Integrates the selection of the {@link sap.ui.model.odata.v4.ODataListBinding} and the table.
30
+ *
31
+ * The selection of a context that is not selectable is not allowed.
32
+ * The following contexts are not selectable:
33
+ * <ul>
34
+ * <li>Header context</li>
35
+ * <li>Contexts that represent group headers</li>
36
+ * <li>Contexts that contain totals</li>
37
+ * </ul>
38
+ * The selection of multiple contexts in <code>Single</code> selection mode is not allowed.
39
+ *
40
+ * This plugin only works in combination with a <code>sap.ui.model.odata.v4.ODataModel</code>. Do not add it to a table that is bound to another
41
+ * model.
34
42
  * @extends sap.ui.table.plugins.SelectionPlugin
35
- * @alias sap.ui.table.plugins.ODataV4Selection
36
- * @constructor
37
- * @since TODO
43
+ *
38
44
  * @author SAP SE
45
+ * @version 1.135.0
46
+ *
39
47
  * @private
48
+ * @alias sap.ui.table.plugins.ODataV4Selection
49
+ *
40
50
  * @borrows sap.ui.table.plugins.PluginBase.findOn as findOn
41
51
  */
42
52
  const ODataV4Selection = SelectionPlugin.extend("sap.ui.table.plugins.ODataV4Selection", {
@@ -82,9 +92,6 @@ sap.ui.define([
82
92
  },
83
93
  aggregations: {
84
94
  icon: {type: "sap.ui.core.Icon", multiple: false, visibility: "hidden"}
85
- },
86
- events: {
87
- selectionChange: {}
88
95
  }
89
96
  }
90
97
  });
@@ -103,20 +110,27 @@ sap.ui.define([
103
110
  };
104
111
 
105
112
  ODataV4Selection.prototype.onActivate = function(oTable) {
113
+ const oBinding = oTable.getBinding();
114
+
115
+ validateBinding(this, oBinding);
106
116
  SelectionPlugin.prototype.onActivate.apply(this, arguments);
107
117
  oTable.setProperty("selectionMode", this.getSelectionMode());
118
+ attachToBinding(this, oBinding);
119
+ TableUtils.Hook.register(oTable, TableUtils.Hook.Keys.Table.RowsBound, onTableRowsBound, this);
108
120
  };
109
121
 
110
122
  ODataV4Selection.prototype.onDeactivate = function(oTable) {
111
123
  SelectionPlugin.prototype.onDeactivate.apply(this, arguments);
112
- oTable.setProperty("selectionMode", TableSelectionMode.None);
113
- detachFromBinding(this, this.getTableBinding());
124
+ oTable.setProperty("selectionMode", library.SelectionMode.None);
114
125
  clearTimeout(this.iSelectionChangeTimeout);
115
126
  delete this.iSelectionChangeTimeout;
127
+ detachFromBinding(this, oTable.getBinding());
128
+ TableUtils.Hook.deregister(oTable, TableUtils.Hook.Keys.Table.RowsBound, onTableRowsBound, this);
116
129
  };
117
130
 
118
131
  ODataV4Selection.prototype.setSelected = function(oRow, bSelected, mConfig) {
119
132
  const oContext = oRow.getRowBindingContext();
133
+ const sSelectionMode = this.getSelectionMode();
120
134
 
121
135
  if (!this.isActive() || !oContext || !isContextSelectable(oContext)) {
122
136
  return;
@@ -131,8 +145,12 @@ sap.ui.define([
131
145
  return;
132
146
  }
133
147
 
148
+ if (sSelectionMode === SelectionMode.Single && bSelected) {
149
+ this.clearSelection();
150
+ }
151
+
134
152
  oContext.setSelected(bSelected);
135
- _private(this).oRangeSelectionStartContext = bSelected && this.getSelectionMode() === SelectionMode.MultiToggle ? oContext : null;
153
+ _private(this).oRangeSelectionStartContext = bSelected && sSelectionMode === SelectionMode.MultiToggle ? oContext : null;
136
154
  };
137
155
 
138
156
  function extendLastSelectionTo(oPlugin, oRow) {
@@ -154,7 +172,7 @@ sap.ui.define([
154
172
 
155
173
  ODataV4Selection.prototype.isSelected = function(oRow) {
156
174
  const oContext = oRow.getRowBindingContext();
157
- return oContext ? this.isActive() && oContext.isSelected() && isContextSelectable(oContext) : false;
175
+ return oContext ? this.isActive() && oContext.isSelected() : false;
158
176
  };
159
177
 
160
178
  ODataV4Selection.prototype.getSelectedCount = function() {
@@ -168,7 +186,7 @@ sap.ui.define([
168
186
  * @returns {int} The number of selectable rows, or -1 if the number cannot be determined.
169
187
  */
170
188
  function getSelectableCount(oPlugin) {
171
- const oBinding = oPlugin.getTableBinding();
189
+ const oBinding = oPlugin.getControl()?.getBinding();
172
190
 
173
191
  if (!oBinding) {
174
192
  return 0;
@@ -186,14 +204,12 @@ sap.ui.define([
186
204
  let iNumberOfSelectableContexts = -1;
187
205
 
188
206
  if (bIsDataAggregation) {
189
- const aAllCurrentContexts = oBinding.getAllCurrentContexts();
207
+ const aAllCurrentContexts = oPlugin.aAllCurrentContexts ?? oBinding.getAllCurrentContexts();
190
208
 
191
209
  // If not all contexts are available, we cannot determine the number of selectable contexts, and therefore cannot determine if all are
192
210
  // selected.
193
211
  if (oBinding.getLength() === aAllCurrentContexts.length) {
194
- iNumberOfSelectableContexts = aAllCurrentContexts.filter(function(oContext) {
195
- return isContextSelectable(oContext);
196
- }).length;
212
+ iNumberOfSelectableContexts = aAllCurrentContexts.filter(isContextSelectable).length;
197
213
  }
198
214
  } else {
199
215
  iNumberOfSelectableContexts = oBinding.getLength();
@@ -229,19 +245,26 @@ sap.ui.define([
229
245
  if (!this.isActive()) {
230
246
  return SelectionPlugin.prototype.getRenderConfig.apply(this, arguments);
231
247
  }
248
+ this.aAllCurrentContexts = this.getControl().getBinding()?.getAllCurrentContexts();
232
249
 
233
250
  updateHeaderSelectorIcon(this);
234
251
 
235
- return {
252
+ const mRenderConfig = {
236
253
  headerSelector: {
237
254
  type: this._isLimitDisabled() ? "toggle" : "custom",
238
255
  icon: this.getAggregation("icon"),
239
256
  visible: this.getSelectionMode() === SelectionMode.MultiToggle && !this.getHideHeaderSelector(),
240
257
  enabled: getSelectableCount(this) !== 0,
241
258
  selected: areAllRowsSelected(this),
242
- tooltip: this.getSelectedCount() === 0 ? TableUtils.getResourceText("TBL_SELECT_ALL") : TableUtils.getResourceText("TBL_DESELECT_ALL")
259
+ tooltip: this.getSelectedCount() === 0
260
+ ? TableUtils.getResourceText("TBL_SELECT_ALL")
261
+ : TableUtils.getResourceText("TBL_DESELECT_ALL")
243
262
  }
244
263
  };
264
+
265
+ delete this.aAllCurrentContexts;
266
+
267
+ return mRenderConfig;
245
268
  };
246
269
 
247
270
  /**
@@ -255,8 +278,8 @@ sap.ui.define([
255
278
  oPlugin.clearSelection();
256
279
  return false;
257
280
  } else if (oPlugin._isLimitDisabled()) {
258
- const oBinding = oPlugin.getTableBinding();
259
- if (oBinding && oBinding.getLength()) {
281
+ const oBinding = oPlugin.getControl()?.getBinding();
282
+ if (oBinding?.getLength()) {
260
283
  select(oPlugin, 0, oBinding.getLength() - 1);
261
284
  return true;
262
285
  }
@@ -292,8 +315,8 @@ sap.ui.define([
292
315
  if (this.getSelectedCount() > 0) {
293
316
  this.clearSelection();
294
317
  } else {
295
- const oBinding = this.getTableBinding();
296
- if (oBinding && oBinding.getLength() > 0) {
318
+ const oBinding = this.getControl()?.getBinding();
319
+ if (oBinding?.getLength() > 0) {
297
320
  select(this, 0, oBinding.getLength() - 1);
298
321
  }
299
322
  }
@@ -315,8 +338,8 @@ sap.ui.define([
315
338
  oEvent.setMarked("sapUiTableClearAll");
316
339
  }
317
340
  } else {
318
- const oBinding = this.getTableBinding();
319
- if (oBinding && oBinding.getLength() > 0) {
341
+ const oBinding = this.getControl()?.getBinding();
342
+ if (oBinding?.getLength() > 0) {
320
343
  select(this, 0, oBinding.getLength() - 1);
321
344
  }
322
345
  }
@@ -327,7 +350,7 @@ sap.ui.define([
327
350
  };
328
351
 
329
352
  ODataV4Selection.prototype.setSelectionMode = function(sSelectionMode) {
330
- const oTable = this.getTable();
353
+ const oTable = this.getControl();
331
354
 
332
355
  this.setProperty("selectionMode", sSelectionMode, true);
333
356
  _private(this).oRangeSelectionStartContext = null;
@@ -346,53 +369,84 @@ sap.ui.define([
346
369
  return this;
347
370
  };
348
371
 
349
- ODataV4Selection.prototype.onTableRowsBound = function(oBinding) {
372
+ /**
373
+ * Validates the given binding for the specified plugin.
374
+ *
375
+ * @param {Object} oPlugin The plugin instance to validate the binding for.
376
+ * @param {Object} oBinding The binding instance to be validated.
377
+ * @throws {Error} If the model is not an instance of sap.ui.model.odata.v4.ODataModel.
378
+ * @throws {Error} If the header context is selected.
379
+ * @throws {Error} If a context that is not selectable is selected.
380
+ * @throws {Error} If multiple contexts are selected in 'Single' selection mode.
381
+ */
382
+ function validateBinding(oPlugin, oBinding) {
383
+ if (!oBinding) {
384
+ return;
385
+ }
386
+
350
387
  if (!oBinding.getModel().isA("sap.ui.model.odata.v4.ODataModel")) {
351
- throw new Error("This plugin only works with a sap.ui.model.odata.v4.ODataModel.");
388
+ throw new Error("Model must be sap.ui.model.odata.v4.ODataModel");
352
389
  }
353
390
 
354
- SelectionPlugin.prototype.onTableRowsBound.apply(this, arguments);
391
+ validateSelection(oPlugin, oBinding);
392
+ }
393
+
394
+ /**
395
+ * Validates the selection of contexts.
396
+ *
397
+ * @param {object} oPlugin The table plugin instance.
398
+ * @param {object} oBinding The binding instance associated with the table.
399
+ * @param {object} [oContext] The specific context to validate. If not provided, all selected contexts will be validated.
400
+ * @throws {Error} If the header context is selected.
401
+ * @throws {Error} If a context that is not selectable is selected.
402
+ * @throws {Error} If multiple contexts are selected in 'Single' selection mode.
403
+ */
404
+ function validateSelection(oPlugin, oBinding, oContext) {
405
+ const aAllSelectedContexts = [oBinding.getHeaderContext(), ...oBinding.getAllCurrentContexts()].filter((oContext) => oContext?.isSelected());
406
+ let aContextsToValidate = aAllSelectedContexts;
407
+
408
+ if (oContext) {
409
+ aContextsToValidate = oContext.isSelected() ? [oContext] : [];
410
+ }
355
411
 
356
- if (this.getSelectionMode() === SelectionMode.Single) {
357
- const oHeaderContext = oBinding.getHeaderContext();
412
+ for (const oContext of aContextsToValidate) {
413
+ // To avoid compatibility issues if support is added. Handling a selected header context might affect UI, behavior, and settings.
414
+ if (oContext === oBinding.getHeaderContext()) {
415
+ throw new Error("Header context must not be selected");
416
+ }
358
417
 
359
- if (oHeaderContext?.isSelected()) {
360
- oHeaderContext.setSelected(false);
361
- Log.error("The header context must not be selected in selection mode 'Single'.", this);
418
+ // To avoid compatibility issues if support is added. Handling selected sums and group headers might affect UI, behavior, and settings.
419
+ if (!isContextSelectable(oContext)) {
420
+ throw new Error(`Context ${oContext} is not allowed to be selected`);
362
421
  }
363
422
  }
364
423
 
424
+ if (oPlugin.getSelectionMode() === SelectionMode.Single && aAllSelectedContexts.length > 1) {
425
+ throw new Error("Multiple contexts selected. Cannot select more than one context in selection mode 'Single'");
426
+ }
427
+ }
428
+
429
+ function onTableRowsBound(oBinding) {
430
+ validateBinding(this, oBinding);
365
431
  attachToBinding(this, oBinding);
366
- };
432
+ }
367
433
 
368
434
  function attachToBinding(oPlugin, oBinding) {
369
- if (oBinding) {
370
- oBinding.attachEvent("selectionChanged", onBindingSelectionChanged, oPlugin);
371
- }
435
+ oBinding?.attachEvent("selectionChanged", onBindingSelectionChanged, oPlugin);
372
436
  }
373
437
 
374
438
  function detachFromBinding(oPlugin, oBinding) {
375
- if (oBinding) {
376
- oBinding.detachEvent("selectionChanged", onBindingSelectionChanged, oPlugin);
377
- }
439
+ oBinding?.detachEvent("selectionChanged", onBindingSelectionChanged, oPlugin);
378
440
  }
379
441
 
380
442
  function onBindingSelectionChanged(oEvent) {
381
443
  const oContext = oEvent.getParameter("context");
382
- const bIsHeaderContext = oContext === oEvent.getSource().getHeaderContext();
383
-
384
- if (!bIsHeaderContext && !isContextSelectable(oContext)) {
385
- return;
386
- }
387
444
 
388
- if (this.getSelectionMode() === SelectionMode.Single && oContext.isSelected()) {
389
- if (bIsHeaderContext) {
390
- oContext.setSelected(false);
391
- Log.error("The header context must not be selected in selection mode 'Single'.", this);
392
- } else if (this.getSelectedCount() > 1) {
393
- this.clearSelection();
394
- oContext.setSelected(true);
395
- }
445
+ try {
446
+ validateSelection(this, oContext.getBinding(), oContext);
447
+ } catch (oError) {
448
+ oContext.setSelected(false);
449
+ throw oError;
396
450
  }
397
451
 
398
452
  if (this.iSelectionChangeTimeout) {
@@ -423,7 +477,7 @@ sap.ui.define([
423
477
  * @param {int} iIndexTo The end index of the range selection.
424
478
  */
425
479
  function select(oPlugin, iIndexFrom, iIndexTo) {
426
- const oTable = oPlugin.getTable();
480
+ const oTable = oPlugin.getControl();
427
481
  const iLimit = oPlugin.getLimit();
428
482
  const bUpwardSelection = iIndexTo < iIndexFrom; // Indicates whether the selection is made from bottom to top.
429
483
  let iGetContextsStartIndex = bUpwardSelection ? iIndexTo : iIndexFrom;
@@ -446,7 +500,7 @@ sap.ui.define([
446
500
  }
447
501
  }
448
502
 
449
- TableUtils.loadContexts(oPlugin.getTableBinding(), iGetContextsStartIndex, iGetContextsLength).then(function(aContexts) {
503
+ TableUtils.loadContexts(oTable.getBinding(), iGetContextsStartIndex, iGetContextsLength).then(function(aContexts) {
450
504
  aContexts.forEach(function(oContext) {
451
505
  if (!isContextSelectable(oContext) || oContext.isSelected()) {
452
506
  return;
@@ -470,8 +524,13 @@ sap.ui.define([
470
524
  }
471
525
 
472
526
  function isContextSelectable(oContext) {
473
- const bIsHierarchy = "hierarchyQualifier" in (oContext.getBinding().getAggregation() || {});
474
- return bIsHierarchy || (oContext.getProperty("@$ui5.node.isExpanded") === undefined && !oContext.getProperty("@$ui5.node.isTotal"));
527
+ const oBinding = oContext.getBinding();
528
+ const bIsHeaderContext = oContext === oBinding.getHeaderContext();
529
+ const bIsLeaf = oContext.getProperty("@$ui5.node.isExpanded") === undefined;
530
+ const bIsTotal = oContext.getProperty("@$ui5.node.isTotal");
531
+ const bIsHierarchy = "hierarchyQualifier" in (oBinding.getAggregation() || {});
532
+
533
+ return !bIsHeaderContext && (bIsHierarchy || (bIsLeaf && !bIsTotal));
475
534
  }
476
535
 
477
536
  ODataV4Selection.prototype.clearSelection = function() {
@@ -481,11 +540,15 @@ sap.ui.define([
481
540
  };
482
541
 
483
542
  ODataV4Selection.prototype.getSelectedContexts = function() {
484
- const oBinding = this.getTableBinding();
543
+ const oBinding = this.getControl()?.getBinding();
544
+
545
+ if (!this.isActive() || !oBinding) {
546
+ return [];
547
+ }
548
+
549
+ const aAllCurrentContexts = this.aAllCurrentContexts ?? oBinding.getAllCurrentContexts();
485
550
 
486
- return this.isActive() && oBinding ? oBinding.getAllCurrentContexts().filter(function(oContext) {
487
- return oContext.isSelected() && isContextSelectable(oContext);
488
- }) : [];
551
+ return aAllCurrentContexts.filter((oContext) => oContext.isSelected());
489
552
  };
490
553
 
491
554
  ODataV4Selection.prototype.onThemeChanged = function() {
@@ -12,23 +12,14 @@ sap.ui.define([
12
12
  ) {
13
13
  "use strict";
14
14
 
15
- const Hook = TableUtils.Hook.Keys;
16
- const oHookInstallation = {};
17
- const _private = TableUtils.createWeakMapFacade();
18
-
19
15
  /**
20
- * Constructor for a new table plugin.
21
- *
22
- * @param {string} [sId] ID for the new plugin, generated automatically if no ID is given
23
- * @param {object} [mSettings] Initial settings for the new plugin
24
- *
25
16
  * @abstract
26
17
  * @class
27
18
  * Base class for table plugins.
28
19
  * @extends sap.ui.core.Element
29
20
  *
30
21
  * @author SAP SE
31
- * @version 1.134.0
22
+ * @version 1.135.0
32
23
  *
33
24
  * @private
34
25
  * @experimental Since 1.75
@@ -38,10 +29,17 @@ sap.ui.define([
38
29
  const PluginBase = Element.extend("sap.ui.table.plugins.PluginBase", /** @lends sap.ui.table.plugins.PluginBase.prototype */ {
39
30
  metadata: {
40
31
  "abstract": true,
41
- library: "sap.ui.table"
32
+ library: "sap.ui.table",
33
+ properties: {
34
+ /**
35
+ * Indicates whether this plugin is active or not.
36
+ */
37
+ enabled: {type: "boolean", defaultValue: true}
38
+ }
42
39
  }
43
40
  });
44
41
 
42
+ // equal to sap.m.plugins.PluginBase
45
43
  /**
46
44
  * Searches a control plugin with a given type in the aggregations of the given <code>Element</code> instance.
47
45
  * The first plugin that is found is returned.
@@ -73,6 +71,7 @@ sap.ui.define([
73
71
  return oElement.getDependents().find(fnCheck) || oElement.findElements(false, fnCheck)[0];
74
72
  };
75
73
 
74
+ // equal to sap.m.plugins.PluginBase
76
75
  /**
77
76
  * Searches a plugin of the corresponding type in the aggregations of the given <code>Table</code> instance.
78
77
  * The first plugin that is found is returned.
@@ -86,24 +85,23 @@ sap.ui.define([
86
85
  return PluginBase.getPlugin(oTable, this);
87
86
  };
88
87
 
89
- /**
90
- * @override
91
- * @inheritDoc
92
- */
93
- PluginBase.prototype.init = function() {
94
- Element.prototype.init.apply(this, arguments);
95
- _private(this).bIsActive = false;
96
- };
88
+ // equal to sap.m.plugins.PluginBase
89
+ PluginBase.prototype.setEnabled = function(bEnabled) {
90
+ const bOldEnabled = this.getEnabled();
91
+ this.setProperty("enabled", bEnabled, true);
97
92
 
98
- /**
99
- * @override
100
- * @inheritDoc
101
- */
102
- PluginBase.prototype.exit = function() {
103
- Element.prototype.exit.apply(this, arguments);
104
- this.deactivate();
93
+ if (this.getEnabled() !== bOldEnabled) {
94
+ if (bOldEnabled) {
95
+ this._deactivate();
96
+ } else {
97
+ this._activate();
98
+ }
99
+ }
100
+
101
+ return this;
105
102
  };
106
103
 
104
+ // equal to sap.m.plugins.PluginBase
107
105
  /**
108
106
  * Called when the plugin is activated. A plugin is activated when it was successfully applied to a table.
109
107
  *
@@ -113,6 +111,7 @@ sap.ui.define([
113
111
  */
114
112
  PluginBase.prototype.onActivate = function(oTable) {};
115
113
 
114
+ // equal to sap.m.plugins.PluginBase
116
115
  /**
117
116
  * Called when the plugin is deactivated.
118
117
  *
@@ -122,6 +121,7 @@ sap.ui.define([
122
121
  */
123
122
  PluginBase.prototype.onDeactivate = function(oTable) {};
124
123
 
124
+ // equal to sap.m.plugins.PluginBase
125
125
  /**
126
126
  * Gets the active state of the plugin.
127
127
  *
@@ -129,9 +129,10 @@ sap.ui.define([
129
129
  * @public
130
130
  */
131
131
  PluginBase.prototype.isActive = function() {
132
- return _private(this).bIsActive;
132
+ return !!(this._bActive);
133
133
  };
134
134
 
135
+ // not equal to sap.m.plugins.PluginBase. sap.ui.table does not need plugin config
135
136
  /**
136
137
  * Determines whether the plugin is applicable to the control.
137
138
  *
@@ -144,149 +145,61 @@ sap.ui.define([
144
145
  return TableUtils.isA(oControl, "sap.ui.table.Table");
145
146
  };
146
147
 
148
+ // equal to sap.m.plugins.PluginBase
147
149
  /**
148
150
  * @override
149
151
  * @inheritDoc
150
152
  */
151
153
  PluginBase.prototype.setParent = function(oParent) {
152
- this.deactivate();
154
+ this._deactivate();
155
+
153
156
  Element.prototype.setParent.apply(this, arguments);
154
157
 
155
- if (oParent) {
156
- if (!this.isApplicable(this.getTable())) {
157
- throw new Error(this + " is not applicable to " + oParent);
158
- }
159
- this.activate();
158
+ if (this.getEnabled()) {
159
+ this._activate();
160
160
  }
161
161
 
162
162
  return this;
163
163
  };
164
164
 
165
- /**
166
- * Called when the <code>rows</code> aggregation of the table is bound.
167
- *
168
- * @protected
169
- * @virtual
170
- */
171
- PluginBase.prototype.onTableBindRows = function() {};
172
- oHookInstallation[Hook.Table.BindRows] = function(oBindingInfo) {
173
- this.onTableBindRows(oBindingInfo);
174
- };
175
-
176
- /**
177
- * Called when a new binding for the <code>rows</code> aggregation of the table is created, or the plugin is activated in a table with an
178
- * already existing binding for the <code>rows</code> aggregation.
179
- *
180
- * @param {sap.ui.model.Binding} oBinding The binding of the <code>rows</code> aggregation of the table
181
- * @protected
182
- * @virtual
183
- */
184
- PluginBase.prototype.onTableRowsBound = function(oBinding) {};
185
- oHookInstallation[Hook.Table.RowsBound] = function(oBinding) {
186
- this.onTableRowsBound(oBinding); // TODO: rename to onTableBindingCreated ?
187
- };
188
-
189
- /**
190
- * Called when the binding of the <code>rows</code> aggregation of the table is removed.
191
- *
192
- * @protected
193
- * @virtual
194
- */
195
- PluginBase.prototype.onTableUnbindRows = function() {};
196
- oHookInstallation[Hook.Table.UnbindRows] = function() {
197
- this.onTableUnbindRows(); // TODO: rename to onTableBindingRemoved ?
198
- };
199
-
200
- /**
201
- * Gets the table this plugin is applied to.
202
- *
203
- * @returns {sap.ui.table.Table|null} The instance of the table this plugin is applied to, or <code>null</code> if not applied to a table
204
- * @protected
205
- */
206
- PluginBase.prototype.getTable = function() {
207
- const oParent = this.getParent();
208
- return TableUtils.isA(oParent, "sap.ui.table.Table") ? oParent : null;
209
- };
210
-
211
- /**
212
- * Gets the binding of the <code>rows</code> aggregation of the table.
213
- *
214
- * @returns {sap.ui.model.Binding|null} Returns the binding of the <code>rows</code> aggregation of the table.
215
- * @protected
216
- */
217
- PluginBase.prototype.getTableBinding = function() {
218
- const oTable = this.getTable();
219
- const oBinding = oTable ? oTable.getBinding() : null;
220
- return oBinding ? oBinding : null;
221
- };
222
-
223
- /**
224
- * Sets soft constraints for the row counts of the table this plugin is currently applied to.
225
- * They may be fully or partially ignored by the table or the row mode. For example, constraints for fixed rows may be ignored if the row mode
226
- * does not support setting fixed rows.
227
- * There can be conflicts if multiple plugins try to constrain the row counts. Only the constraints of the last call of this method are
228
- * considered.
229
- *
230
- * @param {object} [mConstraints]
231
- * Row count constraints
232
- * @param {boolean} [mConstraints.fixedTop]
233
- * The value <code>true</code> means that there is exactly one fixed top row and <code>false</code> means that fixed top rows are disabled.
234
- * By default, there is no constraint for the fixed top rows. This constraint might be ignored if the table or its row mode do not
235
- * support fixed top rows.
236
- * @param {boolean} [mConstraints.fixedBottom]
237
- * The value <code>true</code> means that there is exactly one fixed bottom row and <code>false</code> means that fixed bottom rows are
238
- * disabled. By default, there is no constraint for the fixed bottom rows. This constraint might be ignored if the table or its row mode
239
- * do not support fixed bottom rows.
240
- * @protected
241
- */
242
- PluginBase.prototype.setRowCountConstraints = function(mConstraints) {
243
- // TODO: Add a type definition for a protected type "rowCountConstraints" in the library file to document the parameter
244
- // RowMode#getRowCountConstraints + PluginBase#setRowCountConstraints
245
- const oTable = this.getTable();
246
-
247
- if (oTable) {
248
- oTable._setRowCountConstraints(mConstraints);
249
- }
165
+ // not equal to sap.m.plugins.PluginBase. sap.ui.table does not support PluginOwner concept
166
+ PluginBase.prototype.getControl = function() {
167
+ return this.getParent();
250
168
  };
251
169
 
170
+ // not equal to sap.m.plugins.PluginBase. sap.ui.table does not need plugin config and does not support PluginOwner concept
252
171
  /**
253
172
  * Activates the plugin if it is not active.
254
- *
255
- * @protected
256
173
  */
257
- PluginBase.prototype.activate = function() {
258
- const oTable = this.getTable();
259
-
260
- if (!oTable || this.isActive()) {
174
+ PluginBase.prototype._activate = function() {
175
+ if (this._bActive) {
261
176
  return;
262
177
  }
263
178
 
264
- TableUtils.Hook.install(oTable, oHookInstallation, this);
265
- this.onActivate(oTable);
179
+ const oControl = this.getControl();
180
+ if (!oControl) {
181
+ return;
182
+ }
266
183
 
267
- const oTableBinding = this.getTableBinding();
268
- if (oTableBinding) {
269
- this.onTableRowsBound(oTableBinding);
184
+ if (!this.isApplicable(oControl)) {
185
+ throw new Error(this + " is not applicable to " + oControl);
270
186
  }
271
187
 
272
- _private(this).bIsActive = true;
188
+ this._bActive = true;
189
+ this.onActivate(oControl);
273
190
  };
274
191
 
192
+ // not equal to sap.m.plugins.PluginBase. sap.ui.table does not need plugin config and does not PluginOwner concept
275
193
  /**
276
194
  * Deactivates the plugin if it is active.
277
- *
278
- * @protected
279
195
  */
280
- PluginBase.prototype.deactivate = function() {
281
- const oTable = this.getTable();
282
-
283
- if (!this.isActive()) {
196
+ PluginBase.prototype._deactivate = function() {
197
+ if (!this._bActive) {
284
198
  return;
285
199
  }
286
200
 
287
- TableUtils.Hook.uninstall(oTable, oHookInstallation, this);
288
- this.onDeactivate(oTable);
289
- _private(this).bIsActive = false;
201
+ this._bActive = false;
202
+ this.onDeactivate(this.getControl());
290
203
  };
291
204
 
292
205
  return PluginBase;