function _applyChange(oChange, oRelevantContainer, mPropertyBag, fnIterator) {
		var oModifier = mPropertyBag.modifier;
		var oView = mPropertyBag.view;
		var oAppComponent = mPropertyBag.appComponent;
		var oChangeContent = oChange.getContent();
		var oTargetSource = oChange.getDependentControl(SOURCE_ALIAS, mPropertyBag);
		var oTable = oChange.getDependentControl(TARGET_ALIAS, mPropertyBag);
		var aColumns;
		var oMovedElement;

		return Promise.resolve()
			.then(function() {
				return oModifier.getAggregation(oTable, COLUMNS_AGGREGATION_NAME);
			})
			.then(function(aRetrievedColumns){
				aColumns = aRetrievedColumns;
				if (oTargetSource !== oTable) {
					Log.warning("Moving columns between different tables is not yet supported.");
					return Promise.reject(false);
				}
				// Fetch the information about the movedElements together with the source and target index.
				return oChangeContent.movedElements.reduce(function (oPreviousPromise, mMovedElement) {
					var iSourceIndex;
					var iTargetIndex;
					var iCurrentIndexInAggregation;
					var iStoredSourceIndexInChange;
					var sMovedElementId;

					return oPreviousPromise.then(function() {
							oMovedElement = oModifier.bySelector(mMovedElement.selector, oAppComponent, oView);
							if (!oMovedElement) {
								sMovedElementId = mMovedElement.selector && mMovedElement.selector.id;
								Log.warning("The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied");
								return Promise.reject();
							}
							iCurrentIndexInAggregation = aColumns.indexOf(oMovedElement);
							iStoredSourceIndexInChange = mMovedElement.sourceIndex;
							iTargetIndex = typeof fnIterator === "function" && fnIterator(iStoredSourceIndexInChange);
							iTargetIndex = jQuery.isNumeric(iTargetIndex) ? iTargetIndex : mMovedElement.targetIndex;

							if (iCurrentIndexInAggregation !== iTargetIndex) {
								// By default we are getting the index from the aggregation, because it is possible that the order is
								// already modified and the column that we want to move is not on the passed source index
								iSourceIndex = iCurrentIndexInAggregation;
							} else {
								// In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action.
								// Therefore, we need to use the passed source index
								iSourceIndex = iStoredSourceIndexInChange;
							}
							// move children in `columns` aggregation
							return oModifier.removeAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement);
						})
						.then(function(){
							return oModifier.insertAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement, iTargetIndex, oView);
						})
						// move children in `items` aggregation (actual content)
						.then(function() {
							return oModifier.getBindingTemplate(oTable, ITEMS_AGGREGATION_NAME);
						})
						.then(function(oTemplate) {
							if (oTemplate) {
								return fnSwitchCells(oModifier, oView, oTemplate, iSourceIndex, iTargetIndex)
									.then(oModifier.updateAggregation.bind(oModifier, oTable, ITEMS_AGGREGATION_NAME));
							} else {
								return fnMoveColumns(oModifier, oView, oTable, iSourceIndex, iTargetIndex);
							}
						});
				}, Promise.resolve());
			});
	}
/**
	 * Moves a column from one index to another.
	 * @param {sap.ui.fl.Change} oChange Change object with instructions to be applied on the control
	 * @param {sap.ui.core.Control} oRelevantContainer Control that matches the change selector for applying the change, which is the source of the move
	 * @param {object} mPropertyBag Map of properties
	 * @param {object} mPropertyBag.view XML node representing a ui5 view
	 * @param {sap.ui.core.util.reflection.BaseTreeModifier} mPropertyBag.modifier Modifier for the controls
	 * @param {sap.ui.core.UIComponent} mPropertyBag.appComponent AppComponent
	 * @param {function} fnIterator - Iterator function which is called on each movedElement, as an argument it gets CurrentIndex
	 *  of the element and may return TargetIndex as a result.
	 * @return {Promise} Promise resolving when change was applied
	 */
