<commit_before>/*!
 * ${copyright}
 */
sap.ui.define([
		'sap/m/Button',
		'sap/m/Column',
		'sap/m/ColumnListItem',
		'sap/m/MessageBox',
		'sap/m/PlacementType',
		'sap/m/Popover',
		'sap/m/Table',
		'sap/m/Text',
		'sap/ui/commons/ValueHelpField'
	], function(Button, Column, ColumnListItem, MessageBox, PlacementType, Popover, Table, Text,
		ValueHelpField) {
	"use strict";

	var ValueHelp = ValueHelpField.extend("sap.ui.core.sample.ViewTemplate.valuelist.ValueHelp", {
			metadata : {
				properties : {
					qualifier : {type : "string", defaultValue : ""}, //value list qualifier
					showDetails : {type : "boolean", defaultValue : false}
				}
			},

			init : function () {
				this.setEditable(false);
				this.attachValueHelpRequest(this._onValueHelp.bind(this));
				this.setIconURL("sap-icon://value-help");
				this.setTooltip("No value help");
			},

			onBeforeRendering : function () {
				var oBinding = this.getBinding("value"),
					oModel = oBinding.getModel(),
					oMetaModel = oModel.getMetaModel(),
					sAbsolutePath = oModel.resolve(oBinding.getPath(), oBinding.getContext()),
					that = this;
				oMetaModel.loaded().then(function () {
					var oContext = oMetaModel.getMetaContext(sAbsolutePath);
					if (oContext.getProperty("sap:value-list")) {
						oMetaModel.getODataValueLists(oContext)
							.then(function (mValueList) {
								var oValueList = mValueList[that.getQualifier()];
								that._parameters = [];
								oValueList.Parameters.forEach(function (oParameter) {
									// put parameters written back to entity at the beginning
									if (oParameter.LocalDataProperty) {
										that._parameters.unshift(
											oParameter.ValueListProperty.String);
									} else {
										that._parameters.push(oParameter.ValueListProperty.String);
									}
								});
								that._collectionPath = oValueList.CollectionPath.String;
								that._collectionLabel = oValueList.Label
									? oValueList.Label.String
									: that._collectionPath;
								that._valueListDetails = "ValueList"
									+ (that.getQualifier() !== "" ? "#" + that.getQualifier() : "")
									+ "\n"
									+ JSON.stringify(oValueList, undefined, 2);
								that.updateDetails();
								that.setIconURL("sap-icon://value-help");
								that.setEditable(true);
							});
					}
				}, function (oError) {
					//TODO errors cannot seriously be handled per _instance_ of a control
					MessageBox.alert(oError.message, {
						icon : MessageBox.Icon.ERROR,
						title : "Error"});
				});
			},

			renderer : "sap.ui.commons.ValueHelpFieldRenderer",

			setShowDetails : function (bShowDetails) {
				this.setProperty("showDetails", bShowDetails);
				this.updateDetails();
			},

			updateDetails : function () {
				this.setTooltip(this.getShowDetails() ? this._valueListDetails : "");
			},

			_onValueHelp : function (oEvent) {
				var oButton = new Button({text : "Close"}),
					oColumnListItem = new ColumnListItem(),
					oControl = oEvent.getSource(),
					oPopover = new Popover({endButton : oButton,
						placement : PlacementType.Auto, modal : true}),
					oTable = new Table();

				function createTextOrValueHelp(sPropertyPath, bAsColumnHeader) {
					var oMetaModel = oControl.getModel().getMetaModel(),
						oEntityType = oMetaModel.getODataEntityType(oMetaModel.getODataEntitySet(
							oControl._collectionPath).entityType);
					if (bAsColumnHeader) {
						return new Text({text : oMetaModel.getODataProperty(oEntityType,
							sPropertyPath)["sap:label"]});
					}
						return new ValueHelp({value : "{" + sPropertyPath + "}"});<commit_msg>[INTERNAL] sap.ui.core.demokit.sample.ViewTemplate.valuelist.ValueHelp: show proper tooltip in nested value helps<commit_after>/*!
 * ${copyright}
 */
sap.ui.define([
		'sap/m/Button',
		'sap/m/Column',
		'sap/m/ColumnListItem',
		'sap/m/MessageBox',
		'sap/m/PlacementType',
		'sap/m/Popover',
		'sap/m/Table',
		'sap/m/Text',
		'sap/ui/commons/ValueHelpField'
	], function(Button, Column, ColumnListItem, MessageBox, PlacementType, Popover, Table, Text,
		ValueHelpField) {
	"use strict";

	var ValueHelp = ValueHelpField.extend("sap.ui.core.sample.ViewTemplate.valuelist.ValueHelp", {
			metadata : {
				properties : {
					qualifier : {type : "string", defaultValue : ""}, //value list qualifier
					showDetails : {type : "boolean", defaultValue : false}
				}
			},

			init : function () {
				this.setEditable(false);
				this.attachValueHelpRequest(this._onValueHelp.bind(this));
			},

			onBeforeRendering : function () {
				var oBinding = this.getBinding("value"),
					oModel = oBinding.getModel(),
					oMetaModel = oModel.getMetaModel(),
					sAbsolutePath = oModel.resolve(oBinding.getPath(), oBinding.getContext()),
					that = this;
				oMetaModel.loaded().then(function () {
					var oContext = oMetaModel.getMetaContext(sAbsolutePath);
					if (oContext.getProperty("sap:value-list")) {
						oMetaModel.getODataValueLists(oContext)
							.then(function (mValueList) {
								var oValueList = mValueList[that.getQualifier()];
								that._parameters = [];
								oValueList.Parameters.forEach(function (oParameter) {
									// put parameters written back to entity at the beginning
									if (oParameter.LocalDataProperty) {
										that._parameters.unshift(
											oParameter.ValueListProperty.String);
									} else {
										that._parameters.push(oParameter.ValueListProperty.String);
									}
								});
								that._collectionPath = oValueList.CollectionPath.String;
								that._collectionLabel = oValueList.Label
									? oValueList.Label.String
									: that._collectionPath;
								that._valueListDetails = "ValueList"
									+ (that.getQualifier() !== "" ? "#" + that.getQualifier() : "")
									+ "\n"
									+ JSON.stringify(oValueList, undefined, 2);
								that.updateDetails();
								that.setIconURL("sap-icon://value-help");
								that.setEditable(true);
							});
					} else {
						that.setTooltip("No value help");
					}
				}, function (oError) {
					//TODO errors cannot seriously be handled per _instance_ of a control
					MessageBox.alert(oError.message, {
						icon : MessageBox.Icon.ERROR,
						title : "Error"});
				});
			},

			renderer : "sap.ui.commons.ValueHelpFieldRenderer",

			setShowDetails : function (bShowDetails) {
				this.setProperty("showDetails", bShowDetails);
				this.updateDetails();
			},

			updateDetails : function () {
				this.setTooltip(this.getShowDetails() ? this._valueListDetails : "");
			},

			_onValueHelp : function (oEvent) {
				var oButton = new Button({text : "Close"}),
					oColumnListItem = new ColumnListItem(),
					oControl = oEvent.getSource(),
					oPopover = new Popover({endButton : oButton,
						placement : PlacementType.Auto, modal : true}),
					oTable = new Table();

				function createTextOrValueHelp(sPropertyPath, bAsColumnHeader) {
					var oMetaModel = oControl.getModel().getMetaModel(),
						oEntityType = oMetaModel.getODataEntityType(oMetaModel.getODataEntitySet(
							oControl._collectionPath).entityType);
					if (bAsColumnHeader) {
						return new Text({text : oMetaModel.getODataProperty(oEntityType,
							sPropertyPath)["sap:label"]});
					}
					return new ValueHelp({showDetails : oControl.getShowDetails(),
						value : "{" + sPropertyPath + "}"});
{'fraction_non_alphanumeric': 0.13678474114441416, 'fraction_numerical': 0.00027247956403269756, 'mean_word_length': 3.1172181716208636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3320066', 'n_tokens_mistral': 2988, 'n_tokens_neox': 2224, 'n_words': 378}