@openui5/sap.ui.dt 1.93.3 → 1.96.2

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 (48) hide show
  1. package/.reuse/dep5 +6 -11
  2. package/THIRDPARTY.txt +10 -16
  3. package/package.json +2 -2
  4. package/src/sap/ui/dt/.library +1 -1
  5. package/src/sap/ui/dt/AggregationDesignTimeMetadata.js +1 -1
  6. package/src/sap/ui/dt/AggregationOverlay.js +1 -1
  7. package/src/sap/ui/dt/ControlObserver.js +1 -1
  8. package/src/sap/ui/dt/DOMUtil.js +1 -1
  9. package/src/sap/ui/dt/DesignTime.js +1 -1
  10. package/src/sap/ui/dt/DesignTimeMetadata.js +1 -1
  11. package/src/sap/ui/dt/ElementDesignTimeMetadata.js +2 -2
  12. package/src/sap/ui/dt/ElementOverlay.js +8 -1
  13. package/src/sap/ui/dt/ElementUtil.js +73 -1
  14. package/src/sap/ui/dt/ManagedObjectObserver.js +1 -1
  15. package/src/sap/ui/dt/MetadataPropagationUtil.js +1 -1
  16. package/src/sap/ui/dt/MutationObserver.js +1 -1
  17. package/src/sap/ui/dt/Overlay.js +1 -1
  18. package/src/sap/ui/dt/OverlayRegistry.js +1 -1
  19. package/src/sap/ui/dt/OverlayUtil.js +50 -16
  20. package/src/sap/ui/dt/Plugin.js +1 -1
  21. package/src/sap/ui/dt/ScrollbarSynchronizer.js +1 -1
  22. package/src/sap/ui/dt/SelectionManager.js +1 -1
  23. package/src/sap/ui/dt/SelectionMode.js +1 -1
  24. package/src/sap/ui/dt/TaskManager.js +1 -1
  25. package/src/sap/ui/dt/TaskRunner.js +1 -1
  26. package/src/sap/ui/dt/Util.js +1 -5
  27. package/src/sap/ui/dt/enablement/ElementEnablementTest.js +1 -1
  28. package/src/sap/ui/dt/enablement/Test.js +1 -1
  29. package/src/sap/ui/dt/enablement/Util.js +1 -1
  30. package/src/sap/ui/dt/enablement/report/LibraryReport.js +1 -1
  31. package/src/sap/ui/dt/enablement/report/QUnitReport.js +1 -1
  32. package/src/sap/ui/dt/enablement/report/Statistic.js +1 -1
  33. package/src/sap/ui/dt/enablement/report/StatisticRenderer.js +1 -1
  34. package/src/sap/ui/dt/enablement/report/Table.js +1 -1
  35. package/src/sap/ui/dt/enablement/report/TableRenderer.js +1 -1
  36. package/src/sap/ui/dt/library.js +2 -2
  37. package/src/sap/ui/dt/plugin/ContextMenu.js +122 -374
  38. package/src/sap/ui/dt/plugin/ControlDragDrop.js +1 -1
  39. package/src/sap/ui/dt/plugin/CutPaste.js +1 -1
  40. package/src/sap/ui/dt/plugin/DragDrop.js +1 -1
  41. package/src/sap/ui/dt/plugin/ElementMover.js +39 -42
  42. package/src/sap/ui/dt/plugin/MouseSelection.js +1 -1
  43. package/src/sap/ui/dt/plugin/TabHandling.js +39 -7
  44. package/src/sap/ui/dt/plugin/ToolHooks.js +1 -1
  45. package/src/sap/ui/dt/themes/base/ContextMenu.less +104 -75
  46. package/src/sap/ui/dt/util/ZIndexManager.js +1 -1
  47. package/ui5.yaml +4 -1
  48. package/src/sap/ui/dt/ContextMenuControl.js +0 -929
@@ -5,24 +5,24 @@
5
5
  */