Moves a column from one index to another.
Moves a column from one index to another .
function _applyChange(oChange, oRelevantContainer, mPropertyBag, fnIterator) {
		var oModifier = mPropertyBag.modifier;
		var oView = mPropertyBag.view;
		var oAppComponent = mPropertyBag.appComponent;
		var oChangeContent = oChange.getContent();
		var oTargetSource = oChange.getDependentControl(SOURCE_ALIAS, mPropertyBag);
		var oTable = oChange.getDependentControl(TARGET_ALIAS, mPropertyBag);
		var aColumns;
		var oMovedElement;
		return Promise.resolve()
			.then(function() {
				return oModifier.getAggregation(oTable, COLUMNS_AGGREGATION_NAME);
			})
			.then(function(aRetrievedColumns){
				aColumns = aRetrievedColumns;
				if (oTargetSource !== oTable) {
					Log.warning("Moving columns between different tables is not yet supported.");
					return Promise.reject(false);
				}
				return oChangeContent.movedElements.reduce(function (oPreviousPromise, mMovedElement) {
					var iSourceIndex;
					var iTargetIndex;
					var iCurrentIndexInAggregation;
					var iStoredSourceIndexInChange;
					var sMovedElementId;
					return oPreviousPromise.then(function() {
							oMovedElement = oModifier.bySelector(mMovedElement.selector, oAppComponent, oView);
							if (!oMovedElement) {
								sMovedElementId = mMovedElement.selector && mMovedElement.selector.id;
								Log.warning("The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied");
								return Promise.reject();
							}
							iCurrentIndexInAggregation = aColumns.indexOf(oMovedElement);
							iStoredSourceIndexInChange = mMovedElement.sourceIndex;
							iTargetIndex = typeof fnIterator === "function" && fnIterator(iStoredSourceIndexInChange);
							iTargetIndex = jQuery.isNumeric(iTargetIndex) ? iTargetIndex : mMovedElement.targetIndex;
							if (iCurrentIndexInAggregation !== iTargetIndex) {
								iSourceIndex = iCurrentIndexInAggregation;
							} else {
								iSourceIndex = iStoredSourceIndexInChange;
							}
							return oModifier.removeAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement);
						})
						.then(function(){
							return oModifier.insertAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement, iTargetIndex, oView);
						})
						.then(function() {
							return oModifier.getBindingTemplate(oTable, ITEMS_AGGREGATION_NAME);
						})
						.then(function(oTemplate) {
							if (oTemplate) {
								return fnSwitchCells(oModifier, oView, oTemplate, iSourceIndex, iTargetIndex)
									.then(oModifier.updateAggregation.bind(oModifier, oTable, ITEMS_AGGREGATION_NAME));
							} else {
								return fnMoveColumns(oModifier, oView, oTable, iSourceIndex, iTargetIndex);
							}
						});
				}, Promise.resolve());
			});
	}
function _applyChange ( oChange , oRelevantContainer , mPropertyBag , fnIterator ) { var oModifier = mPropertyBag . modifier ; var oView = mPropertyBag . view ; var oAppComponent = mPropertyBag . appComponent ; var oChangeContent = oChange . getContent ( ) ; var oTargetSource = oChange . getDependentControl ( SOURCE_ALIAS , mPropertyBag ) ; var oTable = oChange . getDependentControl ( TARGET_ALIAS , mPropertyBag ) ; var aColumns ; var oMovedElement ; return Promise . resolve ( ) . then ( function ( ) { return oModifier . getAggregation ( oTable , COLUMNS_AGGREGATION_NAME ) ; } ) . then ( function ( aRetrievedColumns ) { aColumns = aRetrievedColumns ; if ( oTargetSource !== oTable ) { Log . warning ( "Moving columns between different tables is not yet supported." ) ; return Promise . reject ( false ) ; } return oChangeContent . movedElements . reduce ( function ( oPreviousPromise , mMovedElement ) { var iSourceIndex ; var iTargetIndex ; var iCurrentIndexInAggregation ; var iStoredSourceIndexInChange ; var sMovedElementId ; return oPreviousPromise . then ( function ( ) { oMovedElement = oModifier . bySelector ( mMovedElement . selector , oAppComponent , oView ) ; if ( ! oMovedElement ) { sMovedElementId = mMovedElement . selector && mMovedElement . selector . id ; Log . warning ( "The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied" ) ; return Promise . reject ( ) ; } iCurrentIndexInAggregation = aColumns . indexOf ( oMovedElement ) ; iStoredSourceIndexInChange = mMovedElement . sourceIndex ; iTargetIndex = typeof fnIterator === "function" && fnIterator ( iStoredSourceIndexInChange ) ; iTargetIndex = jQuery . isNumeric ( iTargetIndex ) ? iTargetIndex : mMovedElement . targetIndex ; if ( iCurrentIndexInAggregation !== iTargetIndex ) { iSourceIndex = iCurrentIndexInAggregation ; } else { iSourceIndex = iStoredSourceIndexInChange ; } return oModifier . removeAggregation ( oTable , COLUMNS_AGGREGATION_NAME , oMovedElement ) ; } ) . then ( function ( ) { return oModifier . insertAggregation ( oTable , COLUMNS_AGGREGATION_NAME , oMovedElement , iTargetIndex , oView ) ; } ) . then ( function ( ) { return oModifier . getBindingTemplate ( oTable , ITEMS_AGGREGATION_NAME ) ; } ) . then ( function ( oTemplate ) { if ( oTemplate ) { return fnSwitchCells ( oModifier , oView , oTemplate , iSourceIndex , iTargetIndex ) . then ( oModifier . updateAggregation . bind ( oModifier , oTable , ITEMS_AGGREGATION_NAME ) ) ; } else { return fnMoveColumns ( oModifier , oView , oTable , iSourceIndex , iTargetIndex ) ; } } ) ; } , Promise . resolve ( ) ) ; } ) ; }
Moves a column from one index to another.
Moves a column from one index to another .
// Fetch the information about the movedElements together with the source and target index. // By default we are getting the index from the aggregation, because it is possible that the order is // already modified and the column that we want to move is not on the passed source index // In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action. // Therefore, we need to use the passed source index // move children in `columns` aggregation // move children in `items` aggregation (actual content)