6
6
  sap.ui.define([
7
7
  "sap/ui/dt/Plugin",
8
- "sap/ui/dt/ContextMenuControl",
8
+ "sap/m/Menu",
9
+ "sap/m/MenuItem",
9
10
  "sap/ui/dt/Util",
10
11
  "sap/ui/dt/OverlayRegistry",
11
12
  "sap/ui/dt/util/_createPromise",
12
13
  "sap/ui/Device",
13
14
  "sap/base/assert",
14
- "sap/ui/events/KeyCodes",
15
- "sap/base/util/restricted/_debounce"
15
+ "sap/ui/events/KeyCodes"
16
16
  ], function(
17
17
  Plugin,
18
- ContextMenuControl,
18
+ Menu,
19
+ MenuItem,
19
20
  DtUtil,
20
21
  OverlayRegistry,
21
22
  _createPromise,
22
23
  Device,
23
24
  assert,
24
- KeyCodes,
25
- _debounce
25
+ KeyCodes
26
26
  ) {
27
27
  "use strict";
28
28
 
@@ -34,7 +34,7 @@ sap.ui.define([
34
34
  * @class The ContextMenu registers event handler to open the context menu. Menu entries can dynamically be added
35
35
  * @extends sap.ui.dt.Plugin
36
36
  * @author SAP SE
37
- * @version 1.93.3
37
+ * @version 1.96.2
38
38
  * @constructor
39
39
  * @private
40
40
  * @since 1.53
@@ -48,13 +48,6 @@ sap.ui.define([
48
48
  contextElement: {
49
49
  type: "object"
50
50
  },
51
- styleClass: {
52
- type: "string"
53
- },
54
- openOnHover: {
55
- type: "boolean",
56
- defaultValue: true
57
- },
58
51
  openOnClick: {
59
52
  type: "boolean",
60
53
  defaultValue: true
@@ -68,30 +61,23 @@ sap.ui.define([
68
61
 
69
62
  });
70
63
 
71
- ContextMenu.prototype.init = function () {
72
- this.iMenuHoverOpeningDelay = 500;
73
- this.iMenuHoverClosingDelay = 250; //Should be lower than iMenuHoverOpeningDelay, otherwise ContextMenu is instantly closed
74
-
75
- this.oContextMenuControl = new ContextMenuControl({
76
- maxButtonsDisplayed: 4 //The maximum number of buttons which should be displayed in the collapsed version of the ContextMenu (including overflow-button)
77
- });
64
+ var mainStyleClass = "sapUiDtContextMenu";
65
+ var miniMenuStyleClass = "sapUiDtContextMiniMenu";
78
66
 
67
+ ContextMenu.prototype.init = function () {
68
+ this.oContextMenuControl = new Menu();
69
+ this.oContextMenuControl.attachItemSelected(this._onItemSelected, this);
79
70
  this.oContextMenuControl.attachClosed(this._contextMenuClosed, this);
80
- this.oContextMenuControl.attachOverflowButtonPressed(this._pressedOverflowButton, this);
81
-
71
+ this.oContextMenuControl.addStyleClass(mainStyleClass);
82
72
  this._aMenuItems = [];
83
73
  this._aGroupedItems = [];
84
74
  this._aSubMenus = [];
85
75
  };
86
76
 
87
77
  ContextMenu.prototype.exit = function () {
88
- this._clearHoverTimeout();
89
78
  delete this._aMenuItems;
90
79
  if (this.oContextMenuControl) {
91
- this.oContextMenuControl.detachClosed(this._contextMenuClosed, this);
92
- this.oContextMenuControl.detachOverflowButtonPressed(this._pressedOverflowButton, this);
93
80
  this.oContextMenuControl.destroy();
94
- delete this.oContextMenuControl;
95
81
  }
96
82
  };
97
83
 
@@ -101,14 +87,14 @@ sap.ui.define([
101
87
  * @param {object} mMenuItem json object with the menu item settings
102
88
  * @param {string} mMenuItem.id id, which corresponds to the text key
103
89
  * @param {string} mMenuItems.text menu item text (translated)
104
- * @param {string} mMenuItems.icon a icon for the button
90
+ * @param {string} mMenuItems.icon a icon for the menu item
105
91
  * @param {function} mMenuItem.handler event handler if menu is selected, the element for which the menu was opened is passed to the handler
106
92
  * @param {function} mMenuItem.startSection? function to determine if a new section should be started, the element for which the menu was opened
107
93
  * is passed to the handler, default false
108
94
  * @param {function} mMenuItem.enabled? function to determine if the menu entry should be enabled, the element for which the menu should be opened
109
95
  * is passed, default true
110
96
  * @param {boolean} bRetrievedFromPlugin flag to mark if a menu item was retrieved from a plugin (in runtime)
111
- * @param {boolena} bPersistOneTime flag to mark that the Button persist the next Menu clearing
97
+ * @param {boolean} bPersistOneTime flag to mark that the Button persist the next Menu clearing
112
98
  */
113
99
  ContextMenu.prototype.addMenuItem = function (mMenuItem, bRetrievedFromPlugin, bPersistOneTime) {
114
100
  var mMenuItemEntry = {
@@ -126,11 +112,9 @@ sap.ui.define([
126
112
  * @override
127
113
  */
128
114
  ContextMenu.prototype.registerElementOverlay = function (oOverlay) {
129
- oOverlay.attachBrowserEvent("click", this._onContextMenuOrClick, this);
130
- oOverlay.attachBrowserEvent("touchstart", this._onContextMenuOrClick, this);
131
- oOverlay.attachBrowserEvent("contextmenu", this._onContextMenuOrClick, this);
132
- // oOverlay.attachBrowserEvent("mouseover", this._onHover, this); FIXME: wait for hover PoC from UX colleagues
133
- // oOverlay.attachBrowserEvent("mouseout", this._clearHoverTimeout, this);
115
+ oOverlay.attachBrowserEvent("click", this._openContextMenu, this);
116
+ oOverlay.attachBrowserEvent("touchstart", this._openContextMenu, this);
117
+ oOverlay.attachBrowserEvent("contextmenu", this._openContextMenu, this);
134
118
  oOverlay.attachBrowserEvent("keydown", this._onKeyDown, this);
135
119
  oOverlay.attachBrowserEvent("keyup", this._onKeyUp, this);
136
120
  };
@@ -143,25 +127,48 @@ sap.ui.define([
143
127
  * @override
144
128
  */
145
129
  ContextMenu.prototype.deregisterElementOverlay = function (oOverlay) {
146
- oOverlay.detachBrowserEvent("click", this._onContextMenuOrClick, this);
147
- oOverlay.detachBrowserEvent("touchstart", this._onContextMenuOrClick, this);
148
- oOverlay.detachBrowserEvent("contextmenu", this._onContextMenuOrClick, this);
149
- // oOverlay.detachBrowserEvent("mouseover", this._onHover, this); FIXME: wait for hover PoC from UX colleagues
150
- // oOverlay.detachBrowserEvent("mouseout", this._clearHoverTimeout, this);
130
+ oOverlay.detachBrowserEvent("click", this._openContextMenu, this);
131
+ oOverlay.detachBrowserEvent("touchstart", this._openContextMenu, this);
132
+ oOverlay.detachBrowserEvent("contextmenu", this._openContextMenu, this);
151
133
  oOverlay.detachBrowserEvent("keydown", this._onKeyDown, this);
152
134
  oOverlay.detachBrowserEvent("keyup", this._onKeyUp, this);
153
135
  };
154
136
 
155
137
  /**
156
138
  * Opens the Context Menu
157
- * @param {object} mPosition position of the element triggering the open
158
139
  * @param {sap.ui.dt.Overlay} oOverlay overlay object
159
140
  * @param {boolean} bContextMenu whether the control should be opened as a context menu
160
- * @param {boolean} bIsSubMenu whether the new ContextMenu is a SubMenu opened by a button inside another ContextMenu
141
+ * @param {boolean} bIsSubMenu whether the new ContextMenu is a SubMenu opened by a menu item inside another ContextMenu
161
142
  */
162
- ContextMenu.prototype.open = function (mPosition, oOverlay, bContextMenu, bIsSubMenu) {
163
- this._bContextMenu = !!bContextMenu;
143
+ ContextMenu.prototype.open = function (oOverlay, bContextMenu, bIsSubMenu, oEvent) {
144
+ function addMenuItems(oMenu, aMenuItems) {
145
+ aMenuItems.forEach(function(oMenuItem, index) {
146
+ var sText = typeof oMenuItem.text === "function" ? oMenuItem.text(oOverlay) : oMenuItem.text;
147
+ var bEnabled = typeof oMenuItem.enabled === "function" ? oMenuItem.enabled(aSelectedOverlays) : oMenuItem.enabled;
148
+ var sTooltip;
149
+ if (!bContextMenu) {
150
+ sTooltip = sText;
151
+ }
152
+ oMenu.addItem(
153
+ new MenuItem({
154
+ key: oMenuItem.id,
155
+ icon: oMenuItem.icon,
156
+ text: sText,
157
+ enabled: bEnabled
158
+ }).setTooltip(sTooltip)
159
+ );
160
+ if (oMenuItem.submenu) {
161
+ addMenuItems(oMenu.getItems()[index], oMenuItem.submenu);
162
+ }
163
+ });
164
+ }
164
165
 
166
+ this._bContextMenu = !!bContextMenu;
167
+ if (this._bContextMenu) {
168
+ this.oContextMenuControl.removeStyleClass(miniMenuStyleClass);
169
+ } else {
170
+ this.oContextMenuControl.addStyleClass(miniMenuStyleClass);
171
+ }
165
172
  var oNewContextElement = oOverlay.getElement();
166
173
  if (this._fnCancelMenuPromise) {
167
174
  // Menu is still opening
@@ -174,7 +181,6 @@ sap.ui.define([
174
181
  }
175
182
 
176
183
  this.setContextElement(oNewContextElement);
177
-
178
184
  this.getDesignTime().getSelectionManager().attachChange(this._onSelectionChanged, this);
179
185
 
180
186
  var aSelectedOverlays = this.getSelectedOverlays().filter(function (oElementOverlay) {
@@ -182,12 +188,7 @@ sap.ui.define([
182
188
  });
183
189
  aSelectedOverlays.unshift(oOverlay);
184
190
 
185
- //IE sometimes returns null for document.activeElement
186
- if (document.activeElement) {
187
- document.activeElement.blur();
188
- }
189
-
190
- //Remove all previous entries retrieved by plugins (the list should always be rebuilt)
191
+ // Keep all persisted menu items
191
192
  this._aMenuItems = this._aMenuItems.filter(function (mMenuItemEntry) {
192
193
  if (mMenuItemEntry.bPersistOneTime) {
193
194
  mMenuItemEntry.bPersistOneTime = false;
@@ -196,6 +197,9 @@ sap.ui.define([
196
197
  return !mMenuItemEntry.fromPlugin;
197
198
  });
198
199
 
200
+ // Remove all previous entries retrieved by plugins (the list should always be rebuilt)
201
+ this.oContextMenuControl.destroyItems();
202
+
199
203
  var oPromise = Promise.resolve();
200
204
  if (!bIsSubMenu) {
201
205
  var oDtSyncPromise = _createPromise(function (resolve, reject) {
@@ -229,16 +233,21 @@ sap.ui.define([
229
233
  })
230
234
  .then(function(aPluginMenuItems) {
231
235
  aPluginMenuItems.forEach(function (mMenuItem) {
236
+ // Show only enabled items in Minimenu
237
+ var bEnabled = typeof mMenuItem.enabled === "function" ? mMenuItem.enabled(aSelectedOverlays) : mMenuItem.enabled;
238
+ if (!bEnabled && !bContextMenu) {
239
+ return;
240
+ }
232
241
  if (mMenuItem.group !== undefined && !bContextMenu) {
233
242
  this._addMenuItemToGroup(mMenuItem);
234
243
  } else if (mMenuItem.submenu !== undefined) {
235
- this._addSubMenu(mMenuItem, mPosition, oOverlay);
244
+ this._addSubMenu(mMenuItem);
236
245
  } else {
237
246
  this.addMenuItem(mMenuItem, true);
238
247
  }
239
248
  }.bind(this));
240
249
 
241
- this._addItemGroupsToMenu(mPosition, oOverlay);
250
+ this._addItemGroupsToMenu();
242
251
  delete this._fnCancelMenuPromise;
243
252
  }.bind(this));
244
253
  }
@@ -250,23 +259,18 @@ sap.ui.define([
250
259
 
251
260
  if (aMenuItems.length > 0) {
252
261
  aMenuItems = this._sortMenuItems(aMenuItems);
253
- this.oContextMenuControl.setButtons(aMenuItems, this._onItemSelected.bind(this), aSelectedOverlays);
254
- this.oContextMenuControl.setStyleClass(this.getStyleClass());
255
-
256
- this.oContextMenuControl.show(oOverlay, bContextMenu, {
257
- x: mPosition.clientX,
258
- y: mPosition.clientY
259
- });
262
+ addMenuItems(this.oContextMenuControl, aMenuItems);
263
+ this.oContextMenuControl.openAsContextMenu(oEvent, oOverlay);
260
264
  }
261
265
 
262
266
  this.fireOpenedContextMenu();
263
267
  }.bind(this))
264
- .catch(function(oError) {
265
- throw DtUtil.createError(
266
- "ContextMenu#open",
267
- "An error occured during calling getMenuItems: " + oError
268
- );
269
- });
268
+ .catch(function(oError) {
269
+ throw DtUtil.createError(
270
+ "ContextMenu#open",
271
+ "An error occured during calling getMenuItems: " + oError
272
+ );
273
+ });
270
274
  };
271
275
 
272
276
  /**
@@ -291,20 +295,6 @@ sap.ui.define([
291
295
  });
292
296
  };
293
297
 
294
- /**
295
- * Funcion is called when "_onContextMenu" is fired -> opens the ContextMenu
296
- * @param {sap.ui.base.Event} oEvent Event object
297
- * @private
298
- */
299
- ContextMenu.prototype._onContextMenu = function (oEvent) {
300
- var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
301
- var mPosition = {
302
- clientX: oEvent.clientX,
303
- clientY: oEvent.clientY
304
- };
305
- this._openContextMenu(oEvent, oOverlay, mPosition);
306
- };
307
-
308
298
  /**
309
299
  * Called when a context menu item gets selected by user
310
300
  * @param {sap.ui.base.Event} oEventItem event object
@@ -312,156 +302,33 @@ sap.ui.define([
312
302
  * @private
313
303
  */
314
304
  ContextMenu.prototype._onItemSelected = function (oEventItem) {
315
- this.oContextMenuControl.close(true);
316
305
  this._ensureSelection(this._oCurrentOverlay);
317
- this.setFocusLock(true);
318
-
319
- var aSelection = [];
320
- var oContextElement = this.getContextElement();
321
- var sSelectedButtonId = oEventItem.data("id");
322
-
323
- this._aMenuItems.some(function (mMenuItemEntry) {
324
- if (sSelectedButtonId === mMenuItemEntry.menuItem.id) {
325
- var oItem = mMenuItemEntry.menuItem;
326
- aSelection = mMenuItemEntry.menuItem.responsible || this.getSelectedOverlays();
327
- assert(aSelection.length > 0, "sap.ui.rta - Opening context menu, with empty selection - check event order");
328
- var mPropertiesBag = {};
329
- mPropertiesBag.eventItem = oEventItem;
330
- mPropertiesBag.contextElement = oContextElement;
331
- var fnHandler = oItem.handler;
332
- if (this.oContextMenuControl.isPopupOpen()) {
333
- this.oContextMenuControl.attachEventOnce("Closed", function() {
334
- fnHandler(aSelection, mPropertiesBag);
335
- });
336
- } else {
337
- fnHandler(aSelection, mPropertiesBag);
338
- }
339
- oItem = null;
340
- return true;
341
- }
342
- }, this);
343
- };
344
-
345
- ContextMenu.prototype._onContextMenuOrClick = function(oEvent) {
346
- if (!this.fnDebounced) {
347
- this.fnDebounced = _debounce(function() {
348
- if (this._oCurrentEvent.type === "contextmenu") {
349
- this._onContextMenu(this._oCurrentEvent);
350
- } else {
351
- this._onClickorTouch(this._oCurrentEvent);
352
- }
353
- this._oCurrentEvent = undefined;
354
- this.fnDebounced = undefined;
355
- }.bind(this), 50);
356
- }
357
306
 
358
- var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
359
- if (oOverlay && oOverlay.isSelectable() && oOverlay.getSelected()) {
360
- this._oCurrentEvent = oEvent;
361
- oEvent.stopPropagation();
362
- this.fnDebounced();
307
+ function callHandler(oMenuItem, oEventItem) {
308
+ var aSelection = oMenuItem.responsible || this.getSelectedOverlays() || [];
309
+ assert(aSelection.length > 0, "sap.ui.rta - Opening context menu, with empty selection - check event order");
310
+ var mPropertiesBag = {};
311
+ mPropertiesBag.eventItem = oEventItem;
312
+ mPropertiesBag.contextElement = this.getContextElement();
313
+ oMenuItem.handler(aSelection, mPropertiesBag);
363
314
  }
364
- };
365
-
366
- /**
367
- * Called when the user clicks or touches an overlay
368
- * @param {sap.ui.base.Event} oEvent event object
369
- * @private
370
- */
371
- ContextMenu.prototype._onClickorTouch = function (oEvent) {
372
- if (this.getOpenOnClick()) {
373
- if (this.isMenuOpeningLocked()) {
374
- this.unlockMenuOpening();
375
- this.oContextMenuControl.close();
376
- }
377
- this._startOpening(oEvent);
378
- }
379
- };
380
-
381
- /**
382
- * Called before the ContextMenu is opened (except by contextMenu event)
383
- * Checks whether a new ContextMenu should been opened and does so, if check returned true
384
- * @param {sap.ui.base.Event} oEvent event object
385
- * @param {boolean} bLockOpening should the Opening of the ContextMenu be locked
386
- * @return {boolean} Whether a new ContextMenu has been opened or not
387
- * @private
388
- */
389
- ContextMenu.prototype._startOpening = function (oEvent, bLockOpening) {
390
- clearTimeout(this.hoverTimeout);
391
- this._bOpenedByHover = false;
392
-
393
- this._oTempTarget = oEvent.currentTarget.id;
394
-
395
- var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
396
- var sTargetClasses = oEvent.target.className;
397
315
 
398
- if (oOverlay && oOverlay.isSelectable() && sTargetClasses.indexOf("sapUiDtOverlay") > -1 && (!this.isMenuOpeningLocked())) {
399
- oEvent.stopPropagation();
316
+ var sSelectedItemId = oEventItem.getParameter("item").getKey();
400
317
 
401
- if (this._shouldContextMenuOpen(oEvent)) {
402
- this._ensureSelection(oOverlay);
403
- if (this._oCurrentOverlay.isSelected() || Device.os.android) {
404
- if (bLockOpening) {
405
- this.lockMenuOpening();
318
+ this._aMenuItems.some(function (mMenuItemEntry) {
319
+ var oItem = mMenuItemEntry.menuItem;
320
+ if (sSelectedItemId === mMenuItemEntry.menuItem.id) {
321
+ callHandler.apply(this, [oItem, oEventItem]);
322
+ return true;
323
+ } else if (oItem.submenu) {
324
+ oItem.submenu.some(function(mSubMenuItem) {
325
+ if (sSelectedItemId === mSubMenuItem.id) {
326
+ callHandler.apply(this, [mSubMenuItem, oEventItem]);
327
+ return true;
406
328
  }
407
- this.open(
408
- {
409
- clientX: oEvent.clientX,
410
- clientY: oEvent.clientY
411
- },
412
- oOverlay
413
- );
414
-
415
- return true;
416
- }
417
- }
418
- }
419
- };
420
-
421
- /**
422
- * Called when the user hovers over an overlay
423
- * @param {sap.ui.base.Event} oEvent event object
424
- * @private
425
- */
426
- ContextMenu.prototype._onHover = function (oEvent) {
427
- var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
428
- if (oOverlay && oOverlay.isSelectable() && !oEvent.ctrlKey && this.getOpenOnHover()) {
429
- oEvent.stopPropagation();
430
- if (this._shouldContextMenuOpen(oEvent, true)) {
431
- if (this.iMenuHoverClosingDelay >= this.iMenuHoverOpeningDelay) {
432
- throw new Error("sap.ui.dt ContextMenu iMenuHoverClosingDelay is bigger or equal to iMenuHoverOpeningDelay!");
433
- }
434
-
435
- if (this.oContextMenuControl.getPopover().isOpen()) {
436
- this._closingTimeout = setTimeout(function () {
437
- if (this.oContextMenuControl.getPopover().isOpen()) {
438
- this.oContextMenuControl.close();
439
- }
440
- }.bind(this), this.iMenuHoverClosingDelay);
441
- }
442
-
443
- this.hoverTimeout = setTimeout(function () {
444
- OverlayRegistry.getOverlay(oEvent.currentTarget.id).focus();
445
- this._startOpening(oEvent);
446
- this._bOpenedByHover = true;
447
- }.bind(this), this.iMenuHoverOpeningDelay);
329
+ }.bind(this));
448
330
  }
449
- }
450
- };
451
-
452
- /**
453
- * Called when the user stops hovering over an overlay
454
- * @private
455
- */
456
- ContextMenu.prototype._clearHoverTimeout = function () {
457
- if (this.hoverTimeout) {
458
- clearTimeout(this.hoverTimeout);
459
- this.hoverTimeout = null;
460
- }
461
- if (this._closingTimeout) {
462
- clearTimeout(this._closingTimeout);
463
- this._closingTimeout = null;
464
- }
331
+ }, this);
465
332
  };
466
333
 
467
334
  /**
@@ -472,12 +339,19 @@ sap.ui.define([
472
339
  */
473
340
  ContextMenu.prototype._onKeyUp = function (oEvent) {
474
341
  var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
342
+ // Prevents that the context menu opens after finishing a rename with ENTER
343
+ if (oEvent.keyCode === KeyCodes.ENTER && oOverlay.getIgnoreEnterKeyUpOnce()) {
344
+ oOverlay.setIgnoreEnterKeyUpOnce(false);
345
+ oEvent.stopPropagation();
346
+ oEvent.preventDefault();
347
+ return;
348
+ }
475
349
  if ((oEvent.keyCode === KeyCodes.SPACE || oEvent.keyCode === KeyCodes.ENTER) &&
476
350
  (oEvent.shiftKey === false) &&
477
351
  (oEvent.altKey === false) &&
478
352
  (oEvent.ctrlKey === false)) {
479
- if (oOverlay && oOverlay.isSelectable() && !this._checkForPluginLock()) {
480
- this._startOpening(oEvent, true);
353
+ if (!this._checkForPluginLock()) {
354
+ this._openContextMenu(oEvent);
481
355
  oEvent.stopPropagation();
482
356
  oEvent.preventDefault();
483
357
  }
@@ -486,15 +360,10 @@ sap.ui.define([
486
360
  (oEvent.shiftKey === true) &&
487
361
  (oEvent.altKey === false) &&
488
362
  (oEvent.ctrlKey === false)) {
489
- if (oOverlay && oOverlay.isSelectable()) {
363
+ if (!this._checkForPluginLock()) {
364
+ this._openContextMenu(oEvent);
365
+ oEvent.stopPropagation();
490
366
  oEvent.preventDefault();
491
-
492
- var mPosition = {
493
- clientX: "not set",
494
- clientY: "not set"
495
- };
496
-
497
- this._openContextMenu(oEvent, oOverlay, mPosition);
498
367
  }
499
368
  }
500
369
  };
@@ -511,6 +380,7 @@ sap.ui.define([
511
380
  (oEvent.altKey === false) &&
512
381
  (oEvent.ctrlKey === false)) {
513
382
  if (oOverlay && oOverlay.isSelectable() && !this._checkForPluginLock()) {
383
+ oOverlay.setSelected(true);
514
384
  oEvent.stopPropagation();
515
385
  oEvent.preventDefault();
516
386
  }
@@ -518,55 +388,16 @@ sap.ui.define([
518
388
  };
519
389
 
520
390
  /**
521
- * Checks whether a new ContextMenu should be opened
522
- * @param {sap.ui.base.Event} oEvent event object
523
- * @param {boolean} onHover if true, the new overlay doesn't get stored in this._oCurrentOverlay
524
- * @return {boolean} whether the check was sucessfull and a new ContextMenu should be opened
525
- * @private
526
- */
527
- ContextMenu.prototype._shouldContextMenuOpen = function (oEvent, onHover) {
528
- if ((!this._checkForPluginLock() && !this.isMenuOpeningLocked())) {
529
- if (!onHover) {
530
- this._oCurrentOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
531
- }
532
- return true;
533
- }
534
- return false;
535
- };
536
-
537
- /**
538
- * Called when overflow button is pressed on compact ContextMenu
539
- * @param {sap.ui.base.Event} oEvent event object
540
- * @private
391
+ * Called when user presses key on keyboard.
392
+ * Opens the ContextMenu on Click or Shift-F10 when no other plugin is active
393
+ * @param {sap.ui.base.Event} oEvent the event which was fired
541
394
  */
542
- ContextMenu.prototype._pressedOverflowButton = function (oEvent) {
543
- this.lockMenuOpening();
544
- var oOverlay = OverlayRegistry.getOverlay(oEvent.oSource._oTarget.getAttribute("overlay"));
545
- var mPosition = {
546
- clientX: oEvent.mParameters.oButton.$().offset().left,
547
- clientY: oEvent.mParameters.oButton.$().offset().top
548
- };
549
- this._openContextMenu(oEvent, oOverlay, mPosition);
550
-
551
- this.setFocusLock(true);
552
- };
553
-
554
- ContextMenu.prototype._openContextMenu = function(oEvent, oOverlay, mPosition) {
555
- if (oOverlay && oOverlay.isSelectable()) {
556
- oEvent.preventDefault();
395
+ ContextMenu.prototype._openContextMenu = function(oEvent) {
396
+ var oOverlay = OverlayRegistry.getOverlay(oEvent.currentTarget.id);
397
+ if (oOverlay && oOverlay.isSelectable() && oOverlay.getSelected()) {
557
398
  this._oCurrentOverlay = oOverlay;
558
- this.oContextMenuControl.close(true);
559
- this._bOpenedByHover = false;
560
-
561
- clearTimeout(this.hoverTimeout);
562
-
563
- this._ensureSelection(oOverlay);
564
-
565
- this.lockMenuOpening();
566
- this.open(mPosition, oOverlay, true);
567
- if (oEvent.stopPropagation) {
568
- oEvent.stopPropagation();
569
- }
399
+ var bContextMenu = oEvent.type === "contextmenu" || oEvent.keyCode === KeyCodes.F10;
400
+ this.open(oOverlay, bContextMenu, undefined, oEvent);
570
401
  }
571
402
  };
572
403
 
@@ -574,61 +405,19 @@ sap.ui.define([
574
405
  * Called when ContextMenu gets closed
575
406
  */
576
407
  ContextMenu.prototype._contextMenuClosed = function () {
577
- this.unlockMenuOpening();
578
- this.setFocusLock(false);
408
+ this.oContextMenuControl.removeStyleClass(miniMenuStyleClass);
409
+ this.fireClosedContextMenu();
579
410
  };
580
411
 
581
412
  /**
582
413
  * Called when the selection changes
583
414
  */
584
415
  ContextMenu.prototype._onSelectionChanged = function() {
585
- this.oContextMenuControl.close(true);
586
416
  this.getDesignTime().getSelectionManager().detachChange(this._onSelectionChanged, this);
587
417
  };
588
418
 
589
419
  /**
590
- * Locks the Opening of the ContextMenu, no new one gets opened
591
- * Note: should be called BEFORE a new ContextMenu is opened
592
- * @param {boolean} bOverwriteOpenValue overwrites the "isOpen" value from the ContextMenuControl
593
- */
594
- ContextMenu.prototype.lockMenuOpening = function (bOverwriteOpenValue) {
595
- if ((this.oContextMenuControl.getPopover(true).isOpen() ||
596
- this.oContextMenuControl.getPopover(false).isOpen()) &&
597
- bOverwriteOpenValue !== true) { // sometimes this function needs to be called after the old ContextMenu is closed
598
- this._bAsyncLock = true;
599
- } else {
600
- this._bOpeningLocked = true;
601
- }
602
- };
603
-
604
- /**
605
- * Unlocks the Opening of the ContextMenu
606
- */
607
- ContextMenu.prototype.unlockMenuOpening = function () {
608
- this._bOpeningLocked = false;
609
- if (this._bAsyncLock) {
610
- this.lockMenuOpening(true);
611
- }
612
- this._bAsyncLock = false;
613
- };
614
-
615
- /**
616
- * @return {boolean} whether the Opening is locked or not
617
- */
618
- ContextMenu.prototype.isMenuOpeningLocked = function () {
619
- return this._bOpeningLocked;
620
- };
621
-
622
- /**
623
- * Locks/ Unlocks the focus reset
624
- * @param {boolean} bIsLocked whether the Focus should be locked on the ContextMenu or not
625
- */
626
- ContextMenu.prototype.setFocusLock = function (bIsLocked) {
627
- this._bFocusLocked = bIsLocked;
628
- };
629
-
630
- /**
631
- * checks wehther the given Overlay is selected, if not it does so
420
+ * checks whether the given Overlay is selected, if not it does so
632
421
  * @param {object} oOverlay the Overlay which should be checked for
633
422
  */
634
423
  ContextMenu.prototype._ensureSelection = function (oOverlay) {
@@ -639,10 +428,8 @@ sap.ui.define([
639
428
 
640
429
  /**
641
430
  * checks whether a Plugin locks the opening of a new ContextMenu
642
- * @param {object} oOverlay the Overlay which should be checked for
643
431
  * @return {boolean} true, if locked; false if not
644
432
  */
645
-
646
433
  ContextMenu.prototype._checkForPluginLock = function () {
647
434
  //As long as Selection doesn't work correctly on ios we need to ensure that the ContextMenu opens even if a plugin mistakenly locks it
648
435
  if (Device.os.ios) {
@@ -653,12 +440,11 @@ sap.ui.define([
653
440
  return true;
654
441
  }
655
442
 
656
- this.setFocusLock(false);
657
443
  return false;
658
444
  };
659
445
 
660
446
  /**
661
- * Adds single items to an array of groups
447
+ * Adds single item to an array of groups
662
448
  * @param {object} mMenuItem The menu item to add to a group
663
449
  */
664
450
  ContextMenu.prototype._addMenuItemToGroup = function (mMenuItem) {
@@ -680,38 +466,14 @@ sap.ui.define([
680
466
  /**
681
467
  * Adds a submenu to the list of submenus
682
468
  * @param {object} mMenuItem The menu item to add to a group
683
- * @param {object} mPosition The position where the submenu should be opened
684
- * @param {sap.ui.dt.Overlay} oOverlay The Overlay on which the ContextMenu was opened
685
469
  */
686
- ContextMenu.prototype._addSubMenu = function (mMenuItem, mPosition, oOverlay) {
470
+ ContextMenu.prototype._addSubMenu = function (mMenuItem) {
687
471
  mMenuItem.submenu.forEach(function (oSubMenuItem) {
688
472
  if (!oSubMenuItem.handler) {
689
473
  oSubMenuItem.handler = mMenuItem.handler;
690
474
  }
691
475
  });
692
476
 
693
- mMenuItem.handler = function (sMenuItemId, mPosition, oOverlay) {
694
- this._aSubMenus.some(function (_oMenuItem) {
695
- if (_oMenuItem.sSubMenuId === sMenuItemId) {
696
- _oMenuItem.aSubMenuItems.forEach(function (oSubMenuItem) {
697
- this.addMenuItem(oSubMenuItem, true, true);
698
- }.bind(this));
699
- return true;
700
- }
701
- }.bind(this));
702
-
703
- if (!this._bContextMenu) {
704
- mPosition.clientX = null;
705
- mPosition.clientY = null;
706
- }
707
-
708
- this.oContextMenuControl.close();
709
- setTimeout(function () {
710
- this.open(mPosition, oOverlay, true, true);
711
- }.bind(this), 0);
712
- this.lockMenuOpening();
713
- }.bind(this, mMenuItem.id, mPosition, oOverlay);
714
-
715
477
  this._aSubMenus.push({
716
478
  sSubMenuId: mMenuItem.id,
717
479
  aSubMenuItems: mMenuItem.submenu
@@ -721,35 +483,21 @@ sap.ui.define([
721
483
  };
722
484
 
723
485
  /**
724
- * Adds the grouped Button to the collapsed version of a ContextMenu
725
- * @param {object} mPosition The position where the menu is opened
726
- * @param {sap.ui.dt.Overlay} oOverlay The Overlay on which the ContextMenu was opened
486
+ * Adds the grouped menu item to the collapsed version of a ContextMenu
727
487
  */
728
- ContextMenu.prototype._addItemGroupsToMenu = function (mPosition, oOverlay) {
729
- this._aGroupedItems.forEach(function (oGroupedItem, iIndex) {
730
- //If there is only one button that belongs to a group we don't need that group
488
+ ContextMenu.prototype._addItemGroupsToMenu = function () {
489
+ this._aGroupedItems.forEach(function (oGroupedItem) {
490
+ //If there is only one menu item that belongs to a group we don't need that group
731
491
  if (oGroupedItem.aGroupedItems.length === 1) {
732
- this.addMenuItem(oGroupedItem.aGroupedItems[0], true, false);
492
+ this.addMenuItem(oGroupedItem.aGroupedItems[0], true);
733
493
  } else {
734
- var fHandlerForGroupedButton = function (iIndex, mPosition, oOverlay) {
735
- this._aGroupedItems[iIndex].aGroupedItems.forEach(function (mMenuItem) {
736
- this.addMenuItem(mMenuItem, true, true);
737
- }.bind(this));
738
-
739
- this.oContextMenuControl.close();
740
- setTimeout(function () {
741
- this.open(mPosition, oOverlay, true, true);
742
- }.bind(this), 0);
743
- this.lockMenuOpening();
744
- };
745
-
746
494
  this.addMenuItem({
747
- id: oGroupedItem.sGroupName + "-groupButton",
495
+ id: oGroupedItem.sGroupName + "-groupItem",
748
496
  enabled: true,
749
497
  text: oGroupedItem.sGroupName,
750
498
  icon: oGroupedItem.aGroupedItems[0].icon,
751
499
  rank: oGroupedItem.aGroupedItems[0].rank,
752
- handler: fHandlerForGroupedButton.bind(this, iIndex, mPosition, oOverlay)
500
+ submenu: oGroupedItem.aGroupedItems
753
501
  }, true);
754
502
  }
755
503
  }.bind(this));