text,length,is_long_context,metric_val,label_metric "//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the ""License""); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an ""AS IS"" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.controls { import flash.display.DisplayObject; import flash.events.Event; import flash.events.FocusEvent; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.geom.Matrix; import flash.geom.Point; import flash.geom.Rectangle; import flash.text.TextLineMetrics; import flash.ui.Keyboard; import mx.collections.ArrayCollection; import mx.collections.CursorBookmark; import mx.controls.dataGridClasses.DataGridListData; import mx.controls.listClasses.BaseListData; import mx.controls.listClasses.IDropInListItemRenderer; import mx.controls.listClasses.IListItemRenderer; import mx.controls.listClasses.ListBase; import mx.controls.listClasses.ListData; import mx.core.ClassFactory; import mx.core.EdgeMetrics; import mx.core.IDataRenderer; import mx.core.IFactory; import mx.core.LayoutDirection; import mx.core.ScrollPolicy; import mx.core.UIComponent; import mx.core.UIComponentGlobals; import mx.core.mx_internal; import mx.effects.Tween; import mx.events.CollectionEvent; import mx.events.CollectionEventKind; import mx.events.DropdownEvent; import mx.events.FlexEvent; import mx.events.FlexMouseEvent; import mx.events.InterManagerRequest; import mx.events.ListEvent; import mx.events.SandboxMouseEvent; import mx.events.ScrollEvent; import mx.events.ScrollEventDetail; import mx.managers.ISystemManager; import mx.managers.PopUpManager; import mx.styles.CSSStyleDeclaration; import mx.utils.MatrixUtil; use namespace mx_internal; //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when the ComboBox contents changes as a result of user * interaction, when the selectedIndex or * selectedItem property changes, and, if the ComboBox control * is editable, each time a keystroke is entered in the box. * * @eventType mx.events.ListEvent.CHANGE * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""change"", type=""mx.events.ListEvent"")] /** * Dispatched when the drop-down list is dismissed for any reason such when * the user: * * * @eventType mx.events.DropdownEvent.CLOSE * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""close"", type=""mx.events.DropdownEvent"")] /** * Dispatched when the data property changes. * *

When you use a component as an item renderer, * the data property contains an item from the * dataProvider. * You can listen for this event and update the component * when the data property changes.

* * @eventType mx.events.FlexEvent.DATA_CHANGE * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""dataChange"", type=""mx.events.FlexEvent"")] /** * Dispatched if the editable property * is set to true and the user presses the Enter key * while typing in the editable text field. * * @eventType mx.events.FlexEvent.ENTER * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""enter"", type=""mx.events.FlexEvent"")] /** * Dispatched when user rolls the mouse out of a drop-down list item. * The event object's target property contains a reference * to the ComboBox and not the drop-down list. * * @eventType mx.events.ListEvent.ITEM_ROLL_OUT * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""itemRollOut"", type=""mx.events.ListEvent"")] /** * Dispatched when the user rolls the mouse over a drop-down list item. * The event object's target property contains a reference * to the ComboBox and not the drop-down list. * * @eventType mx.events.ListEvent.ITEM_ROLL_OVER * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""itemRollOver"", type=""mx.events.ListEvent"")] /** * Dispatched when the user clicks the drop-down button * to display the drop-down list. It is also dispatched if the user * uses the keyboard and types Ctrl-Down to open the drop-down. * * @eventType mx.events.DropdownEvent.OPEN * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""open"", type=""mx.events.DropdownEvent"")] /** * Dispatched when the user scrolls the ComboBox control's drop-down list. * * @eventType mx.events.ScrollEvent.SCROLL * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""scroll"", type=""mx.events.ScrollEvent"")] //-------------------------------------- // Styles //-------------------------------------- include ""../styles/metadata/FocusStyles.as"" include ""../styles/metadata/IconColorStyles.as"" include ""../styles/metadata/LeadingStyle.as"" include ""../styles/metadata/PaddingStyles.as"" include ""../styles/metadata/SkinStyles.as"" include ""../styles/metadata/TextStyles.as"" /** * The set of BackgroundColors for drop-down list rows in an alternating * pattern. * Value can be an Array of two of more colors. * If undefined then the rows will use the drop-down list's * backgroundColor style. * * @default undefined * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""alternatingItemColors"", type=""Array"", arrayType=""uint"", format=""Color"", inherit=""yes"")] /** * Width of the arrow button in pixels. * * The default value for the Halo theme is 22. * The default value for the Spark theme is 18. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""arrowButtonWidth"", type=""Number"", format=""Length"", inherit=""no"")] /** * The thickness of the border of the drop-down list, in pixels. * This value is overridden if you define * borderThickness when setting the * dropdownStyleName CSSStyleDeclaration. * * @default 1 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""borderThickness"", type=""Number"", format=""Length"", inherit=""no"")] /** * The length of the transition when the drop-down list closes, in milliseconds. * The default transition has the drop-down slide up into the ComboBox. * * The default value for the Halo theme is 250. * The default value for the Spark theme is 50. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""closeDuration"", type=""Number"", format=""Time"", inherit=""no"")] /** * An easing function to control the close transition. Easing functions can * be used to control the acceleration and deceleration of the transition. * * @default undefined * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""closeEasingFunction"", type=""Function"", inherit=""no"")] /** * The color of the border of the ComboBox. If undefined * the drop-down list will use its normal borderColor style. This style * is used by the validators to show the ComboBox in an error state. * * @default undefined * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""dropdownBorderColor"", type=""uint"", format=""Color"", inherit=""yes"", theme=""halo"")] /** * The name of a CSSStyleDeclaration to be used by the drop-down list. This * allows you to control the appearance of the drop-down list or its item * renderers. * * [deprecated] * * @default ""comboDropDown"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""dropDownStyleName"", type=""String"", inherit=""no"", deprecatedReplacement=""dropdownStyleName"")] /** * The name of a CSSStyleDeclaration to be used by the drop-down list. This * allows you to control the appearance of the drop-down list or its item * renderers. * * @default ""comboDropdown"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""dropdownStyleName"", type=""String"", inherit=""no"")] /** * Length of the transition when the drop-down list opens, in milliseconds. * The default transition has the drop-down slide down from the ComboBox. * * The default value for the Halo theme is 250. * The default value for the Spark theme is 0. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""openDuration"", type=""Number"", format=""Time"", inherit=""no"")] /** * An easing function to control the open transition. Easing functions can * be used to control the acceleration and deceleration of the transition. * * @default undefined * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""openEasingFunction"", type=""Function"", inherit=""no"")] /** * Number of pixels between the control's bottom border * and the bottom of its content area. * When the editable property is true, * paddingTop and paddingBottom affect the size * of the ComboBox control, but do not affect the position of the editable text field. * * The default value for the Halo theme is 0. * The default value for the Spark theme is -2. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""paddingBottom"", type=""Number"", format=""Length"", inherit=""no"")] /** * Number of pixels between the control's top border * and the top of its content area. * When the editable property is true, * paddingTop and paddingBottom affect the size * of the ComboBox control, but do not affect the position of the editable text field. * * The default value for the Halo theme is 0. * The default value for the Spark theme is -1. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""paddingTop"", type=""Number"", format=""Length"", inherit=""no"")] /** * The rollOverColor of the drop-down list. * * The default value for the Halo theme is 0xB2E1FF. * The default value for the Spark theme is 0xCEDBEF. * * @see mx.controls.List * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""rollOverColor"", type=""uint"", format=""Color"", inherit=""yes"")] /** * The selectionColor of the drop-down list. * * The default value for the Halo theme is 0x7FCEFF. * The default value for the Spark theme is 0xA8C6EE. * * @see mx.controls.List * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""selectionColor"", type=""uint"", format=""Color"", inherit=""yes"")] /** * The selectionDuration of the drop-down list. * * @default 250 * * @see mx.controls.List * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""selectionDuration"", type=""uint"", format=""Time"", inherit=""no"")] /** * The selectionEasingFunction of the drop-down list. * * @default undefined * * @see mx.controls.List * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""selectionEasingFunction"", type=""Function"", inherit=""no"")] /** * The textRollOverColor of the drop-down list. * * The default value for the Halo theme is 0x2B333C. * The default value for the Spark theme is 0x000000. * * @see mx.controls.List * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""textRollOverColor"", type=""uint"", format=""Color"", inherit=""yes"")] /** * The textSelectedColor of the drop-down list. * * The default value for the Halo theme is 0x2B333C. * The default value for the Spark theme is 0x000000. * * @see mx.controls.List * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""textSelectedColor"", type=""uint"", format=""Color"", inherit=""yes"")] //-------------------------------------- // Other metadata //-------------------------------------- [AccessibilityClass(implementation=""mx.accessibility.ComboBoxAccImpl"")] [DataBindingInfo(""acceptedTypes"", ""{ dataProvider: { label: "String" } }"")] [DefaultBindingProperty(source=""selectedItem"", destination=""dataProvider"")] [DefaultProperty(""dataProvider"")] [DefaultTriggerEvent(""change"")] [IconFile(""ComboBox.png"")] [Alternative(replacement=""spark.components.DropDownList"", since=""4.0"")] [Alternative(replacement=""spark.components.ComboBox"", since=""4.0"")] /** * The ComboBox control contains a drop-down list * from which the user can select a single value. * Its functionality is very similar to that of the * SELECT form element in HTML. * The ComboBox can be editable, in which case * the user can type entries into the TextInput portion * of the ComboBox that are not in the list. * *

The ComboBox control has the following default sizing * characteristics:

* * * * * * * * * * * * * * * * * * * * * * * * * *
CharacteristicDescription
Default sizeWide enough to accommodate the longest entry in the * drop-down list in the display area of the main * control, plus the drop-down button. When the * drop-down list is not visible, the default height * is based on the label text size. * *

The default drop-down list height is five rows, or * the number of entries in the drop-down list, whichever * is smaller. The default height of each entry in the * drop-down list is 22 pixels.

Minimum size0 pixels.
Maximum size5000 by 5000.
dropdownWidthThe width of the ComboBox control.
rowCount5 rows.
* * @mxml * *

The <mx:ComboBox> tag inherits all the tag attributes * of its superclass, and adds the following tag attributes:

* *
 *  <mx:ComboBox
 *    Properties
 *    dataProvider=""null""
 *    dropdownFactory=""ClassFactory that creates an mx.controls.List""
 *    dropdownWidth=""100 or width of the longest text in the dataProvider""
 *    itemRenderer=""null""
 *    labelField=""label""
 *    labelFunction=""null""
 *    prompt=""null""
 *    rowCount=""5""
 *    selectedIndex=""-1""
 *    selectedItem=""null""
 *    
 *    Styles
 *    alternatingItemColors=""undefined""
 *    arrowButtonWidth=""22""
 *    borderColor=""0xB7BABC""
 *    borderThickness=""1""
 *    closeDuration=""250""
 *    closeEasingFunction=""undefined""
 *    color=""0x0B333C""
 *    cornerRadius=""0""
 *    disabledColor=""0xAAB3B3""
 *    disabledIconColor=""0x919999""
 *    dropdownBorderColor=""undefined""
 *    dropdownStyleName=""comboDropdown""
 *    fillAlphas=""[0.6,0.4]""
 *    fillColors=""[0xFFFFFF, 0xCCCCCC]""
 *    focusAlpha=""0.4""
 *    focusRoundedCorners=""tl tr bl br""
 *    fontAntiAliasType=""advanced|normal""
 *    fontFamily=""Verdana""
 *    fontGridFitType=""pixel|none|subpixel""
 *    fontSharpness=""0""
 *    fontSize=""10""
 *    fontStyle=""normal|italic""
 *    fontThickness=""0""
 *    fontWeight=""normal|bold""
 *    highlightAlphas=""[0.3,0.0]""
 *    iconColor=""0x111111""
 *    leading=""0""
 *    openDuration=""250""
 *    openEasingFunction=""undefined""
 *    paddingTop=""0""
 *    paddingBottom=""0""
 *    paddingLeft=""5""
 *    paddingRight=""5""
 *    rollOverColor=""Depends on theme color""
 *    selectionColor=""Depends on theme color""
 *    selectionDuration=""250""
 *    selectionEasingFunction=""undefined""
 *    textAlign=""left|center|right""
 *    textDecoration=""none|underline""
 *    textIndent=""0""
 *    textRollOverColor=""0x2B333C""
 *    textSelectedColor=""0x2B333C""
 *    
 *    Events
 *    change=""No default""
 *    close=""No default""
 *    dataChange=""No default""
 *    enter=""No default""
 *    itemRollOut=""No default""
 *    itemRollOver=""No default""
 *    open=""No default""
 *    scroll=""No default""
 *  />
 *  
* * @includeExample examples/SimpleComboBox.mxml * * @see mx.controls.List * @see mx.effects.Tween * @see mx.managers.PopUpManager * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public class ComboBox extends ComboBase implements IDataRenderer, IDropInListItemRenderer, IListItemRenderer { include ""../core/Version.as""; //-------------------------------------------------------------------------- // // Class mixins // //-------------------------------------------------------------------------- /** * @private * Placeholder for mixin by ComboBoxAccImpl. */ mx_internal static var createAccessibilityImplementation:Function; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function ComboBox() { super(); // It it better to start out with an empty data provider rather than // an undefined one. Otherwise, code in getDropdown() sets it to [] // later, but via setDataProvider(). This API has side effects like // setting selectionChanged, which causes the text in an editable // ComboBox to be lost. dataProvider = new ArrayCollection(); useFullDropdownSkin = true; wrapDownArrowButton = false; addEventListener(""unload"", unloadHandler); addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler); } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * @private * A reference to the internal List that pops up to display a row * for each dataProvider item. */ private var _dropdown:ListBase; /** * @private * A int to track the oldIndex, used when the dropdown is dismissed using the ESC key. */ private var _oldIndex:int; /** * @private * The tween used for showing and hiding the drop-down list. */ private var tween:Tween = null; /** * @private * A flag to track whether the dropDown tweened up or down. */ private var tweenUp:Boolean = false; /** * @private */ private var preferredDropdownWidth:Number; /** * @private */ private var dropdownBorderStyle:String = ""solid""; /** * @private * Is the dropdown list currently shown? */ private var _showingDropdown:Boolean = false; /** * @private */ private var _selectedIndexOnDropdown:int = -1; /** * @private */ private var bRemoveDropdown:Boolean = true; /** * @private */ private var inTween:Boolean = false; /** * @private */ private var bInKeyDown:Boolean = false; /** * @private * Flag that will block default data/listData behavior */ private var selectedItemSet:Boolean; /** * @private * Event that is causing the dropDown to open or close. */ private var triggerEvent:Event; /** * @private * Whether the text property was explicitly set or not */ private var explicitText:Boolean; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // data //---------------------------------- /** * @private * Storage for the data property. */ private var _data:Object; [Bindable(""dataChange"")] [Inspectable(environment=""none"")] /** * The data property lets you pass a value * to the component when you use it in an item renderer or item editor. * You typically use data binding to bind a field of the data * property to a property of this component. * *

The ComboBox control uses the listData property and the * data property as follows. If the ComboBox is in a * DataGrid control, it expects the dataField property of the * column to map to a property in the data and sets * selectedItem to that property. If the ComboBox control is * in a List control, it expects the labelField of the list * to map to a property in the data and sets selectedItem to * that property. * Otherwise, it sets selectedItem to the data itself.

* *

You do not set this property in MXML.

* * @see mx.core.IDataRenderer * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get data():Object { return _data; } /** * @private */ public function set data(value:Object):void { var newSelectedItem:*; _data = value; if (_listData && _listData is DataGridListData) newSelectedItem = _data[DataGridListData(_listData).dataField]; else if (_listData is ListData && ListData(_listData).labelField in _data) newSelectedItem = _data[ListData(_listData).labelField]; else newSelectedItem = _data; if (newSelectedItem !== undefined && !selectedItemSet) { selectedItem = newSelectedItem; selectedItemSet = false; } dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE)); } //---------------------------------- // listData //---------------------------------- /** * @private * Storage for the listData property. */ private var _listData:BaseListData; [Bindable(""dataChange"")] [Inspectable(environment=""none"")] /** * When a component is used as a drop-in item renderer or drop-in item * editor, Flex initializes the listData property of the * component with the appropriate data from the List control. The * component can then use the listData property and the * data property to display the appropriate information * as a drop-in item renderer or drop-in item editor. * *

You do not set this property in MXML or ActionScript; Flex sets it * when the component * is used as a drop-in item renderer or drop-in item editor.

* * @see mx.controls.listClasses.IDropInListItemRenderer * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get listData():BaseListData { return _listData; } /** * @private */ public function set listData(value:BaseListData):void { _listData = value; } //---------------------------------- // dataProvider //---------------------------------- /** * @private */ private var collectionChanged:Boolean = false; [Bindable(""collectionChange"")] [Inspectable(category=""Data"", arrayType=""Object"")] /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override public function set dataProvider(value:Object):void { selectionChanged = true; super.dataProvider = value; destroyDropdown(); invalidateProperties(); invalidateSize(); } //---------------------------------- // itemRenderer //---------------------------------- /** * @private * Storage for itemRenderer property. */ private var _itemRenderer:IFactory; [Inspectable(category=""Data"")] /** * IFactory that generates the instances that displays the data for the * drop-down list of the control. You can use this property to specify * a custom item renderer for the drop-down list. * *

The control uses a List control internally to create the drop-down * list. * The default item renderer for the List control is the ListItemRenderer * class, which draws the text associated with each item in the list, * and an optional icon.

* * @see mx.controls.List * @see mx.controls.listClasses.ListItemRenderer * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get itemRenderer():IFactory { return _itemRenderer; } /** * @private */ public function set itemRenderer(value:IFactory):void { _itemRenderer = value; if (_dropdown) _dropdown.itemRenderer = value; invalidateSize(); invalidateDisplayList(); dispatchEvent(new Event(""itemRendererChanged"")); } //---------------------------------- // selectedIndex //---------------------------------- [Bindable(""change"")] [Bindable(""collectionChange"")] [Bindable(""valueCommit"")] [Inspectable(category=""General"", defaultValue=""0"")] /** * Index of the selected item in the drop-down list. * Setting this property sets the current index and displays * the associated label in the TextInput portion. *

The default value is -1, but it set to 0 * when a dataProvider is assigned, unless there is a prompt. * If the control is editable, and the user types in the TextInput portion, * the value of the selectedIndex property becomes * -1. If the value of the selectedIndex * property is out of range, the selectedIndex property is set to the last * item in the dataProvider.

* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override public function set selectedIndex(value:int):void { super.selectedIndex = value; if (value >= 0) selectionChanged = true; implicitSelectedIndex = false; invalidateDisplayList(); // value committed event needs the text to be set if (textInput && !textChanged && value >= 0) textInput.text = selectedLabel; else if (textInput && prompt) textInput.text = prompt; // [Matt] setting the text of the textInput should take care of this now // Send a valueCommit event, which is used by the data model //dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } //---------------------------------- // selectedItem //---------------------------------- [Bindable(""change"")] [Bindable(""collectionChange"")] [Bindable(""valueCommit"")] /** * Contains a reference to the selected item in the * dataProvider. * If the data is an object or class instance, modifying * properties in the object or instance modifies the dataProvider * and thus its views. Setting the selectedItem itself causes the * ComboBox to select that item (display it in the TextInput portion and set * the selectedIndex) if it exists in the dataProvider. *

If the ComboBox control is editable, the selectedItem * property is null if the user types any text * into the TextInput. * It has a value only if the user selects an item from the drop-down * list, or if it is set programmatically.

* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override public function set selectedItem(value:Object):void { selectedItemSet = true; // We do not want to apply an implicit default index in this case. implicitSelectedIndex = false; super.selectedItem = value; } //---------------------------------- // showInAutomationHierarchy //---------------------------------- /** * @private */ override public function set showInAutomationHierarchy(value:Boolean):void { //do not allow value changes } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // dropdown //---------------------------------- /** * A reference to the List control that acts as the drop-down in the ComboBox. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get dropdown():ListBase { return getDropdown(); } //---------------------------------- // dropdownFactory //---------------------------------- /** * @private * Storage for the dropdownFactory property. */ private var _dropdownFactory:IFactory = new ClassFactory(List); [Bindable(""dropdownFactoryChanged"")] /** * The IFactory that creates a ListBase-derived instance to use * as the drop-down. * The default value is an IFactory for List * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get dropdownFactory():IFactory { return _dropdownFactory; } /** * @private */ public function set dropdownFactory(value:IFactory):void { _dropdownFactory = value; dispatchEvent(new Event(""dropdownFactoryChanged"")); } //---------------------------------- // dropDownStyleFilters //---------------------------------- /** * The set of styles to pass from the ComboBox to the dropDown. * Styles in the dropDownStyleName style will override these styles. * @see mx.styles.StyleProxy * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get dropDownStyleFilters():Object { return null; } //---------------------------------- // dropdownWidth //---------------------------------- /** * @private * Storage for the dropdownWidth property. */ private var _dropdownWidth:Number = 100; [Bindable(""dropdownWidthChanged"")] [Inspectable(category=""Size"", defaultValue=""100"")] /** * Width of the drop-down list, in pixels. *

The default value is 100 or the width of the longest text * in the dataProvider, whichever is greater.

* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get dropdownWidth():Number { return _dropdownWidth; } /** * @private */ public function set dropdownWidth(value:Number):void { _dropdownWidth = value; preferredDropdownWidth = value; if (_dropdown) _dropdown.setActualSize(value, _dropdown.height); dispatchEvent(new Event(""dropdownWidthChanged"")); } //---------------------------------- // labelField //---------------------------------- /** * @private * Storage for the labelField property. */ private var _labelField:String = ""label""; /** * @private */ private var labelFieldChanged:Boolean; [Bindable(""labelFieldChanged"")] [Inspectable(category=""Data"", defaultValue=""label"")] /** * Name of the field in the items in the dataProvider * Array to display as the label in the TextInput portion and drop-down list. * By default, the control uses a property named label * on each Array object and displays it. *

However, if the dataProvider items do not contain * a label property, you can set the labelField * property to use a different property.

* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get labelField():String { return _labelField; } /** * @private */ public function set labelField(value:String):void { _labelField = value; labelFieldChanged = true; invalidateDisplayList(); dispatchEvent(new Event(""labelFieldChanged"")); } //---------------------------------- // labelFunction //---------------------------------- /** * @private * Storage for the labelFunction property. */ private var _labelFunction:Function; /** * @private */ private var labelFunctionChanged:Boolean; [Bindable(""labelFunctionChanged"")] [Inspectable(category=""Data"")] /** * User-supplied function to run on each item to determine its label. * By default the control uses a property named label * on each dataProvider item to determine its label. * However, some data sets do not have a label property, * or do not have another property that can be used for displaying * as a label. *

An example is a data set that has lastName and * firstName fields but you want to display full names. * You use labelFunction to specify a callback function * that uses the appropriate fields and return a displayable String.

* *

The labelFunction takes a single argument which is the item * in the dataProvider and returns a String:

*
     *  myLabelFunction(item:Object):String
     *  
* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get labelFunction():Function { return _labelFunction; } /** * @private */ public function set labelFunction(value:Function):void { _labelFunction = value; labelFunctionChanged = true; invalidateDisplayList(); dispatchEvent(new Event(""labelFunctionChanged"")); } //---------------------------------- // prompt //---------------------------------- private var promptChanged:Boolean = false; /** * @private * Storage for the prompt property. */ private var _prompt:String; [Inspectable(category=""General"")] /** * The prompt for the ComboBox control. A prompt is * a String that is displayed in the TextInput portion of the * ComboBox when selectedIndex = -1. It is usually * a String like ""Select one..."". If there is no * prompt, the ComboBox control sets selectedIndex to 0 * and displays the first item in the dataProvider. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get prompt():String { return _prompt; } /** * @private */ public function set prompt(value:String):void { _prompt = value; promptChanged = true; invalidateProperties(); } //---------------------------------- // rowCount //---------------------------------- /** * @private * Storage for the rowCount property. */ private var _rowCount:int = 5; [Bindable(""resize"")] [Inspectable(category=""General"", defaultValue=""5"")] /** * Maximum number of rows visible in the ComboBox control list. * If there are fewer items in the * dataProvider, the ComboBox shows only as many items as * there are in the dataProvider. * * @default 5 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get rowCount():int { return Math.max(1, Math.min(collection.length, _rowCount)); } /** * @private */ public function set rowCount(value:int):void { _rowCount = value; if (_dropdown) _dropdown.rowCount = value; } //---------------------------------- // selectedLabel //---------------------------------- /** * The String displayed in the TextInput portion of the ComboBox. It * is calculated from the data by using the labelField * or labelFunction. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectedLabel():String { return itemToLabel(selectedItem); } //-------------------------------------------------------------------------- // // Overridden methods: UIComponent // //-------------------------------------------------------------------------- /** * @private */ override protected function initializeAccessibility():void { if (ComboBox.createAccessibilityImplementation != null) ComboBox.createAccessibilityImplementation(this); } /** * @private */ override public function styleChanged(styleProp:String):void { destroyDropdown(); super.styleChanged(styleProp); } /** * Makes sure the control is at least 40 pixels wide, * and tall enough to fit one line of text * in the TextInput portion of the control but at least * 22 pixels high. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override protected function measure():void { super.measure(); // Make sure we're not too small measuredMinWidth = Math.max(measuredWidth, DEFAULT_MEASURED_MIN_WIDTH); // Make sure we're tall enough to hold our text. // Text field height is text height + 4 pixels top/bottom var textHeight:Number = measureText(""M"").height + 6; var bm:EdgeMetrics = borderMetrics; measuredMinHeight = measuredHeight = Math.max(textHeight + bm.top + bm.bottom, DEFAULT_MEASURED_MIN_HEIGHT); measuredMinHeight = measuredHeight += getStyle(""paddingTop"") + getStyle(""paddingBottom""); } /** * @private * Make sure the drop-down width is the same as the rest of the ComboBox */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); // we toss the dropdown when resized // except if we're opening the dropdown // then we assume the updateDisplayList() call is spurious // and will not affect the dropdown size if (_dropdown && !inTween) { // We will not destroy our dropdown if user is actively // interacting with it, this has been legacy behavior since // Flex 3.0. if (!_showingDropdown) destroyDropdown(); } else if (_showingDropdown) { bRemoveDropdown = false; } var ddw:Number = preferredDropdownWidth; if (isNaN(ddw)) ddw = _dropdownWidth = unscaledWidth; if (labelFieldChanged) { if (_dropdown) _dropdown.labelField = _labelField; selectionChanged = true; if (!explicitText) textInput.text = selectedLabel; labelFieldChanged = false; } if (labelFunctionChanged) { selectionChanged = true; if (!explicitText) textInput.text = selectedLabel; labelFunctionChanged = false; } if (selectionChanged) { if (!textChanged) { if (selectedIndex == -1 && prompt) textInput.text = prompt; else if (!explicitText) textInput.text = selectedLabel; } textInput.invalidateDisplayList(); textInput.validateNow(); if (editable) { textInput.selectRange(0, textInput.text.length); textInput.horizontalScrollPosition = 0; } if (_dropdown) _dropdown.selectedIndex = selectedIndex; selectionChanged = false; } // We might need to decrease the number of rows. if (_dropdown && _dropdown.rowCount != rowCount) _dropdown.rowCount = rowCount; } /** * @private */ override protected function commitProperties():void { explicitText = textChanged; super.commitProperties(); if (collectionChanged) { if (selectedIndex == -1 && implicitSelectedIndex && _prompt == null) selectedIndex = 0; selectedIndexChanged = true; collectionChanged = false; } if (promptChanged && prompt != null && selectedIndex == -1) { promptChanged = false; textInput.text = prompt; } } //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * Returns a string representing the item parameter. * *

This method checks in the following order to find a value to return:

* *
    *
  1. If you have specified a labelFunction property, * returns the result of passing the item to the function.
  2. *
  3. If the item is a String, Number, Boolean, or Function, returns * the item.
  4. *
  5. If the item has a property with the name specified by the control's * labelField property, returns the contents of the property.
  6. *
  7. If the item has a label property, returns its value.
  8. *
* * @param item The object that contains the value to convert to a label. * If the item is null, this method returns the empty string. * * @return A string representing the item parameter. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function itemToLabel(item:Object, ...rest):String { // rest args are needed in case dropdown is some other thing like DataGrid // that has multiple arguments to labelFunction // we need to check for null explicitly otherwise // a numeric zero will not get properly converted to a string. // (do not use !item) if (item == null) return """"; if (labelFunction != null) return labelFunction(item); if (typeof(item) == ""object"") { try { if (item[labelField] != null) item = item[labelField]; } catch(e:Error) { } } else if (typeof(item) == ""xml"") { try { if (item[labelField].length() != 0) item = item[labelField]; } catch(e:Error) { } } if (typeof(item) == ""string"") return String(item); try { return item.toString(); } catch(e:Error) { } return "" ""; } /** * Displays the drop-down list. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function open():void { displayDropdown(true); } /** * Hides the drop-down list. * * @param trigger The event to dispatch when the * drop-down list closes. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function close(trigger:Event = null):void { if (_showingDropdown) { if (_dropdown && selectedIndex != _dropdown.selectedIndex) selectedIndex = _dropdown.selectedIndex; displayDropdown(false, trigger); dispatchChangeEvent(new Event(""dummy""), _selectedIndexOnDropdown, selectedIndex); } } /** * @private */ mx_internal function hasDropdown():Boolean { return _dropdown != null; } /** * @private */ private function getDropdown():ListBase { if (!initialized) return null; if (!hasDropdown()) { var dropDownStyleName:String = getStyle(""dropDownStyleName""); if (dropDownStyleName == null ) dropDownStyleName = getStyle(""dropdownStyleName""); _dropdown = dropdownFactory.newInstance(); _dropdown.visible = false; _dropdown.focusEnabled = false; _dropdown.owner = this; if (itemRenderer) _dropdown.itemRenderer = itemRenderer; if (dropDownStyleName) _dropdown.styleName = dropDownStyleName; PopUpManager.addPopUp(_dropdown, this); // Don't display a tween when the selection changes. // The dropdown menu is about to appear anyway, // and other processing can make the tween look choppy. _dropdown.setStyle(""selectionDuration"", 0); // Set up a data provider in case one doesn't yet exist, // so we can share it with the dropdown listbox. if (!dataProvider) dataProvider = new ArrayCollection(); _dropdown.dataProvider = dataProvider; _dropdown.rowCount = rowCount; _dropdown.width = _dropdownWidth; _dropdown.selectedIndex = selectedIndex; _oldIndex = selectedIndex; _dropdown.verticalScrollPolicy = ScrollPolicy.AUTO; _dropdown.labelField = _labelField; _dropdown.labelFunction = itemToLabel; _dropdown.allowDragSelection = true; _dropdown.addEventListener(""change"", dropdown_changeHandler); _dropdown.addEventListener(ScrollEvent.SCROLL, dropdown_scrollHandler); _dropdown.addEventListener(ListEvent.ITEM_ROLL_OVER, dropdown_itemRollOverHandler); _dropdown.addEventListener(ListEvent.ITEM_ROLL_OUT, dropdown_itemRollOutHandler); // the drop down should close if the user clicks on any item. // add a handler to detect a click in the list _dropdown.addEventListener(ListEvent.ITEM_CLICK, dropdown_itemClickHandler); UIComponentGlobals.layoutManager.validateClient(_dropdown, true); _dropdown.setActualSize(_dropdownWidth, _dropdown.getExplicitOrMeasuredHeight()); _dropdown.validateDisplayList(); _dropdown.cacheAsBitmap = true; // weak reference to stage systemManager.addEventListener(Event.RESIZE, stage_resizeHandler, false, 0, true); } var m:Matrix = MatrixUtil.getConcatenatedMatrix(this, systemManager.getSandboxRoot()); _dropdown.scaleX = m.a; //scale x _dropdown.scaleY = m.d; //scale y return _dropdown; } /** * @private */ private function displayDropdown(show:Boolean, trigger:Event = null, playEffect:Boolean = true):void { if (!initialized || show == _showingDropdown) return; if (inTween && tween) tween.endTween(); // Subclasses may extend to do pre-processing // before the dropdown is displayed // or override to implement special display behavior // Show or hide the dropdown var initY:Number; var endY:Number; var duration:Number; var easingFunction:Function; var point:Point = new Point(0, unscaledHeight); point = localToGlobal(point); var sm:ISystemManager = systemManager.topLevelSystemManager; var screen:Rectangle = sm.getVisibleApplicationRect(null, true); //opening the dropdown if (show) { // Store the selectedIndex temporarily so we can tell // if the value changed when the dropdown is closed _selectedIndexOnDropdown = selectedIndex; getDropdown(); _dropdown.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, dropdown_mouseOutsideHandler); _dropdown.addEventListener(FlexMouseEvent.MOUSE_WHEEL_OUTSIDE, dropdown_mouseOutsideHandler); _dropdown.addEventListener(SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE, dropdown_mouseOutsideHandler); _dropdown.addEventListener(SandboxMouseEvent.MOUSE_WHEEL_SOMEWHERE, dropdown_mouseOutsideHandler); if (_dropdown.parent == null) // was popped up then closed PopUpManager.addPopUp(_dropdown, this); else PopUpManager.bringToFront(_dropdown); // if we donot have enough space in the bottom display the dropdown // at the top. But if the space there is also less than required // display it below. if (point.y + _dropdown.height > screen.bottom && point.y > screen.top + _dropdown.height) { // Dropdown will go below the bottom of the stage // and be clipped. Instead, have it grow up. point.y -= (unscaledHeight + _dropdown.height); initY = -_dropdown.height; tweenUp = true; } else { initY = _dropdown.height; tweenUp = false; } point = _dropdown.parent.globalToLocal(point); // If the combobox's layout is mirrored then the the dropdown's // will be too. That also means that (stage coordinate) point.x is // currently the right edge of the dropdown. Fix that: if (layoutDirection == LayoutDirection.RTL) point.x -= _dropdown.width; var sel:int = _dropdown.selectedIndex; if (sel == -1) sel = 0; var pos:Number = _dropdown.verticalScrollPosition; // try to set the verticalScrollPosition one above the selected index so // it looks better when the dropdown is displayed pos = sel - 1; pos = Math.min(Math.max(pos, 0), _dropdown.maxVerticalScrollPosition); _dropdown.verticalScrollPosition = pos; if (_dropdown.x != point.x || _dropdown.y != point.y) _dropdown.move(point.x, point.y); _dropdown.scrollRect = new Rectangle(0, initY, _dropdown.width, _dropdown.height); if (!_dropdown.visible) _dropdown.visible = true; // Make sure we don't remove the dropdown at the end of the tween bRemoveDropdown = false; // Set up the tween and relevant variables. _showingDropdown = show; duration = getStyle(""openDuration""); endY = 0; easingFunction = getStyle(""openEasingFunction"") as Function; } // closing the dropdown else if (_dropdown) { // Set up the tween and relevant variables. endY = (point.y + _dropdown.height > screen.bottom || tweenUp ? -_dropdown.height : _dropdown.height); _showingDropdown = show; initY = 0; duration = getStyle(""closeDuration""); easingFunction = getStyle(""closeEasingFunction"") as Function; _dropdown.resetDragScrolling(); } inTween = true; // only force validation if we're about to show // or closing with effect. Otherwise, if the iterator // is out of sync in the dropdown, we'll get an RTE // when closing if (playEffect || show) UIComponentGlobals.layoutManager.validateNow(); // Block all layout, responses from web service, and other background // processing until the tween finishes executing. UIComponent.suspendBackgroundProcessing(); // Disable the dropdown during the tween. if (_dropdown) _dropdown.enabled = false; duration = Math.max(1, duration); if (!playEffect) duration = 1; tween = new Tween(this, initY, endY, duration); if (easingFunction != null && tween) tween.easingFunction = easingFunction; triggerEvent = trigger; } /** * @private */ private function dispatchChangeEvent(oldEvent:Event, prevValue:int, newValue:int):void { if (prevValue != newValue) { var newEvent:Event = oldEvent is ListEvent ? oldEvent : new ListEvent(""change""); dispatchEvent(newEvent); } } /** * @private */ private function destroyDropdown():void { if (inTween && tween) tween.endTween(); displayDropdown(false, null, false); } //-------------------------------------------------------------------------- // // Overridden event handlers // //-------------------------------------------------------------------------- private var implicitSelectedIndex:Boolean = false; /** * @private */ override protected function collectionChangeHandler(event:Event):void { // Save a copy of the selectedIndex var curSelectedIndex:int = selectedIndex; super.collectionChangeHandler(event); if (event is CollectionEvent) { // trace(""ListBase collectionEvent""); var ce:CollectionEvent = CollectionEvent(event); if (collection.length == 0) { // Special case: Empty dataProvider. if (!selectedIndexChanged && !selectedItemChanged) { if (super.selectedIndex != -1) super.selectedIndex = -1; implicitSelectedIndex = true; invalidateDisplayList(); } // if the combobox is non-editable remove the text // we don't want to remove the text if it is editable as user might // have typed something. if (textInput && !editable) textInput.text = """"; } else if (ce.kind == CollectionEventKind.ADD) { if (collection.length == ce.items.length) { // Special case: Adding the first item(s). Select item 0 // if there is no prompt if (selectedIndex == -1 && _prompt == null) selectedIndex = 0; } else { // we dont want to destroy the dropdown just // because data got added. Especially true // for paged data. return; } } else if (ce.kind == CollectionEventKind.UPDATE) { if (ce.location == selectedIndex || ce.items[0].source == selectedItem) // unsorted lists don't have a valid location // Force an update of the text input selectionChanged = true; } else if (ce.kind == CollectionEventKind.REPLACE) { // bail on a replace, no need to change anything, // especially for paged data return; } else if (ce.kind == CollectionEventKind.RESET) { collectionChanged = true; if (!selectedIndexChanged && !selectedItemChanged) selectedIndex = prompt ? -1 : 0; invalidateProperties(); } invalidateDisplayList(); destroyDropdown(); } } /** * @private */ override protected function textInput_changeHandler(event:Event):void { super.textInput_changeHandler(event); // Force a change event to be dispatched dispatchChangeEvent(event, -1, -2); } /** * @private */ override protected function downArrowButton_buttonDownHandler( event:FlexEvent):void { // The down arrow should always toggle the visibility of the dropdown. if (_showingDropdown) { close(event); } else { displayDropdown(true, event); } } //-------------------------------------------------------------------------- // // Event handlers // //-------------------------------------------------------------------------- /** * @private */ private function dropdown_mouseOutsideHandler(event:Event):void { // trace(""dropdown_mouseOutsideHandler: "" + event); if (event is MouseEvent) { var mouseEvent:MouseEvent = MouseEvent(event); if (mouseEvent.target != _dropdown) // the dropdown's items can dispatch a mouseDownOutside // event which then bubbles up to us return; if (!hitTestPoint(mouseEvent.stageX, mouseEvent.stageY, true)) { close(event); } } else if (event is SandboxMouseEvent) { close(event); } } /** * @private */ private function dropdown_itemClickHandler(event:ListEvent):void { if (_showingDropdown) { close(); } } /** * @private */ override protected function focusOutHandler(event:FocusEvent):void { // Note: event.relatedObject is the object getting focus. // It can be null in some cases, such as when you open // the dropdown and then click outside the application. // If the dropdown is open... if (_showingDropdown && _dropdown && this.contains(DisplayObject(event.target))) { // If focus is moving outside the dropdown... if (!event.relatedObject || !_dropdown.contains(event.relatedObject)) { // Close the dropdown. close(); } } super.focusOutHandler(event); } private function stage_resizeHandler(event:Event):void { destroyDropdown(); } /** * @private */ private function dropdown_scrollHandler(event:Event):void { // TextField.scroll bubbles so you might see it here if (event is ScrollEvent) { var se:ScrollEvent = ScrollEvent(event); if (se.detail == ScrollEventDetail.THUMB_TRACK || se.detail == ScrollEventDetail.THUMB_POSITION || se.detail == ScrollEventDetail.LINE_UP || se.detail == ScrollEventDetail.LINE_DOWN) dispatchEvent(se); } } /** * @private */ private function dropdown_itemRollOverHandler(event:Event):void { dispatchEvent(event); } /** * @private */ private function dropdown_itemRollOutHandler(event:Event):void { dispatchEvent(event); } /** * @private */ private function dropdown_changeHandler(event:Event):void { var prevValue:int = selectedIndex; // This assignment will also assign the label to the text field. // See setSelectedIndex(). if (_dropdown) selectedIndex = _dropdown.selectedIndex; // If this was generated by the dropdown as a result of a keystroke, it is // likely a Page-Up or Page-Down, or Arrow-Up or Arrow-Down. // If the selection changes due to a keystroke, // we leave the dropdown displayed. // If it changes as a result of a mouse selection, // we close the dropdown. if (!_showingDropdown) dispatchChangeEvent(event, prevValue, selectedIndex); else if (!bInKeyDown) { // this will also send a change event if needed close(); } } /** * @private */ override protected function keyDownHandler(event:KeyboardEvent):void { // If the combo box is disabled, don't do anything if (!enabled) return; // If a the editable field currently has focus, it is handling // all arrow keys. We shouldn't also scroll this selection. if (event.target == textInput) return; if (event.ctrlKey && event.keyCode == Keyboard.DOWN) { displayDropdown(true, event); event.stopPropagation(); } else if (event.ctrlKey && event.keyCode == Keyboard.UP) { close(event); event.stopPropagation(); } else if (event.keyCode == Keyboard.ESCAPE) { if (_showingDropdown) { if (_oldIndex != _dropdown.selectedIndex) selectedIndex = _oldIndex; displayDropdown(false); event.stopPropagation(); } } else if (event.keyCode == Keyboard.ENTER) { if (_showingDropdown) { close(); event.stopPropagation(); } } else { if (!editable || event.keyCode == Keyboard.UP || event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.PAGE_UP || event.keyCode == Keyboard.PAGE_DOWN) { var oldIndex:int = selectedIndex; // Make sure we know we are handling a keyDown, // so if the dropdown sends out a ""change"" event // (like when an up-arrow or down-arrow changes // the selection) we know not to close the dropdown. bInKeyDown = _showingDropdown; // Redispatch the event to the dropdown // and let its keyDownHandler() handle it. dropdown.dispatchEvent(event.clone()); event.stopPropagation(); bInKeyDown = false; } } } /** * @private * This acts as the destructor. */ private function unloadHandler(event:Event):void { if (inTween) { UIComponent.resumeBackgroundProcessing(); inTween = false; } if (_dropdown) _dropdown.parent.removeChild(_dropdown); } /** * @private */ private function removedFromStageHandler(event:Event):void { // Ensure we've unregistered ourselves from PopupManager, else // we'll be leaked. destroyDropdown(); } //-------------------------------------------------------------------------- // // Tween handlers // //-------------------------------------------------------------------------- /** * @private */ mx_internal function onTweenUpdate(value:Number):void { if (_dropdown) { _dropdown.scrollRect = new Rectangle(0, value, _dropdown.width, _dropdown.height); } } /** * @private */ mx_internal function onTweenEnd(value:Number):void { if (_dropdown) { // Clear the scrollRect here. This way if drop shadows are // assigned to the dropdown they show up correctly _dropdown.scrollRect = null; inTween = false; _dropdown.enabled = true; _dropdown.visible = _showingDropdown; if (bRemoveDropdown) { _dropdown.removeEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, dropdown_mouseOutsideHandler); _dropdown.removeEventListener(FlexMouseEvent.MOUSE_WHEEL_OUTSIDE, dropdown_mouseOutsideHandler); _dropdown.removeEventListener(SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE, dropdown_mouseOutsideHandler); _dropdown.removeEventListener(SandboxMouseEvent.MOUSE_WHEEL_SOMEWHERE, dropdown_mouseOutsideHandler); PopUpManager.removePopUp(_dropdown); _dropdown = null; } } bRemoveDropdown = true; UIComponent.resumeBackgroundProcessing(); var cbdEvent:DropdownEvent = new DropdownEvent(_showingDropdown ? DropdownEvent.OPEN : DropdownEvent.CLOSE); cbdEvent.triggerEvent = triggerEvent; dispatchEvent(cbdEvent); } /** * Determines default values of the height and width to use for each * entry in the drop-down list, based on the maximum size of the label * text in the first numItems items in the data provider. * * @param count The number of items to check to determine the value. * * @return An Object containing two properties: width and height. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override protected function calculatePreferredSizeFromData(count:int):Object { var maxW:Number = 0; var maxH:Number = 0; var bookmark:CursorBookmark = iterator ? iterator.bookmark : null; iterator.seek(CursorBookmark.FIRST, 0); var more:Boolean = iterator != null; var lineMetrics:TextLineMetrics; for (var i:int = 0; i < count; i++) { var data:Object; if (more) data = iterator ? iterator.current : null; else data = null; var txt:String = itemToLabel(data); lineMetrics = measureText(txt); maxW = Math.max(maxW, lineMetrics.width); maxH = Math.max(maxH, lineMetrics.height); if (iterator) iterator.moveNext(); } if (prompt) { lineMetrics = measureText(prompt); maxW = Math.max(maxW, lineMetrics.width); maxH = Math.max(maxH, lineMetrics.height); } maxW += getStyle(""paddingLeft"") + getStyle(""paddingRight""); if (iterator) iterator.seek(bookmark, 0); return { width: maxW, height: maxH }; } /** * @private */ mx_internal function get isShowingDropdown():Boolean { return _showingDropdown; } } } ",16284,True,2832.65001489805,median "*&---------------------------------------------------------------------* *& Report ZMMR0015 *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zmmr0015. *--------------------------------------------------------------------* * Main Class *--------------------------------------------------------------------* CLASS lcl_zmmr0015 DEFINITION FINAL. PUBLIC SECTION. TYPE-POOLS: icon. METHODS: constructor IMPORTING i_banfn TYPE ANY TABLE i_bnfpo TYPE ANY TABLE i_matnr TYPE ANY TABLE i_werks TYPE ANY TABLE, get_pr_data RETURNING VALUE(e_table_data) TYPE zmmc0012, get_pr_log RETURNING VALUE(e_table_data) TYPE zmmc0013, set_pr_conclusion CHANGING ch_pr_item TYPE zmmc0012, set_pr_exclusion CHANGING ch_pr_item TYPE zmmc0012, set_pr_log IMPORTING i_pr_item TYPE zmmc0012 RETURNING VALUE(not_found) TYPE flag. PRIVATE SECTION. CONSTANTS: BEGIN OF gc_action, conclusion TYPE zmmt010-action VALUE 'CONCLUIR', exclusion TYPE zmmt010-action VALUE 'EXCLUIR', END OF gc_action. DATA: gr_banfn TYPE RANGE OF eban-banfn, gr_bnfpo TYPE RANGE OF eban-bnfpo, gr_matnr TYPE RANGE OF eban-matnr, gr_werks TYPE RANGE OF eban-werks. DATA: gt_generated_log TYPE TABLE OF zmmt010. ENDCLASS. CLASS lcl_zmmr0015 IMPLEMENTATION. METHOD constructor. gr_banfn[] = i_banfn[]. gr_bnfpo[] = i_bnfpo[]. gr_matnr[] = i_matnr[]. gr_werks[] = i_werks[]. ENDMETHOD. METHOD get_pr_data. SELECT a~banfn a~bnfpo a~matnr b~maktx a~werks a~loekz a~ebakz FROM eban AS a INNER JOIN makt AS b ON a~matnr = b~matnr INTO TABLE e_table_data WHERE a~banfn IN gr_banfn AND a~bnfpo IN gr_bnfpo AND a~matnr IN gr_matnr AND a~werks IN gr_werks. ENDMETHOD. METHOD get_pr_log. * Adjust icon LOOP AT gt_generated_log ASSIGNING FIELD-SYMBOL(). APPEND INITIAL LINE TO e_table_data ASSIGNING FIELD-SYMBOL(). MOVE-CORRESPONDING TO . IF -type = 'S'. -icon = icon_led_green. ELSE. -icon = icon_led_red. ENDIF. ENDLOOP. ENDMETHOD. METHOD set_pr_conclusion. DATA: lt_pr_header TYPE zmmc0012, lt_pritem TYPE TABLE OF bapimereqitemimp, lt_pritemx TYPE TABLE OF bapimereqitemx, lt_return TYPE TABLE OF bapiret2. CLEAR gt_generated_log. SORT ch_pr_item BY banfn. * Get purchase requisition header lt_pr_header[] = ch_pr_item[]. DELETE ADJACENT DUPLICATES FROM lt_pr_header COMPARING banfn. * Call funtion for each purchase requisition LOOP AT lt_pr_header ASSIGNING FIELD-SYMBOL(). CLEAR: lt_pritem, lt_return, lt_pritemx. * Groups items by purchase requisition LOOP AT ch_pr_item ASSIGNING FIELD-SYMBOL() WHERE banfn = -banfn. APPEND INITIAL LINE TO lt_pritem ASSIGNING FIELD-SYMBOL(). -preq_item = -bnfpo. -closed = abap_true. APPEND INITIAL LINE TO lt_pritemx ASSIGNING FIELD-SYMBOL(). -preq_item = -bnfpo. -preq_itemx = abap_true. -closed = abap_true. APPEND INITIAL LINE TO gt_generated_log ASSIGNING FIELD-SYMBOL(). -banfn = -banfn. -bnfpo = -bnfpo. -matnr = -matnr. -action = gc_action-conclusion. ENDLOOP. * Set purchase requisition as completed CALL FUNCTION 'BAPI_PR_CHANGE' EXPORTING number = -banfn TABLES return = lt_return pritem = lt_pritem pritemx = lt_pritemx. * Save changes log IF line_exists( lt_return[ type = 'E' ] ). CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. LOOP AT gt_generated_log ASSIGNING WHERE banfn = -banfn. LOOP AT lt_return ASSIGNING FIELD-SYMBOL() WHERE type = 'E'. MOVE-CORRESPONDING TO . -msgno = -number. ENDLOOP. ENDLOOP. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true. LOOP AT gt_generated_log ASSIGNING WHERE banfn = -banfn. READ TABLE lt_return ASSIGNING WITH KEY type = 'S' id = '06' number = '403'. IF sy-subrc = 0. MOVE-CORRESPONDING TO . -msgno = -number. ENDIF. ENDLOOP. ENDIF. ENDLOOP. IF lines( gt_generated_log ) > 0. MODIFY zmmt010 FROM TABLE gt_generated_log. ENDIF. ENDMETHOD. METHOD set_pr_exclusion. DATA: lt_pr_header TYPE zmmc0012, lt_pritem TYPE TABLE OF bapimereqitemimp, lt_pritemx TYPE TABLE OF bapimereqitemx, lt_return TYPE TABLE OF bapiret2. CLEAR gt_generated_log. SORT ch_pr_item BY banfn. * Get purchase requisition header lt_pr_header[] = ch_pr_item[]. DELETE ADJACENT DUPLICATES FROM lt_pr_header COMPARING banfn. * Call funtion for each purchase requisition LOOP AT lt_pr_header ASSIGNING FIELD-SYMBOL(). CLEAR: lt_pritem, lt_return, lt_pritemx. * Groups items by purchase requisition LOOP AT ch_pr_item ASSIGNING FIELD-SYMBOL() WHERE banfn = -banfn. APPEND INITIAL LINE TO lt_pritem ASSIGNING FIELD-SYMBOL(). -preq_item = -bnfpo. -delete_ind = abap_true. APPEND INITIAL LINE TO lt_pritemx ASSIGNING FIELD-SYMBOL(). -preq_item = -bnfpo. -preq_itemx = abap_true. -delete_ind = abap_true. APPEND INITIAL LINE TO gt_generated_log ASSIGNING FIELD-SYMBOL(). -banfn = -banfn. -bnfpo = -bnfpo. -matnr = -matnr. -action = gc_action-exclusion. ENDLOOP. * Set purchase requisition as deleted CALL FUNCTION 'BAPI_PR_CHANGE' EXPORTING number = -banfn TABLES return = lt_return pritem = lt_pritem pritemx = lt_pritemx. * Save changes log IF line_exists( lt_return[ type = 'E' ] ). CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. LOOP AT gt_generated_log ASSIGNING WHERE banfn = -banfn. LOOP AT lt_return ASSIGNING FIELD-SYMBOL() WHERE type = 'E'. MOVE-CORRESPONDING TO . -msgno = -number. ENDLOOP. ENDLOOP. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true. LOOP AT gt_generated_log ASSIGNING WHERE banfn = -banfn. READ TABLE lt_return ASSIGNING WITH KEY type = 'S' id = '06' number = '403'. IF sy-subrc = 0. MOVE-CORRESPONDING TO . -msgno = -number. ENDIF. ENDLOOP. ENDIF. ENDLOOP. IF lines( gt_generated_log ) > 0. MODIFY zmmt010 FROM TABLE gt_generated_log. ENDIF. ENDMETHOD. METHOD set_pr_log. SELECT * FROM zmmt010 INTO TABLE gt_generated_log FOR ALL ENTRIES IN i_pr_item WHERE banfn = i_pr_item-banfn AND bnfpo = i_pr_item-bnfpo. IF sy-subrc <> 0. not_found = abap_true. ENDIF. ENDMETHOD. ENDCLASS. *--------------------------------------------------------------------* * Global Objects *--------------------------------------------------------------------* TABLES: eban. DATA: go_report TYPE REF TO lcl_zmmr0015, gt_alv TYPE zmmc0012, gt_log TYPE zmmc0013, go_alv_9000 TYPE REF TO cl_gui_alv_grid, go_alv_9001 TYPE REF TO cl_gui_alv_grid, go_cont_9000 TYPE REF TO cl_gui_docking_container, go_cont_9001 TYPE REF TO cl_gui_docking_container, go_parent_9000 TYPE REF TO cl_gui_container, go_parent_9001 TYPE REF TO cl_gui_container. *--------------------------------------------------------------------* * Selection Screen *--------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: s_banfn FOR eban-banfn OBLIGATORY, s_bnfpo FOR eban-bnfpo,"" OBLIGATORY, s_matnr FOR eban-matnr, s_werks FOR eban-werks. SELECTION-SCREEN: END OF BLOCK b1. *--------------------------------------------------------------------* * Main event *--------------------------------------------------------------------* START-OF-SELECTION. CREATE OBJECT go_report EXPORTING i_banfn = s_banfn[] i_bnfpo = s_bnfpo[] i_matnr = s_matnr[] i_werks = s_werks[]. CALL SCREEN 9000. *&---------------------------------------------------------------------* *& Module STATUS_9000 OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE status_9000 OUTPUT. SET PF-STATUS 'STATUS_9000'. SET TITLEBAR 'TITLE_9000'. DATA: ls_layout TYPE lvc_s_layo, ls_variant TYPE disvariant, lt_sort TYPE lvc_t_sort. * Edit layout CLEAR ls_layout. ls_layout-sel_mode = 'A'. gt_alv = go_report->get_pr_data( ). DATA: lt_fcat TYPE lvc_t_fcat. CLEAR lt_fcat. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'ZMMS0009' CHANGING ct_fieldcat = lt_fcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. LOOP AT lt_fcat ASSIGNING FIELD-SYMBOL(). IF -fieldname = 'LOEKZ' OR -fieldname = 'EBAKZ'. -outputlen = 8. -just = 'C'. ELSE. -col_opt = abap_true. ENDIF. IF -fieldname = 'BANFN' OR -fieldname = 'BNFPO'. -key = abap_true. ENDIF. ENDLOOP. IF go_cont_9000 IS BOUND. go_alv_9000->set_frontend_fieldcatalog( it_fieldcatalog = lt_fcat ). DATA: ls_stable TYPE lvc_s_stbl. ls_stable-row = abap_true. ls_stable-col = abap_true. go_alv_9000->refresh_table_display( EXPORTING is_stable = ls_stable "" With Stable Rows/Columns EXCEPTIONS finished = 1 "" Display was Ended (by Export) OTHERS = 2 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ELSE. * Cria o Container para a tela do ALV CREATE OBJECT go_cont_9000 EXPORTING side = cl_gui_docking_container=>dock_at_top repid = sy-repid dynnr = '9000' extension = 1000 EXCEPTIONS OTHERS = 6. * Casting para o tipo genério go_parent_9000 = go_cont_9000. * Criia Instância do ALV, referenciando o Container gerado acima CREATE OBJECT go_alv_9000 EXPORTING i_parent = go_parent_9000. ls_variant-report = sy-repid. ls_variant-username = sy-uname. *APPEND INITIAL LINE TO lt_sort ASSIGNING FIELD-SYMBOL(< CLEAR lt_sort. APPEND VALUE #( fieldname = 'BANFN' up = 'X' ) TO lt_sort. APPEND VALUE #( fieldname = 'BNFPO' up = 'X' ) TO lt_sort. * Exibe o ALV go_alv_9000->set_table_for_first_display( EXPORTING is_variant = ls_variant "" Layout i_save = 'A' "" Save Layout is_layout = ls_layout "" Layout CHANGING it_outtab = gt_alv "" Output Table it_fieldcatalog = lt_fcat "" Field Catalog it_sort = lt_sort "" Sort Criteria EXCEPTIONS invalid_parameter_combination = 1 "" Wrong Parameter program_error = 2 "" Program Errors too_many_lines = 3 "" Too many Rows in Ready for Input Grid OTHERS = 4 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDIF. ENDMODULE. *&---------------------------------------------------------------------* *& Module USER_COMMAND_9000 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_9000 INPUT. DATA: lt_selected_data TYPE zmmc0012. CASE sy-ucomm. WHEN '&F03' OR '&F15' OR '&F12'. go_alv_9000->free( ). go_cont_9000->free( ). CALL METHOD cl_gui_cfw=>flush. CLEAR: go_alv_9000, go_cont_9000. LEAVE TO SCREEN 0. WHEN '&CONCL'. * Get selected rows CLEAR lt_selected_data. go_alv_9000->check_changed_data( ). go_alv_9000->get_selected_rows( IMPORTING et_index_rows = DATA(lt_index_rows) ). IF lines( lt_index_rows ) = 0. MESSAGE 'Favor selecionar uma linha para processamento'(002) TYPE 'S' DISPLAY LIKE 'E'. RETURN. ENDIF. * Process rows LOOP AT lt_index_rows ASSIGNING FIELD-SYMBOL(). READ TABLE gt_alv ASSIGNING FIELD-SYMBOL() INDEX . IF sy-subrc = 0. APPEND INITIAL LINE TO lt_selected_data ASSIGNING FIELD-SYMBOL(). = . ENDIF. ENDLOOP. go_report->set_pr_conclusion( CHANGING ch_pr_item = lt_selected_data ). * Display log screen CALL SCREEN 9001. WHEN '&DELET'. * Get selected rows CLEAR lt_selected_data. go_alv_9000->check_changed_data( ). go_alv_9000->get_selected_rows( IMPORTING et_index_rows = lt_index_rows ). IF lines( lt_index_rows ) = 0. MESSAGE 'Favor selecionar uma linha para processamento'(002) TYPE 'S' DISPLAY LIKE 'E'. RETURN. ENDIF. * Process rows LOOP AT lt_index_rows ASSIGNING . READ TABLE gt_alv ASSIGNING INDEX . IF sy-subrc = 0. APPEND INITIAL LINE TO lt_selected_data ASSIGNING . = . ENDIF. ENDLOOP. go_report->set_pr_exclusion( CHANGING ch_pr_item = lt_selected_data ). * Display log screen CALL SCREEN 9001. WHEN '&LOG'. * Get selected rows CLEAR lt_selected_data. go_alv_9000->check_changed_data( ). go_alv_9000->get_selected_rows( IMPORTING et_index_rows = lt_index_rows ). IF lines( lt_index_rows ) = 0. MESSAGE 'Favor selecionar uma linha para processamento'(002) TYPE 'S' DISPLAY LIKE 'E'. RETURN. ENDIF. * Process rows LOOP AT lt_index_rows ASSIGNING . READ TABLE gt_alv ASSIGNING INDEX . IF sy-subrc = 0. APPEND INITIAL LINE TO lt_selected_data ASSIGNING . = . ENDIF. ENDLOOP. IF go_report->set_pr_log( EXPORTING i_pr_item = lt_selected_data ) = abap_true. MESSAGE 'Não foram encontrados registros de log para a req.compra selecionada'(004) TYPE 'S' DISPLAY LIKE 'E'. ELSE. * Display log screen CALL SCREEN 9001. ENDIF. ENDCASE. ENDMODULE. *&---------------------------------------------------------------------* *& Module STATUS_9001 OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE status_9001 OUTPUT. SET PF-STATUS 'STATUS_9001'. SET TITLEBAR 'TITLE_9001'. gt_log = go_report->get_pr_log( ). * Edit layout CLEAR ls_layout. ls_layout-cwidth_opt = abap_true. IF go_cont_9001 IS BOUND. go_alv_9001->set_frontend_layout( is_layout = ls_layout ). ls_stable-row = abap_true. ls_stable-col = abap_true. go_alv_9001->refresh_table_display( EXPORTING is_stable = ls_stable "" With Stable Rows/Columns EXCEPTIONS finished = 1 "" Display was Ended (by Export) OTHERS = 2 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ELSE. * Cria o Container para a tela do ALV CREATE OBJECT go_cont_9001 EXPORTING side = cl_gui_docking_container=>dock_at_top repid = sy-repid dynnr = '9001' extension = 1000 EXCEPTIONS OTHERS = 6. * Casting para o tipo genério go_parent_9001 = go_cont_9001. * Criia Instância do ALV, referenciando o Container gerado acima CREATE OBJECT go_alv_9001 EXPORTING i_parent = go_parent_9001. CLEAR lt_fcat. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'ZMMS0010' CHANGING ct_fieldcat = lt_fcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. LOOP AT lt_fcat ASSIGNING . IF -fieldname CS 'MESSAGE_V'. -no_out = abap_true. ENDIF. IF -fieldname = 'ICON'. -icon = abap_true. -coltext = 'Status'(003). ENDIF. ENDLOOP. * Exibe o ALV go_alv_9001->set_table_for_first_display( EXPORTING * i_buffer_active = "" Buffering Active * i_bypassing_buffer = "" Switch Off Buffer * i_consistency_check = "" Starting Consistency Check for Interface Error Recognition i_structure_name = 'ZMMT010' "" Internal Output Table Structure Name * is_variant = "" Layout * i_save = "" Save Layout * i_default = 'X' "" Default Display Variant is_layout = ls_layout "" Layout * is_print = "" Print Control * it_special_groups = "" Field Groups * it_toolbar_excluding = "" Excluded Toolbar Standard Functions * it_hyperlink = "" Hyperlinks * it_alv_graphics = "" Table of Structure DTC_S_TC * it_except_qinfo = "" Table for Exception Quickinfo * ir_salv_adapter = "" Interface ALV Adapter CHANGING it_outtab = gt_log "" Output Table it_fieldcatalog = lt_fcat "" Field Catalog * it_sort = "" Sort Criteria * it_filter = "" Filter Criteria EXCEPTIONS invalid_parameter_combination = 1 "" Wrong Parameter program_error = 2 "" Program Errors too_many_lines = 3 "" Too many Rows in Ready for Input Grid OTHERS = 4 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDIF. ENDMODULE. *&---------------------------------------------------------------------* *& Module USER_COMMAND_9001 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_9001 INPUT. CASE sy-ucomm. WHEN '&F03' OR '&F15' OR '&F12'. LEAVE TO SCREEN 0. ENDCASE. ENDMODULE. ",5473,False,1033.9443400110895,median "CLASS ltcl_run_checks DEFINITION DEFERRED. CLASS zcl_abapgit_file_status DEFINITION LOCAL FRIENDS ltcl_run_checks. CLASS ltcl_run_checks DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL. PRIVATE SECTION. DATA: mt_results TYPE zif_abapgit_definitions=>ty_results_tt, mo_dot TYPE REF TO zcl_abapgit_dot_abapgit, mi_log TYPE REF TO zif_abapgit_log. METHODS: append_result IMPORTING iv_obj_type TYPE trobjtype iv_obj_name TYPE sobj_name iv_match TYPE abap_bool iv_lstate TYPE char1 iv_rstate TYPE char1 iv_package TYPE devclass iv_path TYPE string iv_filename TYPE string iv_packmove TYPE abap_bool OPTIONAL, setup, positive FOR TESTING RAISING zcx_abapgit_exception, neg_diff_path_for_same_obj FOR TESTING RAISING zcx_abapgit_exception, neg_incorrect_path_vs_pack FOR TESTING RAISING zcx_abapgit_exception, neg_similar_filenames FOR TESTING RAISING zcx_abapgit_exception, neg_empty_filenames FOR TESTING RAISING zcx_abapgit_exception, package_move FOR TESTING RAISING zcx_abapgit_exception. ENDCLASS. CLASS ltcl_run_checks IMPLEMENTATION. METHOD append_result. DATA ls_result LIKE LINE OF mt_results. ls_result-inactive = abap_false. ls_result-obj_type = iv_obj_type. ls_result-obj_name = iv_obj_name. ls_result-match = iv_match. ls_result-lstate = iv_lstate. ls_result-rstate = iv_rstate. ls_result-package = iv_package. ls_result-path = iv_path. ls_result-filename = iv_filename. ls_result-packmove = iv_packmove. APPEND ls_result TO mt_results. ENDMETHOD. METHOD setup. CREATE OBJECT mi_log TYPE zcl_abapgit_log. mo_dot = zcl_abapgit_dot_abapgit=>build_default( ). mo_dot->set_starting_folder( '/' ). "" assumed by unit tests ENDMETHOD. METHOD positive. "" 0 Positive append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = 'zclass1.clas.abap' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = 'zclass1.clas.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = 'ZDOMA1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = 'zdoma1.doma.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = 'ZDOMA2' iv_match = ' ' iv_lstate = 'M' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = 'zdoma2.doma.xml' ). zcl_abapgit_file_status=>run_checks( ii_log = mi_log it_results = mt_results io_dot = mo_dot iv_top = '$Z$' ). cl_abap_unit_assert=>assert_equals( act = mi_log->count( ) exp = 0 ). ENDMETHOD. METHOD neg_diff_path_for_same_obj. "" 1 Negative, different path for same object append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = 'zclass1.clas.abap' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/sub' iv_filename = 'zclass1.clas.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = 'ZDOMA1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = 'zdoma1.doma.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = 'ZDOMA2' iv_match = ' ' iv_lstate = 'M' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = 'zdoma2.doma.xml' ). zcl_abapgit_file_status=>run_checks( ii_log = mi_log it_results = mt_results io_dot = mo_dot iv_top = '$Z$' ). "" This one is not pure - incorrect path also triggers path vs package check cl_abap_unit_assert=>assert_equals( act = mi_log->count( ) exp = 2 ). cl_abap_unit_assert=>assert_equals( act = mi_log->has_rc( '1' ) exp = abap_true ). ENDMETHOD. METHOD neg_incorrect_path_vs_pack. "" 2 Negative, incorrect path vs package append_result( iv_obj_type = 'CLAS' iv_obj_name = '$$ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zclass1.clas.abap' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = '$$ZCLASS1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zclass1.clas.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/sub' iv_filename = '$$zdoma1.doma.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA2' iv_match = ' ' iv_lstate = 'M' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zdoma2.doma.xml' ). zcl_abapgit_file_status=>run_checks( ii_log = mi_log it_results = mt_results io_dot = mo_dot iv_top = '$Z$' ). cl_abap_unit_assert=>assert_equals( act = mi_log->count( ) exp = 1 ). cl_abap_unit_assert=>assert_equals( act = mi_log->has_rc( '2' ) exp = abap_true ). ENDMETHOD. METHOD neg_similar_filenames. "" 3 Negative, similar filenames append_result( iv_obj_type = 'CLAS' iv_obj_name = '$$ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zclass1.clas.abap' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = '$$ZCLASS1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zclass1.clas.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zdoma1.doma.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA2' iv_match = ' ' iv_lstate = 'M' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zdoma1.doma.xml' ). zcl_abapgit_file_status=>run_checks( ii_log = mi_log it_results = mt_results io_dot = mo_dot iv_top = '$Z$' ). cl_abap_unit_assert=>assert_equals( act = mi_log->count( ) exp = 1 ). cl_abap_unit_assert=>assert_equals( act = mi_log->has_rc( '3' ) exp = abap_true ). ENDMETHOD. METHOD neg_empty_filenames. "" 4 Negative, empty filenames append_result( iv_obj_type = 'CLAS' iv_obj_name = '$$ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zclass1.clas.abap' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = '$$ZCLASS1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '$$zclass1.clas.xml' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_match = 'X' iv_lstate = ' ' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = '' ). zcl_abapgit_file_status=>run_checks( ii_log = mi_log it_results = mt_results io_dot = mo_dot iv_top = '$Z$' ). cl_abap_unit_assert=>assert_equals( act = mi_log->count( ) exp = 1 ). cl_abap_unit_assert=>assert_equals( act = mi_log->has_rc( '4' ) exp = abap_true ). ENDMETHOD. METHOD package_move. "" 5 Changed package assignment append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = 'zclass1.clas.abap' iv_packmove = 'X' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = ' ' iv_lstate = 'A' iv_rstate = ' ' iv_package = '$Z$SUB' iv_path = '/sub' iv_filename = 'zclass1.clas.abap' iv_packmove = 'X' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$' iv_path = '/' iv_filename = 'zclass1.clas.xml' iv_packmove = 'X' ). append_result( iv_obj_type = 'CLAS' iv_obj_name = 'ZCLASS1' iv_match = ' ' iv_lstate = 'A' iv_rstate = ' ' iv_package = '$Z$SUB' iv_path = '/sub' iv_filename = 'zclass1.clas.xml' iv_packmove = 'X' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = 'ZDOMA1' iv_match = ' ' iv_lstate = 'A' iv_rstate = ' ' iv_package = '$Z$' iv_path = '/' iv_filename = 'zdoma1.doma.xml' iv_packmove = 'X' ). append_result( iv_obj_type = 'DOMA' iv_obj_name = 'ZDOMA2' iv_match = ' ' iv_lstate = ' ' iv_rstate = 'A' iv_package = '$Z$SUB' iv_path = '/sub' iv_filename = 'zdoma1.doma.xml' iv_packmove = 'X' ). zcl_abapgit_file_status=>run_checks( ii_log = mi_log it_results = mt_results io_dot = mo_dot iv_top = '$Z$' ). "" Three files, but only two msg (for two changed objects) cl_abap_unit_assert=>assert_equals( act = mi_log->count( ) exp = 2 ). cl_abap_unit_assert=>assert_equals( act = mi_log->has_rc( '5' ) exp = abap_true ). ENDMETHOD. ENDCLASS. CLASS lcl_status_result DEFINITION. PUBLIC SECTION. METHODS: constructor IMPORTING it_results TYPE zif_abapgit_definitions=>ty_results_tt, get_line IMPORTING iv_line TYPE i RETURNING VALUE(rs_data) TYPE zif_abapgit_definitions=>ty_result, assert_lines IMPORTING iv_lines TYPE i iv_msg TYPE csequence OPTIONAL. PRIVATE SECTION. DATA: mt_results TYPE zif_abapgit_definitions=>ty_results_tt. ENDCLASS. CLASS lcl_status_result IMPLEMENTATION. METHOD constructor. mt_results = it_results. SORT mt_results BY path filename. ENDMETHOD. METHOD get_line. READ TABLE mt_results INDEX iv_line INTO rs_data. cl_abap_unit_assert=>assert_subrc( ). ENDMETHOD. METHOD assert_lines. cl_abap_unit_assert=>assert_equals( act = lines( mt_results ) exp = iv_lines msg = iv_msg ). ENDMETHOD. ENDCLASS. CLASS ltcl_status_helper DEFINITION DEFERRED. CLASS zcl_abapgit_file_status DEFINITION LOCAL FRIENDS ltcl_status_helper. CLASS ltcl_status_helper DEFINITION FOR TESTING. PUBLIC SECTION. INTERFACES: zif_abapgit_tadir. METHODS: constructor, add_tadir IMPORTING iv_obj_type TYPE tadir-object iv_obj_name TYPE tadir-obj_name iv_devclass TYPE tadir-devclass, add_remote IMPORTING iv_path TYPE string DEFAULT '/' iv_filename TYPE string iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1, add_local IMPORTING iv_path TYPE string DEFAULT '/' iv_filename TYPE string iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1 iv_obj_type TYPE tadir-object OPTIONAL iv_obj_name TYPE tadir-obj_name OPTIONAL iv_devclass TYPE devclass DEFAULT '$Z$', add_state IMPORTING iv_path TYPE string DEFAULT '/' iv_filename TYPE string iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1, run IMPORTING iv_devclass TYPE devclass DEFAULT '$Z$' RETURNING VALUE(ro_result) TYPE REF TO lcl_status_result RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: BEGIN OF ty_tadir, obj_type TYPE tadir-object, obj_name TYPE tadir-obj_name, devclass TYPE tadir-devclass, END OF ty_tadir. DATA: mt_tadir TYPE STANDARD TABLE OF ty_tadir WITH DEFAULT KEY, mt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, mt_remote TYPE zif_abapgit_definitions=>ty_files_tt, mt_state TYPE zif_abapgit_definitions=>ty_file_signatures_tt. ENDCLASS. CLASS ltcl_status_helper IMPLEMENTATION. METHOD constructor. zcl_abapgit_injector=>set_tadir( me ). ENDMETHOD. METHOD add_tadir. FIELD-SYMBOLS: LIKE LINE OF mt_tadir. APPEND INITIAL LINE TO mt_tadir ASSIGNING . -obj_type = iv_obj_type. -obj_name = iv_obj_name. -devclass = iv_devclass. ENDMETHOD. METHOD zif_abapgit_tadir~get_object_package. DATA: ls_tadir LIKE LINE OF mt_tadir. IF lines( mt_tadir ) > 0. READ TABLE mt_tadir INTO ls_tadir WITH KEY obj_type = iv_object obj_name = iv_obj_name. cl_abap_unit_assert=>assert_subrc( ). rv_devclass = ls_tadir-devclass. ENDIF. ENDMETHOD. METHOD zif_abapgit_tadir~read. cl_abap_unit_assert=>fail( ). ENDMETHOD. METHOD zif_abapgit_tadir~read_single. cl_abap_unit_assert=>fail( ). ENDMETHOD. METHOD add_remote. FIELD-SYMBOLS: LIKE LINE OF mt_remote. APPEND INITIAL LINE TO mt_remote ASSIGNING . -path = iv_path. -filename = iv_filename. -sha1 = iv_sha1. ENDMETHOD. METHOD add_local. FIELD-SYMBOLS: LIKE LINE OF mt_local. APPEND INITIAL LINE TO mt_local ASSIGNING . -item-obj_type = iv_obj_type. -item-obj_name = iv_obj_name. -item-devclass = iv_devclass. -file-path = iv_path. -file-filename = iv_filename. -file-sha1 = iv_sha1. ENDMETHOD. METHOD add_state. FIELD-SYMBOLS: LIKE LINE OF mt_state. APPEND INITIAL LINE TO mt_state ASSIGNING . -path = iv_path. -filename = iv_filename. -sha1 = iv_sha1. ENDMETHOD. METHOD run. DATA: lt_results TYPE zif_abapgit_definitions=>ty_results_tt, lo_dot TYPE REF TO zcl_abapgit_dot_abapgit. lo_dot = zcl_abapgit_dot_abapgit=>build_default( ). lo_dot->set_starting_folder( '/' ). "" assumed by unit tests lt_results = zcl_abapgit_file_status=>calculate_status( iv_devclass = iv_devclass io_dot = lo_dot it_local = mt_local it_remote = mt_remote it_cur_state = mt_state ). CREATE OBJECT ro_result EXPORTING it_results = lt_results. ENDMETHOD. ENDCLASS. CLASS ltcl_calculate_status DEFINITION DEFERRED. CLASS zcl_abapgit_file_status DEFINITION LOCAL FRIENDS ltcl_calculate_status. CLASS ltcl_calculate_status DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL. PRIVATE SECTION. DATA: mo_helper TYPE REF TO ltcl_status_helper, mo_result TYPE REF TO lcl_status_result. METHODS: setup, only_remote FOR TESTING RAISING zcx_abapgit_exception, only_local FOR TESTING RAISING zcx_abapgit_exception, match FOR TESTING RAISING zcx_abapgit_exception, diff FOR TESTING RAISING zcx_abapgit_exception, moved FOR TESTING RAISING zcx_abapgit_exception, local_outside_main FOR TESTING RAISING zcx_abapgit_exception, complete FOR TESTING RAISING zcx_abapgit_exception, deleted_remotely FOR TESTING RAISING zcx_abapgit_exception. ENDCLASS. CLASS ltcl_calculate_status IMPLEMENTATION. METHOD setup. CREATE OBJECT mo_helper. ENDMETHOD. METHOD moved. mo_helper->add_local( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_filename = '$$zdoma1.doma.xml' iv_path = '/foo/' iv_devclass = 'FOO' iv_sha1 = 'D1' ). mo_helper->add_remote( iv_filename = '$$zdoma1.doma.xml' iv_path = '/bar/' iv_sha1 = 'D1' ). mo_helper->add_tadir( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_devclass = 'FOO' ). mo_result = mo_helper->run( iv_devclass = 'FOO' ). mo_result->assert_lines( iv_lines = 2 iv_msg = 'there must be a status calculated for both files, they are in different folders' ). ENDMETHOD. METHOD only_remote. mo_helper->add_remote( iv_filename = '$$zdoma1.doma.xml' iv_sha1 = 'D1' ). mo_result = mo_helper->run( ). mo_result->assert_lines( 1 ). cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-rstate exp = zif_abapgit_definitions=>c_state-added ). ENDMETHOD. METHOD only_local. mo_helper->add_local( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_filename = '$$zdoma1.doma.xml' iv_sha1 = 'D1' ). mo_result = mo_helper->run( ). mo_result->assert_lines( 1 ). cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-lstate exp = zif_abapgit_definitions=>c_state-added ). ENDMETHOD. METHOD match. mo_helper->add_local( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_filename = '$$zdoma1.doma.xml' iv_sha1 = 'D1' ). mo_helper->add_remote( iv_filename = '$$zdoma1.doma.xml' iv_sha1 = 'D1' ). mo_result = mo_helper->run( ). mo_result->assert_lines( 1 ). cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-match exp = abap_true ). ENDMETHOD. METHOD diff. mo_helper->add_local( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_filename = '$$zdoma1.doma.xml' iv_sha1 = '12345' ). mo_helper->add_remote( iv_filename = '$$zdoma1.doma.xml' iv_sha1 = '54321' ). mo_result = mo_helper->run( ). mo_result->assert_lines( 1 ). cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-lstate exp = zif_abapgit_definitions=>c_state-modified ). cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-rstate exp = zif_abapgit_definitions=>c_state-modified ). ENDMETHOD. METHOD local_outside_main. mo_helper->add_tadir( iv_obj_type = 'DOMA' iv_obj_name = '$$ZDOMA1' iv_devclass = '$OUTSIDE$' ). mo_helper->add_remote( iv_filename = '$$zdoma1.doma.xml' iv_sha1 = '54321' ). mo_result = mo_helper->run( ). mo_result->assert_lines( 1 ). "" it should appear as not existing locally cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-rstate exp = zif_abapgit_definitions=>c_state-added ). ENDMETHOD. METHOD complete. DATA: ls_line TYPE zif_abapgit_definitions=>ty_result, lv_act TYPE c LENGTH 3, lv_exp TYPE c LENGTH 3. mo_helper->add_local( iv_path = '/' iv_filename = '.abapgit.xml' iv_sha1 = '1017' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_created_locally.prog.abap' iv_sha1 = '1001' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_created_locally.prog.xml' iv_sha1 = '1022' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_deleted_remotely.prog.abap' iv_sha1 = '1016' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_deleted_remotely.prog.xml' iv_sha1 = '1003' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_modified_both.prog.abap' iv_sha1 = '1028' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_modified_both.prog.xml' iv_sha1 = '1032' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_modified_locally.prog.abap' iv_sha1 = '1023' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_modified_locally.prog.xml' iv_sha1 = '1033' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_modified_remotely.prog.abap' iv_sha1 = '1018' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_modified_remotely.prog.xml' iv_sha1 = '1011' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_mod_del.prog.abap' iv_sha1 = '1012' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_mod_del.prog.xml' iv_sha1 = '1006' ). mo_helper->add_local( iv_path = '/src/' iv_filename = 'package.devc.xml' iv_sha1 = '1027' ). mo_helper->add_remote( iv_path = '/' iv_filename = '.abapgit.xml' iv_sha1 = '1017' ). mo_helper->add_remote( iv_path = '/' iv_filename = 'README.md' iv_sha1 = '1007' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'package.devc.xml' iv_sha1 = '1027' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_created_remotely.prog.abap' iv_sha1 = '1025' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_created_remotely.prog.xml' iv_sha1 = '1015' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_del_mod.prog.abap' iv_sha1 = '1024' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_del_mod.prog.xml' iv_sha1 = '1013' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_deleted_locally.prog.abap' iv_sha1 = '1008' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_deleted_locally.prog.xml' iv_sha1 = '1009' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_modified_both.prog.abap' iv_sha1 = '1002' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_modified_both.prog.xml' iv_sha1 = '1030' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_modified_locally.prog.abap' iv_sha1 = '1026' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_modified_locally.prog.xml' iv_sha1 = '1021' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_modified_remotely.prog.abap' iv_sha1 = '1019' ). mo_helper->add_remote( iv_path = '/src/' iv_filename = 'ztest_modified_remotely.prog.xml' iv_sha1 = '1031' ). mo_helper->add_state( iv_path = '/' iv_filename = '.abapgit.xml' iv_sha1 = '1017' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'package.devc.xml' iv_sha1 = '1027' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_deleted_locally.prog.abap' iv_sha1 = '1008' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_deleted_locally.prog.xml' iv_sha1 = '1009' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_deleted_remotely.prog.abap' iv_sha1 = '1016' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_deleted_remotely.prog.xml' iv_sha1 = '1003' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_del_mod.prog.abap' iv_sha1 = '1020' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_del_mod.prog.xml' iv_sha1 = '1029' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_modified_both.prog.abap' iv_sha1 = '1010' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_modified_both.prog.xml' iv_sha1 = '1004' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_modified_locally.prog.abap' iv_sha1 = '1026' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_modified_locally.prog.xml' iv_sha1 = '1021' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_modified_remotely.prog.abap' iv_sha1 = '1018' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_modified_remotely.prog.xml' iv_sha1 = '1011' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_mod_del.prog.abap' iv_sha1 = '1014' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_mod_del.prog.xml' iv_sha1 = '1005' ). mo_result = mo_helper->run( ). mo_result->assert_lines( 21 ). DO 21 TIMES. ls_line = mo_result->get_line( sy-index ). lv_act+0(1) = ls_line-match. lv_act+1(1) = ls_line-lstate. lv_act+2(1) = ls_line-rstate. CASE sy-index. WHEN 1. lv_exp = 'X '. WHEN 2. lv_exp = ' A'. WHEN 3. lv_exp = 'X '. WHEN 4 OR 5. lv_exp = ' A '. WHEN 6 OR 7. lv_exp = ' A'. WHEN 8 OR 9. lv_exp = ' DM'. WHEN 10 OR 11. lv_exp = ' D '. WHEN 12 OR 13. lv_exp = ' D'. WHEN 14 OR 15. lv_exp = ' MD'. WHEN 16 OR 17. lv_exp = ' MM'. WHEN 18 OR 19. lv_exp = ' M '. WHEN 20 OR 21. lv_exp = ' M'. ENDCASE. cl_abap_unit_assert=>assert_equals( act = lv_act exp = lv_exp msg = |Line { sy-index }: { ls_line-filename }| ). ENDDO. ENDMETHOD. METHOD deleted_remotely. DATA: ls_line TYPE zif_abapgit_definitions=>ty_result, lv_act TYPE c LENGTH 3, lv_exp TYPE c LENGTH 3. mo_helper->add_local( iv_path = '/src/' iv_filename = 'ztest_deleted_remotely.prog.abap' iv_sha1 = '1016' ). mo_helper->add_state( iv_path = '/src/' iv_filename = 'ztest_deleted_remotely.prog.abap' iv_sha1 = '2016' ). "" different checksum mo_result = mo_helper->run( ). mo_result->assert_lines( 1 ). "" it should appear as deleted remotely cl_abap_unit_assert=>assert_equals( act = mo_result->get_line( 1 )-rstate exp = zif_abapgit_definitions=>c_state-deleted ). ENDMETHOD. ENDCLASS. ",8114,False,1665.0214393326237,median "CLASS zcl_abapgit_gui_page_diff DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page CREATE PUBLIC. PUBLIC SECTION. TYPES: BEGIN OF ty_file_diff, path TYPE string, filename TYPE string, obj_type TYPE string, obj_name TYPE string, lstate TYPE char1, rstate TYPE char1, fstate TYPE char1, "" FILE state - Abstraction for shorter ifs o_diff TYPE REF TO zcl_abapgit_diff, changed_by TYPE xubname, type TYPE string, END OF ty_file_diff. TYPES: ty_file_diffs TYPE STANDARD TABLE OF ty_file_diff WITH NON-UNIQUE DEFAULT KEY WITH NON-UNIQUE SORTED KEY secondary COMPONENTS path filename. CONSTANTS: BEGIN OF c_fstate, local TYPE char1 VALUE 'L', remote TYPE char1 VALUE 'R', both TYPE char1 VALUE 'B', END OF c_fstate. METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception. METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION. PROTECTED SECTION. DATA mv_unified TYPE abap_bool VALUE abap_true ##NO_TEXT. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mt_diff_files TYPE ty_file_diffs . METHODS get_normalized_fname_with_path IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(rv_filename) TYPE string . METHODS normalize_path IMPORTING !iv_path TYPE string RETURNING VALUE(rv_normalized) TYPE string . METHODS normalize_filename IMPORTING !iv_filename TYPE string RETURNING VALUE(rv_normalized) TYPE string . METHODS add_menu_end IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS calculate_diff IMPORTING !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception . METHODS add_menu_begin IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_table_head_non_unified IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS render_beacon_begin_of_row IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS render_diff_head_after_state IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS insert_nav RETURNING VALUE(rv_insert_nav) TYPE abap_bool . METHODS render_line_split_row IMPORTING !ii_html TYPE REF TO zif_abapgit_html !iv_filename TYPE string !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_index TYPE sy-tabix !iv_fstate TYPE char1 !iv_new TYPE string !iv_old TYPE string RAISING zcx_abapgit_exception . METHODS build_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_content REDEFINITION . PRIVATE SECTION. CONSTANTS: BEGIN OF c_actions, toggle_unified TYPE string VALUE 'toggle_unified', END OF c_actions . DATA mt_delayed_lines TYPE zif_abapgit_definitions=>ty_diffs_tt . DATA mv_repo_key TYPE zif_abapgit_persistence=>ty_repo-key . DATA mv_seed TYPE string . "" Unique page id to bind JS sessionStorage METHODS render_diff IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_diff_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_table_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_beacon IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_line_split IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_filename TYPE string !iv_fstate TYPE char1 !iv_index TYPE sy-tabix RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_line_unified IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff OPTIONAL RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS append_diff IMPORTING !it_remote TYPE zif_abapgit_definitions=>ty_files_tt !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !is_status TYPE zif_abapgit_definitions=>ty_result RAISING zcx_abapgit_exception . METHODS is_binary IMPORTING !iv_d1 TYPE xstring !iv_d2 TYPE xstring RETURNING VALUE(rv_yes) TYPE abap_bool . METHODS add_jump_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS add_filter_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_lines IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_table_head_unified IMPORTING !ii_html TYPE REF TO zif_abapgit_html . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS filter_diff_by_files IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_stage_tt CHANGING !ct_diff_files TYPE ty_file_diffs . ENDCLASS. CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION. METHOD add_filter_sub_menu. DATA: lo_sub_filter TYPE REF TO zcl_abapgit_html_toolbar, lt_types TYPE string_table, lt_users TYPE string_table. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files, TYPE string. "" Get unique LOOP AT mt_diff_files ASSIGNING . APPEND -type TO lt_types. APPEND -changed_by TO lt_users. ENDLOOP. SORT lt_types. DELETE ADJACENT DUPLICATES FROM lt_types. SORT lt_users. DELETE ADJACENT DUPLICATES FROM lt_users. IF lines( lt_types ) > 1 OR lines( lt_users ) > 1. CREATE OBJECT lo_sub_filter EXPORTING iv_id = 'diff-filter'. "" File types IF lines( lt_types ) > 1. lo_sub_filter->add( iv_txt = 'TYPE' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_types ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'type' iv_chk = abap_true ). ENDLOOP. ENDIF. "" Changed by IF lines( lt_users ) > 1. lo_sub_filter->add( iv_txt = 'CHANGED BY' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_users ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'changed-by' iv_chk = abap_true ). ENDLOOP. ENDIF. io_menu->add( iv_txt = 'Filter' io_sub = lo_sub_filter ). ENDIF. ENDMETHOD. METHOD add_jump_sub_menu. DATA: lo_sub_jump TYPE REF TO zcl_abapgit_html_toolbar, lv_jump_target TYPE string. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files. CREATE OBJECT lo_sub_jump EXPORTING iv_id = 'jump'. LOOP AT mt_diff_files ASSIGNING . lv_jump_target = -path && -filename. lo_sub_jump->add( iv_id = |li_jump_{ sy-tabix }| iv_txt = lv_jump_target iv_typ = zif_abapgit_html=>c_action_type-onclick ). ENDLOOP. io_menu->add( iv_txt = 'Jump' io_sub = lo_sub_jump ). ENDMETHOD. METHOD add_menu_begin. ENDMETHOD. METHOD add_menu_end. io_menu->add( iv_txt = 'Split/Unified view' iv_act = c_actions-toggle_unified ). ENDMETHOD. METHOD append_diff. DATA: lv_offs TYPE i, ls_r_dummy LIKE LINE OF it_remote ##NEEDED, ls_l_dummy LIKE LINE OF it_local ##NEEDED. FIELD-SYMBOLS: LIKE LINE OF it_remote, LIKE LINE OF it_local, LIKE LINE OF mt_diff_files. READ TABLE it_remote ASSIGNING WITH KEY filename = is_status-filename path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_r_dummy TO . ENDIF. READ TABLE it_local ASSIGNING WITH KEY file-filename = is_status-filename file-path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_l_dummy TO . ENDIF. IF IS INITIAL AND IS INITIAL. zcx_abapgit_exception=>raise( |DIFF: file not found { is_status-filename }| ). ENDIF. APPEND INITIAL LINE TO mt_diff_files ASSIGNING . -path = is_status-path. -filename = is_status-filename. -obj_type = is_status-obj_type. -obj_name = is_status-obj_name. -lstate = is_status-lstate. -rstate = is_status-rstate. IF -lstate IS NOT INITIAL AND -rstate IS NOT INITIAL. -fstate = c_fstate-both. ELSEIF -lstate IS NOT INITIAL. -fstate = c_fstate-local. ELSE. ""rstate IS NOT INITIAL, lstate = empty. -fstate = c_fstate-remote. ENDIF. "" Changed by IF -item-obj_type IS NOT INITIAL. -changed_by = zcl_abapgit_objects=>changed_by( -item ). ENDIF. IF -changed_by IS INITIAL. -changed_by = zcl_abapgit_objects_super=>c_user_unknown. ENDIF. "" Extension IF -file-filename IS NOT INITIAL. -type = reverse( -file-filename ). ELSE. -type = reverse( -filename ). ENDIF. FIND FIRST OCCURRENCE OF '.' IN -type MATCH OFFSET lv_offs. -type = reverse( substring( val = -type len = lv_offs ) ). IF -type <> 'xml' AND -type <> 'abap'. -type = 'other'. ENDIF. IF -type = 'other' AND is_binary( iv_d1 = -data iv_d2 = -file-data ) = abap_true. -type = 'binary'. ENDIF. "" Diff data IF -type <> 'binary'. IF -fstate = c_fstate-remote. "" Remote file leading changes CREATE OBJECT -o_diff EXPORTING iv_new = -data iv_old = -file-data. ELSE. "" Local leading changes or both were modified CREATE OBJECT -o_diff EXPORTING iv_new = -file-data iv_old = -data. ENDIF. ENDIF. ENDMETHOD. METHOD build_menu. CREATE OBJECT ro_menu. add_menu_begin( ro_menu ). add_jump_sub_menu( ro_menu ). add_filter_sub_menu( ro_menu ). add_menu_end( ro_menu ). ENDMETHOD. METHOD calculate_diff. DATA: lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_status TYPE zif_abapgit_definitions=>ty_results_tt. FIELD-SYMBOLS: LIKE LINE OF lt_status. CLEAR: mt_diff_files. lt_remote = mo_repo->get_files_remote( ). lt_local = mo_repo->get_files_local( ). mo_repo->reset_status( ). lt_status = mo_repo->status( ). IF is_file IS NOT INITIAL. "" Diff for one file READ TABLE lt_status ASSIGNING WITH KEY path = is_file-path filename = is_file-filename. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ELSEIF is_object IS NOT INITIAL. "" Diff for whole object LOOP AT lt_status ASSIGNING WHERE obj_type = is_object-obj_type AND obj_name = is_object-obj_name AND match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ELSE. "" Diff for the whole repo SORT lt_status BY path ASCENDING filename ASCENDING. LOOP AT lt_status ASSIGNING WHERE match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ENDIF. filter_diff_by_files( EXPORTING it_files = it_files CHANGING ct_diff_files = mt_diff_files ). ENDMETHOD. METHOD constructor. DATA: lv_ts TYPE timestamp. super->constructor( ). ms_control-page_title = 'Diff'. mv_unified = zcl_abapgit_persistence_user=>get_instance( )->get_diff_unified( ). mv_repo_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). GET TIME STAMP FIELD lv_ts. mv_seed = |diff{ lv_ts }|. "" Generate based on time ASSERT is_file IS INITIAL OR is_object IS INITIAL. "" just one passed calculate_diff( is_file = is_file is_object = is_object it_files = it_files ). IF lines( mt_diff_files ) = 0. zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ). ENDIF. ms_control-page_menu = build_menu( ). ENDMETHOD. METHOD filter_diff_by_files. FIELD-SYMBOLS: TYPE ty_file_diff. IF lines( it_files ) = 0. RETURN. ENDIF. "" Diff only for specified files LOOP AT ct_diff_files ASSIGNING . READ TABLE it_files TRANSPORTING NO FIELDS WITH KEY file-filename = -filename. IF sy-subrc <> 0. DELETE TABLE ct_diff_files FROM . ENDIF. ENDLOOP. ENDMETHOD. METHOD get_normalized_fname_with_path. rv_filename = normalize_path( is_diff-path ) && `_` && normalize_filename( is_diff-filename ). ENDMETHOD. METHOD insert_nav. ENDMETHOD. METHOD is_binary. FIELD-SYMBOLS LIKE iv_d1. IF iv_d1 IS NOT INITIAL. "" One of them might be new and so empty ASSIGN iv_d1 TO . ELSE. ASSIGN iv_d2 TO . ENDIF. rv_yes = zcl_abapgit_utils=>is_binary( ). ENDMETHOD. METHOD normalize_filename. rv_normalized = replace( val = iv_filename sub = '.' occ = 0 with = '_' ). ENDMETHOD. METHOD normalize_path. rv_normalized = replace( val = iv_path sub = '/' occ = 0 with = '_' ). ENDMETHOD. METHOD render_beacon. DATA: lv_beacon TYPE string, lt_beacons TYPE zif_abapgit_definitions=>ty_string_tt. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_diff_line-beacon > 0. lt_beacons = is_diff-o_diff->get_beacons( ). READ TABLE lt_beacons INTO lv_beacon INDEX is_diff_line-beacon. ELSE. lv_beacon = '---'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). render_beacon_begin_of_row( ii_html = ri_html is_diff = is_diff ). IF mv_unified = abap_true. ri_html->add( '' ). ri_html->add( '' ). ri_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ELSE. ri_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_beacon_begin_of_row. ii_html->add( '' ). ENDMETHOD. METHOD render_content. DATA: ls_diff_file LIKE LINE OF mt_diff_files, li_progress TYPE REF TO zif_abapgit_progress. CREATE OBJECT ri_html TYPE zcl_abapgit_html. li_progress = zcl_abapgit_progress=>get_instance( lines( mt_diff_files ) ). ri_html->add( `
` ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( mo_repo ) ). ri_html->add( `
` ). ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_js_error_banner( ) ). LOOP AT mt_diff_files INTO ls_diff_file. li_progress->show( iv_current = sy-tabix iv_text = |Render Diff - { ls_diff_file-filename }| ). ri_html->add( render_diff( ls_diff_file ) ). ENDLOOP. IF sy-subrc <> 0. ri_html->add( |No more diffs| ). ENDIF. ri_html->add( '
' ). register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_diff. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( render_diff_head( is_diff ) ). "" Content IF is_diff-type <> 'binary'. ri_html->add( '
' ). ri_html->add( || ). ri_html->add( render_table_head( is_diff ) ). ri_html->add( render_lines( is_diff ) ). ri_html->add( '
' ). ELSE. ri_html->add( '
' ). ri_html->add( 'The content seems to be binary.' ). ri_html->add( 'Cannot display as diff.' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_diff_head. DATA: ls_stats TYPE zif_abapgit_definitions=>ty_count, lv_adt_link TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '
' ). ri_html->add_icon( iv_name = 'chevron-down' iv_hint = 'Collapse/Expand' iv_class = 'cursor-pointer' iv_onclick = 'onDiffCollapse(event)' ). IF is_diff-type <> 'binary'. ls_stats = is_diff-o_diff->stats( ). IF is_diff-fstate = c_fstate-both. "" Merge stats into 'update' if both were changed ls_stats-update = ls_stats-update + ls_stats-insert + ls_stats-delete. CLEAR: ls_stats-insert, ls_stats-delete. ENDIF. ri_html->add( |+ { ls_stats-insert }| ). ri_html->add( |- { ls_stats-delete }| ). ri_html->add( |~ { ls_stats-update }| ). ENDIF. "" no links for nonexistent or deleted objects IF NOT ( is_diff-lstate = zif_abapgit_definitions=>c_state-unchanged AND is_diff-rstate = zif_abapgit_definitions=>c_state-added ) AND NOT is_diff-lstate = zif_abapgit_definitions=>c_state-deleted. lv_adt_link = ri_html->a( iv_txt = |{ is_diff-path }{ is_diff-filename }| iv_typ = zif_abapgit_html=>c_action_type-sapevent iv_act = |jump?TYPE={ is_diff-obj_type }&NAME={ is_diff-obj_name }| ). ENDIF. IF lv_adt_link IS NOT INITIAL. ri_html->add( |{ lv_adt_link }| ). ELSE. ri_html->add( |{ is_diff-path }{ is_diff-filename }| ). ENDIF. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_diff-lstate iv_rstate = is_diff-rstate ) ). render_diff_head_after_state( ii_html = ri_html is_diff = is_diff ). ri_html->add( 'Last Changed by: ' ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_user_name( is_diff-changed_by ) ). ri_html->add( '' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_diff_head_after_state. IF is_diff-fstate = c_fstate-both AND mv_unified = abap_true. ii_html->add( 'Attention: Unified mode' && ' highlighting for MM assumes local file is newer ! ' ). ENDIF. ENDMETHOD. METHOD render_lines. DATA: lo_highlighter TYPE REF TO zcl_abapgit_syntax_highlighter, lt_diffs TYPE zif_abapgit_definitions=>ty_diffs_tt, lv_insert_nav TYPE abap_bool, lv_tabix TYPE syst-tabix. FIELD-SYMBOLS LIKE LINE OF lt_diffs. lo_highlighter = zcl_abapgit_syntax_highlighter=>create( is_diff-filename ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. lt_diffs = is_diff-o_diff->get( ). lv_insert_nav = insert_nav( ). LOOP AT lt_diffs ASSIGNING . lv_tabix = sy-tabix. IF -short = abap_false. lv_insert_nav = abap_true. CONTINUE. ENDIF. IF lv_insert_nav = abap_true. "" Insert separator line with navigation ri_html->add( render_beacon( is_diff_line = is_diff = is_diff ) ). lv_insert_nav = abap_false. ENDIF. IF lo_highlighter IS BOUND. -new = lo_highlighter->process_line( -new ). -old = lo_highlighter->process_line( -old ). ELSE. -new = escape( val = -new format = cl_abap_format=>e_html_attr ). -old = escape( val = -old format = cl_abap_format=>e_html_attr ). ENDIF. CONDENSE -new_num. ""get rid of leading spaces CONDENSE -old_num. IF mv_unified = abap_true. ri_html->add( render_line_unified( is_diff_line = ) ). ELSE. ri_html->add( render_line_split( is_diff_line = iv_filename = get_normalized_fname_with_path( is_diff ) iv_fstate = is_diff-fstate iv_index = lv_tabix ) ). ENDIF. ENDLOOP. IF mv_unified = abap_true. ri_html->add( render_line_unified( ) ). "" Release delayed lines ENDIF. ENDMETHOD. METHOD render_line_split. DATA: lv_new TYPE string, lv_old TYPE string, lv_mark TYPE string, lv_bg TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" New line lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-insert. lv_bg = ' diff_ins'. lv_mark = `+`. ENDIF. ENDIF. lv_new = || && |{ lv_mark }| && |{ is_diff_line-new }|. "" Old line CLEAR lv_bg. lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-delete. lv_bg = ' diff_del'. lv_mark = `-`. ENDIF. ENDIF. lv_old = || && |{ lv_mark }| && |{ is_diff_line-old }|. "" render line, inverse sides if remote is newer ri_html->add( '' ). render_line_split_row( ii_html = ri_html iv_filename = iv_filename is_diff_line = is_diff_line iv_index = iv_index iv_fstate = iv_fstate iv_old = lv_old iv_new = lv_new ). ri_html->add( '' ). ENDMETHOD. METHOD render_line_split_row. IF iv_fstate = c_fstate-remote. "" Remote file leading changes ii_html->add( iv_old ). "" local ii_html->add( iv_new ). "" remote ELSE. "" Local leading changes or both were modified ii_html->add( iv_new ). "" local ii_html->add( iv_old ). "" remote ENDIF. ENDMETHOD. METHOD render_line_unified. FIELD-SYMBOLS LIKE LINE OF mt_delayed_lines. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" Release delayed subsequent update lines IF is_diff_line-result <> zif_abapgit_definitions=>c_diff-update. LOOP AT mt_delayed_lines ASSIGNING . ri_html->add( '' ). ri_html->add( |-old_num }"">| && || && |-| && |{ -old }| ). ri_html->add( '' ). ENDLOOP. LOOP AT mt_delayed_lines ASSIGNING . ri_html->add( '' ). ri_html->add( || && |-new_num }"">| && |+| && |{ -new }| ). ri_html->add( '' ). ENDLOOP. CLEAR mt_delayed_lines. ENDIF. ri_html->add( '' ). CASE is_diff_line-result. WHEN zif_abapgit_definitions=>c_diff-update. APPEND is_diff_line TO mt_delayed_lines. "" Delay output of subsequent updates WHEN zif_abapgit_definitions=>c_diff-insert. ri_html->add( || && || && |+| && |{ is_diff_line-new }| ). WHEN zif_abapgit_definitions=>c_diff-delete. ri_html->add( || && || && |-| && |{ is_diff_line-old }| ). WHEN OTHERS. ""none ri_html->add( || && || && | | && |{ is_diff_line-old }| ). ENDCASE. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( 'restoreScrollPosition();' ). ri_html->add( 'var gHelper = new DiffHelper({' ). ri_html->add( | seed: ""{ mv_seed }"",| ). ri_html->add( ' ids: {' ). ri_html->add( ' jump: ""jump"",' ). ri_html->add( ' diffList: ""diff-list"",' ). ri_html->add( ' filterMenu: ""diff-filter"",' ). ri_html->add( ' }' ). ri_html->add( '});' ). ri_html->add( 'addMarginBottom();' ). ri_html->add( 'var gGoJumpPalette = new CommandPalette(enumerateJumpAllFiles, {' ). ri_html->add( ' toggleKey: ""F2"",' ). ri_html->add( ' hotkeyDescription: ""Jump to file ...""' ). ri_html->add( '});' ). "" Feature for selecting ABAP code by column and copy to clipboard ri_html->add( 'var columnSelection = new DiffColumnSelection();' ). ENDMETHOD. METHOD render_table_head. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( '' ). IF mv_unified = abap_true. render_table_head_unified( ri_html ). ELSE. render_table_head_non_unified( ii_html = ri_html is_diff = is_diff ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_table_head_non_unified. ii_html->add( '' ). ii_html->add( '' ). ii_html->add( 'LOCAL' ). ii_html->add( '' ). ii_html->add( '' ). ii_html->add( 'REMOTE' ). ENDMETHOD. METHOD render_table_head_unified. ii_html->add( 'old' ). ii_html->add( 'new' ). ii_html->add( '' ). ii_html->add( 'code' ). ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. CASE ii_event->mv_action. WHEN c_actions-toggle_unified. "" Toggle file diplay mv_unified = zcl_abapgit_persistence_user=>get_instance( )->toggle_diff_unified( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). ENDCASE. ENDMETHOD. ENDCLASS. ",8133,False,1520.3204499224819,median "class ltcl_mockup_stub_factory_test definition final for testing duration short risk level harmless. private section. methods main_test_stub for testing. methods connect_deep_corresponding for testing raising zcx_mockup_loader_error. methods connect_and_overrides for testing raising zcx_mockup_loader_error. methods build_config for testing raising zcx_mockup_loader_error. methods build_config_filter_type for testing raising zcx_mockup_loader_error. methods build_config_multi_filter_neg for testing raising zcx_mockup_loader_error. methods instantiation for testing. methods forward_method for testing. methods proxy_forwarding for testing raising zcx_mockup_loader_error. methods filtering for testing raising zcx_mockup_loader_error. methods filtering_w_const for testing raising zcx_mockup_loader_error. methods filtering_w_struc_param for testing raising zcx_mockup_loader_error. methods filtering_multi for testing raising zcx_mockup_loader_error. methods filtering_multi_and_const for testing raising zcx_mockup_loader_error. methods returning_value for testing raising zcx_mockup_loader_error. methods corresponding for testing raising zcx_mockup_loader_error. methods filter_by_range_param for testing raising zcx_mockup_loader_error. methods controls for testing raising zcx_mockup_loader_error. methods const_value for testing raising zcx_mockup_loader_error. methods connect_string_positive for testing raising zcx_mockup_loader_error. methods parse_string_negative for testing. methods parse_string_positive for testing raising zcx_mockup_loader_error. methods connect_string_multi for testing raising zcx_mockup_loader_error. methods connect_string_multi_const for testing raising zcx_mockup_loader_error. methods connect_string_multi_1value for testing raising zcx_mockup_loader_error. "" HELPERS methods get_ml returning value(ro_ml) type ref to zcl_mockup_loader raising zcx_mockup_loader_error. methods get_factory importing io_ml type ref to zcl_mockup_loader io_proxy type ref to zif_mockup_loader_stub_dummy optional returning value(ro_factory) type ref to zcl_mockup_loader_stub_factory raising zcx_mockup_loader_error. methods get_sflights importing io_ml type ref to zcl_mockup_loader returning value(rt_tab) type flighttab raising zcx_mockup_loader_error. endclass. class lcl_test_proxy_target definition. public section. interfaces zif_mockup_loader_stub_dummy. class-methods create returning value(ro_instance) type ref to lcl_test_proxy_target. endclass. class lcl_test_proxy_target implementation. method create. create object ro_instance. endmethod. method zif_mockup_loader_stub_dummy~proxy_test. r_val = |{ i_p1 } { i_p2 }|. endmethod. method zif_mockup_loader_stub_dummy~tab_return. endmethod. method zif_mockup_loader_stub_dummy~tab_return_w_date. endmethod. method zif_mockup_loader_stub_dummy~tab_return_by_range. endmethod. method zif_mockup_loader_stub_dummy~tab_return_extract_by_date. endmethod. method zif_mockup_loader_stub_dummy~tab_return_w_struc_param. endmethod. method zif_mockup_loader_stub_dummy~tab_export. endmethod. method zif_mockup_loader_stub_dummy~tab_change. endmethod. method zif_mockup_loader_stub_dummy~wrong_return. endmethod. method zif_mockup_loader_stub_dummy~wrong_sift. endmethod. method zif_mockup_loader_stub_dummy~gen_param_target. endmethod. method zif_mockup_loader_stub_dummy~return_value. endmethod. method zif_mockup_loader_stub_dummy~return_value_w_date. endmethod. method zif_mockup_loader_stub_dummy~return_deep. endmethod. endclass. class lcl_test_base definition final. public section. class-methods main_test importing iv_factory_classname type seoclsname. endclass. class lcl_test_base implementation. method main_test. data lo_dc type ref to zcl_mockup_loader_stub_factory. data li_if type ref to zif_mockup_loader_stub_dummy. data lo_ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lo_ex type ref to zcx_mockup_loader_error. try. lo_ml = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_EXAMPLE' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). create object lo_dc type (iv_factory_classname) exporting ii_ml_instance = lo_ml i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo_dc->connect_method( i_sift_param = 'I_CONNID' i_mock_tab_key = 'CONNID' i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). lo_dc->connect_method( i_method_name = 'TAB_EXPORT' i_mock_name = 'EXAMPLE/sflight' i_output_param = 'E_TAB' ). lo_dc->connect_method( i_method_name = 'TAB_CHANGE' i_mock_name = 'EXAMPLE/sflight' i_output_param = 'C_TAB' ). li_if ?= lo_dc->generate_stub( ). lo_ml->load_data( exporting i_obj = 'EXAMPLE/sflight' i_strict = abap_false importing e_container = lt_exp ). delete lt_exp where connid <> '1000'. data lt_res type flighttab. lt_res = li_if->tab_return( i_connid = '1000' ). cl_abap_unit_assert=>assert_equals( act = lt_res exp = lt_exp ). lo_ml->load_data( exporting i_obj = 'EXAMPLE/sflight' i_strict = abap_false importing e_container = lt_exp ). clear lt_res. li_if->tab_export( exporting i_connid = '1000' importing e_tab = lt_res ). cl_abap_unit_assert=>assert_equals( act = lt_res exp = lt_exp ). clear lt_res. li_if->tab_change( exporting i_connid = '1000' changing c_tab = lt_res ). cl_abap_unit_assert=>assert_equals( act = lt_res exp = lt_exp ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( ). endtry. endmethod. endclass. define assert_excode. cl_abap_unit_assert=>assert_not_initial( act = lo_ex ). cl_abap_unit_assert=>assert_equals( exp = &1 act = lo_ex->code ). end-of-definition. class zcl_mockup_loader_stub_factory definition local friends ltcl_mockup_stub_factory_test. class ltcl_mockup_stub_factory_test implementation. method main_test_stub. lcl_test_base=>main_test( 'ZCL_MOCKUP_LOADER_STUB_FACTORY' ). endmethod. method connect_deep_corresponding. data lo_ml type ref to zcl_mockup_loader. data lo_dc type ref to zcl_mockup_loader_stub_factory. data li_if type ref to zif_mockup_loader_stub_dummy. data lt_exp type zif_mockup_loader_stub_dummy=>tt_deep. lo_ml = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_EXAMPLE' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). create object lo_dc exporting ii_ml_instance = lo_ml i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo_dc->connect_method( i_sift_param = 'I_CONNID' i_mock_tab_key = 'CONNID' i_method_name = 'RETURN_DEEP' i_deep = abap_true i_corresponding = abap_true i_mock_name = 'EXAMPLE/sflight' ). li_if ?= lo_dc->generate_stub( ). lo_ml->load_data( exporting i_obj = 'EXAMPLE/sflight' i_strict = abap_false i_corresponding = abap_true i_deep = abap_true importing e_container = lt_exp ). delete lt_exp where connid <> '2000'. data lt_res like lt_exp. lt_res = li_if->return_deep( i_connid = '2000' ). cl_abap_unit_assert=>assert_equals( act = lt_res exp = lt_exp ). endmethod. method connect_and_overrides. data lo_dc type ref to zcl_mockup_loader_stub_factory. data lo_ml type ref to zcl_mockup_loader. data lo_ex type ref to zcx_mockup_loader_error. data ls_config like line of lo_dc->mt_config. lo_ml = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_EXAMPLE' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). create object lo_dc exporting io_proxy_target = lcl_test_proxy_target=>create( ) ii_ml_instance = lo_ml i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo_dc->connect_method( i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). "" Multiple connect try. lo_dc->connect_method( i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>assert_equals( exp = 'MC' act = lo_ex->code ). endtry. try. "" Multiple forward lo_dc->forward_method( 'TAB_RETURN' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>assert_equals( exp = 'MC' act = lo_ex->code ). endtry. "" Override create object lo_dc exporting ii_ml_instance = lo_ml io_proxy_target = lcl_test_proxy_target=>create( ) i_allow_overrides = abap_true i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo_dc->connect_method( i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). lo_dc->connect_method( i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/override' ). cl_abap_unit_assert=>assert_equals( act = lines( lo_dc->mt_config ) exp = 1 ). read table lo_dc->mt_config index 1 into ls_config. cl_abap_unit_assert=>assert_equals( act = ls_config-mock_name exp = 'EXAMPLE/override' ). lo_dc->forward_method( 'TAB_RETURN' ). cl_abap_unit_assert=>assert_equals( act = lines( lo_dc->mt_config ) exp = 1 ). read table lo_dc->mt_config index 1 into ls_config. cl_abap_unit_assert=>assert_equals( act = ls_config-as_proxy exp = abap_true ). endmethod. method build_config. data ld_if type ref to cl_abap_objectdescr. data ls_conf type zif_mockup_loader=>ty_mock_config. data ls_conf_act type zif_mockup_loader=>ty_mock_config. data lo_ex type ref to zcx_mockup_loader_error. ld_if ?= cl_abap_typedescr=>describe_by_name( 'ZIF_MOCKUP_LOADER_STUB_DUMMY' ). try. clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf_act = zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( ). endtry. cl_abap_unit_assert=>assert_equals( act = ls_conf_act-output_param exp = 'R_TAB' ). cl_abap_unit_assert=>assert_equals( act = ls_conf_act-output_pkind exp = 'R' ). cl_abap_unit_assert=>assert_bound( act = ls_conf_act-output_type ). try. "" method missing clear: lo_ex, ls_conf. ls_conf-mock_name = 'EXAMPLE/sflight'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MM'. try. "" mock missing clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MK'. try. "" sift incomplete clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-sift_param = 'I_CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MS'. try. "" sift incomplete clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-mock_tab_key = 'CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MS'. try. "" sift incomplete clear: lo_ex, ls_conf. ls_conf-method_name = '???'. ls_conf-mock_name = 'EXAMPLE/sflight'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MF'. try. "" sift not found clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-sift_param = 'X_CONNID'. ls_conf-mock_tab_key = 'CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PF'. try. "" sift has wrong type clear: lo_ex, ls_conf. ls_conf-method_name = 'WRONG_SIFT'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-sift_param = 'I_CONNID'. ls_conf-mock_tab_key = 'CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PE'. try. "" no return clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_EXPORT'. ls_conf-mock_name = 'EXAMPLE/sflight'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MR'. try. "" no param clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-output_param = '???'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PF'. try. "" no param clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-output_param = 'I_CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PI'. try. "" no param clear: lo_ex, ls_conf. ls_conf-method_name = 'WRONG_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PT'. try. "" field only elementary param clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-field_only = 'PRICE'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PL'. try. "" field only + corresponding clear: lo_ex, ls_conf. ls_conf-method_name = 'TAB_RETURN_EXTRACT_BY_DATE'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-corresponding = abap_true. ls_conf-field_only = 'PRICE'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PC'. endmethod. method build_config_filter_type. data ld_if type ref to cl_abap_objectdescr. data ls_conf type zif_mockup_loader=>ty_mock_config. data ls_conf_act type zif_mockup_loader=>ty_mock_config. data lx type ref to zcx_mockup_loader_error. data ld_otype type ref to cl_abap_structdescr. ld_if ?= cl_abap_typedescr=>describe_by_name( 'ZIF_MOCKUP_LOADER_STUB_DUMMY' ). "" Type from param clear ls_conf. ls_conf-method_name = 'RETURN_VALUE_W_DATE'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-mock_tab_key = 'CONNID'. ls_conf-sift_param = 'I_CONNID'. ls_conf-field_only = 'PRICE'. ls_conf_act = zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). ld_otype ?= ls_conf_act-output_type. cl_abap_unit_assert=>assert_equals( exp = 'S_CONN_ID' act = ld_otype->get_component_type( p_name = 'CONNID' )->get_relative_name( ) ). "" Type from const clear ls_conf. ls_conf-method_name = 'RETURN_VALUE_W_DATE'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-mock_tab_key = 'CONNID'. ls_conf-sift_const = '123'. ls_conf-field_only = 'PRICE'. ls_conf_act = zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). ld_otype ?= ls_conf_act-output_type. cl_abap_unit_assert=>assert_equals( exp = 'STRING' act = ld_otype->get_component_type( p_name = 'CONNID' )->get_relative_name( ) ). endmethod. method build_config_multi_filter_neg. data ld_if type ref to cl_abap_objectdescr. data ls_conf type zif_mockup_loader=>ty_mock_config. data lx type ref to zcx_mockup_loader_error. field-symbols like line of ls_conf-filter. ld_if ?= cl_abap_typedescr=>describe_by_name( 'ZIF_MOCKUP_LOADER_STUB_DUMMY' ). try. "" both filters passed clear ls_conf. ls_conf-method_name = 'TAB_RETURN_W_DATE'. ls_conf-mock_name = 'EXAMPLE/sflight'. ls_conf-mock_tab_key = 'CONNID'. ls_conf-sift_param = 'I_CONNID'. append initial line to ls_conf-filter assigning . -mock_tab_key = 'CONNID'. -sift_param = 'I_CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( exp = 'BF' act = lx->code ). endtry. try. "" duplication clear ls_conf. ls_conf-method_name = 'TAB_RETURN_W_DATE'. ls_conf-mock_name = 'EXAMPLE/sflight'. append initial line to ls_conf-filter assigning . -mock_tab_key = 'CONNID'. -sift_param = 'I_CONNID'. append initial line to ls_conf-filter assigning . -mock_tab_key = 'CONNID'. -sift_param = 'I_CONNID'. zcl_mockup_loader_stub_factory=>build_config( id_if_desc = ld_if i_config = ls_conf ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( exp = 'DF' act = lx->code ). endtry. endmethod. method instantiation. data lo type ref to zcl_mockup_loader_stub_factory. data lo_ex type ref to zcx_mockup_loader_error. data lo_ml type ref to zcl_mockup_loader. try. "" wrong interface lo_ml = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_EXAMPLE' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). clear: lo_ex. create object lo exporting ii_ml_instance = lo_ml i_interface_name = 'CHAR1'. catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'IF'. try. "" wrong proxy target clear: lo_ex. create object lo exporting ii_ml_instance = lo_ml io_proxy_target = lo_ml i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'II'. endmethod. method forward_method. data lo type ref to zcl_mockup_loader_stub_factory. data lo_ex type ref to zcx_mockup_loader_error. data lo_ml type ref to zcl_mockup_loader. try. "" no proxy during creation clear: lo_ex. create object lo exporting ii_ml_instance = lo_ml i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo->forward_method( 'PROXY_TEST' ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'PA'. try. "" missing method clear: lo_ex. create object lo exporting ii_ml_instance = lo_ml io_proxy_target = lcl_test_proxy_target=>create( ) i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo->forward_method( 'PROXY_TEST_XXX' ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MF'. try. "" missing method clear: lo_ex. lo->forward_method( 'PROXY_TEST' ). lo->forward_method( 'PROXY_TEST' ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'MC'. endmethod. method proxy_forwarding. data lo type ref to zcl_mockup_loader_stub_factory. data lo_ml type ref to zcl_mockup_loader. data li_if type ref to zif_mockup_loader_stub_dummy. data l_act type string. create object lo exporting ii_ml_instance = lo_ml io_proxy_target = lcl_test_proxy_target=>create( ) i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo->forward_method( 'PROXY_TEST' ). li_if ?= lo->generate_stub( ). l_act = li_if->proxy_test( i_p1 = 'Hello' i_p2 = 123 ). cl_abap_unit_assert=>assert_equals( act = l_act exp = 'Hello 123' ). endmethod. ********************************************************************** method get_ml. ro_ml = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_EXAMPLE' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). endmethod. method get_factory. create object ro_factory exporting ii_ml_instance = io_ml "" get_ml( ) i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY' io_proxy_target = io_proxy. endmethod. method get_sflights. io_ml->load_data( exporting i_obj = 'EXAMPLE/sflight' i_strict = abap_false importing e_container = rt_tab ). endmethod. method filtering. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where connid <> '1000'. factory->connect_method( i_sift_param = 'I_CONNID' i_mock_tab_key = 'CONNID' i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return( i_connid = '1000' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method filtering_multi. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. data lt_filter type zif_mockup_loader=>tty_stub_filter_params. field-symbols like line of lt_filter. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where not ( connid = '2000' and fldate = '20150102' ). append initial line to lt_filter assigning . -mock_tab_key = 'CONNID'. -sift_param = 'I_CONNID'. append initial line to lt_filter assigning . -mock_tab_key = 'FLDATE'. -sift_param = 'I_FLDATE'. factory->connect_method( i_filter = lt_filter i_method_name = 'TAB_RETURN_W_DATE' i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return_w_date( i_connid = '2000' i_fldate = '20150102' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). lt_act = stub->tab_return_w_date( i_connid = '2000' i_fldate = '20150130' ). cl_abap_unit_assert=>assert_initial( lt_act ). endmethod. method filtering_multi_and_const. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. data lt_filter type zif_mockup_loader=>tty_stub_filter_params. field-symbols like line of lt_filter. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where not ( connid = '2000' and fldate = '20150102' ). append initial line to lt_filter assigning . -mock_tab_key = 'CONNID'. -sift_param = 'I_CONNID'. append initial line to lt_filter assigning . -mock_tab_key = 'FLDATE'. -sift_const = '20150102'. factory->connect_method( i_filter = lt_filter i_method_name = 'TAB_RETURN_W_DATE' i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return_w_date( i_connid = '2000' i_fldate = '20150101' ). "" Intentionally different date ! cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). lt_act = stub->tab_return_w_date( i_connid = '2000' i_fldate = '20150130' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method filtering_w_const. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where connid <> '1000'. factory->connect_method( i_sift_const = '1000' i_mock_tab_key = 'CONNID' i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return( i_connid = '2000' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). "" Fail on const and param data lx type ref to zcx_mockup_loader_error. factory = get_factory( ml ). try. factory->connect_method( i_sift_param = 'I_CONNID' i_sift_const = '1000' i_mock_tab_key = 'CONNID' i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'CS' ). endtry. endmethod. method filtering_w_struc_param. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where connid <> '1000'. factory->connect_method( i_sift_param = 'I_PARAMS-CONNID' i_mock_tab_key = 'CONNID' i_method_name = 'TAB_RETURN_W_STRUC_PARAM' i_mock_name = 'EXAMPLE/sflight' ). data call_params type zif_mockup_loader_stub_dummy=>ty_params. call_params-connid = '1000'. stub ?= factory->generate_stub( ). lt_act = stub->tab_return_w_struc_param( i_params = call_params ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method returning_value. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data ls_exp like line of lt_exp. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). read table lt_exp into ls_exp index 1. factory->connect_method( i_sift_param = 'I_CONNID' i_mock_tab_key = 'CONNID' i_field_only = 'PRICE' i_method_name = 'RETURN_VALUE' i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). cl_abap_unit_assert=>assert_equals( act = stub->return_value( i_connid = '1000' ) exp = '100.00' ). cl_abap_unit_assert=>assert_equals( act = stub->return_value( i_connid = '2000' ) exp = '200.00' ). cl_abap_unit_assert=>assert_equals( act = stub->return_value( i_connid = '9999' ) "" Missing record, return initial exp = '' ). endmethod. method corresponding. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp_base type flighttab. data lt_exp type zif_mockup_loader_stub_dummy=>tt_sflight_extract. data lt_act type zif_mockup_loader_stub_dummy=>tt_sflight_extract. field-symbols like line of lt_exp_base. field-symbols like line of lt_exp. ml = get_ml( ). factory = get_factory( ml ). lt_exp_base = get_sflights( ml ). delete lt_exp_base where fldate <> '20150101'. loop at lt_exp_base assigning . append initial line to lt_exp assigning . move-corresponding to . endloop. factory->connect_method( i_sift_param = 'i_fldate' i_mock_tab_key = 'fldate' i_method_name = 'tab_return_extract_by_date' i_corresponding = abap_true i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return_extract_by_date( i_fldate = '20150101' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method filter_by_range_param. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where connid <> '1000'. data lr_range type zif_mockup_loader_stub_dummy=>ty_connid_range. field-symbols like line of lr_range. append initial line to lr_range assigning . -sign = 'I'. -option = 'EQ'. -low = '1000'. factory->connect_method( i_sift_param = 'ir_connid' i_mock_tab_key = 'connid' i_method_name = 'tab_return_by_range' i_mock_name = 'EXAMPLE/sflight' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return_by_range( ir_connid = lr_range ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method controls. data lo_dc type ref to zcl_mockup_loader_stub_factory. data li_if type ref to zif_mockup_loader_stub_dummy. data lo_ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lo_ex type ref to zcx_mockup_loader_error. data li_control type ref to zif_mockup_loader_stub_control. lo_ml = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_EXAMPLE' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). create object lo_dc exporting ii_ml_instance = lo_ml io_proxy_target = lcl_test_proxy_target=>create( ) i_interface_name = 'ZIF_MOCKUP_LOADER_STUB_DUMMY'. lo_dc->connect_method( i_method_name = 'TAB_RETURN' i_mock_name = 'EXAMPLE/sflight' ). lo_dc->connect_method( i_method_name = 'TAB_EXPORT' i_mock_name = 'EXAMPLE/sflight' i_output_param = 'E_TAB' ). lo_dc->connect_method( i_method_name = 'TAB_CHANGE' i_mock_name = 'EXAMPLE/sflight' i_output_param = 'C_TAB' ). lo_dc->forward_method( 'PROXY_TEST' ). li_if ?= lo_dc->generate_stub( ). li_control ?= li_if. data l_act type string. data lt_res type flighttab. data ls_dummy_res like line of lt_res. ls_dummy_res-carrid = 1. lo_ml->load_data( exporting i_obj = 'EXAMPLE/sflight' i_strict = abap_false importing e_container = lt_exp ). "" Calls before disable l_act = li_if->proxy_test( i_p1 = 'Hello' i_p2 = 123 ). cl_abap_unit_assert=>assert_equals( act = l_act exp = 'Hello 123' ). lt_res = li_if->tab_return( i_connid = '1000' ). cl_abap_unit_assert=>assert_equals( act = lt_res exp = lt_exp ). li_if->return_value( '1000' ). "" for counter check li_control->disable( ). "" Calls after disable lt_res = li_if->tab_return( i_connid = '1000' ). cl_abap_unit_assert=>assert_initial( act = lt_res ). append ls_dummy_res to lt_res. li_if->tab_export( exporting i_connid = '1000' importing e_tab = lt_res ). cl_abap_unit_assert=>assert_initial( act = lt_res ). append ls_dummy_res to lt_res. li_if->tab_change( exporting i_connid = '1000' changing c_tab = lt_res ). cl_abap_unit_assert=>assert_initial( act = lt_res ). l_act = li_if->proxy_test( i_p1 = 'Hello' i_p2 = 123 ). cl_abap_unit_assert=>assert_initial( l_act ). "" Call counts cl_abap_unit_assert=>assert_equals( act = li_control->get_call_count( 'TAB_RETURN' ) exp = 1 ). cl_abap_unit_assert=>assert_equals( act = li_control->get_call_count( 'TAB_EXPORT' ) exp = 0 ). cl_abap_unit_assert=>assert_equals( act = li_control->get_call_count( 'TAB_CHANGE' ) exp = 0 ). cl_abap_unit_assert=>assert_equals( act = li_control->get_call_count( 'PROXY_TEST' ) exp = 1 ). cl_abap_unit_assert=>assert_equals( act = li_control->get_call_count( 'RETURN_VALUE' ) exp = 1 ). endmethod. method const_value. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lv_act type sflight-price. ml = get_ml( ). factory = get_factory( ml ). factory->connect_method( i_method_name = 'return_value' i_const_value = '12.34' ). stub ?= factory->generate_stub( ). lv_act = stub->return_value( i_connid = '1000' ). cl_abap_unit_assert=>assert_equals( act = lv_act exp = '12.34' ). "" NEGATIVES data lx type ref to zcx_mockup_loader_error. factory = get_factory( ml ). try . factory->connect_method( i_method_name = 'return_value' i_mock_name = 'non-empty' i_const_value = '12.34' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'CV' ). endtry. try . factory->connect_method( i_method_name = 'tab_return' i_const_value = '12.34' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'CE' ). endtry. endmethod. method connect_string_positive. data factory type ref to zcl_mockup_loader_stub_factory. data ml type ref to zcl_mockup_loader. data ls_config like line of factory->mt_config. ml = get_ml( ). factory = get_factory( io_ml = ml io_proxy = lcl_test_proxy_target=>create( ) ). factory->connect( 'tab_return -> mock_dummy' ). factory->connect( 'proxy_test -> *' ). cl_abap_unit_assert=>assert_equals( act = lines( factory->mt_config ) exp = 2 ). read table factory->mt_config index 1 into ls_config. cl_abap_unit_assert=>assert_equals( act = ls_config-method_name exp = 'TAB_RETURN' ). cl_abap_unit_assert=>assert_equals( act = ls_config-mock_name exp = 'mock_dummy' ). read table factory->mt_config index 2 into ls_config. cl_abap_unit_assert=>assert_equals( act = ls_config-method_name exp = 'PROXY_TEST' ). cl_abap_unit_assert=>assert_equals( act = ls_config-as_proxy exp = abap_true ). endmethod. method parse_string_negative. data lx type ref to zcx_mockup_loader_error. try . zcl_mockup_loader_stub_factory=>parse_connect_string( 'tab_return -> mock_dummy (field' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'SF' ). endtry. try . zcl_mockup_loader_stub_factory=>parse_connect_string( 'tab_return -> mock_dummy [filter' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'SF' ). endtry. try . zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> mock_path [ field = ""const ]' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'SF' ). endtry. endmethod. method parse_string_positive. data ls_exp type zif_mockup_loader=>ty_mock_config. clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> mock_path' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path~txt'. ls_exp-corresponding = 'X'. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> ~mock_path~txt' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'dir/mock_path'. ls_exp-corresponding = 'X'. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> dir/~mock_path' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = 'result'. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> mock_path (result)' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = ''. ls_exp-sift_param = 'param'. ls_exp-mock_tab_key = 'field'. ls_exp-field_only = ''. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> mock_path [ field = param ]' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = ''. ls_exp-sift_const = 'const'. ls_exp-mock_tab_key = 'field'. ls_exp-field_only = ''. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> mock_path [ field = ""const"" ]' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = ''. ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = 'value'. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> =value' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = '*'. ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> *' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. ls_exp-deep = abap_true. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> :deep:mock_path' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. ls_exp-deep = abap_true. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> :deep: mock_path' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'mock_path'. ls_exp-corresponding = abap_true. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. ls_exp-deep = abap_true. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> ~:deep:mock_path' ) exp = ls_exp ). clear ls_exp. ls_exp-method_name = 'methodX'. ls_exp-mock_name = 'xxx:deep:mock_path'. "" Deep marker is just at the beginning ls_exp-corresponding = ''. ls_exp-sift_param = ''. ls_exp-mock_tab_key = ''. ls_exp-field_only = ''. ls_exp-const_value = ''. ls_exp-deep = abap_false. cl_abap_unit_assert=>assert_equals( act = zcl_mockup_loader_stub_factory=>parse_connect_string( 'methodX -> xxx:deep:mock_path' ) exp = ls_exp ). endmethod. method connect_string_multi. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where not ( connid = '2000' and fldate = '20150102' ). factory->connect( 'tab_return_w_date->example/sflight [connid = i_connid , fldate = i_fldate]' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return_w_date( i_connid = '2000' i_fldate = '20150102' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method connect_string_multi_const. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. data lt_exp type flighttab. data lt_act type flighttab. ml = get_ml( ). factory = get_factory( ml ). lt_exp = get_sflights( ml ). delete lt_exp where not ( connid = '2000' and fldate = '20150102' ). factory->connect( 'tab_return_w_date->example/sflight [connid = i_connid , fldate = ""20150102""]' ). stub ?= factory->generate_stub( ). lt_act = stub->tab_return_w_date( i_connid = '2000' i_fldate = '20150130' ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. method connect_string_multi_1value. data factory type ref to zcl_mockup_loader_stub_factory. data stub type ref to zif_mockup_loader_stub_dummy. data ml type ref to zcl_mockup_loader. ml = get_ml( ). factory = get_factory( ml ). factory->connect( 'return_value_w_date->example/sflight(price) [connid=i_connid, fldate=i_fldate]' ). stub ?= factory->generate_stub( ). cl_abap_unit_assert=>assert_equals( act = stub->return_value_w_date( i_connid = '2000' i_fldate = '20150102' ) exp = '300.00' ). factory = get_factory( ml ). factory->connect( 'return_value_w_date->example/sflight(price) [connid=i_connid, fldate=""02.01.2015""]' ). "" NB: this is a bit tricky, dates in text are formatted and if we don't specify the method param "" we don't know the type of it and so we don't know how to convert value. So contstant filters are always string stub ?= factory->generate_stub( ). cl_abap_unit_assert=>assert_equals( act = stub->return_value_w_date( i_connid = '2000' i_fldate = '20150130' ) exp = '300.00' ). endmethod. endclass. ",12465,True,3039.600493273118,median "CLASS zcl_abapgit_gui_page_repo_view DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_hotkeys . CONSTANTS: BEGIN OF c_actions, repo_list TYPE string VALUE 'abapgit_home' ##NO_TEXT, change_dir TYPE string VALUE 'change_dir' ##NO_TEXT, toggle_hide_files TYPE string VALUE 'toggle_hide_files' ##NO_TEXT, toggle_folders TYPE string VALUE 'toggle_folders' ##NO_TEXT, toggle_changes TYPE string VALUE 'toggle_changes' ##NO_TEXT, toggle_diff_first TYPE string VALUE 'toggle_diff_first ' ##NO_TEXT, display_more TYPE string VALUE 'display_more' ##NO_TEXT, repo_switch_origin_to_pr TYPE string VALUE 'repo_switch_origin_to_pr', repo_reset_origin TYPE string VALUE 'repo_reset_origin', go_data TYPE string VALUE 'go_data', END OF c_actions . METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RAISING zcx_abapgit_exception . METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION . PROTECTED SECTION. METHODS render_content REDEFINITION. PRIVATE SECTION. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mv_cur_dir TYPE string . DATA mv_hide_files TYPE abap_bool . DATA mv_max_lines TYPE i . DATA mv_max_setting TYPE i . DATA mv_show_folders TYPE abap_bool . DATA mv_changes_only TYPE abap_bool . DATA mv_order_by TYPE string . DATA mv_order_descending TYPE abap_bool . DATA mv_diff_first TYPE abap_bool . DATA mv_key TYPE zif_abapgit_persistence=>ty_value . DATA mv_are_changes_recorded_in_tr TYPE abap_bool . METHODS render_head_line IMPORTING !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_head_menu IMPORTING !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_view_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS render_item IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item !iv_render_transports TYPE abap_bool RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_item_files IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_item_command IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS get_item_class IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS get_item_icon IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS render_item_lock_column IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_parent_dir RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_obj_jump_link IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS build_dir_jump_link IMPORTING !iv_path TYPE string RETURNING VALUE(rv_html) TYPE string . METHODS build_inactive_object_code IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_inactive_html_code) TYPE string . METHODS open_in_main_language RAISING zcx_abapgit_exception . METHODS render_order_by RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS apply_order_by CHANGING !ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt . METHODS build_branch_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_branch_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_tag_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_tag_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_advanced_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ro_advanced_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_toolbar IMPORTING !iv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout !iv_lstate TYPE char1 !iv_rstate TYPE char1 !io_tb_branch TYPE REF TO zcl_abapgit_html_toolbar !io_tb_tag TYPE REF TO zcl_abapgit_html_toolbar !io_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS switch_to_pr IMPORTING !it_fields TYPE tihttpnvp OPTIONAL !iv_revert TYPE abap_bool OPTIONAL RETURNING VALUE(rv_switched) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS build_main_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS is_repo_lang_logon_lang RETURNING VALUE(rv_repo_lang_is_logon_lang) TYPE abap_bool . METHODS get_abapgit_tcode RETURNING VALUE(rv_tcode) TYPE tcode . ENDCLASS. CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. METHOD apply_order_by. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort, lt_non_code_and_metadata_items LIKE ct_repo_items, lt_code_items LIKE ct_repo_items, lt_diff_items LIKE ct_repo_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_repo_item. IF mv_order_by IS INITIAL. RETURN. ENDIF. "" we want to preserve non-code and metadata files at the top, "" so we isolate them and and sort only the code artifacts LOOP AT ct_repo_items ASSIGNING . IF -obj_type IS INITIAL AND -is_dir = abap_false. INSERT INTO TABLE lt_non_code_and_metadata_items. ELSE. INSERT INTO TABLE lt_code_items. ENDIF. ENDLOOP. IF mv_diff_first = abap_true. "" fix diffs on the top, right after non-code and metadata LOOP AT lt_code_items ASSIGNING WHERE changes > 0. INSERT INTO TABLE lt_diff_items. ENDLOOP. DELETE lt_code_items WHERE changes > 0. ENDIF. CLEAR: ct_repo_items. ls_sort-name = mv_order_by. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. INSERT ls_sort INTO TABLE lt_sort. SORT lt_code_items BY (lt_sort). SORT lt_diff_items BY (lt_sort). INSERT LINES OF lt_non_code_and_metadata_items INTO TABLE ct_repo_items. INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items. INSERT LINES OF lt_code_items INTO TABLE ct_repo_items. ENDMETHOD. METHOD build_advanced_dropdown. DATA: lv_crossout LIKE zif_abapgit_html=>c_html_opt-crossout. CREATE OBJECT ro_advanced_dropdown. IF iv_rstate IS NOT INITIAL OR iv_lstate IS NOT INITIAL. "" In case of asyncronicities ro_advanced_dropdown->add( iv_txt = 'Reset Local (Force Pull)' iv_act = |{ zif_abapgit_definitions=>c_action-git_reset }?key={ mv_key }| iv_opt = iv_wp_opt ). ENDIF. IF mo_repo->is_offline( ) = abap_false. "" Online ? ro_advanced_dropdown->add( iv_txt = 'Checkout commit' iv_act = |{ zif_abapgit_definitions=>c_action-git_checkout_commit }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_advanced_dropdown->add( iv_txt = 'Background Mode' iv_act = |{ zif_abapgit_definitions=>c_action-go_background }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Change Remote' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_change }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Make Off-line' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_detach }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Force Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-transport_to_branch ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Transport to Branch' iv_act = |{ zif_abapgit_definitions=>c_action-repo_transport_to_branch }?key={ mv_key }| iv_opt = lv_crossout ). ELSE. ro_advanced_dropdown->add( iv_txt = 'Make On-line' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_attach }?key={ mv_key }| ). ENDIF. IF mv_are_changes_recorded_in_tr = abap_true. ro_advanced_dropdown->add( iv_txt = 'Add all objects to transport request' iv_act = |{ zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Syntax Check' iv_act = |{ zif_abapgit_definitions=>c_action-repo_syntax_check }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Run Code Inspector' iv_act = |{ zif_abapgit_definitions=>c_action-repo_code_inspector }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-update_local_checksum ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Update Local Checksums' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh_checksums }?key={ mv_key }| iv_opt = lv_crossout ). ro_advanced_dropdown->add( iv_txt = 'Beta - Data' iv_act = |{ c_actions-go_data }?key={ mv_key }| iv_opt = lv_crossout ). IF is_repo_lang_logon_lang( ) = abap_false AND get_abapgit_tcode( ) IS NOT INITIAL. ro_advanced_dropdown->add( iv_txt = 'Open in Main Language' iv_act = |{ zif_abapgit_definitions=>c_action-repo_open_in_master_lang }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Remove' iv_title = `Remove abapGit's records of the repository (the system's ` && `development objects will remain unaffected)` iv_act = |{ zif_abapgit_definitions=>c_action-repo_remove }?key={ mv_key }| ). CLEAR lv_crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true OR zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-uninstall ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Uninstall' iv_title = `Delete all development objects belonging to this package ` && `(and subpackages) from the system` iv_act = |{ zif_abapgit_definitions=>c_action-repo_purge }?key={ mv_key }| iv_opt = lv_crossout ). ENDMETHOD. METHOD build_branch_dropdown. DATA lo_repo_online TYPE REF TO zcl_abapgit_repo_online. CREATE OBJECT ro_branch_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_branch_dropdown->add( iv_txt = 'Overview' iv_act = |{ zif_abapgit_definitions=>c_action-go_branch_overview }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_branch_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_create }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_delete }?key={ mv_key }| ). lo_repo_online ?= mo_repo. "" TODO refactor this disaster IF lo_repo_online->get_switched_origin( ) IS NOT INITIAL. ro_branch_dropdown->add( iv_txt = 'Revert to Previous Branch' iv_act = |{ c_actions-repo_reset_origin }| ). ELSE. ro_branch_dropdown->add( iv_txt = 'Switch to PR Branch' iv_act = |{ c_actions-repo_switch_origin_to_pr }| ). ENDIF. ENDMETHOD. METHOD build_dir_jump_link. DATA lv_path TYPE string. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_path = iv_path. REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''. lv_encode = zcl_abapgit_html_action_utils=>dir_encode( lv_path ). rv_html = li_html->a( iv_txt = lv_path iv_act = |{ c_actions-change_dir }?{ lv_encode }| ). ENDMETHOD. METHOD build_head_menu. DATA: lo_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_branch TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_tag TYPE REF TO zcl_abapgit_html_toolbar, lv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout, lv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true. lv_wp_opt = zif_abapgit_html=>c_html_opt-crossout. lv_pull_opt = zif_abapgit_html=>c_html_opt-crossout. ELSE. lv_pull_opt = zif_abapgit_html=>c_html_opt-strong. ENDIF. lo_tb_branch = build_branch_dropdown( lv_wp_opt ). lo_tb_tag = build_tag_dropdown( lv_wp_opt ). lo_tb_advanced = build_advanced_dropdown( iv_wp_opt = lv_wp_opt iv_rstate = iv_rstate iv_lstate = iv_lstate ). ro_toolbar = build_main_toolbar( iv_pull_opt = lv_pull_opt iv_rstate = iv_rstate iv_lstate = iv_lstate io_tb_branch = lo_tb_branch io_tb_tag = lo_tb_tag io_tb_advanced = lo_tb_advanced ). ENDMETHOD. METHOD build_inactive_object_code. IF is_item-inactive = abap_true. rv_inactive_html_code = zcl_abapgit_html=>icon( iv_name = 'bolt/orange' iv_hint = 'Object or object part is inactive' iv_class = 'inactive' ). ENDIF. ENDMETHOD. METHOD build_main_menu. CREATE OBJECT ro_menu EXPORTING iv_id = 'toolbar-main'. ro_menu->add( iv_txt = zcl_abapgit_gui_buttons=>repo_list( ) iv_act = zif_abapgit_definitions=>c_action-abapgit_home )->add( iv_txt = zcl_abapgit_gui_buttons=>settings( ) iv_act = zif_abapgit_definitions=>c_action-go_settings )->add( iv_txt = zcl_abapgit_gui_buttons=>advanced( ) iv_title = 'Utilities' io_sub = zcl_abapgit_gui_chunk_lib=>advanced_submenu( ) )->add( iv_txt = zcl_abapgit_gui_buttons=>help( ) iv_title = 'Help' io_sub = zcl_abapgit_gui_chunk_lib=>help_submenu( ) ). ENDMETHOD. METHOD build_main_toolbar. DATA: li_log TYPE REF TO zif_abapgit_log. CREATE OBJECT ro_toolbar EXPORTING iv_id = 'toolbar-repo'. IF mo_repo->is_offline( ) = abap_false. IF iv_rstate IS NOT INITIAL. "" Something new at remote ro_toolbar->add( iv_txt = 'Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = iv_pull_opt ). ENDIF. IF iv_lstate IS NOT INITIAL. "" Something new at local ro_toolbar->add( iv_txt = 'Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. IF iv_rstate IS NOT INITIAL OR iv_lstate IS NOT INITIAL. "" Any changes ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ro_toolbar->add( iv_txt = 'Branch' io_sub = io_tb_branch ). ro_toolbar->add( iv_txt = 'Tag' io_sub = io_tb_tag ). ELSE. IF mo_repo->has_remote_source( ) = abap_true AND iv_rstate IS NOT INITIAL. ro_toolbar->add( iv_txt = 'Pull zip' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Import zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_import }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Export zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ENDIF. ro_toolbar->add( iv_txt = 'Advanced' io_sub = io_tb_advanced ). ro_toolbar->add( iv_txt = 'View' io_sub = build_view_menu( ) ). ro_toolbar->add( iv_txt = 'Refresh' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = zcl_abapgit_html=>icon( iv_name = 'cog' ) iv_act = |{ zif_abapgit_definitions=>c_action-repo_settings }?key={ mv_key }| iv_title = `Repository Settings` ). ENDMETHOD. METHOD build_obj_jump_link. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_encode = zcl_abapgit_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type iv_obj_name = is_item-obj_name ). rv_html = li_html->a( iv_txt = |{ is_item-obj_name }| iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). ENDMETHOD. METHOD build_tag_dropdown. CREATE OBJECT ro_tag_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_tag_dropdown->add( iv_txt = 'Overview' iv_act = |{ zif_abapgit_definitions=>c_action-go_tag_overview }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_tag_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_create }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_delete }?key={ mv_key }| ). ENDMETHOD. METHOD build_view_menu. CREATE OBJECT ro_toolbar. ro_toolbar->add( iv_txt = 'Changes First' iv_chk = mv_diff_first iv_act = c_actions-toggle_diff_first ). IF mo_repo->has_remote_source( ) = abap_true. ro_toolbar->add( iv_txt = 'Changes Only' iv_chk = mv_changes_only iv_act = c_actions-toggle_changes ). ro_toolbar->add( iv_txt = 'File Paths' iv_chk = boolc( NOT mv_hide_files = abap_true ) iv_act = c_actions-toggle_hide_files ). ENDIF. ro_toolbar->add( iv_txt = 'Folders' iv_chk = mv_show_folders iv_act = c_actions-toggle_folders ). ENDMETHOD. METHOD constructor. DATA: lo_settings TYPE REF TO zcl_abapgit_settings, lx_error TYPE REF TO zcx_abapgit_exception. super->constructor( ). TRY. mv_key = iv_key. mo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). mv_cur_dir = '/'. "" Root mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->get_hide_files( ). mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->get_changes_only( ). mv_diff_first = abap_true. ms_control-page_title = 'Repository'. ms_control-page_menu = build_main_menu( ). "" Read global settings to get max # of objects to be listed lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). mv_max_lines = lo_settings->get_max_lines( ). mv_max_setting = mv_max_lines. CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). RAISE EXCEPTION lx_error. ENDTRY. ENDMETHOD. METHOD get_abapgit_tcode. CONSTANTS: lc_report_tcode_hex TYPE x VALUE '80'. DATA: lt_tcodes TYPE STANDARD TABLE OF tcode. SELECT tcode FROM tstc INTO TABLE lt_tcodes WHERE pgmna = sy-cprog AND cinfo = lc_report_tcode_hex. IF lines( lt_tcodes ) = 1. READ TABLE lt_tcodes INDEX 1 INTO rv_tcode. ENDIF. ENDMETHOD. METHOD get_item_class. DATA lt_class TYPE TABLE OF string. IF is_item-is_dir = abap_true. APPEND 'folder' TO lt_class. ELSEIF is_item-changes > 0. APPEND 'modified' TO lt_class. ELSEIF is_item-obj_name IS INITIAL. APPEND 'unsupported' TO lt_class. ENDIF. IF lines( lt_class ) > 0. rv_html = | class=""{ concat_lines_of( table = lt_class sep = ` ` ) }""|. ENDIF. ENDMETHOD. METHOD get_item_icon. CASE is_item-obj_type. WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' iv_hint = 'Code' ). WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' iv_hint = 'Binary' ). WHEN 'DEVC'. rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' iv_hint = 'Package' ). WHEN ''. rv_html = space. "" no icon WHEN OTHERS. rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). ENDCASE. IF is_item-is_dir = abap_true. rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' iv_hint = 'Folder' ). ENDIF. ENDMETHOD. METHOD is_repo_lang_logon_lang. rv_repo_lang_is_logon_lang = boolc( mo_repo->get_dot_abapgit( )->get_master_language( ) = sy-langu ). ENDMETHOD. METHOD open_in_main_language. DATA: lv_main_language TYPE spras, lt_spagpa TYPE STANDARD TABLE OF rfc_spagpa, ls_spagpa LIKE LINE OF lt_spagpa, ls_item TYPE zif_abapgit_definitions=>ty_item, lv_subrc TYPE syst-subrc, lv_save_sy_langu TYPE sy-langu, lv_tcode TYPE tcode. "" https://blogs.sap.com/2017/01/13/logon-language-sy-langu-and-rfc/ lv_main_language = mo_repo->get_dot_abapgit( )->get_master_language( ). lv_tcode = get_abapgit_tcode( ). ASSERT lv_tcode IS NOT INITIAL. IF lv_main_language = sy-langu. zcx_abapgit_exception=>raise( |Repo already opened in main language| ). ENDIF. ls_item-obj_name = lv_tcode. ls_item-obj_type = |TRAN|. IF zcl_abapgit_objects=>exists( ls_item ) = abap_false. zcx_abapgit_exception=>raise( |Please install the abapGit repository| ). ENDIF. lv_save_sy_langu = sy-langu. SET LOCALE LANGUAGE lv_main_language. ls_spagpa-parid = zif_abapgit_definitions=>c_spagpa_param_repo_key. ls_spagpa-parval = mo_repo->get_key( ). INSERT ls_spagpa INTO TABLE lt_spagpa. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' DESTINATION 'NONE' STARTING NEW TASK 'ABAPGIT' EXPORTING tcode = lv_tcode TABLES spagpa_tab = lt_spagpa EXCEPTIONS call_transaction_denied = 1 tcode_invalid = 2 communication_failure = 3 system_failure = 4 OTHERS = 5. lv_subrc = sy-subrc. SET LOCALE LANGUAGE lv_save_sy_langu. IF lv_subrc <> 0. zcx_abapgit_exception=>raise( |Error from ABAP4_CALL_TRANSACTION. Subrc = { lv_subrc }| ). ENDIF. MESSAGE 'Repository opened in a new window' TYPE 'S'. ENDMETHOD. METHOD render_content. DATA: lt_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt, lo_browser TYPE REF TO zcl_abapgit_repo_content_list, lx_error TYPE REF TO zcx_abapgit_exception, lv_lstate TYPE char1, lv_rstate TYPE char1, lv_max TYPE abap_bool, lv_max_str TYPE string, lv_add_str TYPE string, li_log TYPE REF TO zif_abapgit_log, lv_msg TYPE string, lo_news TYPE REF TO zcl_abapgit_news. FIELD-SYMBOLS LIKE LINE OF lt_repo_items. gui_services( )->get_hotkeys_ctl( )->register_hotkeys( me ). gui_services( )->register_event_handler( me ). TRY. "" Reinit, for the case of type change mo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( mo_repo->get_key( ) ). mv_are_changes_recorded_in_tr = zcl_abapgit_factory=>get_sap_package( mo_repo->get_package( ) )->are_changes_recorded_in_tr_req( ). lo_news = zcl_abapgit_news=>create( mo_repo ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo io_news = lo_news iv_interactive_branch = abap_true ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_news( io_news = lo_news ) ). CREATE OBJECT lo_browser EXPORTING io_repo = mo_repo. lt_repo_items = lo_browser->list( iv_path = mv_cur_dir iv_by_folders = mv_show_folders iv_changes_only = mv_changes_only ). apply_order_by( CHANGING ct_repo_items = lt_repo_items ). LOOP AT lt_repo_items ASSIGNING . zcl_abapgit_state=>reduce( EXPORTING iv_cur = -lstate CHANGING cv_prev = lv_lstate ). zcl_abapgit_state=>reduce( EXPORTING iv_cur = -rstate CHANGING cv_prev = lv_rstate ). ENDLOOP. ri_html->add( render_head_line( iv_lstate = lv_lstate iv_rstate = lv_rstate ) ). li_log = lo_browser->get_log( ). IF mo_repo->is_offline( ) = abap_false AND li_log->count( ) > 0. ri_html->add( '
' ). ri_html->add( zcl_abapgit_log_viewer=>to_html( li_log ) ). "" shows eg. list of unsupported objects ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). CLEAR lv_msg. IF mo_repo->is_offline( ) = abap_true AND mo_repo->has_remote_source( ) = abap_true AND lv_lstate IS INITIAL AND lv_rstate IS INITIAL. "" Offline match banner lv_msg = 'ZIP source is attached and completely matches the local state'. ELSEIF lines( lt_repo_items ) = 0. "" Online match banner IF mv_changes_only = abap_true. lv_msg = 'Local state completely matches the remote repository'. ELSE. lv_msg = |Package is empty. Show { build_dir_jump_link( 'parent' ) } package|. ENDIF. ELSE. "" Repo content table ri_html->add( '' ). IF zcl_abapgit_path=>is_root( mv_cur_dir ) = abap_false. ri_html->add( render_parent_dir( ) ). ENDIF. ri_html->add( render_order_by( ) ). LOOP AT lt_repo_items ASSIGNING . IF mv_max_lines > 0 AND sy-tabix > mv_max_lines. lv_max = abap_true. EXIT. "" current loop ENDIF. ri_html->add( render_item( is_item = iv_render_transports = mv_are_changes_recorded_in_tr ) ). ENDLOOP. ri_html->add( '
' ). ENDIF. IF NOT lv_msg IS INITIAL. ri_html->add( |
{ lv_msg }
| ). ENDIF. IF lv_max = abap_true. ri_html->add( '
' ). IF mv_max_lines = 1. lv_max_str = '1 object'. ELSE. lv_max_str = |first { mv_max_lines } objects|. ENDIF. lv_add_str = |+{ mv_max_setting }|. ri_html->add( |Only { lv_max_str } objects shown in list. Display { ri_html->a( iv_txt = lv_add_str iv_act = c_actions-display_more ) } more (change in Settings > { ri_html->a( iv_txt = 'Personal Settings' iv_act = zif_abapgit_definitions=>c_action-go_settings_personal ) })| ). ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). ri_html->add( render_head_line( iv_lstate = lv_lstate iv_rstate = lv_rstate ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_error( iv_extra_style = 'repo_banner' ix_error = lx_error ) ). ENDTRY. register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_head_line. DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar. CREATE OBJECT ri_html TYPE zcl_abapgit_html. lo_toolbar = build_head_menu( iv_lstate = iv_lstate iv_rstate = iv_rstate ). ri_html->add( '
' ). ri_html->add( '' ). IF mv_show_folders = abap_true. ri_html->add( || ). ENDIF. ri_html->add( '' ). ri_html->add( '
{ mv_cur_dir }' ). ri_html->add( lo_toolbar->render( iv_right = abap_true ) ). ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_item. DATA: lv_link TYPE string, lv_colspan TYPE i. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF iv_render_transports = abap_false. lv_colspan = 2. ELSE. lv_colspan = 3. ENDIF. ri_html->add( || ). IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false. ri_html->add( || && '' && 'non-code and meta files' && '' ). ELSE. ri_html->add( |{ get_item_icon( is_item ) }| ). IF iv_render_transports = abap_true. ri_html->add( render_item_lock_column( is_item ) ). ENDIF. IF is_item-is_dir = abap_true. "" Subdir lv_link = build_dir_jump_link( is_item-path ). ri_html->add( |{ lv_link }| ). ELSE. lv_link = build_obj_jump_link( is_item ). ri_html->add( |{ is_item-obj_type }| ). ri_html->add( |{ lv_link } { build_inactive_object_code( is_item ) }| ). ENDIF. ENDIF. "" Files ri_html->add( '' ). ri_html->add( render_item_files( is_item ) ). ri_html->add( '' ). "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_item_command( is_item ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_item_command. DATA: lv_difflink TYPE string, ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-is_dir = abap_true. "" Directory ri_html->add( '
' ). ri_html->add( |{ is_item-changes } changes| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSEIF is_item-changes > 0. IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL. lv_difflink = zcl_abapgit_html_action_utils=>obj_encode( iv_key = mo_repo->get_key( ) ig_object = is_item ). ri_html->add( '
' ). ri_html->add_a( iv_txt = |diff ({ is_item-changes })| iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSE. LOOP AT is_item-files INTO ls_file. ri_html->add( '
' ). IF ls_file-is_changed = abap_true. lv_difflink = zcl_abapgit_html_action_utils=>file_encode( iv_key = mo_repo->get_key( ) ig_file = ls_file ). ri_html->add_a( iv_txt = 'diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = ls_file-lstate iv_rstate = ls_file-rstate ) ). ELSE. ri_html->add( ' ' ). ENDIF. ri_html->add( '
' ). ENDLOOP. ENDIF. ENDIF. ENDMETHOD. METHOD render_item_files. DATA: ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF mv_hide_files = abap_true AND is_item-obj_type IS NOT INITIAL. RETURN. ENDIF. LOOP AT is_item-files INTO ls_file. ri_html->add( |
{ ls_file-path && ls_file-filename }
| ). ENDLOOP. ENDMETHOD. METHOD render_item_lock_column. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, lv_transport TYPE trkorr. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ls_item-obj_type = is_item-obj_type. ls_item-obj_name = is_item-obj_name. TRY. lv_transport = zcl_abapgit_factory=>get_cts_api( )->get_transport_for_object( ls_item ). IF lv_transport IS NOT INITIAL. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport = lv_transport iv_icon_only = abap_true ) ). ENDIF. CATCH zcx_abapgit_exception ##NO_HANDLER. "" Ignore errors related to object check when trying to get transport ENDTRY. ri_html->add( '' ). ENDMETHOD. METHOD render_order_by. DATA: lv_icon TYPE string, lt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt, ls_col_spec TYPE zif_abapgit_definitions=>ty_col_spec. CREATE OBJECT ri_html TYPE zcl_abapgit_html. APPEND INITIAL LINE TO lt_col_spec. IF mv_are_changes_recorded_in_tr = abap_true. APPEND INITIAL LINE TO lt_col_spec. ENDIF. ls_col_spec-tech_name = 'OBJ_TYPE'. ls_col_spec-display_name = 'Type'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_NAME'. ls_col_spec-display_name = 'Name'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'PATH'. ls_col_spec-display_name = 'Path'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. APPEND INITIAL LINE TO lt_col_spec. ri_html->add( || ). ri_html->add( || ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_order_by_header_cells( it_col_spec = lt_col_spec iv_order_by = mv_order_by iv_order_descending = mv_order_descending ) ). IF mv_diff_first = abap_true. lv_icon = 'check/blue'. ELSE. lv_icon = 'check/grey'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_parent_dir. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( |{ ri_html->icon( 'folder' ) }| ). ri_html->add( |{ build_dir_jump_link( '..' ) }| ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( || ). "" Dummy for online ENDIF. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_palette( zif_abapgit_definitions=>c_action-go_repo ) ). ENDMETHOD. METHOD switch_to_pr. DATA lo_repo_online TYPE REF TO zcl_abapgit_repo_online. DATA lt_pulls TYPE zif_abapgit_pr_enum_provider=>ty_pull_requests. DATA ls_pull LIKE LINE OF lt_pulls. IF mo_repo->is_offline( ) = abap_true. zcx_abapgit_exception=>raise( 'Unexpected PR switch for offline repo' ). ENDIF. IF mo_repo->get_local_settings( )-write_protected = abap_true. zcx_abapgit_exception=>raise( 'Cannot switch branch. Local code is write-protected by repo config' ). ENDIF. lo_repo_online ?= mo_repo. IF iv_revert = abap_true. lo_repo_online->switch_origin( '' ). ELSE. lt_pulls = zcl_abapgit_pr_enumerator=>new( lo_repo_online )->get_pulls( ). IF lines( lt_pulls ) = 0. RETURN. "" false ENDIF. SORT lt_pulls BY number DESCENDING. ls_pull = zcl_abapgit_ui_factory=>get_popups( )->choose_pr_popup( lt_pulls ). IF ls_pull IS INITIAL. RETURN. "" false ENDIF. lo_repo_online->switch_origin( ls_pull-head_url ). lo_repo_online->select_branch( |refs/heads/{ ls_pull-head_branch }| ). "" TODO refactor rv_switched = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA lv_path TYPE string. DATA lv_switched TYPE abap_bool. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-go_repo. "" Switch to another repo CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN c_actions-go_data. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_data EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_actions-toggle_hide_files. "" Toggle file diplay mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->toggle_hide_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-change_dir. "" Change dir lv_path = ii_event->query( )->get( 'PATH' ). mv_cur_dir = zcl_abapgit_path=>change_dir( iv_cur_dir = mv_cur_dir iv_cd = lv_path ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_folders. "" Toggle folder view mv_show_folders = boolc( mv_show_folders <> abap_true ). mv_cur_dir = '/'. "" Root rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_changes. "" Toggle changes only view mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->toggle_changes_only( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_diff_first. mv_diff_first = boolc( mv_diff_first = abap_false ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-display_more. "" Increase MAX lines limit mv_max_lines = mv_max_lines + mv_max_setting. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-change_order_by. mv_order_by = ii_event->query( )->get( 'ORDERBY' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-direction. mv_order_descending = boolc( ii_event->query( )->get( 'DIRECTION' ) = 'DESCENDING' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_open_in_master_lang. open_in_main_language( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-repo_switch_origin_to_pr. lv_switched = switch_to_pr( ). IF lv_switched = abap_true. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ELSE. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDIF. WHEN c_actions-repo_reset_origin. switch_to_pr( iv_revert = abap_true ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). "" TODO refactor, move to HOC components ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions. ls_hotkey_action-ui_component = 'Repo'. ls_hotkey_action-description = |Stage changes|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_stage. ls_hotkey_action-hotkey = |s|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Switch branch|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_branch_switch. ls_hotkey_action-hotkey = |b|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Repository list|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-abapgit_home. ls_hotkey_action-hotkey = |o|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Refresh repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_refresh. ls_hotkey_action-hotkey = |r|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Pull|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_pull. ls_hotkey_action-hotkey = |p|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Diff|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_diff. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Uninstall repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_purge. ls_hotkey_action-hotkey = |u|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run syntax check|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_syntax_check. ls_hotkey_action-hotkey = |c|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run code inspector|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_code_inspector. ls_hotkey_action-hotkey = |i|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Show log|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_log. ls_hotkey_action-hotkey = |l|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |abapGit settings|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_settings. ls_hotkey_action-hotkey = |x|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ENDMETHOD. ENDCLASS. ",12170,True,2527.9390596743606,median "class ZCL_ZCA_GW_ATTACHMENT_MPC definition public inheriting from /IWBEP/CL_MGW_PUSH_ABS_MODEL create public . public section. types: TS_ATTACHKEY type ZCA_S_ATTACHMENT_KEY . types: TT_ATTACHKEY type standard table of TS_ATTACHKEY . types: begin of ts_text_element, artifact_name type c length 40, "" technical name artifact_type type c length 4, parent_artifact_name type c length 40, "" technical name parent_artifact_type type c length 4, text_symbol type textpoolky, end of ts_text_element . types: tt_text_elements type standard table of ts_text_element with key text_symbol . types: TS_ATTACHMENT type ZCA_S_ATTACHMENT_SRV . types: TT_ATTACHMENT type standard table of TS_ATTACHMENT . types: TS_COMMENT type ZCA_S_COMMENT_SRV . types: TT_COMMENT type standard table of TS_COMMENT . constants GC_ATTACHKEY type /IWBEP/IF_MGW_MED_ODATA_TYPES=>TY_E_MED_ENTITY_NAME value 'AttachKey' ##NO_TEXT. constants GC_ATTACHMENT type /IWBEP/IF_MGW_MED_ODATA_TYPES=>TY_E_MED_ENTITY_NAME value 'Attachment' ##NO_TEXT. constants GC_COMMENT type /IWBEP/IF_MGW_MED_ODATA_TYPES=>TY_E_MED_ENTITY_NAME value 'Comment' ##NO_TEXT. methods LOAD_TEXT_ELEMENTS final returning value(RT_TEXT_ELEMENTS) type TT_TEXT_ELEMENTS raising /IWBEP/CX_MGW_MED_EXCEPTION . methods DEFINE redefinition . methods GET_LAST_MODIFIED redefinition . protected section. private section. constants GC_INCL_NAME type STRING value 'ZCL_ZCA_GW_ATTACHMENT_MPC=====CP' ##NO_TEXT. methods DEFINE_ATTACHKEY raising /IWBEP/CX_MGW_MED_EXCEPTION . methods DEFINE_ATTACHMENT raising /IWBEP/CX_MGW_MED_EXCEPTION . methods DEFINE_COMMENT raising /IWBEP/CX_MGW_MED_EXCEPTION . methods DEFINE_ASSOCIATIONS raising /IWBEP/CX_MGW_MED_EXCEPTION . ENDCLASS. CLASS ZCL_ZCA_GW_ATTACHMENT_MPC IMPLEMENTATION. method DEFINE. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* model->set_schema_namespace( 'ZCA_GW_ATTACHMENT_SRV' ). define_attachkey( ). define_attachment( ). define_comment( ). define_associations( ). endmethod. method DEFINE_ASSOCIATIONS. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* data: lo_annotation type ref to /iwbep/if_mgw_odata_annotation, ""#EC NEEDED lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ, ""#EC NEEDED lo_association type ref to /iwbep/if_mgw_odata_assoc, ""#EC NEEDED lo_ref_constraint type ref to /iwbep/if_mgw_odata_ref_constr, ""#EC NEEDED lo_assoc_set type ref to /iwbep/if_mgw_odata_assoc_set, ""#EC NEEDED lo_nav_property type ref to /iwbep/if_mgw_odata_nav_prop. ""#EC NEEDED *********************************************************************************************************************************** * ASSOCIATIONS *********************************************************************************************************************************** lo_association = model->create_association( iv_association_name = 'ToAttachment' ""#EC NOTEXT iv_left_type = 'AttachKey' ""#EC NOTEXT iv_right_type = 'Attachment' ""#EC NOTEXT iv_right_card = 'M' ""#EC NOTEXT iv_left_card = '1' ""#EC NOTEXT iv_def_assoc_set = abap_false ). ""#EC NOTEXT * Referential constraint for association - ToAttachment lo_ref_constraint = lo_association->create_ref_constraint( ). lo_ref_constraint->add_property( iv_principal_property = 'InstanceID' iv_dependent_property = 'InstanceID' ). ""#EC NOTEXT lo_ref_constraint->add_property( iv_principal_property = 'TypeID' iv_dependent_property = 'TypeID' ). ""#EC NOTEXT lo_ref_constraint->add_property( iv_principal_property = 'CategoryID' iv_dependent_property = 'CategoryID' ). ""#EC NOTEXT lo_assoc_set = model->create_association_set( iv_association_set_name = 'ToAttachmentSet' ""#EC NOTEXT iv_left_entity_set_name = 'AttachKeySet' ""#EC NOTEXT iv_right_entity_set_name = 'AttachmentSet' ""#EC NOTEXT iv_association_name = 'ToAttachment' ). ""#EC NOTEXT lo_association = model->create_association( iv_association_name = 'ToComment' ""#EC NOTEXT iv_left_type = 'AttachKey' ""#EC NOTEXT iv_right_type = 'Comment' ""#EC NOTEXT iv_right_card = 'M' ""#EC NOTEXT iv_left_card = '1' ""#EC NOTEXT iv_def_assoc_set = abap_false ). ""#EC NOTEXT * Referential constraint for association - ToComment lo_ref_constraint = lo_association->create_ref_constraint( ). lo_ref_constraint->add_property( iv_principal_property = 'InstanceID' iv_dependent_property = 'InstanceID' ). ""#EC NOTEXT lo_ref_constraint->add_property( iv_principal_property = 'TypeID' iv_dependent_property = 'TypeID' ). ""#EC NOTEXT lo_ref_constraint->add_property( iv_principal_property = 'CategoryID' iv_dependent_property = 'CategoryID' ). ""#EC NOTEXT lo_assoc_set = model->create_association_set( iv_association_set_name = 'ToCommentSet' ""#EC NOTEXT iv_left_entity_set_name = 'AttachKeySet' ""#EC NOTEXT iv_right_entity_set_name = 'CommentSet' ""#EC NOTEXT iv_association_name = 'ToComment' ). ""#EC NOTEXT *********************************************************************************************************************************** * NAVIGATION PROPERTIES *********************************************************************************************************************************** * Navigation Properties for entity - AttachKey lo_entity_type = model->get_entity_type( iv_entity_name = 'AttachKey' ). ""#EC NOTEXT lo_nav_property = lo_entity_type->create_navigation_property( iv_property_name = 'CommentSet' ""#EC NOTEXT iv_abap_fieldname = 'COMMENTSET' ""#EC NOTEXT iv_association_name = 'ToComment' ). ""#EC NOTEXT lo_nav_property = lo_entity_type->create_navigation_property( iv_property_name = 'AttachmentSet' ""#EC NOTEXT iv_abap_fieldname = 'ATTACHMENTSET' ""#EC NOTEXT iv_association_name = 'ToAttachment' ). ""#EC NOTEXT endmethod. method DEFINE_ATTACHKEY. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* data: lo_annotation type ref to /iwbep/if_mgw_odata_annotation, ""#EC NEEDED lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ, ""#EC NEEDED lo_complex_type type ref to /iwbep/if_mgw_odata_cmplx_type, ""#EC NEEDED lo_property type ref to /iwbep/if_mgw_odata_property, ""#EC NEEDED lo_entity_set type ref to /iwbep/if_mgw_odata_entity_set. ""#EC NEEDED *********************************************************************************************************************************** * ENTITY - AttachKey *********************************************************************************************************************************** lo_entity_type = model->create_entity_type( iv_entity_type_name = 'AttachKey' iv_def_entity_set = abap_false ). ""#EC NOTEXT *********************************************************************************************************************************** *Properties *********************************************************************************************************************************** lo_property = lo_entity_type->create_property( iv_property_name = 'InstanceID' iv_abap_fieldname = 'INSTANCEID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 70 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'TypeID' iv_abap_fieldname = 'TYPEID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 32 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CategoryID' iv_abap_fieldname = 'CATID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 2 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_entity_type->bind_structure( iv_structure_name = 'ZCA_S_ATTACHMENT_KEY' iv_bind_conversions = 'X' ). ""#EC NOTEXT *********************************************************************************************************************************** * ENTITY SETS *********************************************************************************************************************************** lo_entity_set = lo_entity_type->create_entity_set( 'AttachKeySet' ). ""#EC NOTEXT lo_entity_set->set_creatable( abap_false ). lo_entity_set->set_updatable( abap_false ). lo_entity_set->set_deletable( abap_false ). lo_entity_set->set_pageable( abap_false ). lo_entity_set->set_addressable( abap_true ). lo_entity_set->set_has_ftxt_search( abap_false ). lo_entity_set->set_subscribable( abap_false ). lo_entity_set->set_filter_required( abap_false ). endmethod. method DEFINE_ATTACHMENT. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* data: lo_annotation type ref to /iwbep/if_mgw_odata_annotation, ""#EC NEEDED lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ, ""#EC NEEDED lo_complex_type type ref to /iwbep/if_mgw_odata_cmplx_type, ""#EC NEEDED lo_property type ref to /iwbep/if_mgw_odata_property, ""#EC NEEDED lo_entity_set type ref to /iwbep/if_mgw_odata_entity_set. ""#EC NEEDED *********************************************************************************************************************************** * ENTITY - Attachment *********************************************************************************************************************************** lo_entity_type = model->create_entity_type( iv_entity_type_name = 'Attachment' iv_def_entity_set = abap_false ). ""#EC NOTEXT lo_entity_type->set_is_media( 'X' ). ""#EC NOTEXT *********************************************************************************************************************************** *Properties *********************************************************************************************************************************** lo_property = lo_entity_type->create_property( iv_property_name = 'InstanceID' iv_abap_fieldname = 'INSTANCEID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 70 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'Id' iv_abap_fieldname = 'ID' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '001' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 70 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CreatedBy' iv_abap_fieldname = 'CREATEDBY' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '002' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 12 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CreatedByName' iv_abap_fieldname = 'CREATEDBYNAME' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '003' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 80 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CreatedAt' iv_abap_fieldname = 'CREATEDAT' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '004' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_datetime( ). lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_true ). lo_property->set_nullable( abap_true ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'MimeType' iv_abap_fieldname = 'MIMETYPE' ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 128 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'FileSize' iv_abap_fieldname = 'FILESIZE' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '005' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_int32( ). lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'FileName' iv_abap_fieldname = 'FILENAME' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '006' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'TypeID' iv_abap_fieldname = 'TYPEID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 32 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CategoryID' iv_abap_fieldname = 'CATID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 2 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_entity_type->bind_structure( iv_structure_name = 'ZCA_S_ATTACHMENT_SRV' iv_bind_conversions = 'X' ). ""#EC NOTEXT *********************************************************************************************************************************** * ENTITY SETS *********************************************************************************************************************************** lo_entity_set = lo_entity_type->create_entity_set( 'AttachmentSet' ). ""#EC NOTEXT lo_entity_set->set_creatable( abap_false ). lo_entity_set->set_updatable( abap_false ). lo_entity_set->set_deletable( abap_false ). lo_entity_set->set_pageable( abap_false ). lo_entity_set->set_addressable( abap_true ). lo_entity_set->set_has_ftxt_search( abap_false ). lo_entity_set->set_subscribable( abap_false ). lo_entity_set->set_filter_required( abap_false ). endmethod. method DEFINE_COMMENT. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* data: lo_annotation type ref to /iwbep/if_mgw_odata_annotation, ""#EC NEEDED lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ, ""#EC NEEDED lo_complex_type type ref to /iwbep/if_mgw_odata_cmplx_type, ""#EC NEEDED lo_property type ref to /iwbep/if_mgw_odata_property, ""#EC NEEDED lo_entity_set type ref to /iwbep/if_mgw_odata_entity_set. ""#EC NEEDED *********************************************************************************************************************************** * ENTITY - Comment *********************************************************************************************************************************** lo_entity_type = model->create_entity_type( iv_entity_type_name = 'Comment' iv_def_entity_set = abap_false ). ""#EC NOTEXT *********************************************************************************************************************************** *Properties *********************************************************************************************************************************** lo_property = lo_entity_type->create_property( iv_property_name = 'InstanceID' iv_abap_fieldname = 'INSTANCEID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 70 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'Id' iv_abap_fieldname = 'ID' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '007' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 70 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CreatedBy' iv_abap_fieldname = 'CREATEDBY' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '008' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 12 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CreatedByName' iv_abap_fieldname = 'CREATEDBYNAME' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '009' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 80 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CreatedAt' iv_abap_fieldname = 'CREATEDAT' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '010' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_datetime( ). lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_true ). lo_property->set_nullable( abap_true ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'Note' iv_abap_fieldname = 'NOTE' ). ""#EC NOTEXT lo_property->set_label_from_text_element( iv_text_element_symbol = '011' iv_text_element_container = gc_incl_name ). ""#EC NOTEXT lo_property->set_type_edm_string( ). lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'TypeID' iv_abap_fieldname = 'TYPEID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 32 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_property = lo_entity_type->create_property( iv_property_name = 'CategoryID' iv_abap_fieldname = 'CATID' ). ""#EC NOTEXT lo_property->set_is_key( ). lo_property->set_type_edm_string( ). lo_property->set_maxlength( iv_max_length = 2 ). ""#EC NOTEXT lo_property->set_creatable( abap_false ). lo_property->set_updatable( abap_false ). lo_property->set_sortable( abap_false ). lo_property->set_nullable( abap_false ). lo_property->set_filterable( abap_false ). lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add( EXPORTING iv_key = 'unicode' iv_value = 'false' ). lo_entity_type->bind_structure( iv_structure_name = 'ZCA_S_COMMENT_SRV' iv_bind_conversions = 'X' ). ""#EC NOTEXT *********************************************************************************************************************************** * ENTITY SETS *********************************************************************************************************************************** lo_entity_set = lo_entity_type->create_entity_set( 'CommentSet' ). ""#EC NOTEXT lo_entity_set->set_creatable( abap_false ). lo_entity_set->set_updatable( abap_false ). lo_entity_set->set_deletable( abap_false ). lo_entity_set->set_pageable( abap_false ). lo_entity_set->set_addressable( abap_true ). lo_entity_set->set_has_ftxt_search( abap_false ). lo_entity_set->set_subscribable( abap_false ). lo_entity_set->set_filter_required( abap_false ). endmethod. method GET_LAST_MODIFIED. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* CONSTANTS: lc_gen_date_time TYPE timestamp VALUE '20210415020503'. ""#EC NOTEXT rv_last_modified = super->get_last_modified( ). IF rv_last_modified LT lc_gen_date_time. rv_last_modified = lc_gen_date_time. ENDIF. endmethod. method LOAD_TEXT_ELEMENTS. *&---------------------------------------------------------------------* *& Generated code for the MODEL PROVIDER BASE CLASS &* *& &* *& !!!NEVER MODIFY THIS CLASS. IN CASE YOU WANT TO CHANGE THE MODEL &* *& DO THIS IN THE MODEL PROVIDER SUBCLASS!!! &* *& &* *&---------------------------------------------------------------------* DATA: ls_text_element TYPE ts_text_element. ""#EC NEEDED CLEAR ls_text_element. clear ls_text_element. ls_text_element-artifact_name = 'Id'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Attachment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '001'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'CreatedBy'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Attachment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '002'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'CreatedByName'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Attachment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '003'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'CreatedAt'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Attachment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '004'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'FileSize'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Attachment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '005'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'FileName'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Attachment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '006'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'Id'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Comment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '007'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'CreatedBy'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Comment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '008'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'CreatedByName'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Comment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '009'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'CreatedAt'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Comment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '010'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. clear ls_text_element. ls_text_element-artifact_name = 'Note'. ""#EC NOTEXT ls_text_element-artifact_type = 'PROP'. ""#EC NOTEXT ls_text_element-parent_artifact_name = 'Comment'. ""#EC NOTEXT ls_text_element-parent_artifact_type = 'ETYP'. ""#EC NOTEXT ls_text_element-text_symbol = '011'. ""#EC NOTEXT APPEND ls_text_element TO rt_text_elements. endmethod. ENDCLASS. ",8143,False,2180.567020935572,median "CLASS zcl_abapgit_gui_page_repo_view DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_hotkeys . CONSTANTS: BEGIN OF c_actions, repo_list TYPE string VALUE 'abapgit_home' ##NO_TEXT, change_dir TYPE string VALUE 'change_dir' ##NO_TEXT, toggle_hide_files TYPE string VALUE 'toggle_hide_files' ##NO_TEXT, toggle_folders TYPE string VALUE 'toggle_folders' ##NO_TEXT, toggle_changes TYPE string VALUE 'toggle_changes' ##NO_TEXT, toggle_diff_first TYPE string VALUE 'toggle_diff_first ' ##NO_TEXT, display_more TYPE string VALUE 'display_more' ##NO_TEXT, repo_switch_origin_to_pr TYPE string VALUE 'repo_switch_origin_to_pr', repo_reset_origin TYPE string VALUE 'repo_reset_origin', go_data TYPE string VALUE 'go_data', END OF c_actions . METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RAISING zcx_abapgit_exception . METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION . PROTECTED SECTION. METHODS render_content REDEFINITION. PRIVATE SECTION. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mv_cur_dir TYPE string . DATA mv_hide_files TYPE abap_bool . DATA mv_max_lines TYPE i . DATA mv_max_setting TYPE i . DATA mv_show_folders TYPE abap_bool . DATA mv_changes_only TYPE abap_bool . DATA mv_order_by TYPE string . DATA mv_order_descending TYPE abap_bool . DATA mv_diff_first TYPE abap_bool . DATA mv_key TYPE zif_abapgit_persistence=>ty_value . DATA mv_are_changes_recorded_in_tr TYPE abap_bool . METHODS render_head_line IMPORTING !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_head_menu IMPORTING !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_view_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS render_item IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item !iv_render_transports TYPE abap_bool RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_item_files IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_item_command IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS get_item_class IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS get_item_icon IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS render_item_lock_column IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_parent_dir RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_obj_jump_link IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS build_dir_jump_link IMPORTING !iv_path TYPE string RETURNING VALUE(rv_html) TYPE string . METHODS build_inactive_object_code IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_inactive_html_code) TYPE string . METHODS open_in_main_language RAISING zcx_abapgit_exception . METHODS render_order_by RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS apply_order_by CHANGING !ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt . METHODS build_branch_dropdown RETURNING VALUE(ro_branch_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_tag_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_tag_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_advanced_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ro_advanced_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_toolbar IMPORTING !iv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout !iv_lstate TYPE char1 !iv_rstate TYPE char1 !io_tb_branch TYPE REF TO zcl_abapgit_html_toolbar !io_tb_tag TYPE REF TO zcl_abapgit_html_toolbar !io_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS switch_to_pr IMPORTING !it_fields TYPE tihttpnvp OPTIONAL !iv_revert TYPE abap_bool OPTIONAL RETURNING VALUE(rv_switched) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS build_main_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS is_repo_lang_logon_lang RETURNING VALUE(rv_repo_lang_is_logon_lang) TYPE abap_bool . METHODS get_abapgit_tcode RETURNING VALUE(rv_tcode) TYPE tcode . ENDCLASS. CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. METHOD apply_order_by. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort, lt_non_code_and_metadata_items LIKE ct_repo_items, lt_code_items LIKE ct_repo_items, lt_diff_items LIKE ct_repo_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_repo_item. IF mv_order_by IS INITIAL. RETURN. ENDIF. "" we want to preserve non-code and metadata files at the top, "" so we isolate them and and sort only the code artifacts LOOP AT ct_repo_items ASSIGNING . IF -obj_type IS INITIAL AND -is_dir = abap_false. INSERT INTO TABLE lt_non_code_and_metadata_items. ELSE. INSERT INTO TABLE lt_code_items. ENDIF. ENDLOOP. IF mv_diff_first = abap_true. "" fix diffs on the top, right after non-code and metadata LOOP AT lt_code_items ASSIGNING WHERE changes > 0. INSERT INTO TABLE lt_diff_items. ENDLOOP. DELETE lt_code_items WHERE changes > 0. ENDIF. CLEAR: ct_repo_items. ls_sort-name = mv_order_by. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. INSERT ls_sort INTO TABLE lt_sort. SORT lt_code_items BY (lt_sort). SORT lt_diff_items BY (lt_sort). INSERT LINES OF lt_non_code_and_metadata_items INTO TABLE ct_repo_items. INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items. INSERT LINES OF lt_code_items INTO TABLE ct_repo_items. ENDMETHOD. METHOD build_advanced_dropdown. DATA: lv_crossout LIKE zif_abapgit_html=>c_html_opt-crossout. CREATE OBJECT ro_advanced_dropdown. IF iv_rstate IS NOT INITIAL OR iv_lstate IS NOT INITIAL. "" In case of asyncronicities ro_advanced_dropdown->add( iv_txt = 'Reset Local (Force Pull)' iv_act = |{ zif_abapgit_definitions=>c_action-git_reset }?key={ mv_key }| iv_opt = iv_wp_opt ). ENDIF. IF mo_repo->is_offline( ) = abap_false. "" Online ? ro_advanced_dropdown->add( iv_txt = 'Checkout commit' iv_act = |{ zif_abapgit_definitions=>c_action-git_checkout_commit }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_advanced_dropdown->add( iv_txt = 'Background Mode' iv_act = |{ zif_abapgit_definitions=>c_action-go_background }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Change Remote' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_change }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Make Off-line' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_detach }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Force Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-transport_to_branch ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Transport to Branch' iv_act = |{ zif_abapgit_definitions=>c_action-repo_transport_to_branch }?key={ mv_key }| iv_opt = lv_crossout ). ELSE. ro_advanced_dropdown->add( iv_txt = 'Make On-line' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_attach }?key={ mv_key }| ). ENDIF. IF mv_are_changes_recorded_in_tr = abap_true. ro_advanced_dropdown->add( iv_txt = 'Add all objects to transport request' iv_act = |{ zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Syntax Check' iv_act = |{ zif_abapgit_definitions=>c_action-repo_syntax_check }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Run Code Inspector' iv_act = |{ zif_abapgit_definitions=>c_action-repo_code_inspector }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-update_local_checksum ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Update Local Checksums' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh_checksums }?key={ mv_key }| iv_opt = lv_crossout ). ro_advanced_dropdown->add( iv_txt = 'Beta - Data' iv_act = |{ c_actions-go_data }?key={ mv_key }| iv_opt = lv_crossout ). IF is_repo_lang_logon_lang( ) = abap_false AND get_abapgit_tcode( ) IS NOT INITIAL. ro_advanced_dropdown->add( iv_txt = 'Open in Main Language' iv_act = |{ zif_abapgit_definitions=>c_action-repo_open_in_master_lang }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Remove' iv_title = `Remove abapGit's records of the repository (the system's ` && `development objects will remain unaffected)` iv_act = |{ zif_abapgit_definitions=>c_action-repo_remove }?key={ mv_key }| ). CLEAR lv_crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true OR zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-uninstall ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Uninstall' iv_title = `Delete all development objects belonging to this package ` && `(and subpackages) from the system` iv_act = |{ zif_abapgit_definitions=>c_action-repo_purge }?key={ mv_key }| iv_opt = lv_crossout ). ENDMETHOD. METHOD build_branch_dropdown. DATA lo_repo_online TYPE REF TO zcl_abapgit_repo_online. CREATE OBJECT ro_branch_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_branch_dropdown->add( iv_txt = 'Overview' iv_act = |{ zif_abapgit_definitions=>c_action-go_branch_overview }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_switch }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_create }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_delete }?key={ mv_key }| ). lo_repo_online ?= mo_repo. "" TODO refactor this disaster IF lo_repo_online->get_switched_origin( ) IS NOT INITIAL. ro_branch_dropdown->add( iv_txt = 'Revert to Previous Branch' iv_act = |{ c_actions-repo_reset_origin }| ). ELSE. ro_branch_dropdown->add( iv_txt = 'Switch to PR Branch' iv_act = |{ c_actions-repo_switch_origin_to_pr }| ). ENDIF. ENDMETHOD. METHOD build_dir_jump_link. DATA lv_path TYPE string. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_path = iv_path. REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''. lv_encode = zcl_abapgit_html_action_utils=>dir_encode( lv_path ). rv_html = li_html->a( iv_txt = lv_path iv_act = |{ c_actions-change_dir }?{ lv_encode }| ). ENDMETHOD. METHOD build_head_menu. DATA: lo_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_branch TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_tag TYPE REF TO zcl_abapgit_html_toolbar, lv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout, lv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true. lv_wp_opt = zif_abapgit_html=>c_html_opt-crossout. lv_pull_opt = zif_abapgit_html=>c_html_opt-crossout. ELSE. lv_pull_opt = zif_abapgit_html=>c_html_opt-strong. ENDIF. lo_tb_branch = build_branch_dropdown( ). lo_tb_tag = build_tag_dropdown( lv_wp_opt ). lo_tb_advanced = build_advanced_dropdown( iv_wp_opt = lv_wp_opt iv_rstate = iv_rstate iv_lstate = iv_lstate ). ro_toolbar = build_main_toolbar( iv_pull_opt = lv_pull_opt iv_rstate = iv_rstate iv_lstate = iv_lstate io_tb_branch = lo_tb_branch io_tb_tag = lo_tb_tag io_tb_advanced = lo_tb_advanced ). ENDMETHOD. METHOD build_inactive_object_code. IF is_item-inactive = abap_true. rv_inactive_html_code = zcl_abapgit_html=>icon( iv_name = 'bolt/orange' iv_hint = 'Object or object part is inactive' iv_class = 'inactive' ). ENDIF. ENDMETHOD. METHOD build_main_menu. CREATE OBJECT ro_menu EXPORTING iv_id = 'toolbar-main'. ro_menu->add( iv_txt = zcl_abapgit_gui_buttons=>repo_list( ) iv_act = zif_abapgit_definitions=>c_action-abapgit_home )->add( iv_txt = zcl_abapgit_gui_buttons=>settings( ) iv_act = zif_abapgit_definitions=>c_action-go_settings )->add( iv_txt = zcl_abapgit_gui_buttons=>advanced( ) iv_title = 'Utilities' io_sub = zcl_abapgit_gui_chunk_lib=>advanced_submenu( ) )->add( iv_txt = zcl_abapgit_gui_buttons=>help( ) iv_title = 'Help' io_sub = zcl_abapgit_gui_chunk_lib=>help_submenu( ) ). ENDMETHOD. METHOD build_main_toolbar. DATA: li_log TYPE REF TO zif_abapgit_log. CREATE OBJECT ro_toolbar EXPORTING iv_id = 'toolbar-repo'. IF mo_repo->is_offline( ) = abap_false. IF iv_rstate IS NOT INITIAL. "" Something new at remote ro_toolbar->add( iv_txt = 'Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = iv_pull_opt ). ENDIF. IF iv_lstate IS NOT INITIAL. "" Something new at local ro_toolbar->add( iv_txt = 'Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. IF iv_rstate IS NOT INITIAL OR iv_lstate IS NOT INITIAL. "" Any changes ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ro_toolbar->add( iv_txt = 'Branch' io_sub = io_tb_branch ). ro_toolbar->add( iv_txt = 'Tag' io_sub = io_tb_tag ). ELSE. IF mo_repo->has_remote_source( ) = abap_true AND iv_rstate IS NOT INITIAL. ro_toolbar->add( iv_txt = 'Pull zip' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Import zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_import }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Export zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ENDIF. ro_toolbar->add( iv_txt = 'Advanced' io_sub = io_tb_advanced ). ro_toolbar->add( iv_txt = 'View' io_sub = build_view_menu( ) ). ro_toolbar->add( iv_txt = 'Refresh' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = zcl_abapgit_html=>icon( iv_name = 'cog' ) iv_act = |{ zif_abapgit_definitions=>c_action-repo_settings }?key={ mv_key }| iv_title = `Repository Settings` ). ENDMETHOD. METHOD build_obj_jump_link. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_encode = zcl_abapgit_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type iv_obj_name = is_item-obj_name ). rv_html = li_html->a( iv_txt = |{ is_item-obj_name }| iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). ENDMETHOD. METHOD build_tag_dropdown. CREATE OBJECT ro_tag_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_tag_dropdown->add( iv_txt = 'Overview' iv_act = |{ zif_abapgit_definitions=>c_action-go_tag_overview }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_tag_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_create }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_delete }?key={ mv_key }| ). ENDMETHOD. METHOD build_view_menu. CREATE OBJECT ro_toolbar. ro_toolbar->add( iv_txt = 'Changes First' iv_chk = mv_diff_first iv_act = c_actions-toggle_diff_first ). IF mo_repo->has_remote_source( ) = abap_true. ro_toolbar->add( iv_txt = 'Changes Only' iv_chk = mv_changes_only iv_act = c_actions-toggle_changes ). ro_toolbar->add( iv_txt = 'File Paths' iv_chk = boolc( NOT mv_hide_files = abap_true ) iv_act = c_actions-toggle_hide_files ). ENDIF. ro_toolbar->add( iv_txt = 'Folders' iv_chk = mv_show_folders iv_act = c_actions-toggle_folders ). ENDMETHOD. METHOD constructor. DATA: lo_settings TYPE REF TO zcl_abapgit_settings, lx_error TYPE REF TO zcx_abapgit_exception. super->constructor( ). TRY. mv_key = iv_key. mo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). mv_cur_dir = '/'. "" Root mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->get_hide_files( ). mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->get_changes_only( ). mv_diff_first = abap_true. ms_control-page_title = 'Repository'. ms_control-page_menu = build_main_menu( ). "" Read global settings to get max # of objects to be listed lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). mv_max_lines = lo_settings->get_max_lines( ). mv_max_setting = mv_max_lines. CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). RAISE EXCEPTION lx_error. ENDTRY. ENDMETHOD. METHOD get_abapgit_tcode. CONSTANTS: lc_report_tcode_hex TYPE x VALUE '80'. DATA: lt_tcodes TYPE STANDARD TABLE OF tcode. SELECT tcode FROM tstc INTO TABLE lt_tcodes WHERE pgmna = sy-cprog AND cinfo = lc_report_tcode_hex. IF lines( lt_tcodes ) > 0. READ TABLE lt_tcodes INDEX 1 INTO rv_tcode. ENDIF. ENDMETHOD. METHOD get_item_class. DATA lt_class TYPE TABLE OF string. IF is_item-is_dir = abap_true. APPEND 'folder' TO lt_class. ELSEIF is_item-changes > 0. APPEND 'modified' TO lt_class. ELSEIF is_item-obj_name IS INITIAL. APPEND 'unsupported' TO lt_class. ENDIF. IF lines( lt_class ) > 0. rv_html = | class=""{ concat_lines_of( table = lt_class sep = ` ` ) }""|. ENDIF. ENDMETHOD. METHOD get_item_icon. CASE is_item-obj_type. WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' iv_hint = 'Code' ). WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' iv_hint = 'Binary' ). WHEN 'DEVC'. rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' iv_hint = 'Package' ). WHEN ''. rv_html = space. "" no icon WHEN OTHERS. rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). ENDCASE. IF is_item-is_dir = abap_true. rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' iv_hint = 'Folder' ). ENDIF. ENDMETHOD. METHOD is_repo_lang_logon_lang. rv_repo_lang_is_logon_lang = boolc( mo_repo->get_dot_abapgit( )->get_master_language( ) = sy-langu ). ENDMETHOD. METHOD open_in_main_language. DATA: lv_main_language TYPE spras, lt_spagpa TYPE STANDARD TABLE OF rfc_spagpa, ls_spagpa LIKE LINE OF lt_spagpa, ls_item TYPE zif_abapgit_definitions=>ty_item, lv_subrc TYPE syst-subrc, lv_save_sy_langu TYPE sy-langu, lv_tcode TYPE tcode. "" https://blogs.sap.com/2017/01/13/logon-language-sy-langu-and-rfc/ lv_main_language = mo_repo->get_dot_abapgit( )->get_master_language( ). lv_tcode = get_abapgit_tcode( ). ASSERT lv_tcode IS NOT INITIAL. IF lv_main_language = sy-langu. zcx_abapgit_exception=>raise( |Repo already opened in main language| ). ENDIF. ls_item-obj_name = lv_tcode. ls_item-obj_type = |TRAN|. IF zcl_abapgit_objects=>exists( ls_item ) = abap_false. zcx_abapgit_exception=>raise( |Please install the abapGit repository| ). ENDIF. lv_save_sy_langu = sy-langu. SET LOCALE LANGUAGE lv_main_language. ls_spagpa-parid = zif_abapgit_definitions=>c_spagpa_param_repo_key. ls_spagpa-parval = mo_repo->get_key( ). INSERT ls_spagpa INTO TABLE lt_spagpa. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' DESTINATION 'NONE' STARTING NEW TASK 'ABAPGIT' EXPORTING tcode = lv_tcode TABLES spagpa_tab = lt_spagpa EXCEPTIONS call_transaction_denied = 1 tcode_invalid = 2 communication_failure = 3 system_failure = 4 OTHERS = 5. lv_subrc = sy-subrc. SET LOCALE LANGUAGE lv_save_sy_langu. IF lv_subrc <> 0. zcx_abapgit_exception=>raise( |Error from ABAP4_CALL_TRANSACTION. Subrc = { lv_subrc }| ). ENDIF. MESSAGE 'Repository opened in a new window' TYPE 'S'. ENDMETHOD. METHOD render_content. DATA: lt_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt, lo_browser TYPE REF TO zcl_abapgit_repo_content_list, lx_error TYPE REF TO zcx_abapgit_exception, lv_lstate TYPE char1, lv_rstate TYPE char1, lv_max TYPE abap_bool, lv_max_str TYPE string, lv_add_str TYPE string, li_log TYPE REF TO zif_abapgit_log, lv_msg TYPE string, lo_news TYPE REF TO zcl_abapgit_news. FIELD-SYMBOLS LIKE LINE OF lt_repo_items. gui_services( )->get_hotkeys_ctl( )->register_hotkeys( me ). gui_services( )->register_event_handler( me ). TRY. "" Reinit, for the case of type change mo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( mo_repo->get_key( ) ). mv_are_changes_recorded_in_tr = zcl_abapgit_factory=>get_sap_package( mo_repo->get_package( ) )->are_changes_recorded_in_tr_req( ). lo_news = zcl_abapgit_news=>create( mo_repo ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo io_news = lo_news iv_interactive_branch = abap_true ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_news( io_news = lo_news ) ). CREATE OBJECT lo_browser EXPORTING io_repo = mo_repo. lt_repo_items = lo_browser->list( iv_path = mv_cur_dir iv_by_folders = mv_show_folders iv_changes_only = mv_changes_only ). apply_order_by( CHANGING ct_repo_items = lt_repo_items ). LOOP AT lt_repo_items ASSIGNING . zcl_abapgit_state=>reduce( EXPORTING iv_cur = -lstate CHANGING cv_prev = lv_lstate ). zcl_abapgit_state=>reduce( EXPORTING iv_cur = -rstate CHANGING cv_prev = lv_rstate ). ENDLOOP. ri_html->add( render_head_line( iv_lstate = lv_lstate iv_rstate = lv_rstate ) ). li_log = lo_browser->get_log( ). IF mo_repo->is_offline( ) = abap_false AND li_log->count( ) > 0. ri_html->add( '
' ). ri_html->add( zcl_abapgit_log_viewer=>to_html( li_log ) ). "" shows eg. list of unsupported objects ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). CLEAR lv_msg. IF mo_repo->is_offline( ) = abap_true AND mo_repo->has_remote_source( ) = abap_true AND lv_lstate IS INITIAL AND lv_rstate IS INITIAL. "" Offline match banner lv_msg = 'ZIP source is attached and completely matches the local state'. ELSEIF lines( lt_repo_items ) = 0. "" Online match banner IF mv_changes_only = abap_true. lv_msg = 'Local state completely matches the remote repository'. ELSE. lv_msg = |Package is empty. Show { build_dir_jump_link( 'parent' ) } package|. ENDIF. ELSE. "" Repo content table ri_html->add( '' ). IF zcl_abapgit_path=>is_root( mv_cur_dir ) = abap_false. ri_html->add( render_parent_dir( ) ). ENDIF. ri_html->add( render_order_by( ) ). LOOP AT lt_repo_items ASSIGNING . IF mv_max_lines > 0 AND sy-tabix > mv_max_lines. lv_max = abap_true. EXIT. "" current loop ENDIF. ri_html->add( render_item( is_item = iv_render_transports = mv_are_changes_recorded_in_tr ) ). ENDLOOP. ri_html->add( '
' ). ENDIF. IF NOT lv_msg IS INITIAL. ri_html->add( |
{ lv_msg }
| ). ENDIF. IF lv_max = abap_true. ri_html->add( '
' ). IF mv_max_lines = 1. lv_max_str = '1 object'. ELSE. lv_max_str = |first { mv_max_lines } objects|. ENDIF. lv_add_str = |+{ mv_max_setting }|. ri_html->add( |Only { lv_max_str } objects shown in list. Display { ri_html->a( iv_txt = lv_add_str iv_act = c_actions-display_more ) } more (change in Settings > { ri_html->a( iv_txt = 'Personal Settings' iv_act = zif_abapgit_definitions=>c_action-go_settings_personal ) })| ). ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). ri_html->add( render_head_line( iv_lstate = lv_lstate iv_rstate = lv_rstate ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_error( iv_extra_style = 'repo_banner' ix_error = lx_error ) ). ENDTRY. register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_head_line. DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar. CREATE OBJECT ri_html TYPE zcl_abapgit_html. lo_toolbar = build_head_menu( iv_lstate = iv_lstate iv_rstate = iv_rstate ). ri_html->add( '
' ). ri_html->add( '' ). IF mv_show_folders = abap_true. ri_html->add( || ). ENDIF. ri_html->add( '' ). ri_html->add( '
{ mv_cur_dir }' ). ri_html->add( lo_toolbar->render( iv_right = abap_true ) ). ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_item. DATA: lv_link TYPE string, lv_colspan TYPE i. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF iv_render_transports = abap_false. lv_colspan = 2. ELSE. lv_colspan = 3. ENDIF. ri_html->add( || ). IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false. ri_html->add( || && '' && 'non-code and meta files' && '' ). ELSE. ri_html->add( |{ get_item_icon( is_item ) }| ). IF iv_render_transports = abap_true. ri_html->add( render_item_lock_column( is_item ) ). ENDIF. IF is_item-is_dir = abap_true. "" Subdir lv_link = build_dir_jump_link( is_item-path ). ri_html->add( |{ lv_link }| ). ELSE. lv_link = build_obj_jump_link( is_item ). ri_html->add( |{ is_item-obj_type }| ). ri_html->add( |{ lv_link } { build_inactive_object_code( is_item ) }| ). ENDIF. ENDIF. "" Files ri_html->add( '' ). ri_html->add( render_item_files( is_item ) ). ri_html->add( '' ). "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_item_command( is_item ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_item_command. DATA: lv_difflink TYPE string, ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-is_dir = abap_true. "" Directory ri_html->add( '
' ). ri_html->add( |{ is_item-changes } changes| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSEIF is_item-changes > 0. IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL. lv_difflink = zcl_abapgit_html_action_utils=>obj_encode( iv_key = mo_repo->get_key( ) ig_object = is_item ). ri_html->add( '
' ). ri_html->add_a( iv_txt = |diff ({ is_item-changes })| iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSE. LOOP AT is_item-files INTO ls_file. ri_html->add( '
' ). IF ls_file-is_changed = abap_true. lv_difflink = zcl_abapgit_html_action_utils=>file_encode( iv_key = mo_repo->get_key( ) ig_file = ls_file ). ri_html->add_a( iv_txt = 'diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = ls_file-lstate iv_rstate = ls_file-rstate ) ). ELSE. ri_html->add( ' ' ). ENDIF. ri_html->add( '
' ). ENDLOOP. ENDIF. ENDIF. ENDMETHOD. METHOD render_item_files. DATA: ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF mv_hide_files = abap_true AND is_item-obj_type IS NOT INITIAL. RETURN. ENDIF. LOOP AT is_item-files INTO ls_file. ri_html->add( |
{ ls_file-path && ls_file-filename }
| ). ENDLOOP. ENDMETHOD. METHOD render_item_lock_column. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, lv_transport TYPE trkorr. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ls_item-obj_type = is_item-obj_type. ls_item-obj_name = is_item-obj_name. TRY. lv_transport = zcl_abapgit_factory=>get_cts_api( )->get_transport_for_object( ls_item ). IF lv_transport IS NOT INITIAL. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport = lv_transport iv_icon_only = abap_true ) ). ENDIF. CATCH zcx_abapgit_exception ##NO_HANDLER. "" Ignore errors related to object check when trying to get transport ENDTRY. ri_html->add( '' ). ENDMETHOD. METHOD render_order_by. DATA: lv_icon TYPE string, lt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt, ls_col_spec TYPE zif_abapgit_definitions=>ty_col_spec. CREATE OBJECT ri_html TYPE zcl_abapgit_html. APPEND INITIAL LINE TO lt_col_spec. IF mv_are_changes_recorded_in_tr = abap_true. APPEND INITIAL LINE TO lt_col_spec. ENDIF. ls_col_spec-tech_name = 'OBJ_TYPE'. ls_col_spec-display_name = 'Type'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_NAME'. ls_col_spec-display_name = 'Name'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'PATH'. ls_col_spec-display_name = 'Path'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. APPEND INITIAL LINE TO lt_col_spec. ri_html->add( || ). ri_html->add( || ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_order_by_header_cells( it_col_spec = lt_col_spec iv_order_by = mv_order_by iv_order_descending = mv_order_descending ) ). IF mv_diff_first = abap_true. lv_icon = 'check/blue'. ELSE. lv_icon = 'check/grey'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_parent_dir. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( |{ ri_html->icon( 'folder' ) }| ). ri_html->add( |{ build_dir_jump_link( '..' ) }| ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( || ). "" Dummy for online ENDIF. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_palette( zif_abapgit_definitions=>c_action-go_repo ) ). ENDMETHOD. METHOD switch_to_pr. DATA lo_repo_online TYPE REF TO zcl_abapgit_repo_online. DATA lt_pulls TYPE zif_abapgit_pr_enum_provider=>ty_pull_requests. DATA ls_pull LIKE LINE OF lt_pulls. IF mo_repo->is_offline( ) = abap_true. zcx_abapgit_exception=>raise( 'Unexpected PR switch for offline repo' ). ENDIF. IF mo_repo->get_local_settings( )-write_protected = abap_true. zcx_abapgit_exception=>raise( 'Cannot switch branch. Local code is write-protected by repo config' ). ENDIF. lo_repo_online ?= mo_repo. IF iv_revert = abap_true. lo_repo_online->switch_origin( '' ). ELSE. lt_pulls = zcl_abapgit_pr_enumerator=>new( lo_repo_online )->get_pulls( ). IF lines( lt_pulls ) = 0. RETURN. "" false ENDIF. SORT lt_pulls BY number DESCENDING. ls_pull = zcl_abapgit_ui_factory=>get_popups( )->choose_pr_popup( lt_pulls ). IF ls_pull IS INITIAL. RETURN. "" false ENDIF. lo_repo_online->switch_origin( ls_pull-head_url ). lo_repo_online->select_branch( |refs/heads/{ ls_pull-head_branch }| ). "" TODO refactor rv_switched = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA lv_path TYPE string. DATA lv_switched TYPE abap_bool. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-go_repo. "" Switch to another repo CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN c_actions-go_data. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_data EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_actions-toggle_hide_files. "" Toggle file diplay mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->toggle_hide_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-change_dir. "" Change dir lv_path = ii_event->query( )->get( 'PATH' ). mv_cur_dir = zcl_abapgit_path=>change_dir( iv_cur_dir = mv_cur_dir iv_cd = lv_path ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_folders. "" Toggle folder view mv_show_folders = boolc( mv_show_folders <> abap_true ). mv_cur_dir = '/'. "" Root rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_changes. "" Toggle changes only view mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->toggle_changes_only( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_diff_first. mv_diff_first = boolc( mv_diff_first = abap_false ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-display_more. "" Increase MAX lines limit mv_max_lines = mv_max_lines + mv_max_setting. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-change_order_by. mv_order_by = ii_event->query( )->get( 'ORDERBY' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-direction. mv_order_descending = boolc( ii_event->query( )->get( 'DIRECTION' ) = 'DESCENDING' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_open_in_master_lang. open_in_main_language( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-repo_switch_origin_to_pr. lv_switched = switch_to_pr( ). IF lv_switched = abap_true. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ELSE. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDIF. WHEN c_actions-repo_reset_origin. switch_to_pr( iv_revert = abap_true ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). "" TODO refactor, move to HOC components ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions. ls_hotkey_action-ui_component = 'Repo'. ls_hotkey_action-description = |Stage changes|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_stage. ls_hotkey_action-hotkey = |s|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Switch branch|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_branch_switch. ls_hotkey_action-hotkey = |b|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Repository list|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-abapgit_home. ls_hotkey_action-hotkey = |o|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Refresh repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_refresh. ls_hotkey_action-hotkey = |r|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Pull|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_pull. ls_hotkey_action-hotkey = |p|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Diff|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_repo_diff. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Uninstall repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_purge. ls_hotkey_action-hotkey = |u|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run syntax check|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_syntax_check. ls_hotkey_action-hotkey = |c|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run code inspector|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_code_inspector. ls_hotkey_action-hotkey = |i|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Show log|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_log. ls_hotkey_action-hotkey = |l|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |abapGit settings|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_settings. ls_hotkey_action-hotkey = |x|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ENDMETHOD. ENDCLASS. ",12141,True,2535.5254274032923,median "package com.ankamagames.dofus.logic.game.common.frames { import com.ankama.dofus.enums.ActionIds; import com.ankamagames.berilia.Berilia; import com.ankamagames.berilia.components.Texture; import com.ankamagames.berilia.components.params.TooltipProperties; import com.ankamagames.berilia.factories.TooltipsFactory; import com.ankamagames.berilia.managers.KernelEventsManager; import com.ankamagames.berilia.managers.UiModuleManager; import com.ankamagames.berilia.types.data.UiModule; import com.ankamagames.berilia.types.graphic.UiRootContainer; import com.ankamagames.dofus.datacenter.effects.EffectInstance; import com.ankamagames.dofus.datacenter.idols.Idol; import com.ankamagames.dofus.datacenter.items.Item; import com.ankamagames.dofus.internalDatacenter.DataEnum; import com.ankamagames.dofus.internalDatacenter.items.BuildWrapper; import com.ankamagames.dofus.internalDatacenter.items.IdolsPresetWrapper; import com.ankamagames.dofus.internalDatacenter.items.ItemWrapper; import com.ankamagames.dofus.internalDatacenter.items.ShortcutWrapper; import com.ankamagames.dofus.internalDatacenter.spells.SpellWrapper; import com.ankamagames.dofus.kernel.Kernel; import com.ankamagames.dofus.kernel.net.ConnectionsHandler; import com.ankamagames.dofus.kernel.sound.enum.SoundTypeEnum; import com.ankamagames.dofus.logic.common.managers.FeatureManager; import com.ankamagames.dofus.logic.common.managers.PlayerManager; import com.ankamagames.dofus.logic.common.managers.PopupManager; import com.ankamagames.dofus.logic.game.common.actions.AccessoryPreviewRequestAction; import com.ankamagames.dofus.logic.game.common.managers.InventoryManager; import com.ankamagames.dofus.logic.game.common.managers.PlayedCharacterManager; import com.ankamagames.dofus.logic.game.common.managers.TimeManager; import com.ankamagames.dofus.logic.game.common.misc.DofusEntities; import com.ankamagames.dofus.logic.game.common.misc.IInventoryView; import com.ankamagames.dofus.logic.game.fight.frames.FightBattleFrame; import com.ankamagames.dofus.logic.game.fight.frames.FightContextFrame; import com.ankamagames.dofus.logic.game.roleplay.actions.DeleteObjectAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ObjectDropAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ObjectSetPositionAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ObjectUseAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ObjectUseOnCellAction; import com.ankamagames.dofus.logic.game.roleplay.actions.PresetSetPositionAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ShortcutBarAddRequestAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ShortcutBarRemoveRequestAction; import com.ankamagames.dofus.logic.game.roleplay.actions.ShortcutBarSwapRequestAction; import com.ankamagames.dofus.logic.game.roleplay.actions.preset.CharacterPresetSaveRequestAction; import com.ankamagames.dofus.logic.game.roleplay.actions.preset.IdolsPresetSaveRequestAction; import com.ankamagames.dofus.logic.game.roleplay.actions.preset.PresetDeleteRequestAction; import com.ankamagames.dofus.logic.game.roleplay.actions.preset.PresetUseRequestAction; import com.ankamagames.dofus.logic.game.roleplay.frames.RoleplayMovementFrame; import com.ankamagames.dofus.misc.enum.CharacterBuildType; import com.ankamagames.dofus.misc.lists.ChatHookList; import com.ankamagames.dofus.misc.lists.CraftHookList; import com.ankamagames.dofus.misc.lists.ExternalGameHookList; import com.ankamagames.dofus.misc.lists.HookList; import com.ankamagames.dofus.misc.lists.InventoryHookList; import com.ankamagames.dofus.network.enums.AccessoryPreviewErrorEnum; import com.ankamagames.dofus.network.enums.CharacterInventoryPositionEnum; import com.ankamagames.dofus.network.enums.ChatActivableChannelsEnum; import com.ankamagames.dofus.network.enums.GameContextEnum; import com.ankamagames.dofus.network.enums.GameServerTypeEnum; import com.ankamagames.dofus.network.enums.ObjectErrorEnum; import com.ankamagames.dofus.network.enums.PresetDeleteResultEnum; import com.ankamagames.dofus.network.enums.PresetSaveResultEnum; import com.ankamagames.dofus.network.enums.PresetUseResultEnum; import com.ankamagames.dofus.network.enums.ShortcutBarEnum; import com.ankamagames.dofus.network.enums.SubEntityBindingPointCategoryEnum; import com.ankamagames.dofus.network.messages.game.inventory.KamasUpdateMessage; import com.ankamagames.dofus.network.messages.game.inventory.exchanges.DecraftResultMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.InventoryContentMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.InventoryWeightMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectAddedMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectDeleteMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectDeletedMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectDropMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectErrorMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectModifiedMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectMovementMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectQuantityMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectSetPositionMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectUseMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectUseMultipleMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectUseOnCellMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectUseOnCharacterMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectsAddedMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectsDeletedMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.ObjectsQuantityMessage; import com.ankamagames.dofus.network.messages.game.inventory.items.WatchInventoryContentMessage; import com.ankamagames.dofus.network.messages.game.look.AccessoryPreviewErrorMessage; import com.ankamagames.dofus.network.messages.game.look.AccessoryPreviewMessage; import com.ankamagames.dofus.network.messages.game.look.AccessoryPreviewRequestMessage; import com.ankamagames.dofus.network.messages.game.presets.IconNamedPresetSaveRequestMessage; import com.ankamagames.dofus.network.messages.game.presets.IdolsPresetSaveRequestMessage; import com.ankamagames.dofus.network.messages.game.presets.InvalidPresetsMessage; import com.ankamagames.dofus.network.messages.game.presets.ItemForPresetUpdateMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetDeleteRequestMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetDeleteResultMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetSaveErrorMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetSavedMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetUseRequestMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetUseResultMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetUseResultWithMissingIdsMessage; import com.ankamagames.dofus.network.messages.game.presets.PresetsMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarAddRequestMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarContentMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarRefreshMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarRemoveRequestMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarRemovedMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarReplacedMessage; import com.ankamagames.dofus.network.messages.game.shortcut.ShortcutBarSwapRequestMessage; import com.ankamagames.dofus.network.types.game.data.items.ObjectItem; import com.ankamagames.dofus.network.types.game.data.items.ObjectItemQuantity; import com.ankamagames.dofus.network.types.game.look.EntityLook; import com.ankamagames.dofus.network.types.game.look.SubEntity; import com.ankamagames.dofus.network.types.game.presets.ForgettableSpellsPreset; import com.ankamagames.dofus.network.types.game.presets.FullStatsPreset; import com.ankamagames.dofus.network.types.game.presets.IconNamedPreset; import com.ankamagames.dofus.network.types.game.presets.IdolsPreset; import com.ankamagames.dofus.network.types.game.presets.ItemsPreset; import com.ankamagames.dofus.network.types.game.presets.Preset; import com.ankamagames.dofus.network.types.game.presets.PresetsContainerPreset; import com.ankamagames.dofus.network.types.game.presets.SpellsPreset; import com.ankamagames.dofus.network.types.game.shortcut.Shortcut; import com.ankamagames.dofus.network.types.game.shortcut.ShortcutEmote; import com.ankamagames.dofus.network.types.game.shortcut.ShortcutObjectIdolsPreset; import com.ankamagames.dofus.network.types.game.shortcut.ShortcutObjectItem; import com.ankamagames.dofus.network.types.game.shortcut.ShortcutObjectPreset; import com.ankamagames.dofus.network.types.game.shortcut.ShortcutSmiley; import com.ankamagames.dofus.network.types.game.shortcut.ShortcutSpell; import com.ankamagames.dofus.types.characteristicContextual.CharacteristicContextualManager; import com.ankamagames.dofus.types.enums.ItemCategoryEnum; import com.ankamagames.dofus.types.enums.LanguageEnum; import com.ankamagames.dofus.uiApi.SoundApi; import com.ankamagames.jerakine.benchmark.BenchmarkTimer; import com.ankamagames.jerakine.data.I18n; import com.ankamagames.jerakine.data.XmlConfig; import com.ankamagames.jerakine.entities.interfaces.IEntity; import com.ankamagames.jerakine.entities.interfaces.IMovable; import com.ankamagames.jerakine.logger.Log; import com.ankamagames.jerakine.logger.Logger; import com.ankamagames.jerakine.managers.StoreDataManager; import com.ankamagames.jerakine.messages.Frame; import com.ankamagames.jerakine.messages.Message; import com.ankamagames.jerakine.network.NetworkMessage; import com.ankamagames.jerakine.types.Callback; import com.ankamagames.jerakine.types.DataStoreType; import com.ankamagames.jerakine.types.enums.DataStoreEnum; import com.ankamagames.jerakine.types.enums.Priority; import com.ankamagames.jerakine.utils.pattern.PatternDecoder; import flash.events.TimerEvent; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.text.TextFormat; import flash.utils.Dictionary; import flash.utils.getQualifiedClassName; public class InventoryManagementFrame implements Frame { protected static const _log:Logger = Log.getLogger(getQualifiedClassName(InventoryManagementFrame)); private static const CHARACTER_BUILD_PRESET_TYPE:int = 1; private static const IDOLS_PRESET_TYPE:int = 2; private static const FORGETTABLE_PRESET_TYPE:int = 3; private static const POPUP_WARNING_TIPS_ID:uint = 15; private static var _dataStoreType:DataStoreType; private static const popupSaveKeyClassic:String = ""prevention-phishing""; private var _objectUIDToDrop:int; private var _objectGIDToDrop:uint; private var _quantityToDrop:uint; private var _dropPopup:String; private var _currentPointUseUIDObject:uint; private var _movingObjectUID:int; private var _movingObjectPreviousPosition:int; private var _objectPositionModification:Boolean; private var _soundApi:SoundApi; private var _presetTypeIdByPresetId:Dictionary; private var _invalidPresets:Vector.; private var _waitTimer:BenchmarkTimer; private var _chatText:String; public function InventoryManagementFrame() { this._soundApi = new SoundApi(); this._presetTypeIdByPresetId = new Dictionary(); this._invalidPresets = new Vector.(); super(); } public static function displayNewsPopupClassic() : void { var linkUrl:* = null; _dataStoreType = new DataStoreType(""Module_Ankama_Storage"",true,DataStoreEnum.LOCATION_LOCAL,DataStoreEnum.BIND_CHARACTER); if(!StoreDataManager.getInstance().getData(_dataStoreType,popupSaveKeyClassic)) { linkUrl = ""https://support.ankama.com/hc/""; switch(XmlConfig.getInstance().getEntry(""config.lang.current"")) { case LanguageEnum.LANG_FR: linkUrl += ""fr/articles/201376953-Reconna%C3%AEtre-le-phishing-et-s-en-prot%C3%A9ger-""; break; case LanguageEnum.LANG_ES: linkUrl += ""es/articles/201376953-Reconocer-el-phishing-y-protegerse-""; break; case LanguageEnum.LANG_PT: linkUrl += ""pt-br/articles/201376953-Reconhecendo-e-protegendo-se-contra-o-phishing""; break; default: linkUrl += ""en-us/articles/201376953-Recognizing-and-Protecting-Yourself-from-Phishing-""; } PopupManager.getInstance().showPopup(POPUP_WARNING_TIPS_ID); } } public function get priority() : int { return Priority.NORMAL; } public function get mountFrame() : MountFrame { return Kernel.getWorker().getFrame(MountFrame) as MountFrame; } public function getWrappersFromShortcuts(shortcuts:Vector.) : Array { var shortcutProperties:Object = null; var shortcut:Shortcut = null; var wrappers:Array = new Array(); for each(shortcut in shortcuts) { shortcutProperties = this.getShortcutWrapperPropFromShortcut(shortcut); wrappers[shortcut.slot] = ShortcutWrapper.create(shortcut.slot,shortcutProperties.id,shortcutProperties.type,shortcutProperties.gid); } return wrappers; } public function pushed() : Boolean { InventoryManager.getInstance().init(); return true; } public function process(msg:Message) : Boolean { var preset:Preset = null; var idolsPresets:Vector. = null; var build:BuildWrapper = null; var builds:Array = null; var idolsPreset:IdolsPreset = null; var idolsPresetWrapper:IdolsPresetWrapper = null; var forgettableSpellsActivated:Boolean = false; var wicmsg:WatchInventoryContentMessage = null; var mod:UiModule = null; var icmsg:InventoryContentMessage = null; var equipmentView:IInventoryView = null; var playerCharacterManager:PlayedCharacterManager = null; var oam:ObjectAddedMessage = null; var osam:ObjectsAddedMessage = null; var oqm:ObjectQuantityMessage = null; var osqm:ObjectsQuantityMessage = null; var kumsg:KamasUpdateMessage = null; var iwmsg:InventoryWeightMessage = null; var ommsg:ObjectMovementMessage = null; var sbcmsg:ShortcutBarContentMessage = null; var sbrmsg:ShortcutBarRefreshMessage = null; var inventoryMgr:InventoryManager = null; var sRProperties:Object = null; var sbrmmsg:ShortcutBarRemovedMessage = null; var sbrpmsg:ShortcutBarReplacedMessage = null; var replacingShortcutProperties:Object = null; var sbara:ShortcutBarAddRequestAction = null; var sbarmsg:ShortcutBarAddRequestMessage = null; var sbrra:ShortcutBarRemoveRequestAction = null; var sbrrmsg:ShortcutBarRemoveRequestMessage = null; var sbsra:ShortcutBarSwapRequestAction = null; var sbsrmsg:ShortcutBarSwapRequestMessage = null; var pspa:PresetSetPositionAction = null; var hiddenObjects:Vector. = null; var presetItem:ItemWrapper = null; var ospa:ObjectSetPositionAction = null; var itw:ItemWrapper = null; var omdmsg:ObjectModifiedMessage = null; var effectInst:EffectInstance = null; var petsMountWasAutopilotable:Boolean = false; var previousItemWrapper:ItemWrapper = null; var modifiedItemWrapper:ItemWrapper = null; var updateTooltip:Function = null; var odmsg:ObjectDeletedMessage = null; var osdmsg:ObjectsDeletedMessage = null; var doa:DeleteObjectAction = null; var odmsg2:ObjectDeleteMessage = null; var oua:ObjectUseAction = null; var iw:ItemWrapper = null; var fncUseItem:Function = null; var nbFood:int = 0; var nbBonus:int = 0; var view:IInventoryView = null; var oda:ObjectDropAction = null; var itemItem:Item = null; var objectName:String = null; var ouocmsg:ObjectUseOnCellMessage = null; var ouoca:ObjectUseOnCellAction = null; var oemsg:ObjectErrorMessage = null; var pmsg:PresetsMessage = null; var presetWrappers:Array = null; var presetsCount:int = 0; var iPreset:int = 0; var ipmsg:InvalidPresetsMessage = null; var buildLink:Array = null; var ipiumsg:ItemForPresetUpdateMessage = null; var pdra:PresetDeleteRequestAction = null; var pdmsg:PresetDeleteRequestMessage = null; var pdrmsg:PresetDeleteResultMessage = null; var cpsra:CharacterPresetSaveRequestAction = null; var npsrmsg:IconNamedPresetSaveRequestMessage = null; var ipsra:IdolsPresetSaveRequestAction = null; var ipsrmsg:IdolsPresetSaveRequestMessage = null; var psemsg:PresetSaveErrorMessage = null; var presetSaveErrorReasonText:String = null; var psmsg:PresetSavedMessage = null; var pura:PresetUseRequestAction = null; var pumsg:PresetUseRequestMessage = null; var purmsg:PresetUseResultMessage = null; var presetTypeId:int = 0; var presetUseErrorText:String = null; var apra:AccessoryPreviewRequestAction = null; var aprmsg:AccessoryPreviewRequestMessage = null; var apemsg:AccessoryPreviewErrorMessage = null; var apErrorMsg:String = null; var apmsg:AccessoryPreviewMessage = null; var previewLook:EntityLook = null; var drmsg:DecraftResultMessage = null; var message:String = null; var itwa:ItemWrapper = null; var osait:ObjectItem = null; var item:ItemWrapper = null; var quantity:int = 0; var content:String = null; var shortcutQty:ShortcutWrapper = null; var objoqm:ObjectItemQuantity = null; var shortcutsQty:ShortcutWrapper = null; var itwm:ItemWrapper = null; var shortcuti:ShortcutObjectItem = null; var shortcutp:ShortcutObjectPreset = null; var shortcuts:ShortcutSpell = null; var shortcutsm:ShortcutSmiley = null; var shortcute:ShortcutEmote = null; var shortcutd:ShortcutObjectIdolsPreset = null; var realitem:ItemWrapper = null; var effect:EffectInstance = null; var ospmsg:ObjectSetPositionMessage = null; var ospmsg2:ObjectSetPositionMessage = null; var shortcutItem:ShortcutWrapper = null; var uiName:String = null; var ttProperties:TooltipProperties = null; var autopilotMessage:String = null; var osdit:uint = 0; var t:ItemWrapper = null; var odropmsg:ObjectDropMessage = null; var buildPreset:IconNamedPreset = null; var fullStatsPreset:FullStatsPreset = null; var itemsPreset:ItemsPreset = null; var spellsPreset:SpellsPreset = null; var forgettableSpellsPreset:ForgettableSpellsPreset = null; var subPreset:Preset = null; var characterBuildType:uint = 0; var subSubPreset:Preset = null; var id:uint = 0; var buildWrapper:BuildWrapper = null; var presetIndex:int = 0; var deletePresetTypeId:int = 0; var reason1:String = null; var idolWrapper:IdolsPresetWrapper = null; var newBuild:IconNamedPreset = null; var fullStatsPresetSaved:FullStatsPreset = null; var itemsPresetSaved:ItemsPreset = null; var spellsPresetSaved:SpellsPreset = null; var forgettableSpellsPresetSaved:ForgettableSpellsPreset = null; var subPresetSaved:Preset = null; var characterBuildTypeSaved:uint = 0; var subSubPresetSaved:Preset = null; var chatUseText:String = null; var missingIds:Vector. = null; var missingId:uint = 0; var missingName:String = null; var missingText:String = null; var currentSpellWrapper:SpellWrapper = null; var spellsString:String = null; var chatFrame:ChatFrame = null; var followerPet:SubEntity = null; var sube:SubEntity = null; var commonMod:Object = UiModuleManager.getInstance().getModule(""Ankama_Common"").mainClass; switch(true) { case msg is WatchInventoryContentMessage: InventoryManager.getWatchInstance().init(); wicmsg = msg as WatchInventoryContentMessage; InventoryManager.getWatchInstance().inventory.initializeFromObjectItems(wicmsg.objects); InventoryManager.getWatchInstance().inventory.kamas = wicmsg.kamas; mod = UiModuleManager.getInstance().getModule(""Ankama_Storage""); Berilia.getInstance().loadUi(mod,mod.getUi(""watchEquipment""),""watchEquipment"",{""storageMod"":""watch""},true); return true; case msg is InventoryContentMessage: if(getQualifiedClassName(msg) != getQualifiedClassName(InventoryContentMessage)) { return false; } icmsg = msg as InventoryContentMessage; InventoryManager.getInstance().inventory.initializeFromObjectItems(icmsg.objects); InventoryManager.getInstance().inventory.kamas = icmsg.kamas; equipmentView = InventoryManager.getInstance().inventory.getView(""equipment""); if(equipmentView && equipmentView.content) { if(equipmentView.content[CharacterInventoryPositionEnum.ACCESSORY_POSITION_PETS] && equipmentView.content[CharacterInventoryPositionEnum.ACCESSORY_POSITION_PETS].typeId == DataEnum.ITEM_TYPE_PETSMOUNT) { PlayedCharacterManager.getInstance().isPetsMounting = true; PlayedCharacterManager.getInstance().petsMount = equipmentView.content[CharacterInventoryPositionEnum.ACCESSORY_POSITION_PETS]; } if(equipmentView.content[CharacterInventoryPositionEnum.INVENTORY_POSITION_ENTITY]) { PlayedCharacterManager.getInstance().hasCompanion = true; } } playerCharacterManager = PlayedCharacterManager.getInstance(); playerCharacterManager.inventory = InventoryManager.getInstance().realInventory; if(playerCharacterManager.characteristics) { playerCharacterManager.characteristics.kamas = icmsg.kamas; } if(PlayerManager.getInstance().server.gameTypeId != GameServerTypeEnum.SERVER_TYPE_TEMPORIS && playerCharacterManager.infos.level >= 10) { displayNewsPopupClassic(); } return true; break; case msg is ObjectAddedMessage: oam = msg as ObjectAddedMessage; InventoryManager.getInstance().inventory.addObjectItem(oam.object); if(oam.origin == 1) { this.displayAddedItem(oam.object.objectGID,oam.object.quantity); message = PatternDecoder.combine(I18n.getUiText(""ui.quest.itemObtained"",[oam.object.quantity,""{item,"" + oam.object.objectGID + "","" + oam.object.objectUID + ""}""]),""n"",oam.object.quantity <= 1,oam.object.quantity == 0); KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,message,ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } if((oam.object.position <= CharacterInventoryPositionEnum.INVENTORY_POSITION_MOUNT || oam.object.position == CharacterInventoryPositionEnum.INVENTORY_POSITION_ENTITY || oam.object.position == CharacterInventoryPositionEnum.INVENTORY_POSITION_COSTUME) && oam.object.position >= 0 && !Berilia.getInstance().getUi(""storage"")) { itwa = InventoryManager.getInstance().inventory.getItem(oam.object.objectUID); KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,I18n.getUiText(""ui.item.inUse"",[itwa.name]),ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } return true; case msg is ObjectsAddedMessage: osam = msg as ObjectsAddedMessage; for each(osait in osam.object) { InventoryManager.getInstance().inventory.addObjectItem(osait); } return true; case msg is ObjectQuantityMessage: oqm = msg as ObjectQuantityMessage; if(this._objectUIDToDrop == oqm.objectUID) { this._soundApi.playSound(SoundTypeEnum.DROP_ITEM); this._objectUIDToDrop = -1; } if(oqm.origin == 1) { item = InventoryManager.getInstance().inventory.getItem(oqm.objectUID); quantity = oqm.quantity - item.quantity; if(quantity > 0) { this.displayAddedItem(item.objectGID,quantity); content = PatternDecoder.combine(I18n.getUiText(""ui.quest.itemObtained"",[quantity,""{item,"" + item.objectGID + "","" + oqm.objectUID + ""}""]),""n"",quantity <= 1,quantity == 0); KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,content,ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } } InventoryManager.getInstance().inventory.modifyItemQuantity(oqm.objectUID,oqm.quantity); for each(shortcutQty in InventoryManager.getInstance().shortcutBarItems) { if(shortcutQty && shortcutQty.id == oqm.objectUID) { shortcutQty.quantity = oqm.quantity; KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,0); } } return true; case msg is ObjectsQuantityMessage: osqm = msg as ObjectsQuantityMessage; for each(objoqm in osqm.objectsUIDAndQty) { InventoryManager.getInstance().inventory.modifyItemQuantity(objoqm.objectUID,objoqm.quantity); for each(shortcutsQty in InventoryManager.getInstance().shortcutBarItems) { if(shortcutsQty && shortcutsQty.id == objoqm.objectUID) { shortcutsQty.quantity = objoqm.quantity; } } } KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,0); return true; case msg is KamasUpdateMessage: kumsg = msg as KamasUpdateMessage; InventoryManager.getInstance().inventory.kamas = kumsg.kamasTotal; KernelEventsManager.getInstance().processCallback(InventoryHookList.KamasUpdate,kumsg.kamasTotal); KernelEventsManager.getInstance().processCallback(ExternalGameHookList.DofusBakKamasAmount,kumsg.kamasTotal + InventoryManager.getInstance().bankInventory.kamas); InventoryManager.getInstance().inventory.releaseHooks(); return true; case msg is InventoryWeightMessage: iwmsg = msg as InventoryWeightMessage; PlayedCharacterManager.getInstance().inventoryWeight = iwmsg.inventoryWeight; PlayedCharacterManager.getInstance().shopWeight = iwmsg.shopWeight; PlayedCharacterManager.getInstance().inventoryWeightMax = iwmsg.weightMax; KernelEventsManager.getInstance().processCallback(InventoryHookList.InventoryWeight,iwmsg.inventoryWeight,iwmsg.shopWeight,iwmsg.weightMax); InventoryManager.getInstance().inventory.releaseHooks(); return true; case msg is ObjectMovementMessage: ommsg = msg as ObjectMovementMessage; InventoryManager.getInstance().inventory.modifyItemPosition(ommsg.objectUID,ommsg.position); if(this._objectPositionModification && (ommsg.position <= CharacterInventoryPositionEnum.INVENTORY_POSITION_MOUNT || ommsg.position == CharacterInventoryPositionEnum.INVENTORY_POSITION_ENTITY || ommsg.position == CharacterInventoryPositionEnum.INVENTORY_POSITION_COSTUME) && ommsg.position >= 0 && !Berilia.getInstance().getUi(""storage"")) { itwm = InventoryManager.getInstance().inventory.getItem(ommsg.objectUID); KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,I18n.getUiText(""ui.item.inUse"",[itwm.name]),ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); this._objectPositionModification = false; } return true; case msg is ShortcutBarContentMessage: sbcmsg = msg as ShortcutBarContentMessage; if(sbcmsg.barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR) { InventoryManager.getInstance().shortcutBarItems = this.getWrappersFromShortcuts(sbcmsg.shortcuts); } else if(sbcmsg.barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR) { InventoryManager.getInstance().shortcutBarSpells = this.getWrappersFromShortcuts(sbcmsg.shortcuts); PlayedCharacterManager.getInstance().playerShortcutList = InventoryManager.getInstance().shortcutBarSpells; } KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,sbcmsg.barType); return true; case msg is ShortcutBarRefreshMessage: sbrmsg = msg as ShortcutBarRefreshMessage; inventoryMgr = InventoryManager.getInstance(); sRProperties = this.getShortcutWrapperPropFromShortcut(sbrmsg.shortcut); if(sbrmsg.barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR) { if(inventoryMgr.shortcutBarItems[sbrmsg.shortcut.slot]) { inventoryMgr.shortcutBarItems[sbrmsg.shortcut.slot].update(sbrmsg.shortcut.slot,sRProperties.id,sRProperties.type,sRProperties.gid); } else { inventoryMgr.shortcutBarItems[sbrmsg.shortcut.slot] = ShortcutWrapper.create(sbrmsg.shortcut.slot,sRProperties.id,sRProperties.type,sRProperties.gid); } } else if(sbrmsg.barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR) { if(inventoryMgr.shortcutBarSpells[sbrmsg.shortcut.slot]) { inventoryMgr.shortcutBarSpells[sbrmsg.shortcut.slot].update(sbrmsg.shortcut.slot,sRProperties.id,sRProperties.type,sRProperties.gid); } else { inventoryMgr.shortcutBarSpells[sbrmsg.shortcut.slot] = ShortcutWrapper.create(sbrmsg.shortcut.slot,sRProperties.id,sRProperties.type,sRProperties.gid); } if(PlayedCharacterManager.getInstance().spellsInventory == PlayedCharacterManager.getInstance().playerSpellList) { PlayedCharacterManager.getInstance().playerShortcutList = InventoryManager.getInstance().shortcutBarSpells; } } KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,sbrmsg.barType); return true; case msg is ShortcutBarRemovedMessage: sbrmmsg = msg as ShortcutBarRemovedMessage; if(sbrmmsg.barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR) { InventoryManager.getInstance().shortcutBarItems[sbrmmsg.slot] = null; } else if(sbrmmsg.barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR) { InventoryManager.getInstance().shortcutBarSpells[sbrmmsg.slot] = null; } KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,sbrmmsg.barType); return true; case msg is ShortcutBarReplacedMessage: sbrpmsg = msg as ShortcutBarReplacedMessage; replacingShortcutProperties = this.getShortcutWrapperPropFromShortcut(sbrpmsg.shortcut); if(sbrpmsg.barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR) { InventoryManager.getInstance().shortcutBarItems[sbrpmsg.shortcut.slot] = ShortcutWrapper.create(sbrpmsg.shortcut.slot,replacingShortcutProperties.id,replacingShortcutProperties.type,replacingShortcutProperties.gid); } else if(sbrpmsg.barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR) { InventoryManager.getInstance().shortcutBarSpells[sbrpmsg.shortcut.slot] = ShortcutWrapper.create(sbrpmsg.shortcut.slot,replacingShortcutProperties.id,replacingShortcutProperties.type,replacingShortcutProperties.gid); } KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,sbrpmsg.barType); return true; case msg is ShortcutBarAddRequestAction: sbara = msg as ShortcutBarAddRequestAction; sbarmsg = new ShortcutBarAddRequestMessage(); if(sbara.barType == DataEnum.SHORTCUT_TYPE_ITEM) { shortcuti = new ShortcutObjectItem(); shortcuti.itemUID = sbara.id; shortcuti.slot = sbara.slot; sbarmsg.initShortcutBarAddRequestMessage(sbara.barType,shortcuti); } else if(sbara.barType == DataEnum.SHORTCUT_TYPE_PRESET) { shortcutp = new ShortcutObjectPreset(); shortcutp.presetId = sbara.id; shortcutp.slot = sbara.slot; sbarmsg.initShortcutBarAddRequestMessage(0,shortcutp); } else if(sbara.barType == DataEnum.SHORTCUT_TYPE_SPELL) { shortcuts = new ShortcutSpell(); shortcuts.spellId = sbara.id; shortcuts.slot = sbara.slot; sbarmsg.initShortcutBarAddRequestMessage(1,shortcuts); } else if(sbara.barType == DataEnum.SHORTCUT_TYPE_SMILEY) { shortcutsm = new ShortcutSmiley(); shortcutsm.smileyId = sbara.id; shortcutsm.slot = sbara.slot; sbarmsg.initShortcutBarAddRequestMessage(0,shortcutsm); } else if(sbara.barType == DataEnum.SHORTCUT_TYPE_EMOTE) { shortcute = new ShortcutEmote(); shortcute.emoteId = sbara.id; shortcute.slot = sbara.slot; sbarmsg.initShortcutBarAddRequestMessage(0,shortcute); } else if(sbara.barType == DataEnum.SHORTCUT_TYPE_IDOLS_PRESET) { shortcutd = new ShortcutObjectIdolsPreset(); shortcutd.presetId = sbara.id; shortcutd.slot = sbara.slot; sbarmsg.initShortcutBarAddRequestMessage(0,shortcutd); } ConnectionsHandler.getConnection().send(sbarmsg); return true; case msg is ShortcutBarRemoveRequestAction: sbrra = msg as ShortcutBarRemoveRequestAction; sbrrmsg = new ShortcutBarRemoveRequestMessage(); sbrrmsg.initShortcutBarRemoveRequestMessage(sbrra.barType,sbrra.slot); ConnectionsHandler.getConnection().send(sbrrmsg); return true; case msg is ShortcutBarSwapRequestAction: sbsra = msg as ShortcutBarSwapRequestAction; sbsrmsg = new ShortcutBarSwapRequestMessage(); sbsrmsg.initShortcutBarSwapRequestMessage(sbsra.barType,sbsra.firstSlot,sbsra.secondSlot); ConnectionsHandler.getConnection().send(sbsrmsg); return true; case msg is PresetSetPositionAction: pspa = msg as PresetSetPositionAction; hiddenObjects = new Vector.(); loop4: for each(realitem in InventoryManager.getInstance().inventory.getView(""real"").content) { if(Item.getItemById(realitem.objectGID).typeId == DataEnum.ITEM_TYPE_HIDDEN) { hiddenObjects.push(realitem); if(realitem.effects && realitem.effects.length) { for each(effect in realitem.effects) { if(effect.effectId == ActionIds.ACTION_ITEM_EQUIP_PRESET) { if(int(effect.parameter2) - 1 == pspa.presetId) { presetItem = realitem; break loop4; } } } } } } if(presetItem) { this._movingObjectUID = presetItem.objectUID; this._movingObjectPreviousPosition = 0; ospmsg = new ObjectSetPositionMessage(); ospmsg.initObjectSetPositionMessage(presetItem.objectUID,pspa.position,1); ConnectionsHandler.getConnection().send(ospmsg); } return true; case msg is ObjectSetPositionAction: ospa = msg as ObjectSetPositionAction; itw = InventoryManager.getInstance().inventory.getItem(ospa.objectUID); if(itw && itw.position != ospa.position) { this._movingObjectUID = ospa.objectUID; if(!itw) { this._movingObjectPreviousPosition = 8; } else { this._movingObjectPreviousPosition = itw.position; } this._objectPositionModification = true; ospmsg2 = new ObjectSetPositionMessage(); ospmsg2.initObjectSetPositionMessage(ospa.objectUID,ospa.position,ospa.quantity); ConnectionsHandler.getConnection().send(ospmsg2); } return true; case msg is ObjectModifiedMessage: omdmsg = msg as ObjectModifiedMessage; petsMountWasAutopilotable = false; inventoryMgr = InventoryManager.getInstance(); previousItemWrapper = inventoryMgr.inventory.getItem(omdmsg.object.objectUID); if(previousItemWrapper && previousItemWrapper.type.id == DataEnum.ITEM_TYPE_PETSMOUNT) { for each(effectInst in previousItemWrapper.effects) { if(effectInst.effectId == ActionIds.ACTION_SELF_PILOTING) { petsMountWasAutopilotable = true; break; } } } modifiedItemWrapper = inventoryMgr.inventory.modifyObjectItem(omdmsg.object); for each(shortcutItem in inventoryMgr.shortcutBarItems) { if(!(!shortcutItem || shortcutItem.type != 0 || shortcutItem.id != omdmsg.object.objectUID)) { shortcutItem.update(shortcutItem.slot,shortcutItem.id,shortcutItem.type,shortcutItem.gid); KernelEventsManager.getInstance().processCallback(InventoryHookList.ShortcutBarViewContent,ShortcutBarEnum.GENERAL_SHORTCUT_BAR); } } updateTooltip = function(pUiName:String, pProperties:TooltipProperties):void { var ttUi:UiRootContainer = Berilia.getInstance().getUi(pUiName); if(ttUi && ttUi.uiClass) { ttUi.uiClass.updateContent(pProperties); } }; for(uiName in Berilia.getInstance().uiList) { if(uiName.indexOf(""_pin@"") != -1) { ttProperties = Berilia.getInstance().getUi(uiName).properties; if(ttProperties.data.objectUID == modifiedItemWrapper.objectUID) { ttProperties.tooltip = TooltipsFactory.getMakerInstance(""item"").createTooltip(modifiedItemWrapper,ttProperties.makerParam); ttProperties.data = modifiedItemWrapper; ttProperties.tooltip.askTooltip(new Callback(updateTooltip,uiName,ttProperties)); break; } } } if(modifiedItemWrapper.type.id == DataEnum.ITEM_TYPE_PETSMOUNT && !petsMountWasAutopilotable) { for each(effectInst in modifiedItemWrapper.effects) { if(effectInst.effectId == ActionIds.ACTION_SELF_PILOTING) { autopilotMessage = I18n.getUiText(""ui.mountTrip.autopilotActivatedForPetsMount"",[modifiedItemWrapper.name]); commonMod.openPopup(I18n.getUiText(""ui.common.congratulation""),autopilotMessage,[I18n.getUiText(""ui.common.ok"")]); } } } return false; case msg is ObjectDeletedMessage: odmsg = msg as ObjectDeletedMessage; if(this._objectUIDToDrop == odmsg.objectUID) { this._soundApi.playSound(SoundTypeEnum.DROP_ITEM); this._objectUIDToDrop = -1; } InventoryManager.getInstance().inventory.removeItem(odmsg.objectUID,-1); return true; case msg is ObjectsDeletedMessage: osdmsg = msg as ObjectsDeletedMessage; for each(osdit in osdmsg.objectUID) { InventoryManager.getInstance().inventory.removeItem(osdit,-1); } return true; case msg is DeleteObjectAction: doa = msg as DeleteObjectAction; odmsg2 = new ObjectDeleteMessage(); odmsg2.initObjectDeleteMessage(doa.objectUID,doa.quantity); ConnectionsHandler.getConnection().send(odmsg2); return true; case msg is ObjectUseAction: oua = msg as ObjectUseAction; iw = InventoryManager.getInstance().inventory.getItem(oua.objectUID); if(!iw) { _log.error(""Impossible de retrouver l\\'objet d\\'UID "" + oua.objectUID); return true; } if(!iw.usable && !iw.targetable) { _log.error(""L\\'objet "" + iw.name + "" n\\'est pas utilisable.""); return true; } fncUseItem = function():void { useItem(oua,iw); }; nbFood = 0; nbBonus = 0; view = InventoryManager.getInstance().inventory.getView(""roleplayBuff""); for each(t in view.content) { switch(t.position) { case CharacterInventoryPositionEnum.INVENTORY_POSITION_BOOST_FOOD: if(t.objectGID != iw.objectGID) { nbFood++; } break; case CharacterInventoryPositionEnum.INVENTORY_POSITION_FIRST_BONUS: case CharacterInventoryPositionEnum.INVENTORY_POSITION_SECOND_BONUS: nbBonus++; break; } } if(iw.needUseConfirm) { commonMod.openPopup(I18n.getUiText(""ui.common.confirm""),I18n.getUiText(""ui.common.confirmationUseItem"",[iw.name]),[I18n.getUiText(""ui.common.yes""),I18n.getUiText(""ui.common.no"")],[fncUseItem,null],fncUseItem,function():void { }); } else { this.useItem(oua,iw); } return true; break; case msg is ObjectDropAction: oda = msg as ObjectDropAction; if(Kernel.getWorker().contains(FightContextFrame)) { return true; } itemItem = Item.getItemById(oda.objectGID); if(itemItem.category == ItemCategoryEnum.QUEST_CATEGORY || oda.objectUID == 0 || oda.quantity == 0) { return true; } this._objectUIDToDrop = oda.objectUID; this._objectGIDToDrop = oda.objectGID; this._quantityToDrop = oda.quantity; objectName = itemItem.name; if(Dofus.getInstance().options.getOption(""confirmItemDrop"")) { if(this._dropPopup != null && Berilia.getInstance().getUi(this._dropPopup)) { Berilia.getInstance().unloadUi(this._dropPopup); } this._dropPopup = commonMod.openPopup(I18n.getUiText(""ui.common.confirm""),I18n.getUiText(""ui.common.confirmationDropItem"",[oda.quantity,objectName]),[I18n.getUiText(""ui.common.yes""),I18n.getUiText(""ui.common.no"")],[this.onAcceptDrop,this.onRefuseDrop],this.onAcceptDrop,this.onRefuseDrop); } else { odropmsg = new ObjectDropMessage(); odropmsg.initObjectDropMessage(this._objectUIDToDrop,this._quantityToDrop); ConnectionsHandler.getConnection().send(odropmsg); } return true; break; case msg is ObjectUseOnCellAction: ouocmsg = new ObjectUseOnCellMessage(); ouoca = msg as ObjectUseOnCellAction; ouocmsg.initObjectUseOnCellMessage(ouoca.objectUID,ouoca.targetedCell); ConnectionsHandler.getConnection().send(ouocmsg); break; case msg is ObjectErrorMessage: oemsg = msg as ObjectErrorMessage; if(oemsg.reason == ObjectErrorEnum.SYMBIOTIC_OBJECT_ERROR) { return false; } this._objectPositionModification = false; return false; break; case msg is PresetsMessage: pmsg = msg as PresetsMessage; presetWrappers = new Array(); idolsPresets = new Vector.(0); presetsCount = pmsg.presets.length; for(iPreset = 0; iPreset < presetsCount; ) { preset = pmsg.presets[iPreset]; if(preset is IdolsPreset) { idolsPreset = preset as IdolsPreset; _log.debug("" - "" + preset.id + "" idoles""); idolsPresets.push(IdolsPresetWrapper.create(idolsPreset.id,idolsPreset.iconId,idolsPreset.idolIds)); this._presetTypeIdByPresetId[preset.id] = IDOLS_PRESET_TYPE; } else if(preset is IconNamedPreset) { forgettableSpellsActivated = FeatureManager.getInstance().isFeatureWithKeywordEnabled(""character.spell.forgettable""); buildPreset = preset as IconNamedPreset; _log.debug("" - "" + buildPreset.id + "" build "" + buildPreset.name); fullStatsPreset = null; itemsPreset = null; spellsPreset = null; forgettableSpellsPreset = null; subPreset = null; for each(subPreset in buildPreset.presets) { if(subPreset is PresetsContainerPreset) { for each(subSubPreset in (subPreset as PresetsContainerPreset).presets) { if(subSubPreset is FullStatsPreset) { fullStatsPreset = subSubPreset as FullStatsPreset; } else if(subSubPreset is ItemsPreset) { itemsPreset = subSubPreset as ItemsPreset; } } } else if(subPreset is FullStatsPreset) { fullStatsPreset = subPreset as FullStatsPreset; } else if(subPreset is ItemsPreset) { itemsPreset = subPreset as ItemsPreset; } else if(subPreset is SpellsPreset) { spellsPreset = subPreset as SpellsPreset; } else if(subPreset is ForgettableSpellsPreset && forgettableSpellsActivated) { forgettableSpellsPreset = subPreset as ForgettableSpellsPreset; } } if(forgettableSpellsActivated && fullStatsPreset === null && itemsPreset === null && spellsPreset === null && forgettableSpellsPreset !== null) { characterBuildType = CharacterBuildType.FORGETTABLE_SPELL_TYPE; this._presetTypeIdByPresetId[buildPreset.id] = FORGETTABLE_PRESET_TYPE; } else { characterBuildType = CharacterBuildType.CHARACTER_TYPE; this._presetTypeIdByPresetId[buildPreset.id] = CHARACTER_BUILD_PRESET_TYPE; } presetWrappers.push(BuildWrapper.create(buildPreset.id,characterBuildType,-1,buildPreset.name,buildPreset.iconId,fullStatsPreset,itemsPreset,spellsPreset,forgettableSpellsPreset,true)); } iPreset++; } InventoryManager.getInstance().builds = presetWrappers; PlayedCharacterManager.getInstance().idolsPresets = idolsPresets; return true; case msg is InvalidPresetsMessage: ipmsg = msg as InvalidPresetsMessage; this._invalidPresets = new Vector.(); this._chatText = I18n.getUiText(""ui.preset.warningUpdatePresets""); buildLink = []; for each(id in ipmsg.presetIds) { for each(buildWrapper in InventoryManager.getInstance().builds) { if(id == buildWrapper.id) { this._invalidPresets.push(buildWrapper); buildLink.push(""{openPresets, "" + buildWrapper.id + "":: ["" + buildWrapper.buildName + ""]}""); } } } this._chatText += buildLink + "".\\n"" + I18n.getUiText(""ui.preset.EquipPresets""); this._waitTimer = new BenchmarkTimer(5000,1,""InventoryManagementFrame._waitTimer""); this._waitTimer.addEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerEnd); this._waitTimer.start(); return true; case msg is ItemForPresetUpdateMessage: ipiumsg = msg as ItemForPresetUpdateMessage; builds = InventoryManager.getInstance().builds; for each(build in builds) { if(build.id == ipiumsg.presetId) { break; } } if(!build) { return true; } build.updateObject(ipiumsg.presetItem); builds = InventoryManager.getInstance().builds; KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetsUpdate,build.id); return true; break; case msg is PresetDeleteRequestAction: pdra = msg as PresetDeleteRequestAction; pdmsg = new PresetDeleteRequestMessage(); pdmsg.initPresetDeleteRequestMessage(pdra.presetId); ConnectionsHandler.getConnection().send(pdmsg); return true; case msg is PresetDeleteResultMessage: pdrmsg = msg as PresetDeleteResultMessage; if(pdrmsg.code == PresetDeleteResultEnum.PRESET_DEL_OK) { deletePresetTypeId = this._presetTypeIdByPresetId[pdrmsg.presetId]; this._presetTypeIdByPresetId[pdrmsg.presetId] = null; if(deletePresetTypeId == CHARACTER_BUILD_PRESET_TYPE || deletePresetTypeId == FORGETTABLE_PRESET_TYPE) { builds = InventoryManager.getInstance().builds; for each(build in builds) { if(build && build.id == pdrmsg.presetId) { presetIndex = builds.indexOf(build); break; } } builds.splice(presetIndex,1); KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetsUpdate); } else if(deletePresetTypeId == IDOLS_PRESET_TYPE) { idolsPresets = PlayedCharacterManager.getInstance().idolsPresets; for each(idolsPresetWrapper in idolsPresets) { if(idolsPresetWrapper.id == pdrmsg.presetId) { presetIndex = idolsPresets.indexOf(idolsPresetWrapper); break; } } idolsPresets.splice(presetIndex,1); KernelEventsManager.getInstance().processCallback(HookList.IdolsPresetDelete,pdrmsg.presetId); } } else { switch(pdrmsg.code) { case PresetDeleteResultEnum.PRESET_DEL_ERR_UNKNOWN: reason1 = ""unknownDelete""; break; case PresetDeleteResultEnum.PRESET_DEL_ERR_BAD_PRESET_ID: reason1 = ""badId""; break; case PresetDeleteResultEnum.PRESET_DEL_ERR_SYSTEM_INACTIVE: reason1 = ""inactive""; } KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetError,reason1); } return true; case msg is CharacterPresetSaveRequestAction: cpsra = msg as CharacterPresetSaveRequestAction; npsrmsg = new IconNamedPresetSaveRequestMessage(); npsrmsg.initIconNamedPresetSaveRequestMessage(cpsra.presetId,cpsra.symbolId,cpsra.fullSave,cpsra.name,cpsra.presetType); ConnectionsHandler.getConnection().send(npsrmsg); return true; case msg is IdolsPresetSaveRequestAction: ipsra = msg as IdolsPresetSaveRequestAction; ipsrmsg = new IdolsPresetSaveRequestMessage(); ipsrmsg.initIdolsPresetSaveRequestMessage(ipsra.presetId,ipsra.symbolId,true); ConnectionsHandler.getConnection().send(ipsrmsg); return true; case msg is PresetSaveErrorMessage: psemsg = msg as PresetSaveErrorMessage; switch(psemsg.code) { case PresetSaveResultEnum.PRESET_SAVE_ERR_UNKNOWN: presetSaveErrorReasonText = ""unknownSave""; break; case PresetSaveResultEnum.PRESET_SAVE_ERR_TOO_MANY: presetSaveErrorReasonText = ""tooMany""; break; case PresetSaveResultEnum.PRESET_SAVE_ERR_INVALID_PLAYER_STATE: presetSaveErrorReasonText = ""invalidPlayerState""; break; case PresetSaveResultEnum.PRESET_SAVE_ERR_SYSTEM_INACTIVE: presetSaveErrorReasonText = ""inactive""; break; case PresetSaveResultEnum.PRESET_SAVE_ERR_INVALID_ID: presetSaveErrorReasonText = ""badId""; } KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetError,presetSaveErrorReasonText); return true; case msg is PresetSavedMessage: psmsg = msg as PresetSavedMessage; if(psmsg.preset is IdolsPreset) { idolsPreset = psmsg.preset as IdolsPreset; _log.debug(""Saved "" + psmsg.preset.id + "" idoles""); idolWrapper = IdolsPresetWrapper.create(idolsPreset.id,idolsPreset.iconId,idolsPreset.idolIds); PlayedCharacterManager.getInstance().idolsPresets.push(idolWrapper); this._presetTypeIdByPresetId[psmsg.preset.id] = IDOLS_PRESET_TYPE; KernelEventsManager.getInstance().processCallback(HookList.IdolsPresetSaved,idolWrapper); } else if(psmsg.preset is IconNamedPreset) { forgettableSpellsActivated = FeatureManager.getInstance().isFeatureWithKeywordEnabled(""character.spell.forgettable""); newBuild = psmsg.preset as IconNamedPreset; _log.debug(""Saved "" + newBuild.id + "" build "" + newBuild.name); fullStatsPresetSaved = null; itemsPresetSaved = null; spellsPresetSaved = null; forgettableSpellsPresetSaved = null; subPresetSaved = null; for each(subPresetSaved in newBuild.presets) { if(subPresetSaved is PresetsContainerPreset) { for each(subSubPresetSaved in (subPresetSaved as PresetsContainerPreset).presets) { if(subSubPresetSaved is FullStatsPreset) { fullStatsPresetSaved = subSubPresetSaved as FullStatsPreset; } else if(subSubPresetSaved is ItemsPreset) { itemsPresetSaved = subSubPresetSaved as ItemsPreset; } } } else if(subPresetSaved is FullStatsPreset) { fullStatsPresetSaved = subPresetSaved as FullStatsPreset; } else if(subPresetSaved is ItemsPreset) { itemsPresetSaved = subPresetSaved as ItemsPreset; } else if(subPresetSaved is SpellsPreset) { spellsPresetSaved = subPresetSaved as SpellsPreset; } else if(subPresetSaved is ForgettableSpellsPreset && forgettableSpellsActivated) { forgettableSpellsPresetSaved = subPresetSaved as ForgettableSpellsPreset; } } if(forgettableSpellsActivated && fullStatsPresetSaved === null && itemsPresetSaved === null && spellsPresetSaved === null && forgettableSpellsPresetSaved !== null) { characterBuildTypeSaved = CharacterBuildType.FORGETTABLE_SPELL_TYPE; } else { characterBuildTypeSaved = CharacterBuildType.CHARACTER_TYPE; } if(this._presetTypeIdByPresetId[newBuild.id]) { builds = InventoryManager.getInstance().builds; for each(build in builds) { if(build.id == newBuild.id) { build.updateBuild(newBuild.name,newBuild.iconId,fullStatsPresetSaved,itemsPresetSaved,spellsPresetSaved,forgettableSpellsPresetSaved,characterBuildTypeSaved); } } } else { InventoryManager.getInstance().builds.push(BuildWrapper.create(newBuild.id,characterBuildTypeSaved,-1,newBuild.name,newBuild.iconId,fullStatsPresetSaved,itemsPresetSaved,spellsPresetSaved,forgettableSpellsPresetSaved,true)); if(characterBuildTypeSaved === CharacterBuildType.FORGETTABLE_SPELL_TYPE) { this._presetTypeIdByPresetId[newBuild.id] = FORGETTABLE_PRESET_TYPE; } else { this._presetTypeIdByPresetId[newBuild.id] = CHARACTER_BUILD_PRESET_TYPE; } } KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetsUpdate); KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetSelected,psmsg.preset.id); if(forgettableSpellsActivated) { KernelEventsManager.getInstance().processCallback(HookList.ForgettableSpellPresetSaved,psmsg.preset.id); } } return true; case msg is PresetUseRequestAction: pura = msg as PresetUseRequestAction; pumsg = new PresetUseRequestMessage(); pumsg.initPresetUseRequestMessage(pura.presetId); ConnectionsHandler.getConnection().send(pumsg); return true; case msg is PresetUseResultMessage: purmsg = msg as PresetUseResultMessage; presetTypeId = this._presetTypeIdByPresetId[purmsg.presetId]; if(presetTypeId == 0) { _log.debug(""Unknown preset id ! Aborting the use result""); return true; } if(purmsg.code != PresetUseResultEnum.PRESET_USE_OK && purmsg.code != PresetUseResultEnum.PRESET_USE_OK_PARTIAL && purmsg.code != PresetUseResultEnum.PRESET_USE_ERR_STATS_FIGHT_PREPARATION) { presetUseErrorText = I18n.getUiText(""ui.common.unknownFail""); if(presetTypeId == CHARACTER_BUILD_PRESET_TYPE) { if(purmsg.code != PresetUseResultEnum.PRESET_USE_ERR_UNKNOWN) { presetUseErrorText = I18n.getUiText(""ui.preset.error."" + purmsg.code); } } else if(presetTypeId == FORGETTABLE_PRESET_TYPE) { if(purmsg.code == PresetUseResultEnum.PRESET_USE_ERR_COOLDOWN) { presetUseErrorText = I18n.getUiText(""ui.temporis.spellPreset.error."" + purmsg.code); } } else if(purmsg.code == PresetUseResultEnum.PRESET_USE_ERR_CRITERION || purmsg.code == PresetUseResultEnum.PRESET_USE_ERR_BAD_PRESET_ID || purmsg.code == PresetUseResultEnum.PRESET_USE_ERR_COOLDOWN || purmsg.code == PresetUseResultEnum.PRESET_USE_ERR_INVALID_STATE) { presetUseErrorText = I18n.getUiText(""ui.idol.preset.error."" + purmsg.code); } KernelEventsManager.getInstance().processCallback(HookList.ErrorPopup,presetUseErrorText); } else { chatUseText = null; if(presetTypeId == CHARACTER_BUILD_PRESET_TYPE || presetTypeId == FORGETTABLE_PRESET_TYPE) { build = BuildWrapper.getBuildWrapperById(purmsg.presetId); chatUseText = I18n.getUiText(""ui.preset.inUse"",[build.buildName]); KernelEventsManager.getInstance().processCallback(InventoryHookList.PresetUsed,purmsg.presetId); } else if(presetTypeId == IDOLS_PRESET_TYPE) { KernelEventsManager.getInstance().processCallback(HookList.IdolsPresetEquipped,purmsg.presetId); chatUseText = I18n.getUiText(""ui.idol.preset.inUse"",[purmsg.presetId + 1]); } if(chatUseText !== null) { KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,chatUseText,ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } if(purmsg.code == PresetUseResultEnum.PRESET_USE_OK_PARTIAL && purmsg is PresetUseResultWithMissingIdsMessage) { missingIds = (purmsg as PresetUseResultWithMissingIdsMessage).missingIds; if(presetTypeId == CHARACTER_BUILD_PRESET_TYPE) { presetUseErrorText = I18n.getUiText(""ui.preset.error."" + purmsg.code); KernelEventsManager.getInstance().processCallback(HookList.ErrorPopup,presetUseErrorText); } if(presetTypeId == FORGETTABLE_PRESET_TYPE) { currentSpellWrapper = null; spellsString = """"; for each(missingId in missingIds) { currentSpellWrapper = SpellWrapper.create(missingId,1,false,0,false); if(currentSpellWrapper !== null) { spellsString += ""{spell,"" + currentSpellWrapper.id + "","" + currentSpellWrapper.spellLevel + ""}, ""; } } if(spellsString !== null && spellsString.length > 2) { spellsString = spellsString.substring(0,spellsString.length - 2); missingText = I18n.getUiText(""ui.temporis.missingTemporisSpells"",[spellsString]); chatFrame = Kernel.getWorker().getFrame(ChatFrame) as ChatFrame; if(chatFrame !== null) { KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,missingText,chatFrame.getRedId(),TimeManager.getInstance().getTimestamp()); } } } else { for each(missingId in missingIds) { if(presetTypeId == CHARACTER_BUILD_PRESET_TYPE) { if(missingId == 0) { missingText = I18n.getUiText(""ui.mount.noPlayerMount""); } else { missingName = Item.getItemById(missingId).name; missingText = I18n.getUiText(""ui.preset.missingItem"",[missingName]); } } else { missingName = Idol.getIdolById(missingId).item.name; missingText = I18n.getUiText(""ui.idol.preset.missingIdol"",[missingName]); } KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,missingText,ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } } } else if(purmsg.code == PresetUseResultEnum.PRESET_USE_ERR_STATS_FIGHT_PREPARATION) { presetUseErrorText = I18n.getUiText(""ui.preset.error."" + purmsg.code); KernelEventsManager.getInstance().processCallback(HookList.ErrorPopup,presetUseErrorText); } } return true; break; case msg is AccessoryPreviewRequestAction: apra = msg as AccessoryPreviewRequestAction; aprmsg = new AccessoryPreviewRequestMessage(); aprmsg.initAccessoryPreviewRequestMessage(apra.itemGIDs); ConnectionsHandler.getConnection().send(aprmsg); return true; case msg is AccessoryPreviewErrorMessage: apemsg = msg as AccessoryPreviewErrorMessage; switch(apemsg.error) { case AccessoryPreviewErrorEnum.PREVIEW_BAD_ITEM: apErrorMsg = I18n.getUiText(""ui.shop.preview.badItem""); break; case AccessoryPreviewErrorEnum.PREVIEW_COOLDOWN: apErrorMsg = I18n.getUiText(""ui.shop.preview.cooldown""); break; case AccessoryPreviewErrorEnum.PREVIEW_ERROR: apErrorMsg = I18n.getUiText(""ui.shop.preview.error""); } KernelEventsManager.getInstance().processCallback(InventoryHookList.AccessoryPreview,null); if(apErrorMsg) { KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,apErrorMsg,ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } return true; case msg is AccessoryPreviewMessage: apmsg = msg as AccessoryPreviewMessage; previewLook = apmsg.look; if(apmsg.look.subentities) { for each(sube in apmsg.look.subentities) { if(sube.bindingPointCategory == SubEntityBindingPointCategoryEnum.HOOK_POINT_CATEGORY_PET_FOLLOWER) { followerPet = sube; } } if(followerPet) { followerPet.bindingPointCategory = SubEntityBindingPointCategoryEnum.HOOK_POINT_CATEGORY_PET; previewLook.subentities.push(followerPet); } } KernelEventsManager.getInstance().processCallback(InventoryHookList.AccessoryPreview,previewLook); return true; case msg is DecraftResultMessage: drmsg = msg as DecraftResultMessage; KernelEventsManager.getInstance().processCallback(CraftHookList.DecraftResult,drmsg.results); return true; } return false; } private function onTimerEnd(e:TimerEvent) : void { this._waitTimer.stop(); this._waitTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerEnd); KernelEventsManager.getInstance().processCallback(ChatHookList.TextInformation,this._chatText,ChatActivableChannelsEnum.PSEUDO_CHANNEL_INFO,TimeManager.getInstance().getTimestamp()); } private function openDevBlog() : void { navigateToURL(new URLRequest(I18n.getUiText(""ui.link.newSocialDevBlog""))); } public function pulled() : Boolean { return true; } public function onAcceptDrop() : void { this._dropPopup = null; var odropmsg:ObjectDropMessage = new ObjectDropMessage(); odropmsg.initObjectDropMessage(this._objectUIDToDrop,this._quantityToDrop); if(!PlayedCharacterManager.getInstance().isFighting) { ConnectionsHandler.getConnection().send(odropmsg); } } public function onRefuseDrop() : void { this._dropPopup = null; } private function onCellPointed(success:Boolean, cellId:uint, entityId:Number) : void { var oucmsg:ObjectUseOnCellMessage = null; var ouCharmsg:ObjectUseOnCharacterMessage = null; if(success) { if(entityId < 0) { oucmsg = new ObjectUseOnCellMessage(); oucmsg.initObjectUseOnCellMessage(this._currentPointUseUIDObject,cellId); ConnectionsHandler.getConnection().send(oucmsg); } else { ouCharmsg = new ObjectUseOnCharacterMessage(); ouCharmsg.initObjectUseOnCharacterMessage(this._currentPointUseUIDObject,entityId); ConnectionsHandler.getConnection().send(ouCharmsg); } } this._currentPointUseUIDObject = 0; } private function useItem(oua:ObjectUseAction, iw:ItemWrapper) : void { var cursorIcon:Texture = null; var oumsg:NetworkMessage = null; var playerEntity:IEntity = null; var roleplayMovementFrame:RoleplayMovementFrame = null; if(oua.objectUID == this._currentPointUseUIDObject) { Kernel.getWorker().removeFrame(PointCellFrame.getInstance()); } if(oua.useOnCell && iw.targetable) { if(Kernel.getWorker().getFrame(FightBattleFrame)) { return; } this._currentPointUseUIDObject = oua.objectUID; cursorIcon = new Texture(); cursorIcon.uri = iw.iconUri; cursorIcon.finalize(); PointCellFrame.getInstance().setPointCellParameters(this.onCellPointed,cursorIcon); Kernel.getWorker().addFrame(PointCellFrame.getInstance() as Frame); } else { if(oua.quantity > 1) { oumsg = new ObjectUseMultipleMessage(); (oumsg as ObjectUseMultipleMessage).initObjectUseMultipleMessage(oua.objectUID,oua.quantity); } else { oumsg = new ObjectUseMessage(); (oumsg as ObjectUseMessage).initObjectUseMessage(oua.objectUID); } playerEntity = DofusEntities.getEntity(PlayedCharacterManager.getInstance().id); if(playerEntity && (playerEntity as IMovable).isMoving) { roleplayMovementFrame = Kernel.getWorker().getFrame(RoleplayMovementFrame) as RoleplayMovementFrame; roleplayMovementFrame.setFollowingMessage(oumsg); (playerEntity as IMovable).stop(); } else { ConnectionsHandler.getConnection().send(oumsg); } } } private function displayAddedItem(pItemGID:uint, pItemQuantity:uint) : void { var entity:IEntity = DofusEntities.getEntity(PlayedCharacterManager.getInstance().id); var itemW:ItemWrapper = ItemWrapper.create(0,0,pItemGID,1,null); var icon:Texture = new Texture(); icon.uri = itemW.getIconUri(); icon.finalize(); var textFormat:TextFormat = new TextFormat(""Verdana"",24,7615756,true); CharacteristicContextualManager.getInstance().addStatContextualWithIcon(icon,pItemQuantity.toString(),entity,textFormat,1,GameContextEnum.ROLE_PLAY,1,2000); } private function getShortcutWrapperPropFromShortcut(shortcut:Shortcut) : Object { var id:uint = 0; var shortcutType:uint = 0; var gid:uint = 0; if(shortcut is ShortcutObjectItem) { id = (shortcut as ShortcutObjectItem).itemUID; gid = (shortcut as ShortcutObjectItem).itemGID; shortcutType = DataEnum.SHORTCUT_TYPE_ITEM; } else if(shortcut is ShortcutObjectPreset) { id = (shortcut as ShortcutObjectPreset).presetId; shortcutType = DataEnum.SHORTCUT_TYPE_PRESET; } else if(shortcut is ShortcutSpell) { id = (shortcut as ShortcutSpell).spellId; shortcutType = DataEnum.SHORTCUT_TYPE_SPELL; } else if(shortcut is ShortcutSmiley) { id = (shortcut as ShortcutSmiley).smileyId; shortcutType = DataEnum.SHORTCUT_TYPE_SMILEY; } else if(shortcut is ShortcutEmote) { id = (shortcut as ShortcutEmote).emoteId; shortcutType = DataEnum.SHORTCUT_TYPE_EMOTE; } else if(shortcut is ShortcutObjectIdolsPreset) { id = (shortcut as ShortcutObjectIdolsPreset).presetId; shortcutType = DataEnum.SHORTCUT_TYPE_IDOLS_PRESET; } return { ""id"":id, ""gid"":gid, ""type"":shortcutType }; } } } ",16361,True,2938.2946121468667,median "CLASS zcl_abapgit_gui_page_repo_view DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_hotkeys . CONSTANTS: BEGIN OF c_actions, repo_list TYPE string VALUE 'abapgit_home' ##NO_TEXT, change_dir TYPE string VALUE 'change_dir' ##NO_TEXT, toggle_hide_files TYPE string VALUE 'toggle_hide_files' ##NO_TEXT, toggle_folders TYPE string VALUE 'toggle_folders' ##NO_TEXT, toggle_changes TYPE string VALUE 'toggle_changes' ##NO_TEXT, toggle_diff_first TYPE string VALUE 'toggle_diff_first ' ##NO_TEXT, display_more TYPE string VALUE 'display_more' ##NO_TEXT, repo_switch_origin_to_pr TYPE string VALUE 'repo_switch_origin_to_pr', repo_reset_origin TYPE string VALUE 'repo_reset_origin', END OF c_actions . METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RAISING zcx_abapgit_exception . METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION . PROTECTED SECTION. METHODS render_content REDEFINITION. PRIVATE SECTION. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mv_cur_dir TYPE string . DATA mv_hide_files TYPE abap_bool . DATA mv_max_lines TYPE i . DATA mv_max_setting TYPE i . DATA mv_show_folders TYPE abap_bool . DATA mv_changes_only TYPE abap_bool . DATA mv_order_by TYPE string . DATA mv_order_descending TYPE abap_bool . DATA mv_diff_first TYPE abap_bool . DATA mv_key TYPE zif_abapgit_persistence=>ty_value . DATA mv_are_changes_recorded_in_tr TYPE abap_bool . METHODS render_head_line IMPORTING !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_head_menu IMPORTING !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_view_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS render_item IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item !iv_render_transports TYPE abap_bool RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_item_files IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_item_command IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS get_item_class IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS get_item_icon IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS render_item_lock_column IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_parent_dir RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_obj_jump_link IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS build_dir_jump_link IMPORTING !iv_path TYPE string RETURNING VALUE(rv_html) TYPE string . METHODS build_inactive_object_code IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_inactive_html_code) TYPE string . METHODS open_in_master_language RAISING zcx_abapgit_exception . METHODS render_order_by RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS apply_order_by CHANGING !ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt . METHODS build_branch_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_branch_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_tag_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_tag_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_advanced_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout !iv_lstate TYPE char1 !iv_rstate TYPE char1 RETURNING VALUE(ro_advanced_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_toolbar IMPORTING !iv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout !iv_lstate TYPE char1 !iv_rstate TYPE char1 !io_tb_branch TYPE REF TO zcl_abapgit_html_toolbar !io_tb_tag TYPE REF TO zcl_abapgit_html_toolbar !io_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS switch_to_pr IMPORTING !it_fields TYPE tihttpnvp OPTIONAL !iv_revert TYPE abap_bool OPTIONAL RETURNING VALUE(rv_switched) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS build_main_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS is_repo_lang_logon_lang RETURNING VALUE(rv_repo_lang_is_logon_lang) TYPE abap_bool. METHODS get_abapgit_tcode RETURNING VALUE(rv_tcode) TYPE tcode. ENDCLASS. CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. METHOD apply_order_by. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort, lt_non_code_and_metadata_items LIKE ct_repo_items, lt_code_items LIKE ct_repo_items, lt_diff_items LIKE ct_repo_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_repo_item. IF mv_order_by IS INITIAL. RETURN. ENDIF. "" we want to preserve non-code and metadata files at the top, "" so we isolate them and and sort only the code artifacts LOOP AT ct_repo_items ASSIGNING . IF -obj_type IS INITIAL AND -is_dir = abap_false. INSERT INTO TABLE lt_non_code_and_metadata_items. ELSE. INSERT INTO TABLE lt_code_items. ENDIF. ENDLOOP. IF mv_diff_first = abap_true. "" fix diffs on the top, right after non-code and metadata LOOP AT lt_code_items ASSIGNING WHERE changes > 0. INSERT INTO TABLE lt_diff_items. ENDLOOP. DELETE lt_code_items WHERE changes > 0. ENDIF. CLEAR: ct_repo_items. ls_sort-name = mv_order_by. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. INSERT ls_sort INTO TABLE lt_sort. SORT lt_code_items BY (lt_sort). SORT lt_diff_items BY (lt_sort). INSERT LINES OF lt_non_code_and_metadata_items INTO TABLE ct_repo_items. INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items. INSERT LINES OF lt_code_items INTO TABLE ct_repo_items. ENDMETHOD. METHOD build_advanced_dropdown. DATA: lv_crossout LIKE zif_abapgit_html=>c_html_opt-crossout. CREATE OBJECT ro_advanced_dropdown. IF iv_rstate IS NOT INITIAL OR iv_lstate IS NOT INITIAL. "" In case of asyncronicities ro_advanced_dropdown->add( iv_txt = 'Reset Local (Force Pull)' iv_act = |{ zif_abapgit_definitions=>c_action-git_reset }?key={ mv_key }| iv_opt = iv_wp_opt ). ENDIF. IF mo_repo->is_offline( ) = abap_false. "" Online ? ro_advanced_dropdown->add( iv_txt = 'Checkout commit' iv_act = |{ zif_abapgit_definitions=>c_action-git_checkout_commit }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_advanced_dropdown->add( iv_txt = 'Background Mode' iv_act = |{ zif_abapgit_definitions=>c_action-go_background }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Change Remote' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_change }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Make Off-line' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_detach }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Force Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-transport_to_branch ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Transport to Branch' iv_act = |{ zif_abapgit_definitions=>c_action-repo_transport_to_branch }?key={ mv_key }| iv_opt = lv_crossout ). ELSE. ro_advanced_dropdown->add( iv_txt = 'Make On-line' iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_attach }?key={ mv_key }| ). ENDIF. IF mv_are_changes_recorded_in_tr = abap_true. ro_advanced_dropdown->add( iv_txt = 'Add all objects to transport request' iv_act = |{ zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Syntax Check' iv_act = |{ zif_abapgit_definitions=>c_action-repo_syntax_check }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Run Code Inspector' iv_act = |{ zif_abapgit_definitions=>c_action-repo_code_inspector }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-update_local_checksum ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Update Local Checksums' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh_checksums }?key={ mv_key }| iv_opt = lv_crossout ). IF is_repo_lang_logon_lang( ) = abap_false AND get_abapgit_tcode( ) IS NOT INITIAL. ro_advanced_dropdown->add( iv_txt = 'Open in Main Language' iv_act = |{ zif_abapgit_definitions=>c_action-repo_open_in_master_lang }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Remove' iv_title = `Remove abapGit's records of the repository (the system's ` && `development objects will remain unaffected)` iv_act = |{ zif_abapgit_definitions=>c_action-repo_remove }?key={ mv_key }| ). CLEAR lv_crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true OR zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>gc_authorization-uninstall ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Uninstall' iv_title = `Delete all development objects belonging to this package ` && `(and subpackages) from the system` iv_act = |{ zif_abapgit_definitions=>c_action-repo_purge }?key={ mv_key }| iv_opt = lv_crossout ). ENDMETHOD. METHOD build_branch_dropdown. DATA lo_repo_online TYPE REF TO zcl_abapgit_repo_online. CREATE OBJECT ro_branch_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_branch_dropdown->add( iv_txt = 'Overview' iv_act = |{ zif_abapgit_definitions=>c_action-go_branch_overview }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_branch_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_create }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_delete }?key={ mv_key }| ). lo_repo_online ?= mo_repo. "" TODO refactor this disaster IF lo_repo_online->get_switched_origin( ) IS NOT INITIAL. ro_branch_dropdown->add( iv_txt = 'Revert to Previous Branch' iv_act = |{ c_actions-repo_reset_origin }| ). ELSE. ro_branch_dropdown->add( iv_txt = 'Switch to PR Branch' iv_act = |{ c_actions-repo_switch_origin_to_pr }| ). ENDIF. ENDMETHOD. METHOD build_dir_jump_link. DATA lv_path TYPE string. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_path = iv_path. REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''. lv_encode = zcl_abapgit_html_action_utils=>dir_encode( lv_path ). rv_html = li_html->a( iv_txt = lv_path iv_act = |{ c_actions-change_dir }?{ lv_encode }| ). ENDMETHOD. METHOD build_head_menu. DATA: lo_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_branch TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_tag TYPE REF TO zcl_abapgit_html_toolbar, lv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout, lv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true. lv_wp_opt = zif_abapgit_html=>c_html_opt-crossout. lv_pull_opt = zif_abapgit_html=>c_html_opt-crossout. ELSE. lv_pull_opt = zif_abapgit_html=>c_html_opt-strong. ENDIF. lo_tb_branch = build_branch_dropdown( lv_wp_opt ). lo_tb_tag = build_tag_dropdown( lv_wp_opt ). lo_tb_advanced = build_advanced_dropdown( iv_wp_opt = lv_wp_opt iv_rstate = iv_rstate iv_lstate = iv_lstate ). ro_toolbar = build_main_toolbar( iv_pull_opt = lv_pull_opt iv_rstate = iv_rstate iv_lstate = iv_lstate io_tb_branch = lo_tb_branch io_tb_tag = lo_tb_tag io_tb_advanced = lo_tb_advanced ). ENDMETHOD. METHOD build_inactive_object_code. IF is_item-inactive = abap_true. rv_inactive_html_code = zcl_abapgit_html=>icon( iv_name = 'bolt/orange' iv_hint = 'Object or object part is inactive' iv_class = 'inactive' ). ENDIF. ENDMETHOD. METHOD build_main_menu. CREATE OBJECT ro_menu EXPORTING iv_id = 'toolbar-main'. ro_menu->add( iv_txt = zcl_abapgit_gui_buttons=>repo_list( ) iv_act = zif_abapgit_definitions=>c_action-abapgit_home )->add( iv_txt = zcl_abapgit_gui_buttons=>settings( ) iv_act = zif_abapgit_definitions=>c_action-go_settings )->add( iv_txt = zcl_abapgit_gui_buttons=>advanced( ) iv_title = 'Utilities' io_sub = zcl_abapgit_gui_chunk_lib=>advanced_submenu( ) )->add( iv_txt = zcl_abapgit_gui_buttons=>help( ) iv_title = 'Help' io_sub = zcl_abapgit_gui_chunk_lib=>help_submenu( ) ). ENDMETHOD. METHOD build_main_toolbar. DATA: li_log TYPE REF TO zif_abapgit_log. CREATE OBJECT ro_toolbar EXPORTING iv_id = 'toolbar-repo'. IF mo_repo->is_offline( ) = abap_false. IF iv_rstate IS NOT INITIAL. "" Something new at remote ro_toolbar->add( iv_txt = 'Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = iv_pull_opt ). ENDIF. IF iv_lstate IS NOT INITIAL. "" Something new at local ro_toolbar->add( iv_txt = 'Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. IF iv_rstate IS NOT INITIAL OR iv_lstate IS NOT INITIAL. "" Any changes ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ro_toolbar->add( iv_txt = 'Branch' io_sub = io_tb_branch ). ro_toolbar->add( iv_txt = 'Tag' io_sub = io_tb_tag ). ELSE. IF mo_repo->has_remote_source( ) = abap_true AND iv_rstate IS NOT INITIAL. ro_toolbar->add( iv_txt = 'Pull zip' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Import zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_import }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Export zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ENDIF. ro_toolbar->add( iv_txt = 'Advanced' io_sub = io_tb_advanced ). ro_toolbar->add( iv_txt = 'View' io_sub = build_view_menu( ) ). ro_toolbar->add( iv_txt = 'Refresh' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = zcl_abapgit_html=>icon( iv_name = 'cog' ) iv_act = |{ zif_abapgit_definitions=>c_action-repo_settings }?key={ mv_key }| iv_title = `Repository Settings` ). ENDMETHOD. METHOD build_obj_jump_link. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_encode = zcl_abapgit_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type iv_obj_name = is_item-obj_name ). rv_html = li_html->a( iv_txt = |{ is_item-obj_name }| iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). ENDMETHOD. METHOD build_tag_dropdown. CREATE OBJECT ro_tag_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_tag_dropdown->add( iv_txt = 'Overview' iv_act = |{ zif_abapgit_definitions=>c_action-go_tag_overview }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_tag_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_create }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_delete }?key={ mv_key }| ). ENDMETHOD. METHOD build_view_menu. CREATE OBJECT ro_toolbar. ro_toolbar->add( iv_txt = 'Changes First' iv_chk = mv_diff_first iv_act = c_actions-toggle_diff_first ). IF mo_repo->has_remote_source( ) = abap_true. ro_toolbar->add( iv_txt = 'Changes Only' iv_chk = mv_changes_only iv_act = c_actions-toggle_changes ). ro_toolbar->add( iv_txt = 'File Paths' iv_chk = boolc( NOT mv_hide_files = abap_true ) iv_act = c_actions-toggle_hide_files ). ENDIF. ro_toolbar->add( iv_txt = 'Folders' iv_chk = mv_show_folders iv_act = c_actions-toggle_folders ). ENDMETHOD. METHOD constructor. DATA: lo_settings TYPE REF TO zcl_abapgit_settings, lx_error TYPE REF TO zcx_abapgit_exception, lv_package TYPE devclass. super->constructor( ). TRY. mv_key = iv_key. mo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). mv_cur_dir = '/'. "" Root mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->get_hide_files( ). mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->get_changes_only( ). mv_diff_first = abap_true. ms_control-page_title = 'Repository'. ms_control-page_menu = build_main_menu( ). "" Read global settings to get max # of objects to be listed lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). mv_max_lines = lo_settings->get_max_lines( ). mv_max_setting = mv_max_lines. lv_package = mo_repo->get_package( ). mv_are_changes_recorded_in_tr = zcl_abapgit_factory=>get_sap_package( lv_package )->are_changes_recorded_in_tr_req( ). CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). RAISE EXCEPTION lx_error. ENDTRY. ENDMETHOD. METHOD get_item_class. DATA lt_class TYPE TABLE OF string. IF is_item-is_dir = abap_true. APPEND 'folder' TO lt_class. ELSEIF is_item-changes > 0. APPEND 'modified' TO lt_class. ELSEIF is_item-obj_name IS INITIAL. APPEND 'unsupported' TO lt_class. ENDIF. IF lines( lt_class ) > 0. rv_html = | class=""{ concat_lines_of( table = lt_class sep = ` ` ) }""|. ENDIF. ENDMETHOD. METHOD get_item_icon. CASE is_item-obj_type. WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' iv_hint = 'Code' ). WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' iv_hint = 'Binary' ). WHEN 'DEVC'. rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' iv_hint = 'Package' ). WHEN ''. rv_html = space. "" no icon WHEN OTHERS. rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). ENDCASE. IF is_item-is_dir = abap_true. rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' iv_hint = 'Folder' ). ENDIF. ENDMETHOD. METHOD open_in_master_language. DATA: lv_master_language TYPE spras, lt_spagpa TYPE STANDARD TABLE OF rfc_spagpa, ls_spagpa LIKE LINE OF lt_spagpa, ls_item TYPE zif_abapgit_definitions=>ty_item, lv_subrc TYPE syst-subrc, lv_save_sy_langu TYPE sy-langu, lv_tcode TYPE tcode. "" https://blogs.sap.com/2017/01/13/logon-language-sy-langu-and-rfc/ lv_master_language = mo_repo->get_dot_abapgit( )->get_master_language( ). lv_tcode = get_abapgit_tcode( ). ASSERT lv_tcode IS NOT INITIAL. IF lv_master_language = sy-langu. zcx_abapgit_exception=>raise( |Repo already opened in main language| ). ENDIF. ls_item-obj_name = lv_tcode. ls_item-obj_type = |TRAN|. IF zcl_abapgit_objects=>exists( ls_item ) = abap_false. zcx_abapgit_exception=>raise( |Please install the abapGit repository| ). ENDIF. lv_save_sy_langu = sy-langu. SET LOCALE LANGUAGE lv_master_language. ls_spagpa-parid = zif_abapgit_definitions=>c_spagpa_param_repo_key. ls_spagpa-parval = mo_repo->get_key( ). INSERT ls_spagpa INTO TABLE lt_spagpa. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' DESTINATION 'NONE' STARTING NEW TASK 'ABAPGIT' EXPORTING tcode = lv_tcode TABLES spagpa_tab = lt_spagpa EXCEPTIONS call_transaction_denied = 1 tcode_invalid = 2 communication_failure = 3 system_failure = 4 OTHERS = 5. lv_subrc = sy-subrc. SET LOCALE LANGUAGE lv_save_sy_langu. IF lv_subrc <> 0. zcx_abapgit_exception=>raise( |Error from ABAP4_CALL_TRANSACTION. Subrc = { lv_subrc }| ). ENDIF. MESSAGE 'Repository opened in a new window' TYPE 'S'. ENDMETHOD. METHOD render_content. DATA: lt_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt, lo_browser TYPE REF TO zcl_abapgit_repo_content_list, lx_error TYPE REF TO zcx_abapgit_exception, lv_lstate TYPE char1, lv_rstate TYPE char1, lv_max TYPE abap_bool, lv_max_str TYPE string, lv_add_str TYPE string, li_log TYPE REF TO zif_abapgit_log, lv_render_transports TYPE abap_bool, lv_msg TYPE string, lo_news TYPE REF TO zcl_abapgit_news. FIELD-SYMBOLS LIKE LINE OF lt_repo_items. gui_services( )->get_hotkeys_ctl( )->register_hotkeys( me ). gui_services( )->register_event_handler( me ). TRY. "" Reinit, for the case of type change mo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( mo_repo->get_key( ) ). lo_news = zcl_abapgit_news=>create( mo_repo ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo io_news = lo_news iv_interactive_branch = abap_true ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_news( io_news = lo_news ) ). lv_render_transports = zcl_abapgit_factory=>get_cts_api( )->is_chrec_possible_for_package( mo_repo->get_package( ) ). CREATE OBJECT lo_browser EXPORTING io_repo = mo_repo. lt_repo_items = lo_browser->list( iv_path = mv_cur_dir iv_by_folders = mv_show_folders iv_changes_only = mv_changes_only ). apply_order_by( CHANGING ct_repo_items = lt_repo_items ). LOOP AT lt_repo_items ASSIGNING . zcl_abapgit_state=>reduce( EXPORTING iv_cur = -lstate CHANGING cv_prev = lv_lstate ). zcl_abapgit_state=>reduce( EXPORTING iv_cur = -rstate CHANGING cv_prev = lv_rstate ). ENDLOOP. ri_html->add( render_head_line( iv_lstate = lv_lstate iv_rstate = lv_rstate ) ). li_log = lo_browser->get_log( ). IF mo_repo->is_offline( ) = abap_false AND li_log->count( ) > 0. ri_html->add( '
' ). ri_html->add( zcl_abapgit_log_viewer=>to_html( li_log ) ). "" shows eg. list of unsupported objects ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). CLEAR lv_msg. IF mo_repo->is_offline( ) = abap_true AND mo_repo->has_remote_source( ) = abap_true AND lv_lstate IS INITIAL AND lv_rstate IS INITIAL. "" Offline match banner lv_msg = 'ZIP source is attached and completely matches the local state'. ELSEIF lines( lt_repo_items ) = 0. "" Online match banner IF mv_changes_only = abap_true. lv_msg = 'Local state completely matches the remote repository'. ELSE. lv_msg = |Package is empty. Show { build_dir_jump_link( 'parent' ) } package|. ENDIF. ELSE. "" Repo content table ri_html->add( '' ). IF zcl_abapgit_path=>is_root( mv_cur_dir ) = abap_false. ri_html->add( render_parent_dir( ) ). ENDIF. ri_html->add( render_order_by( ) ). LOOP AT lt_repo_items ASSIGNING . IF mv_max_lines > 0 AND sy-tabix > mv_max_lines. lv_max = abap_true. EXIT. "" current loop ENDIF. ri_html->add( render_item( is_item = iv_render_transports = lv_render_transports ) ). ENDLOOP. ri_html->add( '
' ). ENDIF. IF NOT lv_msg IS INITIAL. ri_html->add( |
{ lv_msg }
| ). ENDIF. IF lv_max = abap_true. ri_html->add( '
' ). IF mv_max_lines = 1. lv_max_str = '1 object'. ELSE. lv_max_str = |first { mv_max_lines } objects|. ENDIF. lv_add_str = |+{ mv_max_setting }|. ri_html->add( |Only { lv_max_str } shown in list. Display { ri_html->a( iv_txt = lv_add_str iv_act = c_actions-display_more ) } more. (Set in Advanced > { ri_html->a( iv_txt = 'Settings' iv_act = zif_abapgit_definitions=>c_action-go_settings_personal ) } )| ). ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). ri_html->add( render_head_line( iv_lstate = lv_lstate iv_rstate = lv_rstate ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_error( iv_extra_style = 'repo_banner' ix_error = lx_error ) ). ENDTRY. register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_head_line. DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar. CREATE OBJECT ri_html TYPE zcl_abapgit_html. lo_toolbar = build_head_menu( iv_lstate = iv_lstate iv_rstate = iv_rstate ). ri_html->add( '
' ). ri_html->add( '' ). IF mv_show_folders = abap_true. ri_html->add( || ). ENDIF. ri_html->add( '' ). ri_html->add( '
{ mv_cur_dir }' ). ri_html->add( lo_toolbar->render( iv_right = abap_true ) ). ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_item. DATA: lv_link TYPE string, lv_colspan TYPE i. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF iv_render_transports = abap_false. lv_colspan = 2. ELSE. lv_colspan = 3. ENDIF. ri_html->add( || ). IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false. ri_html->add( || && '' && 'non-code and meta files' && '' ). ELSE. ri_html->add( |{ get_item_icon( is_item ) }| ). IF iv_render_transports = abap_true. ri_html->add( render_item_lock_column( is_item ) ). ENDIF. IF is_item-is_dir = abap_true. "" Subdir lv_link = build_dir_jump_link( is_item-path ). ri_html->add( |{ lv_link }| ). ELSE. lv_link = build_obj_jump_link( is_item ). ri_html->add( |{ is_item-obj_type }| ). ri_html->add( |{ lv_link } { build_inactive_object_code( is_item ) }| ). ENDIF. ENDIF. "" Files ri_html->add( '' ). ri_html->add( render_item_files( is_item ) ). ri_html->add( '' ). "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_item_command( is_item ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_item_command. DATA: lv_difflink TYPE string, ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-is_dir = abap_true. "" Directory ri_html->add( '
' ). ri_html->add( |{ is_item-changes } changes| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSEIF is_item-changes > 0. IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL. lv_difflink = zcl_abapgit_html_action_utils=>obj_encode( iv_key = mo_repo->get_key( ) ig_object = is_item ). ri_html->add( '
' ). ri_html->add_a( iv_txt = |diff ({ is_item-changes })| iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSE. LOOP AT is_item-files INTO ls_file. ri_html->add( '
' ). IF ls_file-is_changed = abap_true. lv_difflink = zcl_abapgit_html_action_utils=>file_encode( iv_key = mo_repo->get_key( ) ig_file = ls_file ). ri_html->add_a( iv_txt = 'diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = ls_file-lstate iv_rstate = ls_file-rstate ) ). ELSE. ri_html->add( ' ' ). ENDIF. ri_html->add( '
' ). ENDLOOP. ENDIF. ENDIF. ENDMETHOD. METHOD render_item_files. DATA: ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF mv_hide_files = abap_true AND is_item-obj_type IS NOT INITIAL. RETURN. ENDIF. LOOP AT is_item-files INTO ls_file. ri_html->add( |
{ ls_file-path && ls_file-filename }
| ). ENDLOOP. ENDMETHOD. METHOD render_item_lock_column. DATA: li_cts_api TYPE REF TO zif_abapgit_cts_api, lv_transport TYPE trkorr. CREATE OBJECT ri_html TYPE zcl_abapgit_html. li_cts_api = zcl_abapgit_factory=>get_cts_api( ). ri_html->add( '' ). IF is_item-obj_type IS NOT INITIAL AND is_item-obj_name IS NOT INITIAL AND li_cts_api->is_object_type_lockable( is_item-obj_type ) = abap_true AND li_cts_api->is_object_locked_in_transport( iv_object_type = is_item-obj_type iv_object_name = is_item-obj_name ) = abap_true. lv_transport = li_cts_api->get_current_transport_for_obj( iv_object_type = is_item-obj_type iv_object_name = is_item-obj_name iv_resolve_task_to_request = abap_false ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport = lv_transport iv_icon_only = abap_true ) ). ENDIF. ri_html->add( '' ). ENDMETHOD. METHOD render_order_by. DATA: lv_icon TYPE string, lt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt, ls_col_spec TYPE zif_abapgit_definitions=>ty_col_spec. CREATE OBJECT ri_html TYPE zcl_abapgit_html. APPEND INITIAL LINE TO lt_col_spec. IF mv_are_changes_recorded_in_tr = abap_true. APPEND INITIAL LINE TO lt_col_spec. ENDIF. ls_col_spec-tech_name = 'OBJ_TYPE'. ls_col_spec-display_name = 'Type'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_NAME'. ls_col_spec-display_name = 'Name'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'PATH'. ls_col_spec-display_name = 'Path'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. APPEND INITIAL LINE TO lt_col_spec. ri_html->add( || ). ri_html->add( || ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_order_by_header_cells( it_col_spec = lt_col_spec iv_order_by = mv_order_by iv_order_descending = mv_order_descending ) ). IF mv_diff_first = abap_true. lv_icon = 'check/blue'. ELSE. lv_icon = 'check/grey'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_parent_dir. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( |{ ri_html->icon( 'folder' ) }| ). ri_html->add( |{ build_dir_jump_link( '..' ) }| ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( || ). "" Dummy for online ENDIF. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_palette( zif_abapgit_definitions=>c_action-go_repo ) ). ENDMETHOD. METHOD switch_to_pr. DATA lo_repo_online TYPE REF TO zcl_abapgit_repo_online. DATA lt_pulls TYPE zif_abapgit_pr_enum_provider=>ty_pull_requests. DATA ls_pull LIKE LINE OF lt_pulls. IF mo_repo->is_offline( ) = abap_true. zcx_abapgit_exception=>raise( 'Unexpected PR switch for offline repo' ). ENDIF. IF mo_repo->get_local_settings( )-write_protected = abap_true. zcx_abapgit_exception=>raise( 'Cannot switch branch. Local code is write-protected by repo config' ). ENDIF. lo_repo_online ?= mo_repo. IF iv_revert = abap_true. lo_repo_online->switch_origin( '' ). ELSE. lt_pulls = zcl_abapgit_pr_enumerator=>new( lo_repo_online )->get_pulls( ). IF lines( lt_pulls ) = 0. RETURN. "" false ENDIF. SORT lt_pulls BY number DESCENDING. ls_pull = zcl_abapgit_ui_factory=>get_popups( )->choose_pr_popup( lt_pulls ). IF ls_pull IS INITIAL. RETURN. "" false ENDIF. lo_repo_online->switch_origin( ls_pull-head_url ). lo_repo_online->select_branch( |refs/heads/{ ls_pull-head_branch }| ). "" TODO refactor rv_switched = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA lv_path TYPE string. DATA lv_switched TYPE abap_bool. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-go_repo. "" Switch to another repo CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN c_actions-toggle_hide_files. "" Toggle file diplay mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->toggle_hide_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-change_dir. "" Change dir lv_path = ii_event->query( )->get( 'PATH' ). mv_cur_dir = zcl_abapgit_path=>change_dir( iv_cur_dir = mv_cur_dir iv_cd = lv_path ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_folders. "" Toggle folder view mv_show_folders = boolc( mv_show_folders <> abap_true ). mv_cur_dir = '/'. "" Root rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_changes. "" Toggle changes only view mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->toggle_changes_only( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_diff_first. mv_diff_first = boolc( mv_diff_first = abap_false ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-display_more. "" Increase MAX lines limit mv_max_lines = mv_max_lines + mv_max_setting. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-change_order_by. mv_order_by = ii_event->query( )->get( 'ORDERBY' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-direction. mv_order_descending = boolc( ii_event->query( )->get( 'DIRECTION' ) = 'DESCENDING' ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_open_in_master_lang. open_in_master_language( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-repo_switch_origin_to_pr. lv_switched = switch_to_pr( ). IF lv_switched = abap_true. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ELSE. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDIF. WHEN c_actions-repo_reset_origin. switch_to_pr( iv_revert = abap_true ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). "" TODO refactor, move to HOC components ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions. ls_hotkey_action-ui_component = 'Repo'. ls_hotkey_action-description = |Stage changes|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_stage. ls_hotkey_action-hotkey = |s|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Switch branch|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_branch_switch. ls_hotkey_action-hotkey = |b|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Repository list|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-abapgit_home. ls_hotkey_action-hotkey = |o|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Refresh repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_refresh. ls_hotkey_action-hotkey = |r|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Pull|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_pull. ls_hotkey_action-hotkey = |p|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Diff|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_diff. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Uninstall repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_purge. ls_hotkey_action-hotkey = |u|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run syntax check|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_syntax_check. ls_hotkey_action-hotkey = |c|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run code inspector|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_code_inspector. ls_hotkey_action-hotkey = |i|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Show log|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_log. ls_hotkey_action-hotkey = |l|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |abapGit settings|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_settings. ls_hotkey_action-hotkey = |x|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ENDMETHOD. METHOD is_repo_lang_logon_lang. rv_repo_lang_is_logon_lang = boolc( mo_repo->get_dot_abapgit( )->get_master_language( ) = sy-langu ). ENDMETHOD. METHOD get_abapgit_tcode. CONSTANTS: lc_report_tcode_hex TYPE x VALUE '80'. DATA: lt_tcodes TYPE STANDARD TABLE OF tcode. SELECT tcode FROM tstc INTO TABLE lt_tcodes WHERE pgmna = sy-cprog AND cinfo = lc_report_tcode_hex. IF lines( lt_tcodes ) = 1. READ TABLE lt_tcodes INDEX 1 INTO rv_tcode. ENDIF. ENDMETHOD. ENDCLASS. ",12171,True,2552.5113681735447,median "CLASS zcl_abapgit_gui_page_diff DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page CREATE PUBLIC. PUBLIC SECTION. TYPES: BEGIN OF ty_file_diff, path TYPE string, filename TYPE string, obj_type TYPE string, obj_name TYPE string, lstate TYPE char1, rstate TYPE char1, fstate TYPE char1, "" FILE state - Abstraction for shorter ifs o_diff TYPE REF TO zcl_abapgit_diff, changed_by TYPE xubname, type TYPE string, END OF ty_file_diff. TYPES: ty_file_diffs TYPE STANDARD TABLE OF ty_file_diff WITH NON-UNIQUE DEFAULT KEY WITH NON-UNIQUE SORTED KEY secondary COMPONENTS path filename. CONSTANTS: BEGIN OF c_fstate, local TYPE char1 VALUE 'L', remote TYPE char1 VALUE 'R', both TYPE char1 VALUE 'B', END OF c_fstate. METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception. METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION. PROTECTED SECTION. DATA mv_unified TYPE abap_bool VALUE abap_true ##NO_TEXT. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mt_diff_files TYPE ty_file_diffs . METHODS get_normalized_fname_with_path IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(rv_filename) TYPE string . METHODS normalize_path IMPORTING !iv_path TYPE string RETURNING VALUE(rv_normalized) TYPE string . METHODS normalize_filename IMPORTING !iv_filename TYPE string RETURNING VALUE(rv_normalized) TYPE string . METHODS add_menu_end IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS calculate_diff IMPORTING !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception . METHODS add_menu_begin IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_table_head_non_unified IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS render_beacon_begin_of_row IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS render_diff_head_after_state IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS insert_nav RETURNING VALUE(rv_insert_nav) TYPE abap_bool . METHODS render_line_split_row IMPORTING !ii_html TYPE REF TO zif_abapgit_html !iv_filename TYPE string !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_index TYPE sy-tabix !iv_fstate TYPE char1 !iv_new TYPE string !iv_old TYPE string RAISING zcx_abapgit_exception . METHODS build_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS set_layout. METHODS render_content REDEFINITION . PRIVATE SECTION. CONSTANTS: BEGIN OF c_actions, toggle_unified TYPE string VALUE 'toggle_unified', toggle_hidden_chars TYPE string VALUE 'toggle_hidden_chars', END OF c_actions . DATA mt_delayed_lines TYPE zif_abapgit_definitions=>ty_diffs_tt . DATA mv_repo_key TYPE zif_abapgit_persistence=>ty_repo-key . DATA mv_seed TYPE string . "" Unique page id to bind JS sessionStorage DATA mv_hidden_chars TYPE abap_bool . METHODS render_diff IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_diff_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_table_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_beacon IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_line_split IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_filename TYPE string !iv_fstate TYPE char1 !iv_index TYPE sy-tabix RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_line_unified IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff OPTIONAL RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS append_diff IMPORTING !it_remote TYPE zif_abapgit_definitions=>ty_files_tt !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !is_status TYPE zif_abapgit_definitions=>ty_result RAISING zcx_abapgit_exception . METHODS is_binary IMPORTING !iv_d1 TYPE xstring !iv_d2 TYPE xstring RETURNING VALUE(rv_yes) TYPE abap_bool . METHODS add_jump_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS add_filter_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_lines IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_table_head_unified IMPORTING !ii_html TYPE REF TO zif_abapgit_html . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS is_file_requested IMPORTING it_files TYPE zif_abapgit_definitions=>ty_stage_tt is_status TYPE zif_abapgit_definitions=>ty_result RETURNING VALUE(rv_is_file_requested) TYPE abap_bool. ENDCLASS. CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION. METHOD add_filter_sub_menu. DATA: lo_sub_filter TYPE REF TO zcl_abapgit_html_toolbar, lt_types TYPE string_table, lt_users TYPE string_table. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files, TYPE string. "" Get unique LOOP AT mt_diff_files ASSIGNING . APPEND -type TO lt_types. APPEND -changed_by TO lt_users. ENDLOOP. SORT lt_types. DELETE ADJACENT DUPLICATES FROM lt_types. SORT lt_users. DELETE ADJACENT DUPLICATES FROM lt_users. IF lines( lt_types ) > 1 OR lines( lt_users ) > 1. CREATE OBJECT lo_sub_filter EXPORTING iv_id = 'diff-filter'. IF lines( lt_users ) > 1. lo_sub_filter->add( iv_txt = 'Only my changes' iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = |{ sy-uname }| iv_chk = abap_false ). ENDIF. "" File types IF lines( lt_types ) > 1. lo_sub_filter->add( iv_txt = 'TYPE' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_types ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'type' iv_chk = abap_true ). ENDLOOP. ENDIF. "" Changed by IF lines( lt_users ) > 1. lo_sub_filter->add( iv_txt = 'CHANGED BY' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_users ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'changed-by' iv_chk = abap_true ). ENDLOOP. ENDIF. io_menu->add( iv_txt = 'Filter' io_sub = lo_sub_filter ). ENDIF. ENDMETHOD. METHOD add_jump_sub_menu. DATA: lo_sub_jump TYPE REF TO zcl_abapgit_html_toolbar, lv_jump_target TYPE string. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files. CREATE OBJECT lo_sub_jump EXPORTING iv_id = 'jump'. LOOP AT mt_diff_files ASSIGNING . lv_jump_target = -path && -filename. lo_sub_jump->add( iv_id = |li_jump_{ sy-tabix }| iv_txt = lv_jump_target iv_typ = zif_abapgit_html=>c_action_type-onclick ). ENDLOOP. io_menu->add( iv_txt = 'Jump' io_sub = lo_sub_jump ). ENDMETHOD. METHOD add_menu_begin. ENDMETHOD. METHOD add_menu_end. io_menu->add( iv_txt = 'Split/Unified' iv_act = c_actions-toggle_unified ). io_menu->add( iv_txt = '¶' iv_title = 'Toggle Hidden Characters' iv_act = c_actions-toggle_hidden_chars ). ENDMETHOD. METHOD append_diff. DATA: lv_offs TYPE i, ls_r_dummy LIKE LINE OF it_remote ##NEEDED, ls_l_dummy LIKE LINE OF it_local ##NEEDED. FIELD-SYMBOLS: LIKE LINE OF it_remote, LIKE LINE OF it_local, LIKE LINE OF mt_diff_files. READ TABLE it_remote ASSIGNING WITH KEY filename = is_status-filename path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_r_dummy TO . ENDIF. READ TABLE it_local ASSIGNING WITH KEY file-filename = is_status-filename file-path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_l_dummy TO . ENDIF. IF IS INITIAL AND IS INITIAL. zcx_abapgit_exception=>raise( |DIFF: file not found { is_status-filename }| ). ENDIF. APPEND INITIAL LINE TO mt_diff_files ASSIGNING . -path = is_status-path. -filename = is_status-filename. -obj_type = is_status-obj_type. -obj_name = is_status-obj_name. -lstate = is_status-lstate. -rstate = is_status-rstate. IF -lstate IS NOT INITIAL AND -rstate IS NOT INITIAL. -fstate = c_fstate-both. ELSEIF -lstate IS NOT INITIAL. -fstate = c_fstate-local. ELSE. ""rstate IS NOT INITIAL, lstate = empty. -fstate = c_fstate-remote. ENDIF. "" Changed by IF -item-obj_type IS NOT INITIAL. -changed_by = zcl_abapgit_objects=>changed_by( -item ). ENDIF. IF -changed_by IS INITIAL. -changed_by = zcl_abapgit_objects_super=>c_user_unknown. ENDIF. "" Extension IF -file-filename IS NOT INITIAL. -type = reverse( -file-filename ). ELSE. -type = reverse( -filename ). ENDIF. FIND FIRST OCCURRENCE OF '.' IN -type MATCH OFFSET lv_offs. -type = reverse( substring( val = -type len = lv_offs ) ). IF -type <> 'xml' AND -type <> 'abap'. -type = 'other'. ENDIF. IF -type = 'other' AND is_binary( iv_d1 = -data iv_d2 = -file-data ) = abap_true. -type = 'binary'. ENDIF. "" Diff data IF -type <> 'binary'. IF -fstate = c_fstate-remote. "" Remote file leading changes CREATE OBJECT -o_diff EXPORTING iv_new = -data iv_old = -file-data. ELSE. "" Local leading changes or both were modified CREATE OBJECT -o_diff EXPORTING iv_new = -file-data iv_old = -data. ENDIF. ENDIF. ENDMETHOD. METHOD build_menu. CREATE OBJECT ro_menu. add_menu_begin( ro_menu ). add_jump_sub_menu( ro_menu ). add_filter_sub_menu( ro_menu ). add_menu_end( ro_menu ). ENDMETHOD. METHOD calculate_diff. DATA: lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_status TYPE zif_abapgit_definitions=>ty_results_tt. DATA li_exit TYPE REF TO zif_abapgit_exit. FIELD-SYMBOLS: LIKE LINE OF lt_status. CLEAR: mt_diff_files. lt_remote = mo_repo->get_files_remote( ). lt_local = mo_repo->get_files_local( ). mo_repo->reset_status( ). lt_status = mo_repo->status( ). li_exit = zcl_abapgit_exit=>get_instance( ). li_exit->pre_calculate_repo_status( EXPORTING is_repo_meta = mo_repo->ms_data CHANGING ct_local = lt_local ct_remote = lt_remote ). IF is_file IS NOT INITIAL. "" Diff for one file READ TABLE lt_status ASSIGNING WITH KEY path = is_file-path filename = is_file-filename. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ELSEIF is_object IS NOT INITIAL. "" Diff for whole object LOOP AT lt_status ASSIGNING WHERE obj_type = is_object-obj_type AND obj_name = is_object-obj_name AND match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ELSE. "" Diff for the whole repo SORT lt_status BY path ASCENDING filename ASCENDING. LOOP AT lt_status ASSIGNING WHERE match IS INITIAL. IF is_file_requested( it_files = it_files is_status = ) = abap_true. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDIF. ENDLOOP. ENDIF. ENDMETHOD. METHOD constructor. DATA: lv_ts TYPE timestamp. super->constructor( ). ms_control-page_title = 'Diff'. mv_unified = zcl_abapgit_persistence_user=>get_instance( )->get_diff_unified( ). set_layout( ). mv_repo_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). GET TIME STAMP FIELD lv_ts. mv_seed = |diff{ lv_ts }|. "" Generate based on time ASSERT is_file IS INITIAL OR is_object IS INITIAL. "" just one passed calculate_diff( is_file = is_file is_object = is_object it_files = it_files ). IF lines( mt_diff_files ) = 0. zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ). ENDIF. ms_control-page_menu = build_menu( ). ENDMETHOD. METHOD set_layout. IF mv_unified = abap_true. ms_control-page_layout = c_page_layout-centered. ELSE. ms_control-page_layout = c_page_layout-full_width. ENDIF. ENDMETHOD. METHOD get_normalized_fname_with_path. rv_filename = normalize_path( is_diff-path ) && `_` && normalize_filename( is_diff-filename ). ENDMETHOD. METHOD insert_nav. ENDMETHOD. METHOD is_binary. FIELD-SYMBOLS LIKE iv_d1. IF iv_d1 IS NOT INITIAL. "" One of them might be new and so empty ASSIGN iv_d1 TO . ELSE. ASSIGN iv_d2 TO . ENDIF. rv_yes = zcl_abapgit_utils=>is_binary( ). ENDMETHOD. METHOD normalize_filename. rv_normalized = replace( val = iv_filename sub = '.' occ = 0 with = '_' ). ENDMETHOD. METHOD normalize_path. rv_normalized = replace( val = iv_path sub = '/' occ = 0 with = '_' ). ENDMETHOD. METHOD render_beacon. DATA: lv_beacon TYPE string, lt_beacons TYPE zif_abapgit_definitions=>ty_string_tt. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_diff_line-beacon > 0. lt_beacons = is_diff-o_diff->get_beacons( ). READ TABLE lt_beacons INTO lv_beacon INDEX is_diff_line-beacon. ELSE. lv_beacon = '---'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). render_beacon_begin_of_row( ii_html = ri_html is_diff = is_diff ). IF mv_unified = abap_true. ri_html->add( '' ). ri_html->add( '' ). ri_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ELSE. ri_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_beacon_begin_of_row. ii_html->add( '' ). ENDMETHOD. METHOD render_content. DATA: ls_diff_file LIKE LINE OF mt_diff_files, li_progress TYPE REF TO zif_abapgit_progress. CREATE OBJECT ri_html TYPE zcl_abapgit_html. li_progress = zcl_abapgit_progress=>get_instance( lines( mt_diff_files ) ). ri_html->add( `
` ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( mo_repo ) ). ri_html->add( `
` ). ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_js_error_banner( ) ). LOOP AT mt_diff_files INTO ls_diff_file. li_progress->show( iv_current = sy-tabix iv_text = |Render Diff - { ls_diff_file-filename }| ). ri_html->add( render_diff( ls_diff_file ) ). ENDLOOP. IF sy-subrc <> 0. ri_html->add( |No more diffs| ). ENDIF. ri_html->add( '
' ). register_deferred_script( render_scripts( ) ). li_progress->off( ). ENDMETHOD. METHOD render_diff. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( render_diff_head( is_diff ) ). "" Content IF is_diff-type <> 'binary'. ri_html->add( '
' ). ri_html->add( || ). ri_html->add( render_table_head( is_diff ) ). ri_html->add( render_lines( is_diff ) ). ri_html->add( '
' ). ELSE. ri_html->add( '
' ). ri_html->add( 'The content seems to be binary.' ). ri_html->add( 'Cannot display as diff.' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_diff_head. DATA: ls_stats TYPE zif_abapgit_definitions=>ty_count, lv_adt_link TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '
' ). ri_html->add_icon( iv_name = 'chevron-down' iv_hint = 'Collapse/Expand' iv_class = 'cursor-pointer' iv_onclick = 'onDiffCollapse(event)' ). IF is_diff-type <> 'binary'. ls_stats = is_diff-o_diff->stats( ). IF is_diff-fstate = c_fstate-both. "" Merge stats into 'update' if both were changed ls_stats-update = ls_stats-update + ls_stats-insert + ls_stats-delete. CLEAR: ls_stats-insert, ls_stats-delete. ENDIF. ri_html->add( |+ { ls_stats-insert }| ). ri_html->add( |- { ls_stats-delete }| ). ri_html->add( |~ { ls_stats-update }| ). ENDIF. "" no links for nonexistent or deleted objects IF NOT ( is_diff-lstate = zif_abapgit_definitions=>c_state-unchanged AND is_diff-rstate = zif_abapgit_definitions=>c_state-added ) AND NOT is_diff-lstate = zif_abapgit_definitions=>c_state-deleted. lv_adt_link = ri_html->a( iv_txt = |{ is_diff-path }{ is_diff-filename }| iv_typ = zif_abapgit_html=>c_action_type-sapevent iv_act = |jump?TYPE={ is_diff-obj_type }&NAME={ is_diff-obj_name }| ). ENDIF. IF lv_adt_link IS NOT INITIAL. ri_html->add( |{ lv_adt_link }| ). ELSE. ri_html->add( |{ is_diff-path }{ is_diff-filename }| ). ENDIF. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_diff-lstate iv_rstate = is_diff-rstate ) ). render_diff_head_after_state( ii_html = ri_html is_diff = is_diff ). ri_html->add( 'Last Changed by: ' ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_user_name( is_diff-changed_by ) ). ri_html->add( '' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_diff_head_after_state. IF is_diff-fstate = c_fstate-both AND mv_unified = abap_true. ii_html->add( 'Attention: Unified mode' && ' highlighting for MM assumes local file is newer ! ' ). ENDIF. ENDMETHOD. METHOD render_lines. DATA: lo_highlighter TYPE REF TO zcl_abapgit_syntax_highlighter, lt_diffs TYPE zif_abapgit_definitions=>ty_diffs_tt, lv_insert_nav TYPE abap_bool, lv_tabix TYPE syst-tabix. FIELD-SYMBOLS LIKE LINE OF lt_diffs. lo_highlighter = zcl_abapgit_syntax_factory=>create( iv_filename = is_diff-filename iv_hidden_chars = mv_hidden_chars ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. lt_diffs = is_diff-o_diff->get( ). lv_insert_nav = insert_nav( ). LOOP AT lt_diffs ASSIGNING . lv_tabix = sy-tabix. IF -short = abap_false. lv_insert_nav = abap_true. CONTINUE. ENDIF. IF lv_insert_nav = abap_true. "" Insert separator line with navigation ri_html->add( render_beacon( is_diff_line = is_diff = is_diff ) ). lv_insert_nav = abap_false. ENDIF. IF lo_highlighter IS BOUND. -new = lo_highlighter->process_line( -new ). -old = lo_highlighter->process_line( -old ). ELSE. -new = escape( val = -new format = cl_abap_format=>e_html_attr ). -old = escape( val = -old format = cl_abap_format=>e_html_attr ). ENDIF. CONDENSE -new_num. ""get rid of leading spaces CONDENSE -old_num. IF mv_unified = abap_true. ri_html->add( render_line_unified( is_diff_line = ) ). ELSE. ri_html->add( render_line_split( is_diff_line = iv_filename = get_normalized_fname_with_path( is_diff ) iv_fstate = is_diff-fstate iv_index = lv_tabix ) ). ENDIF. ENDLOOP. IF mv_unified = abap_true. ri_html->add( render_line_unified( ) ). "" Release delayed lines ENDIF. ENDMETHOD. METHOD render_line_split. DATA: lv_new TYPE string, lv_old TYPE string, lv_mark TYPE string, lv_bg TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" New line lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-insert. lv_bg = ' diff_ins'. lv_mark = `+`. ENDIF. ENDIF. lv_new = || && |{ lv_mark }| && |{ is_diff_line-new }|. "" Old line CLEAR lv_bg. lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-delete. lv_bg = ' diff_del'. lv_mark = `-`. ENDIF. ENDIF. lv_old = || && |{ lv_mark }| && |{ is_diff_line-old }|. "" render line, inverse sides if remote is newer ri_html->add( '' ). render_line_split_row( ii_html = ri_html iv_filename = iv_filename is_diff_line = is_diff_line iv_index = iv_index iv_fstate = iv_fstate iv_old = lv_old iv_new = lv_new ). ri_html->add( '' ). ENDMETHOD. METHOD render_line_split_row. IF iv_fstate = c_fstate-remote. "" Remote file leading changes ii_html->add( iv_old ). "" local ii_html->add( iv_new ). "" remote ELSE. "" Local leading changes or both were modified ii_html->add( iv_new ). "" local ii_html->add( iv_old ). "" remote ENDIF. ENDMETHOD. METHOD render_line_unified. FIELD-SYMBOLS LIKE LINE OF mt_delayed_lines. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" Release delayed subsequent update lines IF is_diff_line-result <> zif_abapgit_definitions=>c_diff-update. LOOP AT mt_delayed_lines ASSIGNING . ri_html->add( '' ). ri_html->add( |-old_num }"">| && || && |-| && |{ -old }| ). ri_html->add( '' ). ENDLOOP. LOOP AT mt_delayed_lines ASSIGNING . ri_html->add( '' ). ri_html->add( || && |-new_num }"">| && |+| && |{ -new }| ). ri_html->add( '' ). ENDLOOP. CLEAR mt_delayed_lines. ENDIF. ri_html->add( '' ). CASE is_diff_line-result. WHEN zif_abapgit_definitions=>c_diff-update. APPEND is_diff_line TO mt_delayed_lines. "" Delay output of subsequent updates WHEN zif_abapgit_definitions=>c_diff-insert. ri_html->add( || && || && |+| && |{ is_diff_line-new }| ). WHEN zif_abapgit_definitions=>c_diff-delete. ri_html->add( || && || && |-| && |{ is_diff_line-old }| ). WHEN OTHERS. ""none ri_html->add( || && || && | | && |{ is_diff_line-old }| ). ENDCASE. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( 'restoreScrollPosition();' ). ri_html->add( 'var gHelper = new DiffHelper({' ). ri_html->add( | seed: ""{ mv_seed }"",| ). ri_html->add( ' ids: {' ). ri_html->add( ' jump: ""jump"",' ). ri_html->add( ' diffList: ""diff-list"",' ). ri_html->add( ' filterMenu: ""diff-filter"",' ). ri_html->add( ' }' ). ri_html->add( '});' ). ri_html->add( 'addMarginBottom();' ). ri_html->add( 'var gGoJumpPalette = new CommandPalette(enumerateJumpAllFiles, {' ). ri_html->add( ' toggleKey: ""F2"",' ). ri_html->add( ' hotkeyDescription: ""Jump to file ...""' ). ri_html->add( '});' ). "" Feature for selecting ABAP code by column and copy to clipboard ri_html->add( 'var columnSelection = new DiffColumnSelection();' ). ENDMETHOD. METHOD render_table_head. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( '' ). IF mv_unified = abap_true. render_table_head_unified( ri_html ). ELSE. render_table_head_non_unified( ii_html = ri_html is_diff = is_diff ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_table_head_non_unified. ii_html->add( '' ). ii_html->add( '' ). ii_html->add( 'LOCAL' ). ii_html->add( '' ). ii_html->add( '' ). ii_html->add( 'REMOTE' ). ENDMETHOD. METHOD render_table_head_unified. ii_html->add( 'old' ). ii_html->add( 'new' ). ii_html->add( '' ). ii_html->add( 'code' ). ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. CASE ii_event->mv_action. WHEN c_actions-toggle_unified. "" Toggle file diplay mv_unified = zcl_abapgit_persistence_user=>get_instance( )->toggle_diff_unified( ). set_layout( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_hidden_chars. "" Toggle display of hidden characters mv_hidden_chars = boolc( mv_hidden_chars = abap_false ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). ENDCASE. ENDMETHOD. METHOD is_file_requested. IF lines( it_files ) = 0. rv_is_file_requested = abap_true. RETURN. ENDIF. READ TABLE it_files WITH KEY file-path = is_status-path file-filename = is_status-filename TRANSPORTING NO FIELDS. rv_is_file_requested = boolc( sy-subrc = 0 ). ENDMETHOD. ENDCLASS. ",8438,False,1574.5494033739544,median "/** * VERSION: 12.1.1 * DATE: 2013-12-07 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com **/ package com.greensock.core { import com.company.assembleegameclient.parameters.Parameters; import flash.display.Shape; import flash.events.Event; import flash.utils.getTimer; /** * Base class for all TweenLite, TweenMax, TimelineLite, and TimelineMax classes, providing * core methods/properties/functionality, but there is no reason to create an instance of this * class directly. It can be very useful, however, as a data type in AS3/AS2 for methods/properties that * can contain tweens or timelines. For example, maybe you build an animateIn() and * animateOut() method for many of your own custom classes, and they each return an * Animation instance which could be a tween or a timeline: * * function animateIn():Animation { return TweenLite.to(this, 1, {scaleX:1, scaleY:1, autoAlpha:1}); } function animateOut():Animation { var tl:TimelineLite = new TimelineLite(); tl.to(this, 1, {scaleX:0.5, scaleY:0.5}); tl.to(this, 0.5, {autoAlpha:0}, ""-=0.25""); return tl; } var anim:Animation = animateIn(); //now we can control the animation with the common methods: anim.pause(); anim.play(); anim.reverse(); //or somewhere else, we could build a sequence like this: var tl:TimelineLite = new TimelineLite(); tl.add( animateIn() ); tl.add( animateOut(), 3); * *

Copyright 2008-2014, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.

* * @author Jack Doyle, jack@greensock.com */ public class Animation { /** @private **/ public static const version:String = ""12.1.1""; /** * The object that dispatches a ""tick"" event each time the engine updates, making it easy for * you to add your own listener(s) to run custom logic after each update (great for game developers). * Add as many listeners as you want. The basic syntax is the same for all versions (AS2, AS3, and JavaScript): * *

Basic example (AS2, AS3, and JavaScript):

//add listener Animation.ticker.addEventListener(""tick"", myFunction); function myFunction(event) { //executes on every tick after the core engine updates } //to remove the listener later... Animation.ticker.removeEventListener(""tick"", myFunction); * *

Due to differences in the core languages (and to maximize efficiency), the advanced syntax is slightly different * for the AS3 version compared to AS2 and JavaScript. The parameters beyond the first 2 in the addEventListener() * method are outlined below:

* *

JavaScript and AS2

*

addEventListener(type, callback, scope, useParam, priority)

*

Parameters: *

    *
  1. type : String - type of listener, should always be ""tick""
  2. *
  3. callback : Function - the function to call when the event occurs
  4. *
  5. scope : Object - binds the scope to a particular object (scope is basically what ""this"" refers to in your function). This can be very useful in JavaScript and AS2 because scope isn't generally maintained.
  6. *
  7. useParam : Boolean - if true, an event object will be generated and fed to the callback each time the event occurs. The event is a generic object and has two properties: type (always ""tick"") and target which refers to the ticker instance. The default for useParam is false because it improves performance.
  8. *
  9. priority : Integer - influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.
  10. *
*

* *

In JavaScript, the Animation object/class is located at com.greensock.core.Animation - it is not added to the global namespace in order to avoid polluting it (developers rarely directly access the Animation class)

* *

Advanced example (JavaScript and AS2):

//add listener that requests an event object parameter, binds scope to the current scope (this), and sets priority to 1 so that it is called before any other listeners that had a priority lower than 1... Animation.ticker.addEventListener(""tick"", myFunction, this, true, 1); function myFunction(event) { //executes on every tick after the core engine updates } //to remove the listener later... Animation.ticker.removeEventListener(""tick"", myFunction); * *

AS3

*

The AS3 version uses the standard EventDispatcher.addEventListener() syntax which * basically allows you to define a priority and whether or not to use weak references (see Adobe's * docs for details).

* *

Advanced example [AS3 only]:

import flash.events.Event; //add listener with weak reference (standard syntax - notice the 5th parameter is true) Animation.ticker.addEventListener(""tick"", myFunction, false, 0, true); function myFunction(event:Event):void { //executes on every tick after the core engine updates } //to remove the listener later... Animation.ticker.removeEventListener(""tick"", myFunction); **/ public static var ticker:Shape = new Shape(); /** @private root timeline on which all time-based tweens/timelines are initially placed (_rootFramesTimeline is for frames-based tweens/timelines where useFrames:true is defined in the constructor's vars parameter). **/ public static var _rootTimeline:SimpleTimeline; /** @private root timeline on which all frames-based tweens/timelines are initially placed (_rootTimeline is for time-based tweens/timelines). A frames-based animation is one that has useFrames:true defined in the constructor's vars parameter or it is placed into a parent timeline that is frames-based (the parent timeline always defines the timing mode). **/ public static var _rootFramesTimeline:SimpleTimeline; /** @private Each time the root timelines are updated, _rootFrame is incremented in order to keep track of how many frames have been rendered. **/ protected static var _rootFrame:Number = -1; /** @private We reuse this event instance for better memory management rather than recreating a new instance on every frame. **/ protected static var _tickEvent:Event = new Event(""tick""); /** @private **/ protected static var _tinyNum:Number = 0.0000000001; /** @private The onUpdate callback (if one is defined). Checking an instance property is faster than looking it up in the vars object on every render. This is purely a speed optimization **/ protected var _onUpdate:Function; /** @private Delay in seconds (or frames for frames-based tweens/timelines) **/ public var _delay:Number; /** @private Primarily used for zero-duration tweens to determine the direction/momentum of time in its parent timeline which controls whether the starting or ending values should be rendered. See the render() method for usage (which is slightly different in tweens versus timelines) **/ public var _rawPrevTime:Number; /** @private Indicates whether or not the tween is currently active (typically when the parent timeline's playhead is between the start and end time of this animation). Makes conditional logic faster in the rendering queue of the parent timeline because if a tween is active, it'll always get rendered and we can flip _acitve to false when it completes. **/ public var _active:Boolean; /** @private Flagged for garbage collection (indicates the tween has been disabled, but keep in mind that a tween can be re-enabled later too!) **/ public var _gc:Boolean; /** @private Indicates whether or not the animation has been initialized (for tweens, this is when all the tweening properties get analyzed and their start/end values recorded, etc.) **/ public var _initted:Boolean; /** @private The time at which the animation begins, according to its parent timeline's time. For example, if the tween starts at exactly 3 seconds into the timeline on which it is placed, startTime would be 3. **/ public var _startTime:Number; /** @private The local position of the playhead (essentially the current time). If the animation has a non-zero repeat (only available on TweenMax and TimelineMax instances), its time goes back to zero upon repeating even though the totalTime continues forward linearly (or if it yoyo is true, the time alternates between moving forward and backward). time never exceeds the duration whereas the totalTime reflects the overall time including any repeats and repeatDelays. For example, if a TweenMax instance has a duration of 2 and a repeat of 3, totalTime will go from 0 to 8 during the course of the tween (plays once then repeats 3 times, making 4 total cycles) whereas time will go from 0 to 2 a total of 4 times. **/ public var _time:Number; /** @private The overall position of the playhead including any repeats and repeatDelays (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has a duration of 2 and a repeat of 3, totalTime will go from 0 to 8 during the course of the tween (plays once then repeats 3 times, making 4 total cycles) whereas time will go from 0 to 2 a total of 4 times. **/ public var _totalTime:Number; /** @private Duration of the animation, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has a duration of 2 and a repeat of 3, its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles). **/ public var _duration:Number; /** @private Total duration of the animation including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has a duration of 2 and a repeat of 3, its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles). **/ public var _totalDuration:Number; /** @private Records the parent timeline's rawTime when the animation is paused (so that we can place it at the appropriate time when it is unpaused). NaN when the animation isn't paused. **/ public var _pauseTime:Number; /** @private Factor that's used to scale the time in the animation where 1 = normal speed, 0.5 = half speed, 2 = double speed, etc. For example, if a tween's duration is 2 but its timeScale is 0.5, it will take 4 seconds to finish. If you nest that tween in a TimelineLite that has a timeScale of 0.5 as well, it will take 8 seconds to finish. You can even tween another tween's (or timeline's) timeScale to gradually slow it down or speed it up. **/ public var _timeScale:Number; /** @private Indicates whether or not the animation is reversed. **/ public var _reversed:Boolean; /** @private The most recent parent timeline (only null for the _rootTimeline and _rootFramesTimeline). The timeline property (no ""_"" prefix) is null whenever the animation is removed from its parent timeline. We use this internally in slightly different ways. We need to always maintain a reference to the last parent timeline so that if the animation is re-enabled, we know where to put it. ""_gc"" is different in that a Animation could be eligible for gc yet not removed from its timeline, like when a TimelineLite completes for example. It makes things much faster to enable again if/when necessary, like if the TimelineLite gets restarted. **/ public var _timeline:SimpleTimeline; /** @private If true, the _duration or _totalDuration may need refreshing. For example, if a TimelineLite's child had a change in duration or startTime, it could affect the parent timeline's duration but we don't want to always make the update immediately because there may be many more changes made before the timeline actually need to be rendered again, so this helps improve performance. If the _dirty is false, we can skip the method call and quickly read from the _duration and/or _totalDuration. **/ public var _dirty:Boolean; /** @private Provides a quick way to check whether or not a animation is currently paused (skipping the paused() method call). **/ public var _paused:Boolean; /** @private Next Animation in the linked list. **/ public var _next:Animation; /** @private Previous Animation in the linked list. **/ public var _prev:Animation; /** The vars object passed into the constructor which stores configuration variables like onComplete, onUpdate, etc. as well as tweening properties like opacity, x, y or whatever. **/ public var vars:Object; /** [Read-only] Parent timeline. Every animation is placed onto a timeline (the root timeline by default) and can only have one parent. An instance cannot exist in multiple timelines at once. **/ public var timeline:SimpleTimeline; /** A place to store any data you want (initially populated with vars.data if it exists). **/ public var data:*; /** * Constructor * * @param duration duration in seconds (or frames for frames-based tweens) * @param vars configuration variables (for example, {x:100, y:0, opacity:0.5, onComplete:myFunction}) */ public function Animation(duration:Number=0, vars:Object=null) { this.vars = vars || {}; if (this.vars._isGSVars) { this.vars = this.vars.vars; } _duration = _totalDuration = duration || 0; _delay = Number(this.vars.delay) || 0; _timeScale = 1; _totalTime = _time = 0; data = this.vars.data; _rawPrevTime = -1; if (_rootTimeline == null) { if (_rootFrame == -1) { _rootFrame = 0; _rootFramesTimeline = new SimpleTimeline(); _rootTimeline = new SimpleTimeline(); _rootTimeline._startTime = getTimer() / 1000; _rootFramesTimeline._startTime = 0; _rootTimeline._active = _rootFramesTimeline._active = true; ticker.addEventListener(""enterFrame"", _updateRoot, false, 0, true); } else { return; } } var tl:SimpleTimeline = (this.vars.useFrames) ? _rootFramesTimeline : _rootTimeline; tl.add(this, tl._time); _reversed = (this.vars.reversed == true); if (this.vars.paused) { paused(true); } } /** * Begins playing forward, optionally from a specific time (by default playback begins from * wherever the playhead currently is). This also ensures that the instance is neither paused * nor reversed. * *

If you define a ""from"" time (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //begins playing from wherever the playhead currently is: myAnimation.play(); //begins playing from exactly 2-seconds into the animation: myAnimation.play(2); //begins playing from exactly 2-seconds into the animation but doesn't suppress events during the initial move: myAnimation.play(2, false); * * @param from The time (or label for TimelineLite/TimelineMax instances) from which the animation should begin playing (if none is defined, it will begin playing from wherever the playhead currently is). * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter. * @return self (makes chaining easier) */ public function play(from:*=null, suppressEvents:Boolean=true):* { if (from != null) { seek(from, suppressEvents); } reversed(false); return paused(false); } /** * Pauses the instance, optionally jumping to a specific time. * *

If you define a time to jump to (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //pauses wherever the playhead currently is: myAnimation.pause(); //jumps to exactly 2-seconds into the animation and then pauses: myAnimation.pause(2); //jumps to exactly 2-seconds into the animation and pauses but doesn't suppress events during the initial move: myAnimation.pause(2, false); * * @param atTime The time (or label for TimelineLite/TimelineMax instances) that the instance should jump to before pausing (if none is defined, it will pause wherever the playhead is currently located). * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the atTime parameter. * @return self (makes chaining easier) */ public function pause(atTime:*=null, suppressEvents:Boolean=true):* { if (atTime != null) { seek(atTime, suppressEvents); } return paused(true); } /** * Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. * *

If you define a time to jump to (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //resumes from wherever the playhead currently is: myAnimation.resume(); //jumps to exactly 2-seconds into the animation and then resumes playback: myAnimation.resume(2); //jumps to exactly 2-seconds into the animation and resumes playbck but doesn't suppress events during the initial move: myAnimation.resume(2, false); * * @param from The time (or label for TimelineLite/TimelineMax instances) that the instance should jump to before resuming playback (if none is defined, it will resume wherever the playhead is currently located). * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter. * @return self (makes chaining easier) */ public function resume(from:*=null, suppressEvents:Boolean=true):* { if (from != null) { seek(from, suppressEvents); } return paused(false); } /** * Jumps to a specific time without affecting whether or not the instance is paused or reversed. * *

If there are any events/callbacks inbetween where the playhead was and the new time, * they will not be triggered because by default suppressEvents (the 2nd parameter) * is true. Think of it like picking the needle up on a record player and moving it * to a new position before placing it back on the record. If, however, you do not want the * events/callbacks suppressed during that initial move, simply set the suppressEvents * parameter to false.

* * //jumps to exactly 2 seconds myAnimation.seek(2); //jumps to exactly 2 seconds but doesn't suppress events during the initial move: myAnimation.seek(2, false); * * @param time The time (or label for TimelineLite/TimelineMax instances) to go to. * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. * @return self (makes chaining easier) */ public function seek(time:*, suppressEvents:Boolean=true):* { return totalTime(Number(time), suppressEvents); } /** * Restarts and begins playing forward from the beginning. * * //restarts, not including any delay that was defined myAnimation.restart(); //restarts, including any delay, and doesn't suppress events during the initial move back to time:0 myAnimation.restart(true, false); * * @param includeDelay Determines whether or not the delay (if any) is honored when restarting. For example, if a tween has a delay of 1 second, like new TweenLite(mc, 2, {x:100, delay:1}); and then later restart() is called, it will begin immediately, but restart(true) will cause the delay to be honored so that it won't begin for another 1 second. * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. * @return self (makes chaining easier) */ public function restart(includeDelay:Boolean=false, suppressEvents:Boolean=true):* { reversed(false); paused(false); return totalTime((includeDelay ? -_delay : 0), suppressEvents, true); } /** * Reverses playback so that all aspects of the animation are oriented backwards including, for example, * a tween's ease. This will cause the instance's time and totalTime to move * back towards zero as well. You can optionally define a specific time to jump to before reversing * (by default it begins playing in reverse from wherever the playhead currently is). * Calling reverse() also ensures that the instance is neither paused nor reversed. * *

To jump to the very end of the animation and play in reverse from there, use 0 as the * ""from"" parameter, like reverse(0).

* *

To check whether or not the instance is reversed, use the reversed() method, like * if (myAnimation.reversed()) {...}

* *

If you define a ""from"" time (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //reverses playback from wherever the playhead currently is: myAnimation.reverse(); //reverses playback from exactly 2 seconds into the animation: myAnimation.reverse(2); //reverses playback from exactly 2 seconds into the animation but doesn't suppress events during the initial move: myAnimation.reverse(2, false); //reverses playback from the very END of the animation: myAnimation.reverse(0); //reverses playback starting from exactly 1 second before the end of the animation: myAnimation.reverse(-1); //flips the orientation (if it's forward, it will go backward, if it is backward, it will go forward): if (myAnimation.reversed()) { myAnimation.play(); } else { myAnimation.reverse(); } //flips the orientation using the reversed() method instead (shorter version of the code above): myAnimation.reversed( !myAnimation.reversed() ); * * @param from The time (or label for TimelineLite/TimelineMax instances) from which the animation should begin playing in reverse (if none is defined, it will begin playing from wherever the playhead currently is). To begin at the very end of the animation, use 0. Negative numbers are relative to the end of the animation, so -1 would be 1 second from the end. * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter. * @return self (makes chaining easier) */ public function reverse(from:*=null, suppressEvents:Boolean=true):* { if (from != null) { seek((from || totalDuration()), suppressEvents); } reversed(true); return paused(false); } /** * @private * Renders the animation at a particular time (or frame number for frames-based tweens). * The time is based simply on the overall duration. For example, if an animations's duration * is 3, render(1.5) would render it as halfway finished. * * @param time time (or frame number for frames-based animations) to render. If a negative value is used, it will act like 0. If the value exceeds the totalDuration, it will act like the totalDuration. * @param suppressEvents If true, no events or callbacks will be triggered for this render (like onComplete, onUpdate, onReverseComplete, etc.) * @param force Normally the animation will skip rendering if the time matches the _totalTime (to improve performance), but if force is true, it forces a render. This is primarily used internally for tweens with durations of zero in TimelineLite/Max instances. */ public function render(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void { } /** * Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, * you want to restart a tween without reverting to any previously recorded starting values. When you invalidate() * an animation, it will be re-initialized the next time it renders and its vars object will be re-parsed. * The timing of the animation (duration, startTime, delay) will not be affected. * *

Another example would be if you have a TweenMax(mc, 1, {x:100, y:100}) that ran when mc.x and mc.y * were initially at 0, but now mc.x and mc.y are 200 and you want them tween to 100 again, you could simply * invalidate() the tween and restart() it. Without invalidating first, restarting it * would cause the values jump back to 0 immediately (where they started when the tween originally began). * When you invalidate a TimelineLite/TimelineMax, it automatically invalidates all of its children.

* @return self (makes chaining easier) **/ public function invalidate():* { return this; } /** * Indicates whether or not the animation is currently active (meaning the virtual playhead is actively moving across * this instance's time span and it is not paused, nor are any of its ancestor timelines). * So for example, if a tween is in the middle of tweening, it's active, but after it is finished (or before * it begins), it is not active. If it is paused or if it is placed inside of a timeline that's paused * (or if any of its ancestor timelines are paused), isActive() will return false. If the * playhead is directly on top of the animation's start time (even if it hasn't rendered quite yet), that counts * as ""active"". * *

You may also check the progress() or totalProgress(), but those don't take into consideration * the paused state or the position of the parent timeline's playhead.

* * @see #progress() * @see #totalProgress() **/ public function isActive():Boolean { var tl:SimpleTimeline = _timeline, //the 2 root timelines won't have a _timeline; they're always active. rawTime:Number; return ((tl == null) || (!_gc && !_paused && tl.isActive() && (rawTime = tl.rawTime()) >= _startTime && rawTime < _startTime + totalDuration() / _timeScale)); } /** * @private * If an animation is enabled, it is eligible to be rendered (unless it is paused). Disabling it * essentially removes it from its parent timeline and stops protecting it from garbage collection. * * @param enabled Enabled state of the animation * @param ignoreTimeline By default, the tween/timeline will remove itself from its parent timeline when it is disabled and add itself when it is enabled, but this parameter allows you to skip that behavior. * @return Boolean value indicating whether or not important properties may have changed when the animation was enabled/disabled. For example, when a MotionBlurPlugin is disabled, it swaps out a BitmapData for the target and may alter the opacity. We need to know this in order to determine whether or not a new tween that is overwriting this one should be re-initialized with the changed properties. **/ public function _enabled(enabled:Boolean, ignoreTimeline:Boolean=false):Boolean { _gc = !enabled; //note: it is possible for _gc to be true and timeline not to be null in situations where a parent TimelineLite/Max has completed and is removed - the developer might hold a reference to that timeline and later restart() it or something. _active = Boolean(enabled && !_paused && _totalTime > 0 && _totalTime < _totalDuration); if (!ignoreTimeline) { if (enabled && timeline == null) { _timeline.add(this, _startTime - _delay); } else if (!enabled && timeline != null) { _timeline._remove(this, true); } } return false; } /** @private Same as kill() except that it returns a Boolean that indicates whether or not important properties may have changed when the animation was killed. For example, when a MotionBlurPlugin is disabled, it swaps out a BitmapData for the target and may alter the opacity. We need to know this in order to determine whether or not a new tween that is overwriting this one should be re-initialized with the changed properties. **/ public function _kill(vars:Object=null, target:Object=null):Boolean { return _enabled(false, false); } /** * Kills the animation entirely or in part depending on the parameters. Simply calling kill() * (omitting the parameters) will immediately stop the animation and release it for garbage collection. * To kill only particular tweening properties of the animation, use the first parameter which should * be a generic object with enumerable properties corresponding to those that should be killed, * like {x:true, y:true}. The second parameter allows you to define a target * (or array of targets) to affect. * *

Note: the values assigned to each property of the vars parameter object don't * matter - the sole purpose of the object is for iteration over the named properties. In other * words, {x:true, y:true} would produce the same results as {x:false, y:false}.

* * //kill the entire animation: myAnimation.kill(); //kill only the ""x"" and ""y"" properties of the animation (all targets): myAnimation.kill({x:true, y:true}); //kill all parts of the animation related to the target ""myObject"" (if the tween has multiple targets, the others will not be affected): myAnimation.kill(null, myObject); //kill only the ""x"" and ""y"" properties of animations of the target ""myObject"": myAnimation.kill({x:true, y:true}, myObject); //kill only the ""opacity"" properties of animations of the targets ""myObject1"" and ""myObject2"": myAnimation.kill({opacity:true}, [myObject1, myObject2]); * * @param vars To kill only specific properties, use a generic object containing enumerable properties corresponding to the ones that should be killed, like {x:true, y:true}. The values assigned to each property of the object don't matter - the sole purpose of the object is for iteration over the named properties (in this case, x and y). If no object (or null) is defined, ALL properties will be killed. * @param target To kill only aspects of the animation related to a particular target (or targets), reference it here. For example, to kill only parts having to do with myObject, do kill(null, myObject) or to kill only parts having to do with myObject1 and myObject2, do kill(null, [myObject1, myObject2]). If no target is defined, ALL targets will be affected. * @return self (makes chaining easier) **/ public function kill(vars:Object=null, target:Object=null):* { _kill(vars, target); return this; } /** * @private * Sets the _dirty property of all anscestor timelines (and optionally this instance too). Setting * the _dirty property to true forces any necessary recalculation of its _duration and * _totalDuration properties and sorts the affected timelines' children animations so that they're in the proper order * next time the duration or totalDuration is requested. We don't just recalculate them * immediately because it can be much faster to do it this way. * * @param includeSelf indicates whether or not this tween's _dirty property should be affected. * @return self (makes chaining easier) */ protected function _uncache(includeSelf:Boolean):* { var tween:Animation = includeSelf ? this : timeline; while (tween) { tween._dirty = true; tween = tween.timeline; } return this; } /** @private This method gets called on every frame and is responsible for rendering/updating the root timelines. If you want to unhook the engine from its ticker, you could do Animation.ticker.removeEventListener(""enterFrame"", _updateRoot) and then call it yourself whenever you want to update. **/ public static function _updateRoot(event:Event=null):void { _rootFrame++; _rootTimeline.render((getTimer() / 1000 - _rootTimeline._startTime) * _rootTimeline._timeScale, false, false); _rootFramesTimeline.render((_rootFrame - _rootFramesTimeline._startTime) * _rootFramesTimeline._timeScale, false, false); ticker.dispatchEvent(_tickEvent); } /** @private **/ protected function _swapSelfInParams(params:Array):Array { var i:int = params.length, copy:Array = params.concat(); while (--i > -1) { if (params[i] === ""{self}"") { copy[i] = this; } } return copy; } //---- GETTERS / SETTERS ------------------------------------------------------------ /** * Gets or sets an event callback like ""onComplete"", ""onUpdate"", ""onStart"", ""onReverseComplete"" * or ""onRepeat"" (onRepeat only applies to TweenMax or TimelineMax instances) * along with any parameters that should be passed to that callback. This is the same as defining * the values directly in the constructor's vars parameter initially, so the following * two lines are functionally equivalent: * * //the following two lines produce IDENTICAL results: var myAnimation = new TweenLite(mc, 1, {x:100, onComplete:myFunction, onCompleteParams:[""param1"",""param2""]}); myAnimation.eventCallback(""onComplete"", myFunction, [""param1"",""param2""]); *

The benefit of using eventCallback() is that it allows you to set callbacks * even after the animation instance has been created and it also allows you to inspect the * callback references or even delete them on-the-fly (use null to delete the * event callback).

* * //deletes the onUpdate myAnimation.eventCallback(""onUpdate"", null); * *

IMPORTANT:Animation instances can only have one callback associated with each * event type (one onComplete, one onUpdate, one onStart, etc.). * So setting a new value will overwrite the old one. All of the values populate the vars * object too which was originally passed into the constructor (think of that like a storage place for * configuration data).

* *

This method serves as both a getter and setter. Omitting all but the first parameter returns * the current value (getter), whereas defining more than the first parameter sets the value (setter) * and returns the instance itself for easier chaining, like * myAnimation.eventCallback(""onComplete"", completeHandler).eventCallback(""onUpdate"", updateHandler, [""param1"",""{self}""]).play(1);

* * var currentOnComplete = myAnimation.eventCallback(""onComplete""); //gets current onComplete myAnimation.eventCallback(""onComplete"", myFunction); //sets the onComplete * *

JavaScript and AS2 note: - Due to the way JavaScript and AS2 don't * maintain scope (what ""this"" refers to, or the context) in function calls, * it can be useful to define the scope specifically. Therefore, in the JavaScript and AS2 * versions accept an extra (4th) parameter for scope.

* * @param type The type of event callback, like ""onComplete"", ""onUpdate"", ""onStart"" or ""onRepeat"". This is case-sensitive. * @param callback The function that should be called when the event occurs. * @param params An array of parameters to pass the callback. Use ""{self}"" to refer to the animation instance itself. Example: [""param1"",""{self}""] * @return Omitting the all but the first parameter returns the current value (getter), whereas defining more than the first parameter sets the callback (setter) and returns the instance itself for easier chaining. */ public function eventCallback(type:String, callback:Function=null, params:Array=null):* { if (type == null) { return null; } else if (type.substr(0,2) == ""on"") { if (arguments.length == 1) { return vars[type]; } if (callback == null) { delete vars[type]; } else { vars[type] = callback; vars[type + ""Params""] = ((params is Array) && params.join("""").indexOf(""{self}"") !== -1) ? _swapSelfInParams(params) : params; } if (type == ""onUpdate"") { _onUpdate = callback; } } return this; } /** * Gets or sets the animation's initial delay which is the length of time in seconds * (or frames for frames-based tweens) before the animation should begin. * A tween's starting values are not recorded until after the delay has expired (except in * from() tweens which render immediately by default unless immediateRender:false * is set in the vars parameter). An animation's delay is unaffected * by its timeScale, so if you were to change timeScale from 1 to 10, * for example, it wouldn't cause the delay to grow tenfold. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.delay(2).timeScale(0.5).play(1);

* * var currentDelay = myAnimation.delay(); //gets current delay myAnimation.delay(2); //sets delay * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. **/ public function delay(value:Number=NaN):* { if (!arguments.length) { return _delay; } if (_timeline.smoothChildTiming) { startTime( _startTime + value - _delay ); } _delay = value; return this; } /** * Gets or sets the animation's duration, not including any repeats or repeatDelays * (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has * a duration of 2 and a repeat of 3, its totalDuration * would be 8 (one standard play plus 3 repeats equals 4 total cycles). * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.duration(2).delay(0.5).play(1);

* * var currentDuration = myAnimation.duration(); //gets current duration myAnimation.duration(2); //sets duration * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #totalDuration() * @see #timeScale() **/ public function duration(value:Number=NaN):* { if (!arguments.length) { _dirty = false; return _duration; } _duration = _totalDuration = value; _uncache(true); //true in case it's a TweenMax or TimelineMax that has a repeat - we'll need to refresh the totalDuration. if (_timeline.smoothChildTiming) if (_time > 0) if (_time < _duration) if (value != 0) { totalTime(_totalTime * (value / _duration), true); } return this; } /** * Gets or sets the animation's total duration including * any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). * For example, if a TweenMax instance has a duration of 2 and a repeat of 3, * its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles). * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.totalDuration(2).delay(0.5).play(1);

* * var ctd = myAnimation.totalDuration(); //gets current total duration myAnimation.totalDuration(2); //sets total duration * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #duration() * @see #timeScale() **/ public function totalDuration(value:Number=NaN):* { _dirty = false; return (!arguments.length) ? _totalDuration : duration(value); } /** * Gets or sets the local position of the playhead (essentially the current time), * described in seconds (or frames for frames-based animations) which * will never be less than 0 or greater than the animation's duration. * For example, if the duration is 10 and you were to watch the * time during the course of the animation, you'd see it go from 0 * at the beginning to 10 at the end. Setting time to 5 would cause the * animation to jump to its midway point (because it's half of the duration). * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* * var currentTime = myAnimation.time(); //gets current time myAnimation.time(2); //sets time, jumping to new value just like seek(). * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. Negative values will be interpreted from the END of the animation. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position defined in the value parameter. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #seek() * @see #play() * @see #reverse() * @see #pause() * @see #totalTime() **/ public function time(value:Number=NaN, suppressEvents:Boolean=false):* { if (!arguments.length) { return _time; } if (_dirty) { totalDuration(); } if (value > _duration) { value = _duration; } return totalTime(value, suppressEvents); } /** * Gets or sets the position of the playhead according to the totalDuration * which includes any repeats and repeatDelays (only available * in TweenMax and TimelineMax). For example, if a TweenMax instance has a * duration of 2 and a repeat of 3, totalTime * will go from 0 to 8 during the course of the tween (plays once then repeats 3 times, * making 4 total cycles) whereas time will go from 0 to 2 a total of 4 times. * If you added a repeatDelay of 1, that would make the totalTime * go from 0 to 11 over the course of the tween. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* *

totalTime will never exceed the totalDuration, nor will it be * less than 0 (values will be clipped appropriately). Negative values will be interpreted from * the END of the animation. For example, -2 would be 2 seconds before the end. If the * animation's totalDuration is 6 and you do myAnimation.totalTime(-2), * it will jump to a totalTime of 4.

* * var tt = myAnimation.totalTime(); //gets total time myAnimation.totalTime(2); //sets total time, jumping to new value just like seek(). * * @param time Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. Negative values will be interpreted from the END of the animation. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. * @param uncapped By default, the time will be capped at totalDuration and if a negative number is used, it will be measured from the END of the animation, but if uncapped is true, the time won't be adjusted at all (negatives will be allowed, as will values that exceed totalDuration). * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #time() * @see #seek() * @see #play() * @see #reverse() * @see #pause() **/ public function totalTime(time:Number=NaN, suppressEvents:Boolean=false, uncapped:Boolean=false):* { if (!arguments.length) { return _totalTime; } if (_timeline) { if (time < 0 && !uncapped) { time += totalDuration(); } if (_timeline.smoothChildTiming) { if (_dirty) { totalDuration(); } if (time > _totalDuration && !uncapped) { time = _totalDuration; } var tl:SimpleTimeline = _timeline; _startTime = (_paused ? _pauseTime : tl._time) - ((!_reversed ? time : _totalDuration - time) / _timeScale); if (!_timeline._dirty) { //for performance improvement. If the parent's cache is already dirty, it already took care of marking the anscestors as dirty too, so skip the function call here. _uncache(false); } //in case any of the ancestor timelines had completed but should now be enabled, we should reset their totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The startTime of that child would get pushed out, but one of the ancestors may have completed. if (tl._timeline != null) { while (tl._timeline) { if (tl._timeline._time !== (tl._startTime + tl._totalTime) / tl._timeScale) { tl.totalTime(tl._totalTime, true); } tl = tl._timeline; } } } if (_gc) { _enabled(true, false); } if (_totalTime != time || _duration === 0) { render(time, suppressEvents, false); } } return this; } /** * Gets or sets the animations's progress which is a value between 0 and 1 indicating the position * of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, * and 1 is at the end (complete). If the animation has a non-zero repeat defined (only available in TweenMax and TimelineMax), * progress() and totalProgress() will be different because progress() doesn't include the * repeat or repeatDelay whereas totalProgress() does. For example, if a TimelineMax instance * is set to repeat once, at the end of the first cycle totalProgress() would only be 0.5 * whereas progress() would be 1. If you watched both properties over the course of the entire * animation, you'd see progress() go from 0 to 1 twice (once for each cycle) in the * same time it takes the totalProgress() to go from 0 to 1 once. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.progress(0.5).play();

* * var progress = myAnimation.progress(); //gets current progress myAnimation.progress(0.25); //sets progress to one quarter finished * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #seek() * @see #time() * @see #totalTime() * @see #totalProgress() **/ public function progress(value:Number=NaN, suppressEvents:Boolean=false):* { return (!arguments.length) ? _time / duration() : totalTime(duration() * value, suppressEvents); } /** * Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position * of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is * at the halfway point, and 1 is at the end (complete). If the animation has a non-zero repeat defined (only available in TweenMax and TimelineMax), * progress() and totalProgress() will be different because progress() * doesn't include the repeat or repeatDelay whereas totalProgress() does. For example, * if a TimelineMax instance is set to repeat once, at the end of the first cycle totalProgress() * would only be 0.5 whereas progress would be 1. If you watched both properties over the * course of the entire animation, you'd see progress go from 0 to 1 twice (once for * each cycle) in the same time it takes the totalProgress() to go from 0 to 1 once. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.totalProgress(0.5).play();

* * var progress = myAnimation.totalProgress(); //gets total progress myAnimation.totalProgress(0.25); //sets total progress to one quarter finished * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #progress() * @see #seek() * @see #time() * @see #totalTime() **/ public function totalProgress(value:Number=NaN, suppressEvents:Boolean=false):* { return (!arguments.length) ? _time / duration() : totalTime(duration() * value, suppressEvents); } /** * Gets or sets the time at which the animation begins on its parent timeline (after any delay * that was defined). For example, if a tween starts at exactly 3 seconds into the timeline * on which it is placed, the tween's startTime would be 3. * *

The startTime may be automatically adjusted to make the timing appear * seamless if the parent timeline's smoothChildTiming property is true * and a timing-dependent change is made on-the-fly, like reverse() is called or * timeScale() is changed, etc. See the documentation for the smoothChildTiming * property of timelines for more details.

* *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* * var start = myAnimation.startTime(); //gets current start time myAnimation.startTime(2); //sets the start time * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. **/ public function startTime(value:Number=NaN):* { if (!arguments.length) { return _startTime; } if (value != _startTime) { _startTime = value; if (timeline) if (timeline._sortChildren) { timeline.add(this, value - _delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct. } } return this; } /** * Factor that's used to scale time in the animation where 1 = normal speed (the default), * 0.5 = half speed, 2 = double speed, etc. For example, if an animation's duration * is 2 but its timeScale is 0.5, it will take 4 seconds to finish. If you nest that * animation in a timeline whose timeScale is 0.5 as well, it would take 8 seconds * to finish. You can even tween the timeScale to gradually slow it down or speed it up. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.timeScale(2).play(1);

* * var currentTimeScale = myAnimation.timeScale(); //gets current timeScale myAnimation.timeScale( 0.5 ); //sets timeScale to half-speed * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #duration() **/ public function timeScale(value:Number=NaN):* { if (!arguments.length) { return _timeScale; } value = value || 0.000001; //can't allow zero because it'll throw the math off if (_timeline && _timeline.smoothChildTiming) { var t:Number = (_pauseTime || _pauseTime == 0) ? _pauseTime : _timeline._totalTime; _startTime = t - ((t - _startTime) * _timeScale / value); } _timeScale = value; return _uncache(false); } /** * Gets or sets the animation's reversed state which indicates whether or not the animation * should be played backwards. This value is not affected by yoyo repeats * (TweenMax and TimelineMax only) and it does not take into account the reversed state of * anscestor timelines. So for example, a tween that is not reversed might appear reversed * if its parent timeline (or any ancenstor timeline) is reversed. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* * var rev = myAnimation.reversed(); //gets current orientation myAnimation.reversed( true ); //sets the orientation to reversed myAnimation.reversed( !myAnimation.reversed() ); //toggles the orientation * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #reverse() * @see #play() **/ public function reversed(value:Boolean=false):* { if (!arguments.length) { return _reversed; } if (value != _reversed) { _reversed = value; totalTime(((_timeline && !_timeline.smoothChildTiming) ? totalDuration() - _totalTime : _totalTime), true); } return this; } /** * Gets or sets the animation's paused state which indicates whether or not the animation * is currently paused. This does not take into account anscestor timelines. So for example, * a tween that is not paused might appear paused if its parent timeline (or any ancenstor * timeline) is paused. Pausing an animation doesn't remove it from its parent timeline, * but it does cause it not to be factored into the parent timeline's * duration/totalDuration. When an animation completes, it does * NOT alter its paused state. * *

In most cases, it is easiest to use the pause() method to pause * the animation, and resume() to resume it. But to check the current * state, you must use the paused() method. It can also be useful for * toggling like myAnimation.paused( !myAnimation.paused() );

* *

You can set the paused state initially by passing paused:true * in the vars parameter.

* *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.paused(true).delay(2).timeScale(0.5);

* * var paused = myAnimation.paused(); //gets current paused state myAnimation.paused( true ); //sets paused state to true (just like pause()) myAnimation.paused( !myAnimation.paused() ); //toggles the paused state * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #pause() * @see #resume() * @see #play() **/ public function paused(value:Boolean=false):* { if (!arguments.length) { return _paused; } if (value != _paused) if (_timeline) { var raw:Number = _timeline.rawTime(), elapsed:Number = raw - _pauseTime; if (!value && _timeline.smoothChildTiming) { _startTime += elapsed; _uncache(false); } _pauseTime = value ? raw : NaN; _paused = value; _active = (!value && _totalTime > 0 && _totalTime < _totalDuration); if (!value && elapsed != 0 && _initted && duration() !== 0) { render((_timeline.smoothChildTiming ? _totalTime : (raw - _startTime) / _timeScale), true, true); //in case the target's properties changed via some other tween or manual update by the user, we should force a render. } } if (_gc && !value) { _enabled(true, false); } return this; } } }",16216,True,3311.8321291959533,median "CLASS zcl_abapgit_gui_page_diff DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page CREATE PUBLIC. PUBLIC SECTION. TYPES: BEGIN OF ty_file_diff, path TYPE string, filename TYPE string, obj_type TYPE string, obj_name TYPE string, lstate TYPE char1, rstate TYPE char1, fstate TYPE char1, "" FILE state - Abstraction for shorter ifs o_diff TYPE REF TO zcl_abapgit_diff, changed_by TYPE xubname, type TYPE string, END OF ty_file_diff. TYPES: tt_file_diff TYPE STANDARD TABLE OF ty_file_diff WITH NON-UNIQUE DEFAULT KEY WITH NON-UNIQUE SORTED KEY secondary COMPONENTS path filename. CONSTANTS: BEGIN OF c_fstate, local TYPE char1 VALUE 'L', remote TYPE char1 VALUE 'R', both TYPE char1 VALUE 'B', END OF c_fstate. METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception. METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION. PROTECTED SECTION. DATA mv_unified TYPE abap_bool VALUE abap_true ##NO_TEXT. DATA mo_repo TYPE REF TO zcl_abapgit_repo. DATA mt_diff_files TYPE tt_file_diff . METHODS: get_normalized_fname_with_path IMPORTING is_diff TYPE ty_file_diff RETURNING VALUE(rv_filename) TYPE string, normalize_path IMPORTING iv_path TYPE string RETURNING VALUE(rv_normalized) TYPE string, normalize_filename IMPORTING iv_filename TYPE string RETURNING VALUE(rv_normalized) TYPE string, render_content REDEFINITION, add_menu_end IMPORTING io_menu TYPE REF TO zcl_abapgit_html_toolbar , calculate_diff IMPORTING is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception, add_menu_begin IMPORTING io_menu TYPE REF TO zcl_abapgit_html_toolbar, render_table_head_non_unified IMPORTING io_html TYPE REF TO zcl_abapgit_html is_diff TYPE ty_file_diff, render_beacon_begin_of_row IMPORTING io_html TYPE REF TO zcl_abapgit_html is_diff TYPE ty_file_diff, render_diff_head_after_state IMPORTING io_html TYPE REF TO zcl_abapgit_html is_diff TYPE ty_file_diff, insert_nav RETURNING VALUE(rv_insert_nav) TYPE abap_bool, render_line_split_row IMPORTING io_html TYPE REF TO zcl_abapgit_html iv_filename TYPE string is_diff_line TYPE zif_abapgit_definitions=>ty_diff iv_index TYPE sy-tabix iv_fstate TYPE char1 iv_new TYPE string iv_old TYPE string RAISING zcx_abapgit_exception, build_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar. PRIVATE SECTION. CONSTANTS: BEGIN OF c_actions, toggle_unified TYPE string VALUE 'toggle_unified', END OF c_actions . DATA mt_delayed_lines TYPE zif_abapgit_definitions=>ty_diffs_tt . DATA mv_repo_key TYPE zif_abapgit_persistence=>ty_repo-key . DATA mv_seed TYPE string . "" Unique page id to bind JS sessionStorage METHODS render_diff IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception . METHODS render_diff_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS render_table_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS render_beacon IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS render_line_split IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_filename TYPE string !iv_fstate TYPE char1 !iv_index TYPE sy-tabix RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception . METHODS render_line_unified IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff OPTIONAL RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS append_diff IMPORTING !it_remote TYPE zif_abapgit_definitions=>ty_files_tt !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !is_status TYPE zif_abapgit_definitions=>ty_result RAISING zcx_abapgit_exception . METHODS is_binary IMPORTING !iv_d1 TYPE xstring !iv_d2 TYPE xstring RETURNING VALUE(rv_yes) TYPE abap_bool . METHODS add_jump_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS add_filter_sub_menu IMPORTING io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_lines IMPORTING is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception. METHODS render_table_head_unified IMPORTING io_html TYPE REF TO zcl_abapgit_html. METHODS render_scripts RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception. METHODS filter_diff_by_files IMPORTING it_files TYPE zif_abapgit_definitions=>ty_stage_tt CHANGING ct_diff_files TYPE tt_file_diff. ENDCLASS. CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION. METHOD add_filter_sub_menu. DATA: lo_sub_filter TYPE REF TO zcl_abapgit_html_toolbar, lt_types TYPE string_table, lt_users TYPE string_table. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files, TYPE string. "" Get unique LOOP AT mt_diff_files ASSIGNING . APPEND -type TO lt_types. APPEND -changed_by TO lt_users. ENDLOOP. SORT lt_types. DELETE ADJACENT DUPLICATES FROM lt_types. SORT lt_users. DELETE ADJACENT DUPLICATES FROM lt_users. IF lines( lt_types ) > 1 OR lines( lt_users ) > 1. CREATE OBJECT lo_sub_filter EXPORTING iv_id = 'diff-filter'. "" File types IF lines( lt_types ) > 1. lo_sub_filter->add( iv_txt = 'TYPE' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_types ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'type' iv_chk = abap_true ). ENDLOOP. ENDIF. "" Changed by IF lines( lt_users ) > 1. lo_sub_filter->add( iv_txt = 'CHANGED BY' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_users ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'changed-by' iv_chk = abap_true ). ENDLOOP. ENDIF. io_menu->add( iv_txt = 'Filter' io_sub = lo_sub_filter ) ##NO_TEXT. ENDIF. ENDMETHOD. METHOD add_jump_sub_menu. DATA: lo_sub_jump TYPE REF TO zcl_abapgit_html_toolbar, lv_jump_target TYPE string. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files. CREATE OBJECT lo_sub_jump EXPORTING iv_id = 'jump'. LOOP AT mt_diff_files ASSIGNING . lv_jump_target = -path && -filename. lo_sub_jump->add( iv_id = |li_jump_{ sy-tabix }| iv_txt = lv_jump_target iv_typ = zif_abapgit_html=>c_action_type-onclick ). ENDLOOP. io_menu->add( iv_txt = 'Jump' io_sub = lo_sub_jump ) ##NO_TEXT. ENDMETHOD. METHOD add_menu_begin. ENDMETHOD. METHOD add_menu_end. io_menu->add( iv_txt = 'Split/Unified view' iv_act = c_actions-toggle_unified ) ##NO_TEXT. ENDMETHOD. METHOD append_diff. DATA: lv_offs TYPE i, ls_r_dummy LIKE LINE OF it_remote ##NEEDED, ls_l_dummy LIKE LINE OF it_local ##NEEDED. FIELD-SYMBOLS: LIKE LINE OF it_remote, LIKE LINE OF it_local, LIKE LINE OF mt_diff_files. READ TABLE it_remote ASSIGNING WITH KEY filename = is_status-filename path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_r_dummy TO . ENDIF. READ TABLE it_local ASSIGNING WITH KEY file-filename = is_status-filename file-path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_l_dummy TO . ENDIF. IF IS INITIAL AND IS INITIAL. zcx_abapgit_exception=>raise( |DIFF: file not found { is_status-filename }| ). ENDIF. APPEND INITIAL LINE TO mt_diff_files ASSIGNING . -path = is_status-path. -filename = is_status-filename. -obj_type = is_status-obj_type. -obj_name = is_status-obj_name. -lstate = is_status-lstate. -rstate = is_status-rstate. IF -lstate IS NOT INITIAL AND -rstate IS NOT INITIAL. -fstate = c_fstate-both. ELSEIF -lstate IS NOT INITIAL. -fstate = c_fstate-local. ELSE. ""rstate IS NOT INITIAL, lstate = empty. -fstate = c_fstate-remote. ENDIF. "" Changed by IF -item-obj_type IS NOT INITIAL. -changed_by = to_lower( zcl_abapgit_objects=>changed_by( -item ) ). ENDIF. IF -changed_by IS INITIAL. -changed_by = to_lower( zcl_abapgit_objects_super=>c_user_unknown ). ENDIF. "" Extension IF -file-filename IS NOT INITIAL. -type = reverse( -file-filename ). ELSE. -type = reverse( -filename ). ENDIF. FIND FIRST OCCURRENCE OF '.' IN -type MATCH OFFSET lv_offs. -type = reverse( substring( val = -type len = lv_offs ) ). IF -type <> 'xml' AND -type <> 'abap'. -type = 'other'. ENDIF. IF -type = 'other' AND is_binary( iv_d1 = -data iv_d2 = -file-data ) = abap_true. -type = 'binary'. ENDIF. "" Diff data IF -type <> 'binary'. IF -fstate = c_fstate-remote. "" Remote file leading changes CREATE OBJECT -o_diff EXPORTING iv_new = -data iv_old = -file-data. ELSE. "" Local leading changes or both were modified CREATE OBJECT -o_diff EXPORTING iv_new = -file-data iv_old = -data. ENDIF. ENDIF. ENDMETHOD. METHOD build_menu. CREATE OBJECT ro_menu. add_menu_begin( ro_menu ). add_jump_sub_menu( ro_menu ). add_filter_sub_menu( ro_menu ). add_menu_end( ro_menu ). ENDMETHOD. METHOD calculate_diff. DATA: lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_status TYPE zif_abapgit_definitions=>ty_results_tt. FIELD-SYMBOLS: LIKE LINE OF lt_status. CLEAR: mt_diff_files. lt_remote = mo_repo->get_files_remote( ). lt_local = mo_repo->get_files_local( ). mo_repo->reset_status( ). lt_status = mo_repo->status( ). IF is_file IS NOT INITIAL. "" Diff for one file READ TABLE lt_status ASSIGNING WITH KEY path = is_file-path filename = is_file-filename. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ELSEIF is_object IS NOT INITIAL. "" Diff for whole object LOOP AT lt_status ASSIGNING WHERE obj_type = is_object-obj_type AND obj_name = is_object-obj_name AND match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ELSE. "" Diff for the whole repo SORT lt_status BY path ASCENDING filename ASCENDING. LOOP AT lt_status ASSIGNING WHERE match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ENDIF. filter_diff_by_files( EXPORTING it_files = it_files CHANGING ct_diff_files = mt_diff_files ). ENDMETHOD. METHOD constructor. DATA: lv_ts TYPE timestamp. super->constructor( ). ms_control-page_title = 'DIFF'. mv_unified = zcl_abapgit_persistence_user=>get_instance( )->get_diff_unified( ). mv_repo_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). GET TIME STAMP FIELD lv_ts. mv_seed = |diff{ lv_ts }|. "" Generate based on time ASSERT is_file IS INITIAL OR is_object IS INITIAL. "" just one passed calculate_diff( is_file = is_file is_object = is_object it_files = it_files ). IF lines( mt_diff_files ) = 0. zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ). ENDIF. ms_control-page_menu = build_menu( ). ENDMETHOD. METHOD get_normalized_fname_with_path. rv_filename = normalize_path( is_diff-path ) && `_` && normalize_filename( is_diff-filename ). ENDMETHOD. METHOD insert_nav. ENDMETHOD. METHOD is_binary. FIELD-SYMBOLS LIKE iv_d1. IF iv_d1 IS NOT INITIAL. "" One of them might be new and so empty ASSIGN iv_d1 TO . ELSE. ASSIGN iv_d2 TO . ENDIF. rv_yes = zcl_abapgit_utils=>is_binary( ). ENDMETHOD. METHOD normalize_filename. rv_normalized = replace( val = iv_filename sub = '.' occ = 0 with = '_' ). ENDMETHOD. METHOD normalize_path. rv_normalized = replace( val = iv_path sub = '/' occ = 0 with = '_' ). ENDMETHOD. METHOD render_beacon. DATA: lv_beacon TYPE string, lt_beacons TYPE zif_abapgit_definitions=>ty_string_tt. CREATE OBJECT ro_html. IF is_diff_line-beacon > 0. lt_beacons = is_diff-o_diff->get_beacons( ). READ TABLE lt_beacons INTO lv_beacon INDEX is_diff_line-beacon. ELSE. lv_beacon = '---'. ENDIF. ro_html->add( '' ). ro_html->add( '' ). render_beacon_begin_of_row( io_html = ro_html is_diff = is_diff ). IF mv_unified = abap_true. ro_html->add( '' ). ro_html->add( '' ). ro_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ELSE. ro_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ENDIF. ro_html->add( '' ). ro_html->add( '' ). ENDMETHOD. METHOD render_beacon_begin_of_row. io_html->add( '' ). ENDMETHOD. METHOD render_content. DATA: ls_diff_file LIKE LINE OF mt_diff_files, li_progress TYPE REF TO zif_abapgit_progress. CREATE OBJECT ri_html TYPE zcl_abapgit_html. li_progress = zcl_abapgit_progress=>get_instance( lines( mt_diff_files ) ). ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_js_error_banner( ) ). LOOP AT mt_diff_files INTO ls_diff_file. li_progress->show( iv_current = sy-tabix iv_text = |Render Diff - { ls_diff_file-filename }| ). ri_html->add( render_diff( ls_diff_file ) ). ENDLOOP. IF sy-subrc <> 0. ri_html->add( |No more diffs| ). ENDIF. ri_html->add( '
' ). register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_diff. CREATE OBJECT ro_html. ro_html->add( |
| ). ""#EC NOTEXT ro_html->add( render_diff_head( is_diff ) ). "" Content IF is_diff-type <> 'binary'. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add( || ). ""#EC NOTEXT ro_html->add( render_table_head( is_diff ) ). ro_html->add( render_lines( is_diff ) ). ro_html->add( '
' ). ""#EC NOTEXT ELSE. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add( 'The content seems to be binary.' ). ""#EC NOTEXT ro_html->add( 'Cannot display as diff.' ). ""#EC NOTEXT ENDIF. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add( '
' ). ""#EC NOTEXT ENDMETHOD. METHOD render_diff_head. DATA: ls_stats TYPE zif_abapgit_definitions=>ty_count, lv_adt_link TYPE string. CREATE OBJECT ro_html. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add_icon( iv_name = 'chevron-down' iv_hint = 'Collapse/Expand' iv_class = 'cursor-pointer' iv_onclick = 'onDiffCollapse(event)' ). IF is_diff-type <> 'binary'. ls_stats = is_diff-o_diff->stats( ). IF is_diff-fstate = c_fstate-both. "" Merge stats into 'update' if both were changed ls_stats-update = ls_stats-update + ls_stats-insert + ls_stats-delete. CLEAR: ls_stats-insert, ls_stats-delete. ENDIF. ro_html->add( |+ { ls_stats-insert }| ). ro_html->add( |- { ls_stats-delete }| ). ro_html->add( |~ { ls_stats-update }| ). ENDIF. "" no links for nonexistent or deleted objects IF is_diff-lstate IS NOT INITIAL AND is_diff-lstate <> 'D'. lv_adt_link = zcl_abapgit_html=>a( iv_txt = |{ is_diff-path }{ is_diff-filename }| iv_typ = zif_abapgit_html=>c_action_type-sapevent iv_act = |jump?TYPE={ is_diff-obj_type }&NAME={ is_diff-obj_name }| ). ENDIF. IF lv_adt_link IS NOT INITIAL. ro_html->add( |{ lv_adt_link }| ). ""#EC NOTEXT ELSE. ro_html->add( |{ is_diff-path }{ is_diff-filename }| ). ""#EC NOTEXT ENDIF. ro_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_diff-lstate iv_rstate = is_diff-rstate ) ). render_diff_head_after_state( io_html = ro_html is_diff = is_diff ). ro_html->add( |last change by: { is_diff-changed_by }| ). ro_html->add( '
' ). ""#EC NOTEXT ENDMETHOD. METHOD render_diff_head_after_state. IF is_diff-fstate = c_fstate-both AND mv_unified = abap_true. io_html->add( 'Attention: Unified mode' && ' highlighting for MM assumes local file is newer ! ' ). ""#EC NOTEXT ENDIF. ENDMETHOD. METHOD render_lines. DATA: lo_highlighter TYPE REF TO zcl_abapgit_syntax_highlighter, lt_diffs TYPE zif_abapgit_definitions=>ty_diffs_tt, lv_insert_nav TYPE abap_bool, lv_tabix TYPE syst-tabix. FIELD-SYMBOLS LIKE LINE OF lt_diffs. lo_highlighter = zcl_abapgit_syntax_highlighter=>create( is_diff-filename ). CREATE OBJECT ro_html. lt_diffs = is_diff-o_diff->get( ). lv_insert_nav = insert_nav( ). LOOP AT lt_diffs ASSIGNING . lv_tabix = sy-tabix. IF -short = abap_false. lv_insert_nav = abap_true. CONTINUE. ENDIF. IF lv_insert_nav = abap_true. "" Insert separator line with navigation ro_html->add( render_beacon( is_diff_line = is_diff = is_diff ) ). lv_insert_nav = abap_false. ENDIF. IF lo_highlighter IS BOUND. -new = lo_highlighter->process_line( -new ). -old = lo_highlighter->process_line( -old ). ELSE. -new = escape( val = -new format = cl_abap_format=>e_html_attr ). -old = escape( val = -old format = cl_abap_format=>e_html_attr ). ENDIF. CONDENSE -new_num. ""get rid of leading spaces CONDENSE -old_num. IF mv_unified = abap_true. ro_html->add( render_line_unified( is_diff_line = ) ). ELSE. ro_html->add( render_line_split( is_diff_line = iv_filename = get_normalized_fname_with_path( is_diff ) iv_fstate = is_diff-fstate iv_index = lv_tabix ) ). ENDIF. ENDLOOP. IF mv_unified = abap_true. ro_html->add( render_line_unified( ) ). "" Release delayed lines ENDIF. ENDMETHOD. METHOD render_line_split. DATA: lv_new TYPE string, lv_old TYPE string, lv_mark TYPE string, lv_bg TYPE string. CREATE OBJECT ro_html. "" New line lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-insert. lv_bg = ' diff_ins'. lv_mark = `+`. ENDIF. ENDIF. lv_new = || && |{ lv_mark }| && |{ is_diff_line-new }|. "" Old line CLEAR lv_bg. lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-delete. lv_bg = ' diff_del'. lv_mark = `-`. ENDIF. ENDIF. lv_old = || && |{ lv_mark }| && |{ is_diff_line-old }|. "" render line, inverse sides if remote is newer ro_html->add( '' ). ""#EC NOTEXT render_line_split_row( io_html = ro_html iv_filename = iv_filename is_diff_line = is_diff_line iv_index = iv_index iv_fstate = iv_fstate iv_old = lv_old iv_new = lv_new ). ro_html->add( '' ). ""#EC NOTEXT ENDMETHOD. METHOD render_line_split_row. IF iv_fstate = c_fstate-remote. "" Remote file leading changes io_html->add( iv_old ). "" local io_html->add( iv_new ). "" remote ELSE. "" Local leading changes or both were modified io_html->add( iv_new ). "" local io_html->add( iv_old ). "" remote ENDIF. ENDMETHOD. METHOD render_line_unified. FIELD-SYMBOLS LIKE LINE OF mt_delayed_lines. CREATE OBJECT ro_html. "" Release delayed subsequent update lines IF is_diff_line-result <> zif_abapgit_definitions=>c_diff-update. LOOP AT mt_delayed_lines ASSIGNING . ro_html->add( '' ). ""#EC NOTEXT ro_html->add( |-old_num }"">| && || && |-| && |{ -old }| ). ro_html->add( '' ). ""#EC NOTEXT ENDLOOP. LOOP AT mt_delayed_lines ASSIGNING . ro_html->add( '' ). ""#EC NOTEXT ro_html->add( || && |-new_num }"">| && |+| && |{ -new }| ). ro_html->add( '' ). ""#EC NOTEXT ENDLOOP. CLEAR mt_delayed_lines. ENDIF. ro_html->add( '' ). ""#EC NOTEXT CASE is_diff_line-result. WHEN zif_abapgit_definitions=>c_diff-update. APPEND is_diff_line TO mt_delayed_lines. "" Delay output of subsequent updates WHEN zif_abapgit_definitions=>c_diff-insert. ro_html->add( || && || && |+| && |{ is_diff_line-new }| ). WHEN zif_abapgit_definitions=>c_diff-delete. ro_html->add( || && || && |-| && |{ is_diff_line-old }| ). WHEN OTHERS. ""none ro_html->add( || && || && | | && |{ is_diff_line-old }| ). ENDCASE. ro_html->add( '' ). ""#EC NOTEXT ENDMETHOD. METHOD render_scripts. CREATE OBJECT ro_html. ro_html->zif_abapgit_html~set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ro_html->add( 'restoreScrollPosition();' ). ro_html->add( 'var gHelper = new DiffHelper({' ). ro_html->add( | seed: ""{ mv_seed }"",| ). ro_html->add( ' ids: {' ). ro_html->add( ' jump: ""jump"",' ). ro_html->add( ' diffList: ""diff-list"",' ). ro_html->add( ' filterMenu: ""diff-filter"",' ). ro_html->add( ' }' ). ro_html->add( '});' ). ro_html->add( 'addMarginBottom();' ). ro_html->add( 'var gGoJumpPalette = new CommandPalette(enumerateJumpAllFiles, {' ). ro_html->add( ' toggleKey: ""F2"",' ). ro_html->add( ' hotkeyDescription: ""Jump to file ...""' ). ro_html->add( '});' ). "" Feature for selecting ABAP code by column and copy to clipboard ro_html->add( 'var columnSelection = new DiffColumnSelection();' ). ENDMETHOD. METHOD render_table_head. CREATE OBJECT ro_html. ro_html->add( '' ). ""#EC NOTEXT ro_html->add( '' ). ""#EC NOTEXT IF mv_unified = abap_true. render_table_head_unified( ro_html ). ELSE. render_table_head_non_unified( io_html = ro_html is_diff = is_diff ). ENDIF. ro_html->add( '' ). ""#EC NOTEXT ro_html->add( '' ). ""#EC NOTEXT ENDMETHOD. METHOD render_table_head_non_unified. io_html->add( '' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( 'LOCAL' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( 'REMOTE' ). ""#EC NOTEXT ENDMETHOD. METHOD render_table_head_unified. io_html->add( 'old' ). ""#EC NOTEXT io_html->add( 'new' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( 'code' ). ""#EC NOTEXT ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. CASE iv_action. WHEN c_actions-toggle_unified. "" Toggle file diplay mv_unified = zcl_abapgit_persistence_user=>get_instance( )->toggle_diff_unified( ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. super->zif_abapgit_gui_event_handler~on_event( EXPORTING iv_action = iv_action iv_getdata = iv_getdata it_postdata = it_postdata IMPORTING ei_page = ei_page ev_state = ev_state ). ENDCASE. ENDMETHOD. METHOD filter_diff_by_files. FIELD-SYMBOLS: TYPE ty_file_diff. IF lines( it_files ) = 0. RETURN. ENDIF. "" Diff only for specified files LOOP AT ct_diff_files ASSIGNING . READ TABLE it_files TRANSPORTING NO FIELDS WITH KEY file-filename = -filename. IF sy-subrc <> 0. DELETE TABLE ct_diff_files FROM . ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. ",8177,False,1553.8437885770131,median "/** * VERSION: 1.6 * DATE: 2010-10-02 * AS3 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/ **/ package com.greensock.loading { import com.greensock.events.LoaderEvent; import com.greensock.loading.core.DisplayObjectLoader; import com.greensock.loading.core.LoaderCore; import flash.display.AVM1Movie; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.MovieClip; import flash.events.Event; import flash.events.ProgressEvent; import flash.media.SoundTransform; import flash.utils.getQualifiedClassName; /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches an OPEN event. **/ [Event(name=""childOpen"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a PROGRESS event. **/ [Event(name=""childProgress"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a COMPLETE event. **/ [Event(name=""childComplete"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a FAIL event. **/ [Event(name=""childFail"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a CANCEL event. **/ [Event(name=""childCancel"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when the loader is denied script access to the swf which can happen if it is loaded from another domain and there's no crossdomain.xml file in place. **/ [Event(name=""scriptAccessDenied"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when the loader's httpStatus value changes. **/ [Event(name=""httpStatus"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when the loader experiences a SECURITY_ERROR while loading or auditing its size. **/ [Event(name=""securityError"", type=""com.greensock.events.LoaderEvent"")] /** * Loads a swf file and automatically searches for active loaders in that swf that have * the requireWithRoot vars property set to that swf's root. If it finds any, * it will factor those loaders' progress into its own progress and not dispatch its * COMPLETE event until the nested loaders have finished.

* * The SWFLoader's content refers to a ContentDisplay (a Sprite) that * is created immediately so that you can position/scale/rotate it or add ROLL_OVER/ROLL_OUT/CLICK listeners * before (or while) the swf loads. Use the SWFLoader's content property to get the ContentDisplay * Sprite, or use the rawContent property to get the actual root of the loaded swf file itself. * If a container is defined in the vars object, the ContentDisplay will * immediately be added to that container).

* * If you define a width and height, it will draw a rectangle * in the ContentDisplay so that interactive events fire appropriately (rollovers, etc.) and width/height/bounds * get reported accurately. This rectangle is invisible by default, but you can control its color and alpha * with the bgColor and bgAlpha properties. When the swf loads, it will be * added to the ContentDisplay at index 0 with addChildAt() and scaled to fit the width/height according to * the scaleMode. These are all optional features - you do not need to define a * width or height in which case the swf will load at its native size. * See the list below for all the special properties that can be passed through the vars * parameter but don't let the list overwhelm you - these are all optional and they are intended to make * your job as a developer much easier.

* * By default, the SWFLoader will attempt to load the swf in a way that allows full script * access (same SecurityDomain and child ApplicationDomain). However, if a security error is thrown because * the swf is being loaded from another domain and the appropriate crossdomain.xml file isn't in place * to grant access, the SWFLoader will automatically adjust the default LoaderContext so that it falls * back to the more restricted mode which will have the following effect: *
    *
  • A LoaderEvent.SCRIPT_ACCESS_DENIED event will be dispatched and the scriptAccessDenied property of the SWFLoader will be set to true. You can check this value before performing any restricted operations on the content like BitmapData.draw().
  • *
  • Other LoaderMax-related loaders inside the swf will not be recognized or integrated into the SWFLoader's overall progress.
  • *
  • A Loader instance will be added to the ContentDisplay Sprite instead of the swf's root.
  • *
  • The getClass() and getSWFChild() methods will always return null.
  • *
  • BitmapData operations like draw() will not be able to be performed on the swf.
  • *
* * If the loaded swf is an AVM1Movie (built in AS1 or AS2), scriptAccessDenied will be true * and a Loader instance will be added to the content Sprite instead of the swf's root.

* * To maximize the likelihood of your swf loading without any security problems, consider taking the following steps: *
    *
  • Use a crossdomain.xml file - See Adobe's docs for details, but here is an example that grants full access (put this in a crossdomain.xml file that is at the root of the remote domain):
    * <?xml version=""1.0"" encoding=""utf-8""?>
    * <cross-domain-policy>
    * <allow-access-from domain=""~~"" />
    * </cross-domain-policy>
  • *
  • In the embed code of any HTML wrapper, set AllowScriptAccess to ""always""
  • *
  • If possible, in the remote swf make sure you explicitly allow script access using something like flash.system.Security.allowDomain(""~~"");
  • *

* * OPTIONAL VARS PROPERTIES
* The following special properties can be passed into the SWFLoader constructor via its vars * parameter which can be either a generic object or an SWFLoaderVars object:
*
    *
  • name : String - A name that is used to identify the SWFLoader instance. This name can be fed to the LoaderMax.getLoader() or LoaderMax.getContent() methods. This name is also applied to the Sprite that is created to hold the swf (The SWFLoader's content refers to this Sprite). Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like ""loader21"".
  • *
  • container : DisplayObjectContainer - A DisplayObjectContainer into which the content Sprite should be added immediately.
  • *
  • width : Number - Sets the ContentDisplay's width property (applied before rotation, scaleX, and scaleY).
  • *
  • height : Number - Sets the ContentDisplay's height property (applied before rotation, scaleX, and scaleY).
  • *
  • centerRegistration : Boolean - if true, the registration point will be placed in the center of the ContentDisplay Sprite which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center.
  • *
  • scaleMode : String - When a width and height are defined, the scaleMode controls how the loaded swf will be scaled to fit the area. The following values are recognized (you may use the com.greensock.layout.ScaleMode constants if you prefer): *
      *
    • ""stretch"" (the default) - The swf will fill the width/height exactly.
    • *
    • ""proportionalInside"" - The swf will be scaled proportionally to fit inside the area defined by the width/height
    • *
    • ""proportionalOutside"" - The swf will be scaled proportionally to completely fill the area, allowing portions of it to exceed the bounds defined by the width/height.
    • *
    • ""widthOnly"" - Only the width of the swf will be adjusted to fit.
    • *
    • ""heightOnly"" - Only the height of the swf will be adjusted to fit.
    • *
    • ""none"" - No scaling of the swf will occur.
    • *
  • *
  • hAlign : String - When a width and height are defined, the hAlign determines how the swf is horizontally aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered horizontally in the area
    • *
    • ""left"" - The swf will be aligned with the left side of the area
    • *
    • ""right"" - The swf will be aligned with the right side of the area
    • *
  • *
  • vAlign : String - When a width and height are defined, the vAlign determines how the swf is vertically aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered vertically in the area
    • *
    • ""top"" - The swf will be aligned with the top of the area
    • *
    • ""bottom"" - The swf will be aligned with the bottom of the area
    • *
  • *
  • crop : Boolean - When a width and height are defined, setting crop to true will cause the swf to be cropped within that area (by applying a scrollRect for maximum performance) based on its native size (not the bounding box of the swf's current contents). This is typically useful when the scaleMode is ""proportionalOutside"" or ""none"" or when the swf contains objects that are positioned off-stage. Any parts of the swf that exceed the dimensions defined by width and height are visually chopped off. Use the hAlign and vAlign special properties to control the vertical and horizontal alignment within the cropped area.
  • *
  • x : Number - Sets the ContentDisplay's x property (for positioning on the stage).
  • *
  • y : Number - Sets the ContentDisplay's y property (for positioning on the stage).
  • *
  • scaleX : Number - Sets the ContentDisplay's scaleX property.
  • *
  • scaleY : Number - Sets the ContentDisplay's scaleY property.
  • *
  • rotation : Number - Sets the ContentDisplay's rotation property.
  • *
  • alpha : Number - Sets the ContentDisplay's alpha property.
  • *
  • visible : Boolean - Sets the ContentDisplay's visible property.
  • *
  • blendMode : String - Sets the ContentDisplay's blendMode property.
  • *
  • autoPlay : Boolean - If autoPlay is true (the default), the swf will begin playing immediately when the INIT event fires. To prevent this behavior, set autoPlay to false which will also mute the swf until the SWFLoader completes.
  • *
  • bgColor : uint - When a width and height are defined, a rectangle will be drawn inside the ContentDisplay Sprite immediately in order to ease the development process. It is transparent by default, but you may define a bgAlpha if you prefer.
  • *
  • bgAlpha : Number - Controls the alpha of the rectangle that is drawn when a width and height are defined.
  • *
  • context : LoaderContext - To control things like the ApplicationDomain, SecurityDomain, and whether or not a policy file is checked, define a LoaderContext object. The default context is null when running locally and new LoaderContext(true, new ApplicationDomain(ApplicationDomain.currentDomain), SecurityDomain.currentDomain) when running remotely in order to avoid common security sandbox errors (see Adobe's LoaderContext documentation for details and precautions). Please make sure that if you load swfs from another domain that you have a crossdomain.xml file installed on that remote server that grants your swf access rights (see Adobe's docs for crossdomain.xml details). Again, if you want to impose security restrictions on the loaded swf, please define your own LoaderContext.
  • *
  • integrateProgress : Boolean - By default, a SWFLoader instance will automatically look for LoaderMax loaders in the swf when it initializes. Every loader found with a requireWithRoot parameter set to that swf's root will be integrated into the SWFLoader's overall progress. The SWFLoader's COMPLETE event won't fire until all such loaders are also complete. If you prefer NOT to integrate the subloading loaders into the SWFLoader's overall progress, set integrateProgress to false.
  • *
  • alternateURL : String - If you define an alternateURL, the loader will initially try to load from its original url and if it fails, it will automatically (and permanently) change the loader's url to the alternateURL and try again. Think of it as a fallback or backup url. It is perfectly acceptable to use the same alternateURL for multiple loaders (maybe a default image for various ImageLoaders for example).
  • *
  • noCache : Boolean - If noCache is true, a ""cacheBusterID"" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you getLoader() or getContent() by url and when you're running locally)
  • *
  • estimatedBytes : uint - Initially, the loader's bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the swf initializes and has been analyzed enough to determine the size of any nested loaders that were found inside the swf with their requireWithRoot set to that swf's root, it will adjust the bytesTotal accordingly. Setting estimatedBytes is optional, but it provides a way to avoid situations where the progress and bytesTotal values jump around as SWFLoader recognizes nested loaders in the swf and audits their size. The estimatedBytes value should include all nested loaders as well, so if your swf file itself is 2000 bytes and it has 3 nested ImageLoaders, each loading a 2000-byte image, your SWFLoader's estimatedBytes should be 8000. The more accurate the value, the more accurate the loaders' overall progress will be.
  • *
  • requireWithRoot : DisplayObject - LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this SWFLoader as part of its parent SWFLoader's progress, you must set the requireWithRoot property to your swf's root. For example, var loader:SWFLoader = new SWFLoader(""subload.swf"", {name:""subloadSWF"", requireWithRoot:this.root});
  • *
  • autoDispose : Boolean - When autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with LoaderMax.getLoader() or LoaderMax.getContent() - it is essentially destroyed but its content is not unloaded (you must call unload() or dispose(true) to unload its content). The default autoDispose value is false. * *

    ----EVENT HANDLER SHORTCUTS----
  • *
  • onOpen : Function - A handler function for LoaderEvent.OPEN events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onInit : Function - A handler function for LoaderEvent.INIT events which are called when the swf has streamed enough of its content to render the first frame and determine if there are any required LoaderMax-related loaders recognized. It also adds the swf to the ContentDisplay Sprite at this point. Make sure your onInit function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onProgress : Function - A handler function for LoaderEvent.PROGRESS events which are dispatched whenever the bytesLoaded changes. Make sure your onProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can use the LoaderEvent's target.progress to get the loader's progress value or use its target.bytesLoaded and target.bytesTotal.
  • *
  • onComplete : Function - A handler function for LoaderEvent.COMPLETE events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onCancel : Function - A handler function for LoaderEvent.CANCEL events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or cancel() was manually called. Make sure your onCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onError : Function - A handler function for LoaderEvent.ERROR events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the onFail special property. Make sure your onError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onFail : Function - A handler function for LoaderEvent.FAIL events which are dispatched whenever the loader fails and its status changes to LoaderStatus.FAILED. Make sure your onFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onIOError : Function - A handler function for LoaderEvent.IO_ERROR events which will also call the onError handler, so you can use that as more of a catch-all whereas onIOError is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onHTTPStatus : Function - A handler function for LoaderEvent.HTTP_STATUS events. Make sure your onHTTPStatus function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can determine the httpStatus code using the LoaderEvent's target.httpStatus (LoaderItems keep track of their httpStatus when possible, although certain environments prevent Flash from getting httpStatus information).
  • *
  • onSecurityError : Function - A handler function for LoaderEvent.SECURITY_ERROR events which onError handles as well, so you can use that as more of a catch-all whereas onSecurityError is specifically for SECURITY_ERROR events. Make sure your onSecurityError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onScriptAccessDenied : Function - A handler function for LoaderMax.SCRIPT_ACCESS_DENIED events which occur when the swf is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like BitmapData manipulation or integration of LoaderMax data inside the swf, etc. You can also check the scriptAccessDenied property after the swf has loaded. Make sure your function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildOpen : Function - A handler function for LoaderEvent.CHILD_OPEN events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) begins loading. Make sure your onChildOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildProgress : Function - A handler function for LoaderEvent.CHILD_PROGRESS events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) dispatches a PROGRESS event. To listen for changes in the SWFLoader's overall progress, use the onProgress special property instead. You can use the LoaderEvent's target.progress to get the child loader's progress value or use its target.bytesLoaded and target.bytesTotal. The LoaderEvent's currentTarget refers to the SWFLoader, so you can check its overall progress with the LoaderEvent's currentTarget.progress. Make sure your onChildProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildComplete : Function - A handler function for LoaderEvent.CHILD_COMPLETE events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildCancel : Function - A handler function for LoaderEvent.CHILD_CANCEL events which are dispatched each time loading is aborted on any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) due to either an error or because another loader was prioritized in the queue or because cancel() was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildFail : Function - A handler function for LoaderEvent.CHILD_FAIL events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) fails (and its status chances to LoaderStatus.FAILED). Make sure your onChildFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *

* * Note: Using a SWFLoaderVars instance * instead of a generic object to define your vars is a bit more verbose but provides * code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.

* * content data type: com.greensock.loading.display.ContentDisplay (a Sprite). * When the swf has finished loading, the rawContent will be added to the ContentDisplay * Sprite at index 0 using addChildAt(). rawContent refers to the loaded swf's root * unless unless script access is denied in which case it will be a flash.display.Loader (to avoid security errors).

* * @example Example AS3 code: import com.greensock.~~; import com.greensock.loading.~~; // create a SWFLoader that will add the content to the display list at position x:50, y:100 when it has loaded: var loader:SWFLoader = new SWFLoader(""swf/main.swf"", {name:""mainSWF"", container:this, x:50, y:100, onInit:initHandler, estimatedBytes:9500}); // begin loading loader.load(); function initHandler(event:LoaderEvent):void { // fade the swf in as soon as it inits TweenLite.from(event.target.content, 1, {alpha:0}); // get a MovieClip named ""phoneAnimation_mc"" that's on the root of the subloaded swf var mc:DisplayObject = loader.getSWFChild(""phoneAnimation_mc""); // find the ""com.greensock.TweenLite"" class that's inside the subloaded swf var tweenClass:Class = loader.getClass(""com.greensock.TweenLite""); } // Or you could put the SWFLoader into a LoaderMax. Create one first... var queue:LoaderMax = new LoaderMax({name:""mainQueue"", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); // append the SWFLoader and several other loaders queue.append( loader ); queue.append( new XMLLoader(""xml/doc.xml"", {name:""xmlDoc"", estimatedBytes:425}) ); queue.append( new ImageLoader(""img/photo1.jpg"", {name:""photo1"", estimatedBytes:3500}) ); // start loading queue.load(); function progressHandler(event:LoaderEvent):void { trace(""progress: "" + event.target.progress); } function completeHandler(event:LoaderEvent):void { trace(event.target + "" is complete!""); } function errorHandler(event:LoaderEvent):void { trace(""error occured with "" + event.target + "": "" + event.text); } * * Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. * * @see com.greensock.loading.data.SWFLoaderVars * * @author Jack Doyle, jack@greensock.com */ public class SWFLoader extends DisplayObjectLoader { /** @private **/ private static var _classActivated : Boolean = _activateClass(""SWFLoader"", SWFLoader, ""swf""); /** @private **/ protected var _queue : LoaderMax; /** @private When the INIT event is dispatched, we'll check to see if there's a runtime shared library like for TLF and we must do some backflips to accommodate it - _hasRSL will be toggled to true if we find one. **/ protected var _hasRSL : Boolean; /** @private **/ protected var _rslAddedCount : uint; /** @private In certain browsers, there's a bug in the Flash Player that incorrectly reports the Loader's bytesLoaded as never reaching bytesTotal even AFTER the Loader completes (only when gzip is enabled on the server). This helps us get around that bug. **/ protected var _loaderCompleted : Boolean; /** * Constructor * * @param urlOrRequest The url (String) or URLRequest from which the loader should get its content * @param vars An object containing optional configuration details. For example: new SWFLoader(""swf/main.swf"", {name:""main"", container:this, x:100, y:50, alpha:0, autoPlay:false, onComplete:completeHandler, onProgress:progressHandler}).

* * The following special properties can be passed into the constructor via the vars parameter * which can be either a generic object or an SWFLoaderVars object:
*
    *
  • name : String - A name that is used to identify the SWFLoader instance. This name can be fed to the LoaderMax.getLoader() or LoaderMax.getContent() methods. This name is also applied to the Sprite that is created to hold the swf (The SWFLoader's content refers to this Sprite). Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like ""loader21"".
  • *
  • container : DisplayObjectContainer - A DisplayObjectContainer into which the content Sprite should be added immediately.
  • *
  • width : Number - Sets the ContentDisplay's width property (applied before rotation, scaleX, and scaleY).
  • *
  • height : Number - Sets the ContentDisplay's height property (applied before rotation, scaleX, and scaleY).
  • *
  • centerRegistration : Boolean - if true, the registration point will be placed in the center of the ContentDisplay Sprite which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center.
  • *
  • scaleMode : String - When a width and height are defined, the scaleMode controls how the loaded swf will be scaled to fit the area. The following values are recognized (you may use the com.greensock.layout.ScaleMode constants if you prefer): *
      *
    • ""stretch"" (the default) - The swf will fill the width/height exactly.
    • *
    • ""proportionalInside"" - The swf will be scaled proportionally to fit inside the area defined by the width/height
    • *
    • ""proportionalOutside"" - The swf will be scaled proportionally to completely fill the area, allowing portions of it to exceed the bounds defined by the width/height.
    • *
    • ""widthOnly"" - Only the width of the swf will be adjusted to fit.
    • *
    • ""heightOnly"" - Only the height of the swf will be adjusted to fit.
    • *
    • ""none"" - No scaling of the swf will occur.
    • *
  • *
  • hAlign : String - When a width and height are defined, the hAlign determines how the swf is horizontally aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered horizontally in the area
    • *
    • ""left"" - The swf will be aligned with the left side of the area
    • *
    • ""right"" - The swf will be aligned with the right side of the area
    • *
  • *
  • vAlign : String - When a width and height are defined, the vAlign determines how the swf is vertically aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered vertically in the area
    • *
    • ""top"" - The swf will be aligned with the top of the area
    • *
    • ""bottom"" - The swf will be aligned with the bottom of the area
    • *
  • *
  • crop : Boolean - When a width and height are defined, setting crop to true will cause the swf to be cropped within that area (by applying a scrollRect for maximum performance) based on its native size (not the bounding box of the swf's current contents). This is typically useful when the scaleMode is ""proportionalOutside"" or ""none"" or when the swf contains objects that are positioned off-stage. Any parts of the swf that exceed the dimensions defined by width and height are visually chopped off. Use the hAlign and vAlign special properties to control the vertical and horizontal alignment within the cropped area.
  • *
  • x : Number - Sets the ContentDisplay's x property (for positioning on the stage).
  • *
  • y : Number - Sets the ContentDisplay's y property (for positioning on the stage).
  • *
  • scaleX : Number - Sets the ContentDisplay's scaleX property.
  • *
  • scaleY : Number - Sets the ContentDisplay's scaleY property.
  • *
  • rotation : Number - Sets the ContentDisplay's rotation property.
  • *
  • alpha : Number - Sets the ContentDisplay's alpha property.
  • *
  • visible : Boolean - Sets the ContentDisplay's visible property.
  • *
  • blendMode : String - Sets the ContentDisplay's blendMode property.
  • *
  • autoPlay : Boolean - If autoPlay is true (the default), the swf will begin playing immediately when the INIT event fires. To prevent this behavior, set autoPlay to false which will also mute the swf until the SWFLoader completes.
  • *
  • bgColor : uint - When a width and height are defined, a rectangle will be drawn inside the ContentDisplay Sprite immediately in order to ease the development process. It is transparent by default, but you may define a bgAlpha if you prefer.
  • *
  • bgAlpha : Number - Controls the alpha of the rectangle that is drawn when a width and height are defined.
  • *
  • context : LoaderContext - To control things like the ApplicationDomain, SecurityDomain, and whether or not a policy file is checked, define a LoaderContext object. The default context is null when running locally and new LoaderContext(true, new ApplicationDomain(ApplicationDomain.currentDomain), SecurityDomain.currentDomain) when running remotely in order to avoid common security sandbox errors (see Adobe's LoaderContext documentation for details and precautions). Please make sure that if you load swfs from another domain that you have a crossdomain.xml file installed on that remote server that grants your swf access rights (see Adobe's docs for crossdomain.xml details). Again, if you want to impose security restrictions on the loaded swf, please define your own LoaderContext.
  • *
  • integrateProgress : Boolean - By default, a SWFLoader instance will automatically look for LoaderMax loaders in the swf when it initializes. Every loader found with a requireWithRoot parameter set to that swf's root will be integrated into the SWFLoader's overall progress. The SWFLoader's COMPLETE event won't fire until all such loaders are also complete. If you prefer NOT to integrate the subloading loaders into the SWFLoader's overall progress, set integrateProgress to false.
  • *
  • alternateURL : String - If you define an alternateURL, the loader will initially try to load from its original url and if it fails, it will automatically (and permanently) change the loader's url to the alternateURL and try again. Think of it as a fallback or backup url. It is perfectly acceptable to use the same alternateURL for multiple loaders (maybe a default image for various ImageLoaders for example).
  • *
  • noCache : Boolean - If noCache is true, a ""cacheBusterID"" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you getLoader() or getContent() by url and when you're running locally)
  • *
  • estimatedBytes : uint - Initially, the loader's bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the swf initializes and has been analyzed enough to determine the size of any nested loaders that were found inside the swf with their requireWithRoot set to that swf's root, it will adjust the bytesTotal accordingly. Setting estimatedBytes is optional, but it provides a way to avoid situations where the progress and bytesTotal values jump around as SWFLoader recognizes nested loaders in the swf and audits their size. The estimatedBytes value should include all nested loaders as well, so if your swf file itself is 2000 bytes and it has 3 nested ImageLoaders, each loading a 2000-byte image, your SWFLoader's estimatedBytes should be 8000. The more accurate the value, the more accurate the loaders' overall progress will be.
  • *
  • requireWithRoot : DisplayObject - LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this SWFLoader as part of its parent SWFLoader's progress, you must set the requireWithRoot property to your swf's root. For example, var loader:SWFLoader = new SWFLoader(""subload.swf"", {name:""subloadSWF"", requireWithRoot:this.root});
  • *
  • autoDispose : Boolean - When autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with LoaderMax.getLoader() or LoaderMax.getContent() - it is essentially destroyed but its content is not unloaded (you must call unload() or dispose(true) to unload its content). The default autoDispose value is false. * *

    ----EVENT HANDLER SHORTCUTS----
  • *
  • onOpen : Function - A handler function for LoaderEvent.OPEN events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onInit : Function - A handler function for LoaderEvent.INIT events which are called when the swf has streamed enough of its content to render the first frame and determine if there are any required LoaderMax-related loaders recognized. It also adds the swf to the ContentDisplay Sprite at this point. Make sure your onInit function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onProgress : Function - A handler function for LoaderEvent.PROGRESS events which are dispatched whenever the bytesLoaded changes. Make sure your onProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can use the LoaderEvent's target.progress to get the loader's progress value or use its target.bytesLoaded and target.bytesTotal.
  • *
  • onComplete : Function - A handler function for LoaderEvent.COMPLETE events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onCancel : Function - A handler function for LoaderEvent.CANCEL events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or cancel() was manually called. Make sure your onCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onError : Function - A handler function for LoaderEvent.ERROR events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the onFail special property. Make sure your onError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onFail : Function - A handler function for LoaderEvent.FAIL events which are dispatched whenever the loader fails and its status changes to LoaderStatus.FAILED. Make sure your onFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onIOError : Function - A handler function for LoaderEvent.IO_ERROR events which will also call the onError handler, so you can use that as more of a catch-all whereas onIOError is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onHTTPStatus : Function - A handler function for LoaderEvent.HTTP_STATUS events. Make sure your onHTTPStatus function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can determine the httpStatus code using the LoaderEvent's target.httpStatus (LoaderItems keep track of their httpStatus when possible, although certain environments prevent Flash from getting httpStatus information).
  • *
  • onSecurityError : Function - A handler function for LoaderEvent.SECURITY_ERROR events which onError handles as well, so you can use that as more of a catch-all whereas onSecurityError is specifically for SECURITY_ERROR events. Make sure your onSecurityError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onScriptAccessDenied : Function - A handler function for LoaderMax.SCRIPT_ACCESS_DENIED events which occur when the swf is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like BitmapData manipulation or integration of LoaderMax data inside the swf, etc. You can also check the scriptAccessDenied property after the swf has loaded. Make sure your function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildOpen : Function - A handler function for LoaderEvent.CHILD_OPEN events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) begins loading. Make sure your onChildOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildProgress : Function - A handler function for LoaderEvent.CHILD_PROGRESS events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) dispatches a PROGRESS event. To listen for changes in the SWFLoader's overall progress, use the onProgress special property instead. You can use the LoaderEvent's target.progress to get the child loader's progress value or use its target.bytesLoaded and target.bytesTotal. The LoaderEvent's currentTarget refers to the SWFLoader, so you can check its overall progress with the LoaderEvent's currentTarget.progress. Make sure your onChildProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildComplete : Function - A handler function for LoaderEvent.CHILD_COMPLETE events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildCancel : Function - A handler function for LoaderEvent.CHILD_CANCEL events which are dispatched each time loading is aborted on any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) due to either an error or because another loader was prioritized in the queue or because cancel() was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildFail : Function - A handler function for LoaderEvent.CHILD_FAIL events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) fails (and its status chances to LoaderStatus.FAILED). Make sure your onChildFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
* @see com.greensock.loading.data.SWFLoaderVars */ public function SWFLoader(urlOrRequest : *, vars : Object = null) { super(urlOrRequest, vars); _preferEstimatedBytesInAudit = true; _type = ""SWFLoader""; } /** @private **/ override protected function _load() : void { if (_stealthMode) { // it's already loading, so exit stealth mode (stealth mode is entered when the SWFLoader is canceled before the Loader has dispatched the INIT event - bugs in Flash cause gc problems if we try to close() or unload() a Loader between the time it starts loading and when INIT fires... _stealthMode = false; } else if (!_initted) { super._load(); } else if (_queue != null) { _changeQueueListeners(true); _queue.load(false); } } /** @private **/ override protected function _refreshLoader(unloadContent : Boolean = true) : void { super._refreshLoader(unloadContent); _loaderCompleted = false; } /** @private **/ protected function _changeQueueListeners(add : Boolean) : void { if (_queue != null) { var p : String; if (add && this.vars.integrateProgress != false) { _queue.addEventListener(LoaderEvent.COMPLETE, _completeHandler, false, 0, true); _queue.addEventListener(LoaderEvent.PROGRESS, _progressHandler, false, 0, true); _queue.addEventListener(LoaderEvent.FAIL, _failHandler, false, 0, true); for (p in _listenerTypes) { if (p != ""onProgress"" && p != ""onInit"") { _queue.addEventListener(_listenerTypes[p], _passThroughEvent, false, 0, true); } } } else { _queue.removeEventListener(LoaderEvent.COMPLETE, _completeHandler); _queue.removeEventListener(LoaderEvent.PROGRESS, _progressHandler); _queue.removeEventListener(LoaderEvent.FAIL, _failHandler); for (p in _listenerTypes) { if (p != ""onProgress"" && p != ""onInit"") { _queue.removeEventListener(_listenerTypes[p], _passThroughEvent); } } } } } /** @private scrubLevel: 0 = cancel, 1 = unload, 2 = dispose, 3 = flush **/ override protected function _dump(scrubLevel : int = 0, newStatus : int = 0, suppressEvents : Boolean = false) : void { // Flash will refuse to properly unload it if the INIT event hasn't been dispatched! Technically we allow it to keep loading until _initHandler() is called where we'll unload it. if (_status == LoaderStatus.LOADING && !_initted) { _stealthMode = true; super._dump(scrubLevel, newStatus, suppressEvents); return; } if (_initted && !_scriptAccessDenied && scrubLevel != 2) { _stopMovieClips(_loader.content); if (_loader.content in _rootLookup) { _queue = LoaderMax(_rootLookup[_loader.content]); _changeQueueListeners(false); if (scrubLevel == 1) { _queue.cancel(); } else { if (scrubLevel == 1) { _queue.unload(); } _queue.dispose(); } } } if (_stealthMode) { try { _loader.close(); } catch (error : Error) { } } _stealthMode = _hasRSL = false; _cacheIsDirty = true; if (scrubLevel >= 1) { _queue = null; _initted = _loaderCompleted = false; super._dump(scrubLevel, newStatus, suppressEvents); } else { var content : * = _content; super._dump(scrubLevel, newStatus, suppressEvents); _content = content; // super._dump() will null ""_content"", but if the swf has loaded but not the _queue, we should keep the content so that if resume() is called, it just starts loading the queue. } } /** @private **/ protected function _stopMovieClips(obj : DisplayObject) : void { var mc : MovieClip = obj as MovieClip; if (mc == null) { return; } mc.stop(); var i : int = mc.numChildren; while (--i > -1) { _stopMovieClips(mc.getChildAt(i)); } } /** @private **/ override protected function _determineScriptAccess() : void { // don't test the BitmapData.draw() until the swf has fully loaded because it can incorrectly throw security errors in certain situations (like NetStreams that haven't started yet). try { var mc : DisplayObject = _loader.content; } catch (error : Error) { _scriptAccessDenied = true; dispatchEvent(new LoaderEvent(LoaderEvent.SCRIPT_ACCESS_DENIED, this, error.message)); return; } if (_loader.content is AVM1Movie) { _scriptAccessDenied = true; dispatchEvent(new LoaderEvent(LoaderEvent.SCRIPT_ACCESS_DENIED, this, ""AVM1Movie denies script access"")); } } /** @private **/ override protected function _calculateProgress() : void { _cachedBytesLoaded = (_stealthMode) ? 0 : _loader.contentLoaderInfo.bytesLoaded; _cachedBytesTotal = _loader.contentLoaderInfo.bytesTotal; if (_cachedBytesTotal < _cachedBytesLoaded || _loaderCompleted) { // In Chrome when the file exceeds a certain size and gzip is enabled on the server, Adobe's Loader reports bytesTotal as 0!!! // and in Firefox, if gzip was enabled, on very small files the Loader's bytesLoaded would never quite reach the bytesTotal even after the COMPLETE event fired! _cachedBytesTotal = _cachedBytesLoaded; } if (this.vars.integrateProgress == false) { // do nothing } else if (_queue != null && (uint(this.vars.estimatedBytes) < _cachedBytesLoaded || _queue.auditedSize)) { // make sure that estimatedBytes is prioritized until the _queue has audited its size successfully! if (_queue.status <= LoaderStatus.COMPLETED) { _cachedBytesLoaded += _queue.bytesLoaded; _cachedBytesTotal += _queue.bytesTotal; } } else if (uint(this.vars.estimatedBytes) > _cachedBytesLoaded && (!_initted || (_queue != null && _queue.status <= LoaderStatus.COMPLETED && !_queue.auditedSize))) { _cachedBytesTotal = uint(this.vars.estimatedBytes); } if ((_hasRSL && _content == null) || (!_initted && _cachedBytesLoaded == _cachedBytesTotal)) { _cachedBytesLoaded = int(_cachedBytesLoaded * 0.99); // don't allow the progress to hit 1 yet } _cacheIsDirty = false; } /** @private **/ protected function _checkRequiredLoaders() : void { if (_queue == null && this.vars.integrateProgress != false && !_scriptAccessDenied) { _queue = _rootLookup[_loader.content]; if (_queue != null) { _changeQueueListeners(true); _queue.load(false); _cacheIsDirty = true; } } } /** * Searches the loaded swf (and any of its subloaded swfs that were loaded using SWFLoader) for a particular * class by name. For example, if the swf contains a class named ""com.greensock.TweenLite"", you can get a * reference to that class like:

* * var tweenLite:Class = loader.getClass(""com.greensock.TweenLite"");
* // then you can create an instance of TweenLite like:
* var tween:Object = new tweenLite(mc, 1, {x:100});
* * @param className The full name of the class, like ""com.greensock.TweenLite"". * @return The class associated with the className */ public function getClass(className : String) : Class { if (_content == null || _scriptAccessDenied) { return null; } var result : Object = _content.loaderInfo.applicationDomain.getDefinition(className); if (result != null) { return result as Class; } else if (_queue != null) { var loaders : Array = _queue.getChildren(true, true); var i : int = loaders.length; while (--i > -1) { if (loaders[i] is SWFLoader) { result = (loaders[i] as SWFLoader).getClass(className); if (result != null) { return result as Class; } } } } return null; } /** * Finds a DisplayObject that's on the root of the loaded SWF by name. For example, * you could put a MovieClip with an instance name of ""phoneAnimation_mc"" on the stage (along with * any other objects of course) and then when you load that swf you could use * loader.getSWFChild(""phoneAnimation_mc"") to get that MovieClip. It would be * similar to doing (loader.rawContent as DisplayObjectContainer).getChildByName(""phoneAnimation_mc"") * but in a more concise way that doesn't require checking to see if the rawContent is null. getSWFChild() * will return null if the content hasn't loaded yet or if scriptAccessDenied is true. * * @param name The name of the child DisplayObject that is located at the root of the swf. * @return The DisplayObject with the specified name. Returns null if the content hasn't loaded yet or if scriptAccessDenied is true. */ public function getSWFChild(name : String) : DisplayObject { return (!_scriptAccessDenied && _content is DisplayObjectContainer) ? DisplayObjectContainer(_content).getChildByName(name) : null; } /** * @private * Finds a particular loader inside any active LoaderMax instances that were discovered in the subloaded swf * which had their requireWithRoot set to the swf's root. This is only useful in situations * where the swf contains other loaders that are required. * * @param nameOrURL The name or url associated with the loader that should be found. * @return The loader associated with the name or url. Returns null if none were found. */ public function getLoader(nameOrURL : String) : * { return (_queue != null) ? _queue.getLoader(nameOrURL) : null; } /** * @private * Finds a particular loader's content from inside any active LoaderMax instances that were discovered in the * subloaded swf which had their requireWithRoot set to the swf's root. This is only useful * in situations where the swf contains other loaders that are required. * * @param nameOrURL The name or url associated with the loader whose content should be found. * @return The content associated with the name or url. Returns null if none was found. */ public function getContent(nameOrURL : String) : * { if (nameOrURL == this.name || nameOrURL == _url) { return this.content; } var loader : LoaderCore = this.getLoader(nameOrURL); return (loader != null) ? loader.content : null; } /** @private **/ public function getChildren(includeNested : Boolean = false, omitLoaderMaxes : Boolean = false) : Array { return (_queue != null) ? _queue.getChildren(includeNested, omitLoaderMaxes) : []; } // ---- EVENT HANDLERS ------------------------------------------------------------------------------------ /** @private **/ override protected function _initHandler(event : Event) : void { // if the SWFLoader was cancelled before _initHandler() was called, Flash will refuse to properly unload it, so we allow it to continue but check the status here and _dump() if necessary. if (_stealthMode) { _initted = true; _dump(1, _status, true); return; } // swfs with TLF use their own funky preloader system that causes problems, so we need to work around them here... _hasRSL = false; try { var tempContent : DisplayObject = _loader.content; var className : String = getQualifiedClassName(tempContent); if (className.substr(-13) == ""__Preloader__"") { var rslPreloader : Object = tempContent[""__rslPreloader""]; if (rslPreloader != null) { className = getQualifiedClassName(rslPreloader); if (className == ""fl.rsl::RSLPreloader"") { _hasRSL = true; _rslAddedCount = 0; tempContent.addEventListener(Event.ADDED, _rslAddedHandler); } } } } catch (error : Error) { } if (!_hasRSL) { _init(); } } /** @private **/ protected function _init() : void { _determineScriptAccess(); if (!_scriptAccessDenied) { if (!_hasRSL) { _content = _loader.content; } if (_content != null) { if (this.vars.autoPlay == false && _content is MovieClip) { var st : SoundTransform = _content.soundTransform; st.volume = 0; // just make sure you can't hear any sounds as it's loading in the background. _content.soundTransform = st; _content.stop(); } _checkRequiredLoaders(); } } else { _content = _loader; } super._initHandler(null); } /** @private Works around bug - see http://kb2.adobe.com/cps/838/cpsid_83812.html **/ protected function _rslAddedHandler(event : Event) : void { // check to ensure this was actually something added to the _loader.content if (event.target is DisplayObject && event.currentTarget is DisplayObjectContainer && event.target.parent == event.currentTarget) { _rslAddedCount++; } // the first thing added will be the loader animation swf - ignore that if (_rslAddedCount > 1) { event.currentTarget.removeEventListener(Event.ADDED, _rslAddedHandler); if (_status == LoaderStatus.LOADING) { _content = event.target; _init(); _calculateProgress(); dispatchEvent(new LoaderEvent(LoaderEvent.PROGRESS, this)); _completeHandler(null); } } } /** @private **/ override protected function _passThroughEvent(event : Event) : void { if (event.target != _queue) { super._passThroughEvent(event); } } /** @private **/ override protected function _progressHandler(event : Event) : void { if (_status == LoaderStatus.LOADING) { if (_queue == null && _initted) { _checkRequiredLoaders(); } if (_dispatchProgress) { var bl : uint = _cachedBytesLoaded; var bt : uint = _cachedBytesTotal; _calculateProgress(); if (_cachedBytesLoaded != _cachedBytesTotal && (bl != _cachedBytesLoaded || bt != _cachedBytesTotal)) { dispatchEvent(new LoaderEvent(LoaderEvent.PROGRESS, this)); } } else { _cacheIsDirty = true; } } } /** @private **/ override protected function _completeHandler(event : Event = null) : void { _loaderCompleted = true; _checkRequiredLoaders(); _calculateProgress(); if (this.progress == 1) { if (!_scriptAccessDenied && this.vars.autoPlay == false && _content is MovieClip) { var st : SoundTransform = _content.soundTransform; st.volume = 1; _content.soundTransform = st; } _changeQueueListeners(false); super._determineScriptAccess(); // now do the BitmapData.draw() test. super._completeHandler(event); } } } }",16345,True,3362.845059493443,median "*&---------------------------------------------------------------------* *& Report ZBC_DDIC_FINDER *& ABAP Dictionary object finder tool *&---------------------------------------------------------------------* *& Repository: https://github.com/coreline/ZDDIC_FINDER *& Developer: admin@abap4.ru *&---------------------------------------------------------------------* REPORT zddic_finder. TABLES: tadir, dd01l, dd01t, dd02l, dd03l, dd02t, dd04t, dd40l, dd40t. SELECTION-SCREEN BEGIN OF BLOCK select_object WITH FRAME TITLE text-sel. PARAMETERS f_doma TYPE flag RADIOBUTTON GROUP gr0 USER-COMMAND sel_obj. PARAMETERS f_dtel TYPE flag RADIOBUTTON GROUP gr0. PARAMETERS f_tabl TYPE flag RADIOBUTTON GROUP gr0 DEFAULT 'X'. PARAMETERS f_ttyp TYPE flag RADIOBUTTON GROUP gr0. PARAMETERS f_srng TYPE flag RADIOBUTTON GROUP gr0. PARAMETERS f_trng TYPE flag RADIOBUTTON GROUP gr0. SELECTION-SCREEN END OF BLOCK select_object. SELECTION-SCREEN BEGIN OF BLOCK table WITH FRAME TITLE text-tab. SELECT-OPTIONS s_tab_nm FOR dd40l-typename NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_tab_tx FOR dd40t-ddtext NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_tab_rt FOR dd40l-rowtype NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_tab_dt FOR dd40l-datatype NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_tab_dl FOR dd40l-leng NO-EXTENSION. SELECT-OPTIONS s_tab_dc FOR dd40l-decimals NO-EXTENSION. SELECTION-SCREEN END OF BLOCK table. SELECTION-SCREEN BEGIN OF BLOCK structure WITH FRAME TITLE text-str. SELECT-OPTIONS s_str_nm FOR dd02l-tabname NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_str_tx FOR dd02t-ddtext NO-EXTENSION NO INTERVALS. SELECTION-SCREEN END OF BLOCK structure. SELECTION-SCREEN BEGIN OF BLOCK range_table WITH FRAME TITLE text-rgt. SELECT-OPTIONS s_rgt_nm FOR dd40l-typename NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_rgt_tx FOR dd40t-ddtext NO-EXTENSION NO INTERVALS. SELECTION-SCREEN END OF BLOCK range_table. SELECTION-SCREEN BEGIN OF BLOCK range_structure WITH FRAME TITLE text-rgs. SELECT-OPTIONS s_rgs_nm FOR dd02l-tabname NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_rgs_tx FOR dd02t-ddtext NO-EXTENSION NO INTERVALS. SELECTION-SCREEN END OF BLOCK range_structure. SELECTION-SCREEN BEGIN OF BLOCK range_components WITH FRAME TITLE text-rng. SELECT-OPTIONS s_rng_en FOR dd04t-rollname NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_rng_dn FOR dd01l-domname NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_rng_dt FOR dd01l-datatype NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_rng_dl FOR dd01l-leng NO-EXTENSION. SELECT-OPTIONS s_rng_dc FOR dd01l-decimals NO-EXTENSION. SELECTION-SCREEN END OF BLOCK range_components. SELECTION-SCREEN BEGIN OF BLOCK structure_components WITH FRAME TITLE text-scm. DEFINE scm_line. SELECTION-SCREEN BEGIN OF LINE. PARAMETERS p_scm_c&1 TYPE dd03l-fieldname VISIBLE LENGTH 30. PARAMETERS p_scm_e&1 TYPE dd03l-rollname VISIBLE LENGTH 30. PARAMETERS p_scm_t&1 TYPE dd03l-datatype VISIBLE LENGTH 10. PARAMETERS p_scm_l&1 TYPE dd03l-leng VISIBLE LENGTH 4. PARAMETERS p_scm_d&1 TYPE dd03l-decimals VISIBLE LENGTH 4. SELECTION-SCREEN END OF LINE. END-OF-DEFINITION. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) p_scm_c0. SELECTION-SCREEN COMMENT 32(30) p_scm_e0. SELECTION-SCREEN COMMENT 63(10) p_scm_t0. SELECTION-SCREEN COMMENT 74(4) p_scm_l0. SELECTION-SCREEN COMMENT 79(4) p_scm_d0. SELECTION-SCREEN END OF LINE. scm_line: 1, 2, 3, 4, 5, 6, 7, 8, 9. SELECT-OPTIONS s_scm_cn FOR dd03l-position NO-EXTENSION. PARAMETERS p_scm_so TYPE flag AS CHECKBOX DEFAULT 'X'. SELECTION-SCREEN END OF BLOCK structure_components. SELECTION-SCREEN BEGIN OF BLOCK data_item_parameters WITH FRAME TITLE text-itm. SELECT-OPTIONS s_elm_nm FOR dd04t-rollname NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_elm_tx FOR dd04t-ddtext NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_elm_tr FOR dd04t-reptext NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_elm_ts FOR dd04t-scrtext_s NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_elm_tm FOR dd04t-scrtext_m NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_elm_tl FOR dd04t-scrtext_l NO-EXTENSION NO INTERVALS. SELECTION-SCREEN END OF BLOCK data_item_parameters. SELECTION-SCREEN BEGIN OF BLOCK domain_parameters WITH FRAME TITLE text-dom. SELECT-OPTIONS s_dom_nm FOR dd01l-domname NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_dom_tx FOR dd01t-ddtext NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_dom_dt FOR dd01l-datatype NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_dom_dl FOR dd01l-leng NO-EXTENSION. SELECT-OPTIONS s_dom_ol FOR dd01l-outputlen NO-EXTENSION. SELECT-OPTIONS s_dom_dc FOR dd01l-decimals NO-EXTENSION. SELECT-OPTIONS s_dom_lc FOR dd01l-lowercase NO-EXTENSION NO INTERVALS. SELECT-OPTIONS s_dom_sf FOR dd01l-signflag NO-EXTENSION NO INTERVALS. SELECTION-SCREEN END OF BLOCK domain_parameters. SELECTION-SCREEN BEGIN OF BLOCK display_options WITH FRAME TITLE text-dis. PARAMETERS p_langu TYPE sy-langu DEFAULT sy-langu. PARAMETERS p_rows TYPE i DEFAULT 200. PARAMETERS p_limit TYPE i NO-DISPLAY. SELECT-OPTIONS s_devcls FOR tadir-devclass NO-EXTENSION NO INTERVALS. PARAMETERS p_as4loc TYPE as4local DEFAULT 'A' NO-DISPLAY. "" Запись активирована или создана в этой форме PARAMETERS p_as4ver TYPE as4vers DEFAULT '0000' NO-DISPLAY. "" Версия записи (не используется) SELECTION-SCREEN END OF BLOCK display_options. INITIALIZATION. PERFORM init. AT SELECTION-SCREEN. PERFORM pai. AT SELECTION-SCREEN OUTPUT. PERFORM pbo. FORM init. PERFORM init_text. ENDFORM. FORM init_text. CASE sy-langu. WHEN 'R'. "" Russian PERFORM set_title USING 'Поиск по ABAP-словарю'. PERFORM set_frame_text USING 'SEL' 'ABAP-словарь'. PERFORM set_param_text USING f_doma 'Домен'. PERFORM set_param_text USING f_dtel 'Элемент данных'. PERFORM set_param_text USING f_tabl 'Таблица / структура'. PERFORM set_param_text USING f_ttyp 'Тип таблицы'. PERFORM set_param_text USING f_srng 'Структура диапазона'. PERFORM set_param_text USING f_trng 'Тип таблицы диапазона'. PERFORM set_frame_text USING 'DOM' 'Параметры домена'. PERFORM set_param_text USING s_dom_nm 'Домен'. PERFORM set_param_text USING s_dom_tx 'Краткое описание'. PERFORM set_param_text USING s_dom_dt 'Тип данных в ABAP-словаре'. PERFORM set_param_text USING s_dom_dl 'Длина (число знаков)'. PERFORM set_param_text USING s_dom_ol 'Длина вывода'. PERFORM set_param_text USING s_dom_dc 'Число десятичных разрядов'. PERFORM set_param_text USING s_dom_lc 'Разрешить строчные буквы'. PERFORM set_param_text USING s_dom_sf 'Просмотр знака +/-'. PERFORM set_frame_text USING 'ITM' 'Параметры элемента данных'. PERFORM set_param_text USING s_elm_nm 'Элемент данных'. PERFORM set_param_text USING s_elm_tx 'Краткое описание'. PERFORM set_param_text USING s_elm_tr 'Заголовок'. PERFORM set_param_text USING s_elm_ts 'Краткая метка поля'. PERFORM set_param_text USING s_elm_tm 'Средняя метка поля'. PERFORM set_param_text USING s_elm_tl 'Длинная метка поля'. PERFORM set_frame_text USING 'STR' 'Параметры таблицы / структуры'. PERFORM set_param_text USING s_str_nm 'Имя таблицы / структуры'. PERFORM set_param_text USING s_str_tx 'Краткое описание'. PERFORM set_frame_text USING 'TAB' 'Параметры типа таблицы'. PERFORM set_param_text USING s_tab_nm 'Имя типа таблицы'. PERFORM set_param_text USING s_tab_tx 'Краткое описание'. PERFORM set_param_text USING s_tab_rt 'Тип строки'. PERFORM set_param_text USING s_tab_dt 'Тип данных в ABAP-словаре'. PERFORM set_param_text USING s_tab_dl 'Длина (число знаков)'. PERFORM set_param_text USING s_tab_dc 'Число десятичных разрядов'. PERFORM set_frame_text USING 'RGT' 'Параметры типа таблицы диапазона'. PERFORM set_param_text USING s_rgt_nm 'Имя типа таблицы'. PERFORM set_param_text USING s_rgt_tx 'Краткое описание'. PERFORM set_frame_text USING 'RGS' 'Параметры структуры диапазона'. PERFORM set_param_text USING s_rgs_nm 'Имя структуры'. PERFORM set_param_text USING s_rgs_tx 'Краткое описание'. PERFORM set_frame_text USING 'RNG' 'Параметры LIGH/LOW-компонентов'. PERFORM set_param_text USING s_rng_en 'Имя элемента данных'. PERFORM set_param_text USING s_rng_dn 'Имя домена'. PERFORM set_param_text USING s_rng_dt 'Тип данных в ABAP-словаре'. PERFORM set_param_text USING s_rng_dl 'Длина (число знаков)'. PERFORM set_param_text USING s_rng_dc 'Число десятичных разрядов'. PERFORM set_frame_text USING 'SCM' 'Поля структуры'. PERFORM set_param_text USING p_scm_c0 'Имя поля'. PERFORM set_param_text USING p_scm_e0 'Элемент данных'. PERFORM set_param_text USING p_scm_t0 'Тип данных'. PERFORM set_param_text USING p_scm_l0 'Длина'. PERFORM set_param_text USING p_scm_d0 'ДесРазряды'. PERFORM set_param_text USING s_scm_cn 'Количество полей'. PERFORM set_param_text USING p_scm_so 'Строгий порядок полей'. PERFORM set_frame_text USING 'DIS' 'Параметры поиска'. PERFORM set_param_text USING p_langu 'Язык'. PERFORM set_param_text USING p_rows 'Макс. число совпадений'. PERFORM set_param_text USING s_devcls 'Пакет'. PERFORM set_param_text USING p_as4loc 'Статус активации объекта'. PERFORM set_param_text USING p_as4ver 'Версия записи'. WHEN OTHERS. PERFORM set_title USING 'Objects in the ABAP Dictionary'. PERFORM set_frame_text USING 'SEL' 'ABAP Dictionary'. PERFORM set_param_text USING f_doma 'Domain'. PERFORM set_param_text USING f_dtel 'Data element'. PERFORM set_param_text USING f_tabl 'Table'. PERFORM set_param_text USING f_ttyp 'Table type'. PERFORM set_param_text USING f_srng 'Ranges'. PERFORM set_param_text USING f_trng 'Ranges table'. PERFORM set_frame_text USING 'DOM' 'Domain parameters'. PERFORM set_param_text USING s_dom_nm 'Domain'. PERFORM set_param_text USING s_dom_tx 'Short description'. PERFORM set_param_text USING s_dom_dt 'Data type'. PERFORM set_param_text USING s_dom_dl 'No. characters'. PERFORM set_param_text USING s_dom_ol 'Output length'. PERFORM set_param_text USING s_dom_dc 'Decimal places'. PERFORM set_param_text USING s_dom_lc 'Lower case'. PERFORM set_param_text USING s_dom_sf 'Sign'. PERFORM set_frame_text USING 'ITM' 'Data element parameters'. PERFORM set_param_text USING s_elm_nm 'Data element'. PERFORM set_param_text USING s_elm_tx 'Short description'. PERFORM set_param_text USING s_elm_tr 'Heading'. PERFORM set_param_text USING s_elm_ts 'Short text'. PERFORM set_param_text USING s_elm_tm 'Medium text'. PERFORM set_param_text USING s_elm_tl 'Long text'. PERFORM set_frame_text USING 'STR' 'Table parameters'. PERFORM set_param_text USING s_str_nm 'Table name'. PERFORM set_param_text USING s_str_tx 'Short description'. PERFORM set_frame_text USING 'TAB' 'Table type parameters'. PERFORM set_param_text USING s_tab_nm 'Table name'. PERFORM set_param_text USING s_tab_tx 'Short description'. PERFORM set_param_text USING s_tab_rt 'Row type'. PERFORM set_param_text USING s_tab_dt 'Data type'. PERFORM set_param_text USING s_tab_dl 'No. characters'. PERFORM set_param_text USING s_tab_dc 'Decimal places'. PERFORM set_frame_text USING 'RGT' 'Ranges table parameters'. PERFORM set_param_text USING s_rgt_nm 'Ranges table type'. PERFORM set_param_text USING s_rgt_tx 'Short description'. PERFORM set_frame_text USING 'RGS' 'Ranges parameters'. PERFORM set_param_text USING s_rgs_nm 'Structure'. PERFORM set_param_text USING s_rgs_tx 'Short description'. PERFORM set_frame_text USING 'RNG' 'LIGH/LOW components'. PERFORM set_param_text USING s_rng_en 'Data element'. PERFORM set_param_text USING s_rng_dn 'Domain'. PERFORM set_param_text USING s_rng_dt 'Data type'. PERFORM set_param_text USING s_rng_dl 'No. characters'. PERFORM set_param_text USING s_rng_dc 'Decimal places'. PERFORM set_frame_text USING 'SCM' 'Structure components'. PERFORM set_param_text USING p_scm_c0 'Component'. PERFORM set_param_text USING p_scm_e0 'Component type'. PERFORM set_param_text USING p_scm_t0 'Data type'. PERFORM set_param_text USING p_scm_l0 'Length'. PERFORM set_param_text USING p_scm_d0 'Dec. places'. PERFORM set_param_text USING s_scm_cn 'Components count'. PERFORM set_param_text USING p_scm_so 'Strict field order'. PERFORM set_frame_text USING 'DIS' 'Search options'. PERFORM set_param_text USING p_langu 'Language'. PERFORM set_param_text USING p_rows 'Maximum No. of Hits'. PERFORM set_param_text USING s_devcls 'Package'. PERFORM set_param_text USING p_as4loc 'Activation status'. PERFORM set_param_text USING p_as4ver 'Version'. ENDCASE. ENDFORM. FORM set_title USING iv_text TYPE clike. SET TITLEBAR '%_T' OF PROGRAM 'RSSYSTDB' WITH iv_text. ENDFORM. FORM set_frame_text USING iv_name TYPE clike iv_text TYPE clike. LOOP AT SCREEN. CHECK screen-group3 EQ 'BLK'. CHECK iv_name EQ screen-name+2(3). ASSIGN (screen-name) TO FIELD-SYMBOL(). IF sy-subrc EQ 0. = iv_text. EXIT. ENDIF. ENDLOOP. ENDFORM. FORM set_param_text USING i_param TYPE any iv_text TYPE clike. DESCRIBE FIELD i_param TYPE DATA(lv_type). DATA(lv_range) = xsdbool( lv_type EQ 'u' ). IF lv_range IS INITIAL. ASSIGN i_param TO FIELD-SYMBOL(). ELSE. ASSIGN COMPONENT 'LOW' OF STRUCTURE i_param TO . ENDIF. CHECK IS ASSIGNED. LOOP AT SCREEN. CHECK screen-name IS NOT INITIAL. ASSIGN (screen-name) TO FIELD-SYMBOL(). CHECK sy-subrc EQ 0. CHECK REF #( ) EQ REF #( ). IF screen-group3 EQ 'COM'. = iv_text. EXIT. ENDIF. DATA(lv_text) = '%_' && COND #( WHEN lv_range EQ abap_true THEN substring_before( val = screen-name sub = '-' ) ELSE screen-name ) && '_%_APP_%-TEXT'. ASSIGN (lv_text) TO FIELD-SYMBOL(). IF sy-subrc EQ 0. = iv_text. EXIT. ENDIF. ENDLOOP. ENDFORM. FORM pbo. PERFORM display_ddic_param. ENDFORM. FORM display_ddic_param. CASE abap_true. WHEN f_doma. PERFORM display_block USING 'SEL DOM DIS'. WHEN f_dtel. PERFORM display_block USING 'SEL ITM DOM DIS'. PERFORM enabled_field USING s_dom_tx abap_false. WHEN f_tabl. PERFORM display_block USING 'SEL STR SCM DIS'. WHEN f_ttyp. PERFORM display_block USING 'SEL TAB SCM DIS'. WHEN f_srng. PERFORM display_block USING 'SEL RGS RNG DIS'. WHEN f_trng. PERFORM display_block USING 'SEL RGT RNG DIS'. WHEN OTHERS. PERFORM display_block USING 'SEL DIS'. ENDCASE. ENDFORM. FORM display_block USING iv_blocks TYPE clike. DATA lv_block TYPE string. LOOP AT SCREEN. IF screen-group3 EQ 'BLK'. lv_block = screen-name+2(3). ENDIF. screen-active = strlen( xsdbool( iv_blocks CS lv_block ) ). MODIFY SCREEN. ENDLOOP. ENDFORM. FORM enabled_field USING i_param TYPE any iv_value TYPE abap_bool. DESCRIBE FIELD i_param TYPE DATA(lv_type). DATA(lv_range) = xsdbool( lv_type EQ 'u' ). IF lv_range IS INITIAL. ASSIGN i_param TO FIELD-SYMBOL(). ELSE. ASSIGN COMPONENT 'LOW' OF STRUCTURE i_param TO . ENDIF. CHECK IS ASSIGNED. LOOP AT SCREEN. CHECK screen-name IS NOT INITIAL. ASSIGN (screen-name) TO FIELD-SYMBOL(). CHECK sy-subrc EQ 0. IF REF #( ) EQ REF #( ). screen-input = strlen( iv_value ). MODIFY SCREEN. EXIT. ENDIF. ENDLOOP. ENDFORM. FORM pai. IF sy-ucomm EQ 'ONLI'. PERFORM main. ENDIF. ENDFORM. FORM main. p_limit = p_rows + 1. CASE abap_true. WHEN f_ttyp. "" Тип таблицы PERFORM search_table. WHEN f_tabl. "" Таблица / структура PERFORM search_structure. WHEN f_trng. "" Тип таблицы диапазона PERFORM search_range_table. WHEN f_srng. "" Структура диапазона PERFORM search_range_structure. WHEN f_dtel. "" Элемент данных PERFORM search_data_item. WHEN f_doma. "" Домен PERFORM search_domains. ENDCASE. ENDFORM. FORM search_domains. CONSTANTS lc_object TYPE tadir-object VALUE 'DOMA'. SELECT dd01l~domname, dd01t~ddtext, tadir~devclass, dd01l~datatype, dd01l~leng, dd01l~outputlen, dd01l~decimals, dd01l~lowercase, dd01l~signflag UP TO @p_limit ROWS INTO TABLE @DATA(lt_table) FROM dd01l JOIN tadir ON tadir~obj_name EQ dd01l~domname LEFT JOIN dd01t ON dd01t~domname EQ dd01l~domname AND dd01t~as4local EQ dd01l~as4local AND dd01t~as4vers EQ dd01l~as4vers AND dd01t~ddlanguage EQ @p_langu WHERE dd01l~as4local EQ @p_as4loc AND dd01l~as4vers EQ @p_as4ver AND dd01l~domname IN @s_dom_nm AND dd01t~ddtext IN @s_dom_tx AND dd01l~datatype IN @s_dom_dt AND dd01l~leng IN @s_dom_dl AND dd01l~outputlen IN @s_dom_ol AND dd01l~decimals IN @s_dom_dc AND dd01l~lowercase IN @s_dom_lc AND dd01l~signflag IN @s_dom_sf AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls. SORT lt_table BY domname devclass. PERFORM display USING lt_table. ENDFORM. FORM search_data_item. CONSTANTS lc_object TYPE tadir-object VALUE 'DTEL'. SELECT dd04l~rollname, dd04t~ddtext, tadir~devclass, dd04t~reptext, dd04t~scrtext_s, dd04t~scrtext_m, dd04t~scrtext_l, dd01l~domname, dd01l~datatype, dd01l~leng, dd01l~outputlen, dd01l~decimals, dd01l~lowercase, dd01l~signflag UP TO @p_limit ROWS INTO TABLE @DATA(lt_table) FROM dd04l JOIN tadir ON tadir~obj_name EQ dd04l~rollname LEFT JOIN dd04t ON dd04t~rollname EQ dd04l~rollname AND dd04t~as4local EQ dd04l~as4local AND dd04t~as4vers EQ dd04l~as4vers AND dd04t~ddlanguage EQ @p_langu JOIN dd01l ON dd01l~domname EQ dd04l~domname AND dd01l~as4local EQ dd04l~as4local AND dd01l~as4vers EQ dd04l~as4vers WHERE dd04l~as4local EQ @p_as4loc AND dd04l~as4vers EQ @p_as4ver AND dd04l~rollname IN @s_elm_nm AND dd04t~ddtext IN @s_elm_tx AND dd04t~reptext IN @s_elm_tr AND dd04t~scrtext_s IN @s_elm_ts AND dd04t~scrtext_m IN @s_elm_tm AND dd04t~scrtext_l IN @s_elm_tl AND dd01l~domname IN @s_dom_nm AND dd01l~datatype IN @s_dom_dt AND dd01l~leng IN @s_dom_dl AND dd01l~outputlen IN @s_dom_ol AND dd01l~decimals IN @s_dom_dc AND dd01l~lowercase IN @s_dom_lc AND dd01l~signflag IN @s_dom_sf AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls. DATA(lv_limit) = nmax( val1 = 0 val2 = p_limit - lines( lt_table ) ). IF p_limit EQ 0 OR lv_limit GT 0. SELECT dd04t~rollname, dd04t~ddtext, tadir~devclass, dd04t~reptext, dd04t~scrtext_s, dd04t~scrtext_m, dd04t~scrtext_l, dd04l~domname, dd04l~datatype, dd04l~leng, dd04l~outputlen, dd04l~decimals, dd04l~lowercase, dd04l~signflag UP TO @lv_limit ROWS APPENDING TABLE @lt_table FROM dd04l JOIN tadir ON tadir~obj_name EQ dd04l~rollname LEFT JOIN dd04t ON dd04t~rollname EQ dd04l~rollname AND dd04t~as4local EQ dd04l~as4local AND dd04t~as4vers EQ dd04l~as4vers AND dd04t~ddlanguage EQ @p_langu WHERE dd04l~as4local EQ @p_as4loc AND dd04l~as4vers EQ @p_as4ver AND dd04t~rollname IN @s_elm_nm AND dd04t~ddtext IN @s_elm_tx AND dd04t~reptext IN @s_elm_tr AND dd04t~scrtext_s IN @s_elm_ts AND dd04t~scrtext_m IN @s_elm_tm AND dd04t~scrtext_l IN @s_elm_tl AND dd04l~domname EQ @space AND dd04l~datatype IN @s_dom_dt AND dd04l~leng IN @s_dom_dl AND dd04l~outputlen IN @s_dom_ol AND dd04l~decimals IN @s_dom_dc AND dd04l~lowercase IN @s_dom_lc AND dd04l~signflag IN @s_dom_sf AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls AND dd04l~rollname NE @space. ENDIF. SORT lt_table BY rollname devclass. PERFORM display USING lt_table. ENDFORM. FORM search_structure. CONSTANTS lc_object TYPE tadir-object VALUE 'TABL'. DATA lv_join TYPE string. DATA lv_where TYPE string. SELECT dd03l~tabname, dd02t~ddtext, tadir~devclass, dd03l~position, dd03l~fieldname, dd03t~ddtext AS fieldname_ddtext, dd03l~rollname, dd03l~domname, dd03l~datatype, dd03l~leng, dd03l~decimals UP TO 1 ROWS INTO TABLE @DATA(lt_table) FROM dd03l LEFT JOIN dd02t ON dd02t~tabname EQ dd03l~tabname AND dd02t~as4local EQ dd03l~as4local AND dd02t~as4vers EQ dd03l~as4vers AND dd02t~ddlanguage EQ @p_langu LEFT JOIN dd03t ON dd03t~tabname EQ dd03l~tabname AND dd03t~as4local EQ dd03l~as4local AND dd03t~fieldname EQ dd03l~fieldname AND dd03t~ddlanguage EQ @p_langu JOIN tadir ON tadir~obj_name EQ dd03l~tabname. CLEAR lt_table. PERFORM get_struct_clause CHANGING lv_join lv_where. DATA(lv_from) = | dd03l | && | LEFT JOIN dd02t ON dd02t~tabname EQ dd03l~tabname | && | AND dd02t~as4local EQ dd03l~as4local | && | AND dd02t~as4vers EQ dd03l~as4vers | && | AND dd02t~ddlanguage EQ @p_langu | && | LEFT JOIN dd03t ON dd03t~tabname EQ dd03l~tabname | && | AND dd03t~as4local EQ dd03l~as4local | && | AND dd03t~fieldname EQ dd03l~fieldname | && | AND dd03t~ddlanguage EQ @p_langu | && | LEFT JOIN dd04t ON dd04t~rollname EQ dd03l~rollname | && | AND dd04t~as4local EQ dd03l~as4local | && | AND dd04t~as4vers EQ dd03l~as4vers | && | AND dd04t~ddlanguage EQ @p_langu | && | JOIN tadir ON tadir~obj_name EQ dd03l~tabname | && lv_join. lv_from = to_upper( lv_from ). lv_where = to_upper( lv_where ). SELECT dd03l~tabname, dd02t~ddtext, tadir~devclass, dd03l~position, dd03l~fieldname, COALESCE( dd03t~ddtext, dd04t~ddtext ) AS fieldname_ddtext, dd03l~rollname, dd03l~domname, dd03l~datatype, dd03l~leng, dd03l~decimals UP TO @p_limit ROWS APPENDING TABLE @lt_table FROM (lv_from) WHERE dd03l~as4local EQ @p_as4loc AND dd03l~as4vers EQ @p_as4ver AND dd03l~tabname IN @s_str_nm AND dd02t~ddtext IN @s_str_tx AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls AND (lv_where). SORT lt_table BY tabname position. PERFORM display USING lt_table. ENDFORM. FORM search_table. CONSTANTS lc_object TYPE tadir-object VALUE 'TTYP'. DATA lv_join TYPE string. DATA lv_where TYPE string. SELECT dd40l~typename, dd40t~ddtext, dd40l~rowtype, tadir~devclass, dd03l~position, dd03l~fieldname, dd03t~ddtext AS fieldname_ddtext, dd03l~rollname, dd03l~domname, dd03l~datatype, dd03l~leng, dd03l~decimals UP TO 1 ROWS INTO TABLE @DATA(lt_table) FROM dd40l LEFT JOIN dd40t ON dd40t~typename EQ dd40l~typename AND dd40t~as4local EQ dd40l~as4local AND dd40t~ddlanguage EQ @p_langu LEFT JOIN dd03l ON dd03l~tabname EQ dd40l~rowtype AND dd03l~as4local EQ dd40l~as4local AND dd03l~as4vers EQ @p_as4ver LEFT JOIN dd02t ON dd02t~tabname EQ dd03l~tabname AND dd02t~as4local EQ dd03l~as4local AND dd02t~as4vers EQ dd03l~as4vers AND dd02t~ddlanguage EQ @p_langu LEFT JOIN dd03t ON dd03t~tabname EQ dd03l~tabname AND dd03t~as4local EQ dd03l~as4local AND dd03t~fieldname EQ dd03l~fieldname AND dd03t~ddlanguage EQ @p_langu JOIN tadir ON tadir~obj_name EQ dd40l~typename. CLEAR lt_table. PERFORM get_struct_clause CHANGING lv_join lv_where. DATA(lv_from) = | dd40l | && | LEFT JOIN dd40t ON dd40t~typename EQ dd40l~typename | && | AND dd40t~as4local EQ dd40l~as4local | && | AND dd40t~ddlanguage EQ @p_langu | && | LEFT JOIN dd03l ON dd03l~tabname EQ dd40l~rowtype | && | AND dd03l~as4local EQ dd40l~as4local | && | AND dd03l~as4vers EQ @p_as4ver | && | LEFT JOIN dd02t ON dd02t~tabname EQ dd03l~tabname | && | AND dd02t~as4local EQ dd03l~as4local | && | AND dd02t~as4vers EQ dd03l~as4vers | && | AND dd02t~ddlanguage EQ @p_langu | && | LEFT JOIN dd03t ON dd03t~tabname EQ dd03l~tabname | && | AND dd03t~as4local EQ dd03l~as4local | && | AND dd03t~fieldname EQ dd03l~fieldname | && | AND dd03t~ddlanguage EQ @p_langu | && | LEFT JOIN dd04t ON dd04t~rollname EQ dd03l~rollname | && | AND dd04t~as4local EQ dd03l~as4local | && | AND dd04t~as4vers EQ dd03l~as4vers | && | AND dd04t~ddlanguage EQ @p_langu | && | JOIN tadir ON tadir~obj_name EQ dd40l~typename | && lv_join. lv_from = to_upper( lv_from ). lv_where = to_upper( lv_where ). SELECT dd40l~typename, dd40t~ddtext, dd40l~rowtype, tadir~devclass, dd03l~position, dd03l~fieldname, COALESCE( dd03t~ddtext, dd04t~ddtext ) AS fieldname_ddtext, dd03l~rollname, dd03l~domname, dd03l~datatype, dd03l~leng, dd03l~decimals UP TO @p_limit ROWS APPENDING TABLE @lt_table FROM (lv_from) WHERE dd40l~as4local EQ @p_as4loc AND dd40l~typename IN @s_tab_nm AND dd40l~rowtype IN @s_tab_rt AND dd40l~datatype IN @s_tab_dt AND dd40l~leng IN @s_tab_dl AND dd40l~decimals IN @s_tab_dc AND dd40t~ddtext IN @s_tab_tx AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls AND (lv_where). SORT lt_table BY typename position. PERFORM display USING lt_table. ENDFORM. FORM get_struct_clause CHANGING ev_from TYPE clike ev_where TYPE clike. DATA lr_fieldname TYPE RANGE OF dd03l-fieldname. DATA lr_rollname TYPE RANGE OF dd03l-rollname. DATA lr_datatype TYPE RANGE OF dd03l-datatype. DATA lr_leng TYPE RANGE OF dd03l-leng. DATA lr_decimals TYPE RANGE OF dd03l-decimals. DATA lv_position TYPE dd03l-position. CLEAR: ev_from, ev_where. DO 9 TIMES. lv_position = sy-index. PERFORM get_struct_param USING 'P_SCM_C' lv_position CHANGING lr_fieldname[]. PERFORM get_struct_param USING 'P_SCM_E' lv_position CHANGING lr_rollname[]. PERFORM get_struct_param USING 'P_SCM_T' lv_position CHANGING lr_datatype[]. PERFORM get_struct_param USING 'P_SCM_L' lv_position CHANGING lr_leng[]. PERFORM get_struct_param USING 'P_SCM_D' lv_position CHANGING lr_decimals[]. CHECK lr_fieldname IS NOT INITIAL OR lr_rollname IS NOT INITIAL OR lr_datatype IS NOT INITIAL OR lr_leng IS NOT INITIAL OR lr_decimals IS NOT INITIAL. DATA(lv_tab) = |dd03l_{ lv_position }|. DATA(lv_join) = | LEFT JOIN dd03l AS { lv_tab } | && | ON { lv_tab }~tabname EQ dd03l~tabname | && | AND { lv_tab }~as4local EQ dd03l~as4local | && | AND { lv_tab }~as4vers EQ dd03l~as4vers |. IF p_scm_so EQ abap_true. lv_join = lv_join && | AND { lv_tab }~POSITION EQ '{ lv_position }' |. ENDIF. ev_from = ev_from && lv_join. DATA(lt_range) = VALUE rsds_trange( ( tablename = lv_tab frange_t = VALUE rsds_frange_t( ( fieldname = lv_tab && '~FIELDNAME' selopt_t = CORRESPONDING #( lr_fieldname ) ) ( fieldname = lv_tab && '~ROLLNAME' selopt_t = CORRESPONDING #( lr_rollname ) ) ( fieldname = lv_tab && '~DATATYPE' selopt_t = CORRESPONDING #( lr_datatype ) ) ( fieldname = lv_tab && '~LENG' selopt_t = CORRESPONDING #( lr_leng ) ) ( fieldname = lv_tab && '~DECIMALS' selopt_t = CORRESPONDING #( lr_decimals ) ) ) ) ). DATA(lt_where) = VALUE rsds_twhere( ). CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE' EXPORTING field_ranges = lt_range IMPORTING where_clauses = lt_where. IF line_exists( lt_where[ tablename = lv_tab ] ). ev_where = ev_where && concat_lines_of( table = lt_where[ tablename = lv_tab ]-where_tab sep = | | ). ev_where = ev_where && | AND |. ENDIF. ENDDO. IF s_scm_cn[] IS NOT INITIAL. DATA(lv_min) = VALUE dd03l-position( ). DATA(lv_max) = VALUE dd03l-position( ). DO 999 TIMES. CHECK sy-index IN s_scm_cn. IF lv_min IS INITIAL. lv_min = sy-index. ENDIF. lv_max = sy-index + 1. ENDDO. ev_where = ev_where && | EXISTS ( | && | SELECT tabname | && | FROM dd03l AS dd03l_min | && | WHERE tabname EQ dd03l~tabname | && | AND as4local EQ dd03l~as4local | && | AND as4vers EQ dd03l~as4vers | && | AND position EQ '{ lv_min }' | && | ) AND |. ev_where = ev_where && | NOT EXISTS ( | && | SELECT tabname | && | FROM dd03l AS dd03l_max | && | WHERE tabname EQ dd03l~tabname | && | AND as4local EQ dd03l~as4local | && | AND as4vers EQ dd03l~as4vers | && | AND position EQ '{ lv_max }' | && | ) AND |. ENDIF. IF ev_where IS NOT INITIAL. ev_where = ev_where && | dd03l~tabname IS NOT NULL|. ENDIF. ENDFORM. FORM get_struct_param USING iv_name TYPE clike iv_num TYPE clike CHANGING et_range TYPE STANDARD TABLE. DATA(lv_num) = CONV i( iv_num ). CLEAR et_range[]. DATA(lv_name) = |{ iv_name }{ lv_num }|. ASSIGN (lv_name) TO FIELD-SYMBOL(). ASSERT sy-subrc EQ 0. CHECK IS NOT INITIAL. DATA(lv_option) = COND #( WHEN CA '+*' THEN rs_c_range_opt-pattern ELSE rs_c_range_opt-equal ). APPEND |{ rs_c_range_sign-including }{ lv_option }{ }| TO et_range. ENDFORM. FORM search_range_structure. CONSTANTS lc_object TYPE tadir-object VALUE 'TABL'. SELECT dd02l~tabname, dd02t~ddtext, tadir~devclass, dd03l_low~rollname, dd03l_low~domname, dd03l_low~datatype, dd03l_low~leng, dd03l_low~decimals UP TO @p_limit ROWS INTO TABLE @DATA(lt_table) FROM dd02l JOIN tadir ON tadir~obj_name EQ dd02l~tabname JOIN dd03l AS dd03l_sign ON dd03l_sign~tabname EQ dd02l~tabname AND dd03l_sign~as4local EQ dd02l~as4local AND dd03l_sign~as4vers EQ dd02l~as4vers AND dd03l_sign~position EQ '0001' JOIN dd03l AS dd03l_opt ON dd03l_opt~tabname EQ dd02l~tabname AND dd03l_opt~as4local EQ dd02l~as4local AND dd03l_opt~as4vers EQ dd02l~as4vers AND dd03l_opt~position EQ '0002' JOIN dd03l AS dd03l_low ON dd03l_low~tabname EQ dd02l~tabname AND dd03l_low~as4local EQ dd02l~as4local AND dd03l_low~as4vers EQ dd02l~as4vers AND dd03l_low~position EQ '0003' JOIN dd03l AS dd03l_high ON dd03l_high~tabname EQ dd02l~tabname AND dd03l_high~as4local EQ dd02l~as4local AND dd03l_high~as4vers EQ dd02l~as4vers AND dd03l_high~position EQ '0004' AND dd03l_high~rollname EQ dd03l_low~rollname AND dd03l_high~inttype EQ dd03l_low~inttype AND dd03l_high~intlen EQ dd03l_low~intlen AND dd03l_high~domname EQ dd03l_low~domname AND dd03l_high~datatype EQ dd03l_low~datatype AND dd03l_high~leng EQ dd03l_low~leng LEFT JOIN dd02t ON dd02t~tabname EQ dd02l~tabname AND dd02t~as4local EQ dd02l~as4local AND dd02t~as4vers EQ dd02l~as4vers AND dd02t~ddlanguage EQ @p_langu WHERE dd02l~as4local EQ @p_as4loc AND dd02l~as4vers EQ @p_as4ver AND dd02l~tabname IN @s_rgs_nm AND dd02t~ddtext IN @s_rgs_tx AND dd03l_sign~fieldname EQ 'SIGN' AND dd03l_sign~datatype EQ 'CHAR' AND dd03l_sign~leng EQ '000001' AND dd03l_opt~fieldname EQ 'OPTION' AND dd03l_opt~datatype EQ 'CHAR' AND dd03l_opt~leng EQ '000002' AND dd03l_low~fieldname EQ 'LOW' AND dd03l_high~fieldname EQ 'HIGH' AND dd03l_low~rollname IN @s_rng_en AND dd03l_low~domname IN @s_rng_dn AND dd03l_low~datatype IN @s_rng_dt AND dd03l_low~leng IN @s_rng_dl AND dd03l_low~decimals IN @s_rng_dc AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls AND NOT EXISTS ( SELECT tabname FROM dd03l WHERE tabname EQ dd02l~tabname AND as4local EQ dd02l~as4local AND as4vers EQ dd02l~as4vers AND position NOT IN ('0001', '0002', '0003', '0004') ). SORT lt_table BY tabname devclass. PERFORM display USING lt_table. ENDFORM. FORM search_range_table. CONSTANTS lc_object TYPE tadir-object VALUE 'TTYP'. SELECT dd40l~typename, dd40t~ddtext, tadir~devclass, dd40l~rowtype, dd03l_low~rollname, dd03l_low~domname, dd03l_low~datatype, dd03l_low~leng, dd03l_low~decimals UP TO @p_limit ROWS INTO TABLE @DATA(lt_table) FROM dd40l JOIN tadir ON tadir~obj_name EQ dd40l~typename JOIN dd02l ON dd02l~tabname EQ dd40l~rowtype AND dd02l~as4local EQ dd40l~as4local JOIN dd03l AS dd03l_sign ON dd03l_sign~tabname EQ dd02l~tabname AND dd03l_sign~as4local EQ dd02l~as4local AND dd03l_sign~as4vers EQ dd02l~as4vers AND dd03l_sign~position EQ '0001' JOIN dd03l AS dd03l_opt ON dd03l_opt~tabname EQ dd02l~tabname AND dd03l_opt~as4local EQ dd02l~as4local AND dd03l_opt~as4vers EQ dd02l~as4vers AND dd03l_opt~position EQ '0002' JOIN dd03l AS dd03l_low ON dd03l_low~tabname EQ dd02l~tabname AND dd03l_low~as4local EQ dd02l~as4local AND dd03l_low~as4vers EQ dd02l~as4vers AND dd03l_low~position EQ '0003' JOIN dd03l AS dd03l_high ON dd03l_high~tabname EQ dd02l~tabname AND dd03l_high~as4local EQ dd02l~as4local AND dd03l_high~as4vers EQ dd02l~as4vers AND dd03l_high~position EQ '0004' AND dd03l_high~rollname EQ dd03l_low~rollname AND dd03l_high~inttype EQ dd03l_low~inttype AND dd03l_high~intlen EQ dd03l_low~intlen AND dd03l_high~domname EQ dd03l_low~domname AND dd03l_high~datatype EQ dd03l_low~datatype AND dd03l_high~leng EQ dd03l_low~leng LEFT JOIN dd40t ON dd40t~typename EQ dd40l~typename AND dd40t~as4local EQ dd40l~as4local AND dd40t~ddlanguage EQ @p_langu WHERE dd40l~as4local EQ @p_as4loc AND dd40l~typename IN @s_rgt_nm AND dd02l~as4vers EQ @p_as4ver AND dd40t~ddtext IN @s_rgt_tx AND dd03l_sign~fieldname EQ 'SIGN' AND dd03l_sign~datatype EQ 'CHAR' AND dd03l_sign~leng EQ '000001' AND dd03l_opt~fieldname EQ 'OPTION' AND dd03l_opt~datatype EQ 'CHAR' AND dd03l_opt~leng EQ '000002' AND dd03l_low~fieldname EQ 'LOW' AND dd03l_high~fieldname EQ 'HIGH' AND dd03l_low~rollname IN @s_rng_en AND dd03l_low~domname IN @s_rng_dn AND dd03l_low~datatype IN @s_rng_dt AND dd03l_low~leng IN @s_rng_dl AND dd03l_low~decimals IN @s_rng_dc AND tadir~object EQ @lc_object AND tadir~devclass IN @s_devcls AND NOT EXISTS ( SELECT tabname FROM dd03l WHERE tabname EQ dd02l~tabname AND as4local EQ dd02l~as4local AND as4vers EQ dd02l~as4vers AND position NOT IN ('0001', '0002', '0003', '0004') ). SORT lt_table BY typename devclass rowtype. PERFORM display USING lt_table. ENDFORM. FORM display USING it_table TYPE STANDARD TABLE. STATICS lo_salv TYPE REF TO cl_salv_table. DATA(lv_lines) = lines( it_table ). IF lv_lines EQ p_limit. DELETE it_table INDEX p_limit. MESSAGE s016(es) WITH p_rows. "" Выбор ограничен до &1 совпадений. ELSE. MESSAGE s006(sv) WITH lv_lines. "" Число выбранных записей: &. ENDIF. TRY. CALL METHOD cl_salv_table=>factory IMPORTING r_salv_table = lo_salv CHANGING t_table = it_table. READ TABLE lo_salv->get_columns( )->get( ) INTO DATA(ls_key) INDEX 1. IF sy-subrc EQ 0. CAST cl_salv_column_list( ls_key-r_column )->set_key( abap_true ). ENDIF. LOOP AT lo_salv->get_columns( )->get( ) INTO DATA(ls_sort). lo_salv->get_sorts( )->add_sort( columnname = ls_sort-r_column->get_columnname( ) ). IF ls_sort-r_column->get_columnname( ) EQ 'DEVCLASS'. EXIT. ENDIF. ENDLOOP. lo_salv->get_columns( )->set_optimize( abap_true ). lo_salv->get_functions( )->set_all( abap_true ). lo_salv->get_display_settings( )->set_striped_pattern( abap_true ). lo_salv->display( ). CATCH cx_salv_msg INTO DATA(lx_salv). MESSAGE lx_salv TYPE rs_c_info DISPLAY LIKE rs_c_error. ENDTRY. ENDFORM. ",12247,False,2321.807762659509,median "CLASS z2mse_main_test DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. METHODS: setup, z2mse_test_initial_selection, z2mse_test_initial_selection2, specific_search, specific_search_program, specific_search_function. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS z2mse_main_test IMPLEMENTATION. METHOD setup. "" This is mandatory to decouple the separate unit tests z2mse_extr3=>clear_all( ). ENDMETHOD. METHOD specific_search. "" This test is a stub, it will probably be replaced by new tests DATA: mse_model_act TYPE z2mse_model=>lines_type. DATA: nothing_done_act TYPE abap_bool. DATA(initial_elements) = NEW z2mse_extr3_initial_elements( ). DATA(model_builder) = NEW z2mse_extr3_model_builder( ). DATA(element_manager) = NEW z2mse_extr3_element_manager( i_model_builder = model_builder i_exclude_found_sap_intf = abap_true ). model_builder->initialize( i_element_manager = element_manager i_dynamic_read = |Z2MSE_TEST_DYNAMIC_USAGE| ). initial_elements->select_specific( EXPORTING model_builder = model_builder element_manager = element_manager i_element_type_filter = z2mse_extr3_initial_elements=>select_class_method i_parent_name_filter = 'Z2MSE_TEST_CL_A' i_name_filter = 'EVENT_A' ). DATA(f_cut) = NEW z2mse_extract3( ). f_cut->extract( EXPORTING model_builder = model_builder element_manager = element_manager initial_elements = initial_elements i_search_up = 1 i_search_down = 1 i_exclude_found_sap_intf = abap_true IMPORTING mse_model = mse_model_act nothing_done = nothing_done_act ). DATA: fes_act TYPE z2mse_extr3_model_builder=>found_elements_type, fes_exp TYPE z2mse_extr3_model_builder=>found_elements_type. model_builder->write_found_elements( EXPORTING write = abap_false IMPORTING fes = fes_act ). fes_exp = VALUE #( ( where = |I| level = 0 alternate_level = 0 element_type = |ABAPClassEvent| parent_name = |Z2MSE_TEST_CL_A| name = |EVENT_A| specific = |X| ) ( where = |I| level = 1 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST_CL_A| name = |METHOD_A| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST_CL_A2| name = |METHOD_A| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST_CL_B1| name = |METHOD_A| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |BW-ODSO-Z2MSET001-CUBE-Z2MSET002| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST_FUNCTION_A| specific = |X| ) *( where = |S| level = 3 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |LZ2MSE_TEST_FGR_AF01| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |Z2MSE_TEST_PROGRAM_A| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |WebDynproController| parent_name = |Z2MSE_TEST_WDY_A| name = |COMPONENTCONTROLLER| specific = |X| ) *( where = |S| level = 2 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST_CL_B1| name = |METHOD_B| specific = |X| ) *( where = |S| level = 3 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST_CL_B2| name = |METHOD_A| specific = |X| ) *( where = |I| level = 4 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST_CL_A| name = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| specific = |X| ) ). SORT fes_act. SORT fes_exp. cl_abap_unit_assert=>assert_equals( msg = 'Expect correct list of found elements' exp = fes_exp act = fes_act ). DATA: equalized_harmonized_mse_act TYPE z2mse_mse_harmonize=>harmonized_mse, equalized_harmonized_mse_exp TYPE z2mse_mse_harmonize=>harmonized_mse. equalized_harmonized_mse_act = z2mse_mse_harmonize=>mse_2_harmonized( mse = mse_model_act ). equalized_harmonized_mse_exp = VALUE #( ). DATA maker TYPE REF TO z2mse_mse_harmonize_maker. maker = NEW #( ). maker->to_change = equalized_harmonized_mse_exp. maker->add_class( name = |Z2MSE_TEST_CL_A| parentpackage = || ). maker->add_attribute( attribute = |Z2MSE_TEST_IF_A_00000000000000~ATTRIBUTE_A_000000000000000000| ). maker->add_method( method = |CONSTRUCTOR| at_line = 11 ). maker->add_method( method = |EVENTHANDLER_A| at_line = 13 ). maker->add_method( method = |EVENT_A| at_line = 9 ). maker->add_method( method = |METHOD_A| at_line = 12 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |EVENT_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A2| used = |METHOD_A| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_B2| used = |METHOD_A| ). maker->add_class( name = |Z2MSE_TEST_CL_A2| parentpackage = || ). maker->add_method( method = |METHOD_A| at_line = 8 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_B| ). maker->add_class( name = |Z2MSE_TEST_CL_B1| parentpackage = || ). maker->add_method( method = |EVENT_A| at_line = 8 ). maker->add_attribute( attribute = |ATTRIBUTE_A| at_line = 13 ). maker->add_method( method = |METHOD_A| at_line = 10 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->add_method( method = |METHOD_B| at_line = 11 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->add_class( name = |Z2MSE_TEST_CL_B2| parentpackage = || ). maker->add_attribute( attribute = |Z2MSE_TEST_IF_A_00000000000000~ATTRIBUTE_A_000000000000000000| ). maker->add_method( method = |METHOD_A| at_line = 12 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->add_interface( name = |Z2MSE_TEST_IF_A_00000000000000| parentpackage = || ). maker->add_interface_method( method = |EVENT_A_0000000000000000000000| at_line = 7 ). maker->usage( used_group = |Z2MSE_TEST_CL_B2| used = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->add_interface_method( method = |METHOD_A_000000000000000000000| at_line = 9 ). maker->usage( used_group = |Z2MSE_TEST_CL_B2| used = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->add_interface_attribute( attribute = |ATTRIBUTE_A_000000000000000000| at_line = 5 ). maker->add_program( name = |Z2MSE_TEST_PROGRAM_A| parentpackage = || ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->usage( used_group = |FGR-Z2MSE_TEST_FGR_A| used = |F-Z2MSE_TEST_FUNCTION_A| ). maker->add_bw_transformation( bw_transformation = |BW-ODSO-Z2MSET001-CUBE-Z2MSET002| at_line = 123 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->add_function_group( name = |Z2MSE_TEST_FGR_A| parentpackage = || ). "" TBD Add Parentpackage maker->add_function( function = |Z2MSE_TEST_FUNCTION_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->add_function_group_include( include = |LZ2MSE_TEST_FGR_AF01| ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->add_web_dynpro_component( wda_name = |Z2MSE_TEST_WDY_A| parentpackage = || ). maker->add_web_dynpro_component_view( view = |COMPONENTCONTROLLER| ). maker->usage( used_group = 'Z2MSE_TEST_CL_A' used = |METHOD_A| ). maker->add_web_dynpro_component_view( view = |EMPTYVIEW| ). maker->add_web_dynpro_component_view( view = |V_MAIN| ). maker->add_web_dynpro_component_view( view = |W_MAIN| ). equalized_harmonized_mse_exp = maker->to_change. z2mse_mse_harmonize=>equalize_harmonized( CHANGING harmonized_mse = equalized_harmonized_mse_exp ). z2mse_mse_harmonize=>equalize_harmonized( CHANGING harmonized_mse = equalized_harmonized_mse_exp ). ENDMETHOD. METHOD specific_search_function. DATA: mse_model_act TYPE z2mse_model=>lines_type. DATA: nothing_done_act TYPE abap_bool. DATA(initial_elements) = NEW z2mse_extr3_initial_elements( ). DATA(model_builder) = NEW z2mse_extr3_model_builder( ). DATA(element_manager) = NEW z2mse_extr3_element_manager( i_model_builder = model_builder i_exclude_found_sap_intf = abap_true ). model_builder->initialize( i_element_manager = element_manager i_dynamic_read = |Z2MSE_TEST_DYNAMIC_USAGE| ). initial_elements->select_specific( EXPORTING model_builder = model_builder element_manager = element_manager i_element_type_filter = z2mse_extr3_initial_elements=>select_function i_parent_name_filter = '' i_name_filter = 'Z2MSE_TEST2_I_FUNCTION_A' ). DATA(f_cut) = NEW z2mse_extract3( ). f_cut->extract( EXPORTING model_builder = model_builder element_manager = element_manager initial_elements = initial_elements i_search_up = 2 i_search_down = 2 i_exclude_found_sap_intf = abap_true IMPORTING mse_model = mse_model_act nothing_done = nothing_done_act ). DATA: fes_act TYPE z2mse_extr3_model_builder=>found_elements_type, fes_exp TYPE z2mse_extr3_model_builder=>found_elements_type. model_builder->write_found_elements( EXPORTING write = abap_false IMPORTING fes = fes_act ). fes_exp = VALUE #( ( where = |S| level = -2 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_M2_FUNCTION_A| specific = |X| ) ( where = |S| level = -1 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_M1_FUNCTION_A| specific = |X| ) ( where = |I| level = 0 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_I_FUNCTION_A| specific = |X| ) ( where = |S| level = 1 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_P1_FUNCTION_A| specific = |X| ) ( where = |S| level = 2 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_P2_FUNCTION_A| specific = |X| ) ). SORT fes_act. SORT fes_exp. cl_abap_unit_assert=>assert_equals( msg = 'Expect correct list of found elements' exp = fes_exp act = fes_act ). DATA: equalized_harmonized_mse_act TYPE z2mse_mse_harmonize=>harmonized_mse, equalized_harmonized_mse_exp TYPE z2mse_mse_harmonize=>harmonized_mse. equalized_harmonized_mse_act = z2mse_mse_harmonize=>mse_2_harmonized( mse = mse_model_act ). equalized_harmonized_mse_exp = VALUE #( ). DATA maker TYPE REF TO z2mse_mse_harmonize_maker. maker = NEW #( ). maker->to_change = equalized_harmonized_mse_exp. maker->add_custom_source_language( |SAP| ). maker->add_package( package = |Z2MSE_TEST2_INITIAL| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_I_FGR_A| parentpackage = |Z2MSE_TEST2_INITIAL| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_I_FUNCTION_A| ). * "" This is to be found with the down search for functions * maker->add_package( package = |Z2MSE_TEST2_M1| ). * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_M1_FGR_A| parentpackage = |Z2MSE_TEST2_M1| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_M1_FUNCTION_A| ). * maker->usage( EXPORTING using_group = |FGR-Z2MSE_TEST2_I_FGR_A| using = |F-Z2MSE_TEST2_I_FUNCTION_A| used_group = |FGR-Z2MSE_TEST2_M1_FGR_A| used = |F-Z2MSE_TEST2_M1_FUNCTION_A| ). * "" This is now found with the up search for functions: * maker->add_package( package = |Z2MSE_TEST2_P1| ). * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_P1_FGR_A| parentpackage = |Z2MSE_TEST2_P1| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_P1_FUNCTION_A| ). maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_I_FGR_A| used = |F-Z2MSE_TEST2_I_FUNCTION_A| ). "" Test downsearch for programs * maker->add_program( EXPORTING name = |Z2MSE_TEST2_I_PROGRAM| * parentpackage = |Z2MSE_TEST2_INITIAL| ). "" Test function used by program is found * maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_M1_FGR_A| * used = |F-Z2MSE_TEST2_M1_FUNCTION_A| ). "" Test class used by program is found * maker->add_class( EXPORTING name = |Z2MSE_TEST2_M1_CL_A| * parentpackage = || ). ""Z2MSE_TEST2_M1 * maker->add_method( EXPORTING method = |STATIC_METHOD_A| * at_line = 7 ). * maker->usage( EXPORTING using_group = || * using = |Z2MSE_TEST2_I_PROGRAM| * used_group = |Z2MSE_TEST2_M1_CL_A| * used = |STATIC_METHOD_A| ). * "" Test function used by function is found in down search * maker->add_package( package = |Z2MSE_TEST2_M2| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_M2_FGR_A| parentpackage = |Z2MSE_TEST2_M2| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_M2_FUNCTION_A| ). maker->usage( EXPORTING using_group = |FGR-Z2MSE_TEST2_M1_FGR_A| using = |F-Z2MSE_TEST2_M1_FUNCTION_A| used_group = |FGR-Z2MSE_TEST2_M2_FGR_A| used = |F-Z2MSE_TEST2_M2_FUNCTION_A| ). * "" Test function used by function is found in up search * maker->add_package( package = |Z2MSE_TEST2_P2| ). * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_P2_FGR_A| parentpackage = |Z2MSE_TEST2_P2| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_P2_FUNCTION_A| ). maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_P1_FGR_A| used = |F-Z2MSE_TEST2_P1_FUNCTION_A| ). "" Test program that uses a program is found in up search * maker->add_program( EXPORTING name = |Z2MSE_TEST2_P1_PROGRAM| * parentpackage = |Z2MSE_TEST2_P1| ). * * maker->usage( EXPORTING used_group = || * used = |Z2MSE_TEST2_I_PROGRAM| ). equalized_harmonized_mse_exp = maker->to_change. z2mse_mse_harmonize=>equalize_harmonized( CHANGING harmonized_mse = equalized_harmonized_mse_exp ). cl_abap_unit_assert=>assert_equals( EXPORTING act = equalized_harmonized_mse_act exp = equalized_harmonized_mse_exp msg = 'Wrong mse file for new class' ). ENDMETHOD. METHOD specific_search_program. DATA: mse_model_act TYPE z2mse_model=>lines_type. DATA: nothing_done_act TYPE abap_bool. DATA(initial_elements) = NEW z2mse_extr3_initial_elements( ). DATA(model_builder) = NEW z2mse_extr3_model_builder( ). DATA(element_manager) = NEW z2mse_extr3_element_manager( i_model_builder = model_builder i_exclude_found_sap_intf = abap_true ). model_builder->initialize( i_element_manager = element_manager i_dynamic_read = |Z2MSE_TEST_DYNAMIC_USAGE| ). initial_elements->select_specific( EXPORTING model_builder = model_builder element_manager = element_manager i_element_type_filter = z2mse_extr3_initial_elements=>select_program i_parent_name_filter = '' i_name_filter = 'Z2MSE_TEST2_I_PROGRAM' ). DATA(f_cut) = NEW z2mse_extract3( ). f_cut->extract( EXPORTING model_builder = model_builder element_manager = element_manager initial_elements = initial_elements i_search_up = 2 i_search_down = 2 i_exclude_found_sap_intf = abap_true IMPORTING mse_model = mse_model_act nothing_done = nothing_done_act ). DATA: fes_act TYPE z2mse_extr3_model_builder=>found_elements_type, fes_exp TYPE z2mse_extr3_model_builder=>found_elements_type. model_builder->write_found_elements( EXPORTING write = abap_false IMPORTING fes = fes_act ). fes_exp = VALUE #( ( where = |S| level = -2 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_M2_FUNCTION_A| specific = |X| ) ( where = |S| level = -1 alternate_level = 0 element_type = |ABAPClassMethod| parent_name = |Z2MSE_TEST2_M1_CL_A| name = |STATIC_METHOD_A| specific = |X| ) ( where = |S| level = -1 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |F-Z2MSE_TEST2_M1_FUNCTION_A| specific = |X| ) ( where = |I| level = 0 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |Z2MSE_TEST2_I_PROGRAM| specific = |X| ) ( where = |S| level = 1 alternate_level = 0 element_type = |ABAPProgramOrFunctionOrSAPBW| parent_name = || name = |Z2MSE_TEST2_P1_PROGRAM| specific = |X| ) ). SORT fes_act. SORT fes_exp. cl_abap_unit_assert=>assert_equals( msg = 'Expect correct list of found elements' exp = fes_exp act = fes_act ). DATA: equalized_harmonized_mse_act TYPE z2mse_mse_harmonize=>harmonized_mse, equalized_harmonized_mse_exp TYPE z2mse_mse_harmonize=>harmonized_mse. equalized_harmonized_mse_act = z2mse_mse_harmonize=>mse_2_harmonized( mse = mse_model_act ). equalized_harmonized_mse_exp = VALUE #( ). DATA maker TYPE REF TO z2mse_mse_harmonize_maker. maker = NEW #( ). maker->to_change = equalized_harmonized_mse_exp. maker->add_custom_source_language( |SAP| ). maker->add_package( package = |Z2MSE_TEST2_INITIAL| ). * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_I_FGR_A| * parentpackage = |Z2MSE_TEST2_INITIAL| ). * * maker->add_function( EXPORTING function = |Z2MSE_TEST2_I_FUNCTION_A| ). * "" This is to be found with the down search for functions * maker->add_package( package = |Z2MSE_TEST2_M1| ). * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_M1_FGR_A| parentpackage = |Z2MSE_TEST2_M1| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_M1_FUNCTION_A| ). * * maker->usage( EXPORTING using_group = |FGR-Z2MSE_TEST2_I_FGR_A| * using = |F-Z2MSE_TEST2_I_FUNCTION_A| * used_group = |FGR-Z2MSE_TEST2_M1_FGR_A| * used = |F-Z2MSE_TEST2_M1_FUNCTION_A| ). * "" This is now found with the up search for functions: * maker->add_package( package = |Z2MSE_TEST2_P1| ). * * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_P1_FGR_A| * parentpackage = |Z2MSE_TEST2_P1| ). * * maker->add_function( EXPORTING function = |Z2MSE_TEST2_P1_FUNCTION_A| ). * * maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_I_FGR_A| * used = |F-Z2MSE_TEST2_I_FUNCTION_A| ). "" Test downsearch for programs maker->add_program( EXPORTING name = |Z2MSE_TEST2_I_PROGRAM| parentpackage = |Z2MSE_TEST2_INITIAL| ). "" Test function used by program is found maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_M1_FGR_A| used = |F-Z2MSE_TEST2_M1_FUNCTION_A| ). "" Test class used by program is found maker->add_class( EXPORTING name = |Z2MSE_TEST2_M1_CL_A| parentpackage = |Z2MSE_TEST2_M1| ). "" maker->add_method( EXPORTING method = |STATIC_METHOD_A| at_line = 7 ). maker->usage( EXPORTING using_group = || using = |Z2MSE_TEST2_I_PROGRAM| used_group = |Z2MSE_TEST2_M1_CL_A| used = |STATIC_METHOD_A| ). * "" Test function used by function is found in down search * maker->add_package( package = |Z2MSE_TEST2_M2| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_M2_FGR_A| parentpackage = |Z2MSE_TEST2_M2| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_M2_FUNCTION_A| ). maker->usage( EXPORTING using_group = |FGR-Z2MSE_TEST2_M1_FGR_A| using = |F-Z2MSE_TEST2_M1_FUNCTION_A| used_group = |FGR-Z2MSE_TEST2_M2_FGR_A| used = |F-Z2MSE_TEST2_M2_FUNCTION_A| ). * "" Test function used by function is found in up search * * maker->add_package( package = |Z2MSE_TEST2_P2| ). * * maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_P2_FGR_A| * parentpackage = |Z2MSE_TEST2_P2| ). * * maker->add_function( EXPORTING function = |Z2MSE_TEST2_P2_FUNCTION_A| ). * * maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_P1_FGR_A| * used = |F-Z2MSE_TEST2_P1_FUNCTION_A| ). "" Test program that uses a program is found in up search maker->add_program( EXPORTING name = |Z2MSE_TEST2_P1_PROGRAM| parentpackage = |Z2MSE_TEST2_P1| ). maker->usage( EXPORTING used_group = || used = |Z2MSE_TEST2_I_PROGRAM| ). equalized_harmonized_mse_exp = maker->to_change. z2mse_mse_harmonize=>equalize_harmonized( CHANGING harmonized_mse = equalized_harmonized_mse_exp ). cl_abap_unit_assert=>assert_equals( EXPORTING act = equalized_harmonized_mse_act exp = equalized_harmonized_mse_exp msg = 'Wrong mse file for new class' ). ENDMETHOD. METHOD z2mse_test_initial_selection. DATA: mse_model_act TYPE z2mse_model=>lines_type. DATA: nothing_done_act TYPE abap_bool. DATA(top_packages) = VALUE z2mse_extr3_initial_elements=>ty_s_pack( ( sign = 'I' option = 'EQ' low = 'Z2MSE_TEST_INITIAL_SELECTION' ) ). DATA(sub_packages_filter) = VALUE z2mse_extr3_initial_elements=>ty_s_pack( ). DATA(initial_elements) = NEW z2mse_extr3_initial_elements( ). initial_elements->select_packages( EXPORTING top_packages = top_packages sub_packages_filter = sub_packages_filter including_sub_packages = abap_true ). DATA(model_builder) = NEW z2mse_extr3_model_builder( ). DATA(element_manager) = NEW z2mse_extr3_element_manager( i_model_builder = model_builder i_exclude_found_sap_intf = abap_true ). model_builder->initialize( i_element_manager = element_manager i_dynamic_read = |Z2MSE_TEST_DYNAMIC_USAGE| ). DATA(f_cut) = NEW z2mse_extract3( ). f_cut->extract( EXPORTING model_builder = model_builder element_manager = element_manager initial_elements = initial_elements i_search_up = -1 i_search_down = 2 i_exclude_found_sap_intf = abap_true IMPORTING mse_model = mse_model_act nothing_done = nothing_done_act ). DATA: equalized_harmonized_mse_act TYPE z2mse_mse_harmonize=>harmonized_mse, equalized_harmonized_mse_exp TYPE z2mse_mse_harmonize=>harmonized_mse. equalized_harmonized_mse_act = z2mse_mse_harmonize=>mse_2_harmonized( mse = mse_model_act ). equalized_harmonized_mse_exp = VALUE #( ). DATA maker TYPE REF TO z2mse_mse_harmonize_maker. maker = NEW #( ). maker->to_change = equalized_harmonized_mse_exp. maker->add_custom_source_language( |SAP| ). maker->add_package( package = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_package( package = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_db_table( name = |Z2MSE_TEST_A| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_db_table( name = |Z2MSE_TEST_DB_B| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_class( name = |Z2MSE_TEST_CL_A| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_attribute( attribute = |Z2MSE_TEST_IF_A_00000000000000~ATTRIBUTE_A_000000000000000000| ). maker->add_method( method = |CONSTRUCTOR| at_line = 11 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |EVENTHANDLER_A| ). maker->add_method( method = |EVENTHANDLER_A| at_line = 13 ). maker->add_method( method = |EVENT_A| at_line = 9 ). maker->add_method( method = |METHOD_A| at_line = 12 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |EVENT_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A2| used = |METHOD_A| ). maker->access( used_group = |Z2MSE_TEST_A| used = |Z2MSE_TEST_A| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_B2| used = |METHOD_A| ). maker->add_class( name = |Z2MSE_TEST_CL_A2| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_method( method = |METHOD_A| at_line = 8 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_B| ). maker->add_class( name = |Z2MSE_TEST_CL_A3| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_method( method = |METHOD_A| at_line = 9 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->access( used = |Z2MSE_TEST_DB_B| ). maker->add_class( name = |Z2MSE_TEST_CL_B1| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_method( method = |EVENT_A| at_line = 8 ). maker->add_attribute( attribute = |ATTRIBUTE_A| at_line = 13 ). maker->add_method( method = |METHOD_A| at_line = 10 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |CONSTRUCTOR| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_IF_A_00000000000000| used = |METHOD_A_000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->access( used = |Z2MSE_TEST_A| ). maker->access( used_group = |Z2MSE_TEST_IF_A_00000000000000| used = |ATTRIBUTE_A_000000000000000000| ). maker->access( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~ATTRIBUTE_A_000000000000000000| ). maker->add_method( method = |METHOD_B| at_line = 11 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |CONSTRUCTOR| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->add_class( name = |Z2MSE_TEST_CL_B2| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_attribute( attribute = |Z2MSE_TEST_IF_A_00000000000000~ATTRIBUTE_A_000000000000000000| ). maker->add_method( method = |METHOD_A| at_line = 12 ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->add_method( method = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->add_interface( name = |Z2MSE_TEST_IF_A_00000000000000| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_interface_method( method = |EVENT_A_0000000000000000000000| at_line = 7 ). maker->usage( used_group = |Z2MSE_TEST_CL_B2| used = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~EVENT_A_0000000000000000000000| ). maker->add_interface_method( method = |METHOD_A_000000000000000000000| at_line = 9 ). maker->usage( used_group = |Z2MSE_TEST_CL_B2| used = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |Z2MSE_TEST_IF_A_00000000000000~METHOD_A_000000000000000000000| ). maker->add_interface_attribute( attribute = |ATTRIBUTE_A_000000000000000000| at_line = 5 ). maker->add_interface( name = |ZIWCI_2MSE_TEST_WDY_A| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_interface_method( method = |WD_GET_API| at_line = 17 ). maker->add_web_dynpro_component( wda_name = |Z2MSE_TEST_WDY_A| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_web_dynpro_component_view( view = |COMPONENTCONTROLLER| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |CONSTRUCTOR| ). maker->usage( used_group = |ZIWCI_2MSE_TEST_WDY_A| used = |WD_GET_API| ). maker->access( used = |Z2MSE_TEST_A| ). maker->add_web_dynpro_component_view( view = |EMPTYVIEW| ). maker->add_web_dynpro_component_view( view = |V_MAIN| ). maker->add_web_dynpro_component_view( view = |W_MAIN| ). maker->add_program( name = |Z2MSE_TEST_PROGRAM_A| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). maker->access( used_group = |Z2MSE_TEST_CL_B1| used = |ATTRIBUTE_A| ). maker->access( used = |Z2MSE_TEST_DB_B| ). maker->usage( used = |Z2MSE_TEST_PROGRAM_B| ). maker->usage( used = |Z2MSE_TEST_PROGRAM_C| ). maker->usage( used = |Z2MSE_TEST_INCLUDE_A| ). maker->usage( used_group = |FGR-Z2MSE_TEST_FGR_A| used = |F-Z2MSE_TEST_FUNCTION_A| ). maker->usage( used_group = |FGR-Z2MSE_TEST_FGR_B| used = |F-Z2MSE_TEST_FUNCTION_B| ). maker->add_program( name = |Z2MSE_TEST_PROGRAM_B| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_program( name = |Z2MSE_TEST_PROGRAM_C| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->usage( used = |Z2MSE_TEST_PROGRAM_D| ). maker->add_program( name = |Z2MSE_TEST_PROGRAM_D| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_program( name = |Z2MSE_TEST_INCLUDE_A| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_function_group( name = |Z2MSE_TEST_FGR_B| parentpackage = |Z2MSE_TEST_NO_INITIAL_SELECTN| ). maker->add_function( function = |Z2MSE_TEST_FUNCTION_B| ). maker->add_bw_transformation( bw_transformation = |BW-ODSO-Z2MSET001-CUBE-Z2MSET002| at_line = 123 ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |CONSTRUCTOR| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->add_function_group( name = |Z2MSE_TEST_FGR_A| parentpackage = |Z2MSE_TEST_INITIAL_SELECTION| ). maker->add_function( function = |Z2MSE_TEST_FUNCTION_A| ). maker->usage( used_group = |Z2MSE_TEST_CL_A| used = |METHOD_A| ). maker->usage( used_group = |FGR-Z2MSE_TEST_FGR_B| used = |F-Z2MSE_TEST_FUNCTION_B| ). maker->add_function_group_include( include = |LZ2MSE_TEST_FGR_AF01| ). maker->usage( used_group = |Z2MSE_TEST_CL_B1| used = |METHOD_A| ). equalized_harmonized_mse_exp = maker->to_change. z2mse_mse_harmonize=>equalize_harmonized( CHANGING harmonized_mse = equalized_harmonized_mse_exp ). cl_abap_unit_assert=>assert_equals( EXPORTING act = equalized_harmonized_mse_act exp = equalized_harmonized_mse_exp msg = 'Wrong mse file for new class' ). ENDMETHOD. METHOD z2mse_test_initial_selection2. DATA: mse_model_act TYPE z2mse_model=>lines_type. DATA: nothing_done_act TYPE abap_bool. DATA(top_packages) = VALUE z2mse_extr3_initial_elements=>ty_s_pack( ( sign = 'I' option = 'EQ' low = 'Z2MSE_TEST2_INITIAL' ) ). DATA(sub_packages_filter) = VALUE z2mse_extr3_initial_elements=>ty_s_pack( ). DATA(initial_elements) = NEW z2mse_extr3_initial_elements( ). initial_elements->select_packages( EXPORTING top_packages = top_packages sub_packages_filter = sub_packages_filter including_sub_packages = abap_true ). DATA(model_builder) = NEW z2mse_extr3_model_builder( ). DATA(element_manager) = NEW z2mse_extr3_element_manager( i_model_builder = model_builder i_exclude_found_sap_intf = abap_true ). model_builder->initialize( i_element_manager = element_manager i_dynamic_read = |Z2MSE_TEST_DYNAMIC_USAGE| ). DATA(f_cut) = NEW z2mse_extract3( ). f_cut->extract( EXPORTING model_builder = model_builder element_manager = element_manager initial_elements = initial_elements i_search_up = 2 "" There are elements 3 layers up, these are not to be found here i_search_down = 2 "" There are elements 3 layers down, these are not to be found here i_exclude_found_sap_intf = abap_true IMPORTING mse_model = mse_model_act nothing_done = nothing_done_act ). DATA: equalized_harmonized_mse_act TYPE z2mse_mse_harmonize=>harmonized_mse, equalized_harmonized_mse_exp TYPE z2mse_mse_harmonize=>harmonized_mse. equalized_harmonized_mse_act = z2mse_mse_harmonize=>mse_2_harmonized( mse = mse_model_act ). equalized_harmonized_mse_exp = VALUE #( ). DATA maker TYPE REF TO z2mse_mse_harmonize_maker. maker = NEW #( ). maker->to_change = equalized_harmonized_mse_exp. maker->add_custom_source_language( |SAP| ). maker->add_package( package = |Z2MSE_TEST2_INITIAL| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_I_FGR_A| parentpackage = |Z2MSE_TEST2_INITIAL| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_I_FUNCTION_A| ). "" This is to be found with the down search for functions maker->add_package( package = |Z2MSE_TEST2_M1| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_M1_FGR_A| parentpackage = |Z2MSE_TEST2_M1| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_M1_FUNCTION_A| ). maker->usage( EXPORTING using_group = |FGR-Z2MSE_TEST2_I_FGR_A| using = |F-Z2MSE_TEST2_I_FUNCTION_A| used_group = |FGR-Z2MSE_TEST2_M1_FGR_A| used = |F-Z2MSE_TEST2_M1_FUNCTION_A| ). "" This is now found with the up search for functions: maker->add_package( package = |Z2MSE_TEST2_P1| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_P1_FGR_A| parentpackage = |Z2MSE_TEST2_P1| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_P1_FUNCTION_A| ). maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_I_FGR_A| used = |F-Z2MSE_TEST2_I_FUNCTION_A| ). "" Test downsearch for programs maker->add_program( EXPORTING name = |Z2MSE_TEST2_I_PROGRAM| parentpackage = |Z2MSE_TEST2_INITIAL| ). "" Test function used by program is found maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_M1_FGR_A| used = |F-Z2MSE_TEST2_M1_FUNCTION_A| ). "" Test class used by program is found maker->add_class( EXPORTING name = |Z2MSE_TEST2_M1_CL_A| parentpackage = |Z2MSE_TEST2_M1| ). maker->add_method( EXPORTING method = |STATIC_METHOD_A| at_line = 7 ). maker->usage( EXPORTING using_group = || using = |Z2MSE_TEST2_I_PROGRAM| used_group = |Z2MSE_TEST2_M1_CL_A| used = |STATIC_METHOD_A| ). "" Test function used by function is found in down search maker->add_package( package = |Z2MSE_TEST2_M2| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_M2_FGR_A| parentpackage = |Z2MSE_TEST2_M2| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_M2_FUNCTION_A| ). maker->usage( EXPORTING using_group = |FGR-Z2MSE_TEST2_M1_FGR_A| using = |F-Z2MSE_TEST2_M1_FUNCTION_A| used_group = |FGR-Z2MSE_TEST2_M2_FGR_A| used = |F-Z2MSE_TEST2_M2_FUNCTION_A| ). "" Test function used by function is found in up search maker->add_package( package = |Z2MSE_TEST2_P2| ). maker->add_function_group( EXPORTING name = |Z2MSE_TEST2_P2_FGR_A| parentpackage = |Z2MSE_TEST2_P2| ). maker->add_function( EXPORTING function = |Z2MSE_TEST2_P2_FUNCTION_A| ). maker->usage( EXPORTING used_group = |FGR-Z2MSE_TEST2_P1_FGR_A| used = |F-Z2MSE_TEST2_P1_FUNCTION_A| ). "" Test program that uses a program is found in up search maker->add_program( EXPORTING name = |Z2MSE_TEST2_P1_PROGRAM| parentpackage = |Z2MSE_TEST2_P1| ). maker->usage( EXPORTING used_group = || used = |Z2MSE_TEST2_I_PROGRAM| ). equalized_harmonized_mse_exp = maker->to_change. z2mse_mse_harmonize=>equalize_harmonized( CHANGING harmonized_mse = equalized_harmonized_mse_exp ). cl_abap_unit_assert=>assert_equals( EXPORTING act = equalized_harmonized_mse_act exp = equalized_harmonized_mse_exp msg = 'Wrong mse file' ). ENDMETHOD. ENDCLASS. ",12457,True,3192.7173997384753,median "*&---------------------------------------------------------------------* *& Report ZANGRY_BIRDS *& Just for fun *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zangry_birds. DATA: lo_excel TYPE REF TO zcl_excel, lo_excel_writer TYPE REF TO zif_excel_writer, lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_border_light TYPE REF TO zcl_excel_style_border, lo_style_color0 TYPE REF TO zcl_excel_style, lo_style_color1 TYPE REF TO zcl_excel_style, lo_style_color2 TYPE REF TO zcl_excel_style, lo_style_color3 TYPE REF TO zcl_excel_style, lo_style_color4 TYPE REF TO zcl_excel_style, lo_style_color5 TYPE REF TO zcl_excel_style, lo_style_color6 TYPE REF TO zcl_excel_style, lo_style_color7 TYPE REF TO zcl_excel_style, lo_style_credit TYPE REF TO zcl_excel_style, lo_style_link TYPE REF TO zcl_excel_style, lo_column TYPE REF TO zcl_excel_column, lo_row TYPE REF TO zcl_excel_row, lo_hyperlink TYPE REF TO zcl_excel_hyperlink. DATA: lv_style_color0_guid TYPE zexcel_cell_style, lv_style_color1_guid TYPE zexcel_cell_style, lv_style_color2_guid TYPE zexcel_cell_style, lv_style_color3_guid TYPE zexcel_cell_style, lv_style_color4_guid TYPE zexcel_cell_style, lv_style_color5_guid TYPE zexcel_cell_style, lv_style_color6_guid TYPE zexcel_cell_style, lv_style_color7_guid TYPE zexcel_cell_style, lv_style_credit_guid TYPE zexcel_cell_style, lv_style_link_guid TYPE zexcel_cell_style. DATA: lv_col_str TYPE zexcel_cell_column_alpha, lv_row TYPE i, lv_col TYPE i, lt_mapper TYPE TABLE OF zexcel_cell_style, ls_mapper TYPE zexcel_cell_style. DATA: lv_file TYPE xstring, lv_bytecount TYPE i, lt_file_tab TYPE solix_tab. DATA: lv_full_path TYPE string, lv_workdir TYPE string, lv_file_separator TYPE c. CONSTANTS: lv_default_file_name TYPE string VALUE 'angry_birds.xlsx'. PARAMETERS: p_path TYPE zexcel_export_dir. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path. lv_workdir = p_path. cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir CHANGING selected_folder = lv_workdir ). p_path = lv_workdir. INITIALIZATION. cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ). cl_gui_cfw=>flush( ). p_path = lv_workdir. START-OF-SELECTION. IF p_path IS INITIAL. p_path = lv_workdir. ENDIF. cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ). CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path. "" Creates active sheet CREATE OBJECT lo_excel. CREATE OBJECT lo_border_light. lo_border_light->border_color-rgb = zcl_excel_style_color=>c_white. lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. "" Create color white lo_style_color0 = lo_excel->add_new_style( ). lo_style_color0->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color0->fill->fgcolor-rgb = 'FFFFFFFF'. lo_style_color0->borders->allborders = lo_border_light. lv_style_color0_guid = lo_style_color0->get_guid( ). "" Create color black lo_style_color1 = lo_excel->add_new_style( ). lo_style_color1->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color1->fill->fgcolor-rgb = 'FF252525'. lo_style_color1->borders->allborders = lo_border_light. lv_style_color1_guid = lo_style_color1->get_guid( ). "" Create color dark green lo_style_color2 = lo_excel->add_new_style( ). lo_style_color2->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color2->fill->fgcolor-rgb = 'FF75913A'. lo_style_color2->borders->allborders = lo_border_light. lv_style_color2_guid = lo_style_color2->get_guid( ). "" Create color light green lo_style_color3 = lo_excel->add_new_style( ). lo_style_color3->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color3->fill->fgcolor-rgb = 'FF9DFB73'. lo_style_color3->borders->allborders = lo_border_light. lv_style_color3_guid = lo_style_color3->get_guid( ). "" Create color green lo_style_color4 = lo_excel->add_new_style( ). lo_style_color4->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color4->fill->fgcolor-rgb = 'FF92CF56'. lo_style_color4->borders->allborders = lo_border_light. lv_style_color4_guid = lo_style_color4->get_guid( ). "" Create color 2dark green lo_style_color5 = lo_excel->add_new_style( ). lo_style_color5->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color5->fill->fgcolor-rgb = 'FF506228'. lo_style_color5->borders->allborders = lo_border_light. lv_style_color5_guid = lo_style_color5->get_guid( ). "" Create color yellow lo_style_color6 = lo_excel->add_new_style( ). lo_style_color6->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color6->fill->fgcolor-rgb = 'FFC3E224'. lo_style_color6->borders->allborders = lo_border_light. lv_style_color6_guid = lo_style_color6->get_guid( ). "" Create color yellow lo_style_color7 = lo_excel->add_new_style( ). lo_style_color7->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color7->fill->fgcolor-rgb = 'FFB3C14F'. lo_style_color7->borders->allborders = lo_border_light. lv_style_color7_guid = lo_style_color7->get_guid( ). "" Credits lo_style_credit = lo_excel->add_new_style( ). lo_style_credit->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. lo_style_credit->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. lo_style_credit->font->size = 20. lv_style_credit_guid = lo_style_credit->get_guid( ). "" Link lo_style_link = lo_excel->add_new_style( ). lo_style_link->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. lo_style_link->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. * lo_style_link->font->size = 20. lv_style_link_guid = lo_style_link->get_guid( ). "" Create image map "" line 2 DO 30 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 3 DO 28 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 4 DO 27 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 5 DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 15 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 6 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 7 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 8 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 9 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 10 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 11 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 12 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 13 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 14 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 12 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 15 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 16 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 17 DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 13 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 18 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 19 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 27 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 20 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 21 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 19 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 22 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 23 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 24 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 25 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 26 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 27 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 28 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 29 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 30 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 31 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 32 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 33 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 34 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 35 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 36 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 37 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 38 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 39 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 22 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 40 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 41 DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 15 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 42 DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 43 DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 7 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 44 DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 45 DO 16 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 13 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 46 DO 18 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" Get active sheet lo_worksheet = lo_excel->get_active_worksheet( ). lo_worksheet->set_title( ip_title = 'Angry Birds' ). lv_row = 1. lv_col = 1. LOOP AT lt_mapper INTO ls_mapper. lv_col_str = zcl_excel_common=>convert_column2alpha( lv_col ). IF ls_mapper IS INITIAL. lo_row = lo_worksheet->get_row( ip_row = lv_row ). lo_row->set_row_height( ip_row_height = 8 ). lv_col = 1. lv_row = lv_row + 1. CONTINUE. ENDIF. lo_worksheet->set_cell( ip_column = lv_col_str ip_row = lv_row ip_value = space ip_style = ls_mapper ). lv_col = lv_col + 1. lo_column = lo_worksheet->get_column( ip_column = lv_col_str ). lo_column->set_width( ip_width = 2 ). ENDLOOP. lo_worksheet->set_show_gridlines( i_show_gridlines = abap_false ). lo_worksheet->set_cell( ip_column = 'AP' ip_row = 15 ip_value = 'Created with abap2xlsx' ip_style = lv_style_credit_guid ). lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'https://abap2xlsx.github.io/abap2xlsx' ). lo_worksheet->set_cell( ip_column = 'AP' ip_row = 24 ip_value = 'https://abap2xlsx.github.io/abap2xlsx' ip_style = lv_style_link_guid ip_hyperlink = lo_hyperlink ). lo_column = lo_worksheet->get_column( ip_column = 'AP' ). lo_column->set_auto_size( ip_auto_size = abap_true ). lo_worksheet->set_merge( ip_row = 15 ip_column_start = 'AP' ip_row_to = 22 ip_column_end = 'AR' ). lo_worksheet->set_merge( ip_row = 24 ip_column_start = 'AP' ip_row_to = 26 ip_column_end = 'AR' ). CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. lv_file = lo_excel_writer->write_file( lo_excel ). "" Convert to binary CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = lv_file IMPORTING output_length = lv_bytecount TABLES binary_tab = lt_file_tab. * "" This method is only available on AS ABAP > 6.40 * lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ). * lv_bytecount = xstrlen( lv_file ). "" Save the file cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount filename = lv_full_path filetype = 'BIN' CHANGING data_tab = lt_file_tab ). ",13074,True,4571.246761690209,median "CLASS zcl_excel_drawing DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. *""* public components of class ZCL_EXCEL_DRAWING *""* do not include other source files here!!! *""* protected components of class ZCL_EXCEL_DRAWING *""* do not include other source files here!!! *""* protected components of class ZCL_EXCEL_DRAWING *""* do not include other source files here!!! *""* protected components of class ZCL_EXCEL_DRAWING *""* do not include other source files here!!! TYPE-POOLS abap . CONSTANTS c_graph_pie TYPE zexcel_graph_type VALUE 1. ""#EC NOTEXT CONSTANTS c_graph_line TYPE zexcel_graph_type VALUE 2. ""#EC NOTEXT CONSTANTS c_graph_bars TYPE zexcel_graph_type VALUE 0. ""#EC NOTEXT DATA graph_type TYPE zexcel_graph_type . DATA title TYPE string VALUE 'image1.jpg'. ""#EC NOTEXT CONSTANTS type_image TYPE zexcel_drawing_type VALUE 'image'. ""#EC NOTEXT CONSTANTS type_chart TYPE zexcel_drawing_type VALUE 'chart'. ""#EC NOTEXT CONSTANTS anchor_absolute TYPE zexcel_drawing_anchor VALUE 'ABS'. ""#EC NOTEXT CONSTANTS anchor_one_cell TYPE zexcel_drawing_anchor VALUE 'ONE'. ""#EC NOTEXT CONSTANTS anchor_two_cell TYPE zexcel_drawing_anchor VALUE 'TWO'. ""#EC NOTEXT DATA graph TYPE REF TO zcl_excel_graph . CONSTANTS c_media_type_bmp TYPE string VALUE 'bmp'. ""#EC NOTEXT CONSTANTS c_media_type_xml TYPE string VALUE 'xml'. ""#EC NOTEXT CONSTANTS c_media_type_jpg TYPE string VALUE 'jpg'. ""#EC NOTEXT CONSTANTS type_image_header_footer TYPE zexcel_drawing_type VALUE 'hd_ft'. ""#EC NOTEXT METHODS constructor IMPORTING !ip_type TYPE zexcel_drawing_type DEFAULT zcl_excel_drawing=>type_image !ip_title TYPE clike OPTIONAL . METHODS create_media_name IMPORTING !ip_index TYPE i . METHODS get_from_col RETURNING VALUE(r_from_col) TYPE zexcel_cell_column . METHODS get_from_row RETURNING VALUE(r_from_row) TYPE zexcel_cell_row . METHODS get_guid RETURNING VALUE(ep_guid) TYPE guid_16 . METHODS get_height_emu_str RETURNING VALUE(r_height) TYPE string . METHODS get_media RETURNING VALUE(r_media) TYPE xstring . METHODS get_media_name RETURNING VALUE(r_name) TYPE string . METHODS get_media_type RETURNING VALUE(r_type) TYPE string . METHODS get_name RETURNING VALUE(r_name) TYPE string . METHODS get_to_col RETURNING VALUE(r_to_col) TYPE zexcel_cell_column . METHODS get_to_row RETURNING VALUE(r_to_row) TYPE zexcel_cell_row . METHODS get_width_emu_str RETURNING VALUE(r_width) TYPE string . CLASS-METHODS pixel2emu IMPORTING !ip_pixel TYPE int4 !ip_dpi TYPE int2 OPTIONAL RETURNING VALUE(r_emu) TYPE string . CLASS-METHODS emu2pixel IMPORTING !ip_emu TYPE int4 !ip_dpi TYPE int2 OPTIONAL RETURNING VALUE(r_pixel) TYPE int4 . METHODS set_media IMPORTING !ip_media TYPE xstring OPTIONAL !ip_media_type TYPE string !ip_width TYPE int4 DEFAULT 0 !ip_height TYPE int4 DEFAULT 0 . METHODS set_media_mime IMPORTING !ip_io TYPE skwf_io !ip_width TYPE int4 !ip_height TYPE int4 . METHODS set_media_www IMPORTING !ip_key TYPE wwwdatatab !ip_width TYPE int4 !ip_height TYPE int4 . METHODS set_position IMPORTING !ip_from_row TYPE zexcel_cell_row !ip_from_col TYPE zexcel_cell_column_alpha !ip_rowoff TYPE int4 OPTIONAL !ip_coloff TYPE int4 OPTIONAL RAISING zcx_excel . METHODS set_position2 IMPORTING !ip_from TYPE zexcel_drawing_location !ip_to TYPE zexcel_drawing_location !ip_anchor TYPE zexcel_drawing_anchor OPTIONAL . METHODS get_position RETURNING VALUE(rp_position) TYPE zexcel_drawing_position . METHODS get_type RETURNING VALUE(rp_type) TYPE zexcel_drawing_type . METHODS get_index RETURNING VALUE(rp_index) TYPE string . METHODS load_chart_attributes IMPORTING VALUE(ip_chart) TYPE REF TO if_ixml_document . PROTECTED SECTION. PRIVATE SECTION. *""* private components of class ZCL_EXCEL_DRAWING *""* do not include other source files here!!! DATA type TYPE zexcel_drawing_type VALUE type_image. ""#EC NOTEXT . . . . . . . . . . . "" . DATA index TYPE string . DATA anchor TYPE zexcel_drawing_anchor VALUE anchor_one_cell. ""#EC NOTEXT . . . . . . . . . . . "" . CONSTANTS c_media_source_www TYPE c VALUE 1. ""#EC NOTEXT CONSTANTS c_media_source_xstring TYPE c VALUE 0. ""#EC NOTEXT CONSTANTS c_media_source_mime TYPE c VALUE 2. ""#EC NOTEXT DATA guid TYPE guid_16 . DATA media TYPE xstring . DATA media_key_www TYPE wwwdatatab . DATA media_name TYPE string . DATA media_source TYPE c . DATA media_type TYPE string . DATA io TYPE skwf_io . DATA from_loc TYPE zexcel_drawing_location . DATA to_loc TYPE zexcel_drawing_location . DATA size TYPE zexcel_drawing_size . ENDCLASS. CLASS zcl_excel_drawing IMPLEMENTATION. METHOD constructor. me->guid = zcl_excel_obsolete_func_wrap=>guid_create( ). "" ins issue #379 - replacement for outdated function call IF ip_title IS NOT INITIAL. title = ip_title. ELSE. title = me->guid. ENDIF. me->type = ip_type. * inizialize dimension range anchor = anchor_one_cell. from_loc-col = 1. from_loc-row = 1. ENDMETHOD. METHOD create_media_name. * if media name is initial, create unique name CHECK media_name IS INITIAL. index = ip_index. CONCATENATE me->type index INTO media_name. CONDENSE media_name NO-GAPS. ENDMETHOD. METHOD emu2pixel. * suppose 96 DPI IF ip_dpi IS SUPPLIED. r_pixel = ip_emu * ip_dpi / 914400. ELSE. * suppose 96 DPI r_pixel = ip_emu * 96 / 914400. ENDIF. ENDMETHOD. METHOD get_from_col. r_from_col = me->from_loc-col. ENDMETHOD. METHOD get_from_row. r_from_row = me->from_loc-row. ENDMETHOD. METHOD get_guid. ep_guid = me->guid. ENDMETHOD. METHOD get_height_emu_str. r_height = pixel2emu( size-height ). CONDENSE r_height NO-GAPS. ENDMETHOD. METHOD get_index. rp_index = me->index. ENDMETHOD. METHOD get_media. DATA: lv_language TYPE sylangu. DATA: lt_bin_mime TYPE sdokcntbins. DATA: lt_mime TYPE tsfmime, lv_filesize TYPE i, lv_filesizec(10). CASE media_source. WHEN c_media_source_xstring. r_media = media. WHEN c_media_source_www. CALL FUNCTION 'WWWDATA_IMPORT' EXPORTING key = media_key_www TABLES mime = lt_mime EXCEPTIONS OTHERS = 1. CALL FUNCTION 'WWWPARAMS_READ' EXPORTING relid = media_key_www-relid objid = media_key_www-objid name = 'filesize' IMPORTING value = lv_filesizec. lv_filesize = lv_filesizec. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING input_length = lv_filesize IMPORTING buffer = r_media TABLES binary_tab = lt_mime EXCEPTIONS failed = 1 OTHERS = 2. WHEN c_media_source_mime. lv_language = sy-langu. cl_wb_mime_repository=>load_mime( EXPORTING io = me->io IMPORTING filesize = lv_filesize bin_data = lt_bin_mime CHANGING language = lv_language ). CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING input_length = lv_filesize IMPORTING buffer = r_media TABLES binary_tab = lt_bin_mime EXCEPTIONS failed = 1 OTHERS = 2. ENDCASE. ENDMETHOD. METHOD get_media_name. CONCATENATE media_name `.` media_type INTO r_name. ENDMETHOD. METHOD get_media_type. r_type = media_type. ENDMETHOD. METHOD get_name. r_name = title. ENDMETHOD. METHOD get_position. rp_position-anchor = anchor. rp_position-from = from_loc. rp_position-to = to_loc. rp_position-size = size. ENDMETHOD. METHOD get_to_col. r_to_col = me->to_loc-col. ENDMETHOD. METHOD get_to_row. r_to_row = me->to_loc-row. ENDMETHOD. METHOD get_type. rp_type = me->type. ENDMETHOD. METHOD get_width_emu_str. r_width = pixel2emu( size-width ). CONDENSE r_width NO-GAPS. ENDMETHOD. METHOD load_chart_attributes. DATA: node TYPE REF TO if_ixml_element. DATA: node2 TYPE REF TO if_ixml_element. DATA: node3 TYPE REF TO if_ixml_element. DATA: node4 TYPE REF TO if_ixml_element. DATA lo_barchart TYPE REF TO zcl_excel_graph_bars. DATA lo_piechart TYPE REF TO zcl_excel_graph_pie. DATA lo_linechart TYPE REF TO zcl_excel_graph_line. TYPES: BEGIN OF t_prop, val TYPE string, rtl TYPE string, lang TYPE string, formatcode TYPE string, sourcelinked TYPE string, END OF t_prop. TYPES: BEGIN OF t_pagemargins, b TYPE string, l TYPE string, r TYPE string, t TYPE string, header TYPE string, footer TYPE string, END OF t_pagemargins. DATA ls_prop TYPE t_prop. DATA ls_pagemargins TYPE t_pagemargins. DATA lo_collection TYPE REF TO if_ixml_node_collection. DATA lo_node TYPE REF TO if_ixml_node. DATA lo_iterator TYPE REF TO if_ixml_node_iterator. DATA lv_idx TYPE i. DATA lv_order TYPE i. DATA lv_invertifnegative TYPE string. DATA lv_symbol TYPE string. DATA lv_smooth TYPE c. DATA lv_sername TYPE string. DATA lv_label TYPE string. DATA lv_value TYPE string. DATA lv_axid TYPE string. DATA lv_orientation TYPE string. DATA lv_delete TYPE string. DATA lv_axpos TYPE string. DATA lv_formatcode TYPE string. DATA lv_sourcelinked TYPE string. DATA lv_majortickmark TYPE string. DATA lv_minortickmark TYPE string. DATA lv_ticklblpos TYPE string. DATA lv_crossax TYPE string. DATA lv_crosses TYPE string. DATA lv_auto TYPE string. DATA lv_lblalgn TYPE string. DATA lv_lbloffset TYPE string. DATA lv_nomultilvllbl TYPE string. DATA lv_crossbetween TYPE string. node ?= ip_chart->if_ixml_node~get_first_child( ). CHECK node IS NOT INITIAL. CASE me->graph_type. WHEN c_graph_bars. CREATE OBJECT lo_barchart. me->graph = lo_barchart. WHEN c_graph_pie. CREATE OBJECT lo_piechart. me->graph = lo_piechart. WHEN c_graph_line. CREATE OBJECT lo_linechart. me->graph = lo_linechart. WHEN OTHERS. ENDCASE. ""Fill properties node2 ?= node->find_from_name( name = 'date1904' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_1904val = ls_prop-val. node2 ?= node->find_from_name( name = 'lang' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_langval = ls_prop-val. node2 ?= node->find_from_name( name = 'roundedCorners' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_roundedcornersval = ls_prop-val. ""style node2 ?= node->find_from_name( name = 'style' namespace = 'c14' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_c14styleval = ls_prop-val. node2 ?= node->find_from_name( name = 'style' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_styleval = ls_prop-val. ""---------------------------Read graph properties ""ADDED CLEAR node2. node2 ?= node->find_from_name( name = 'title' namespace = 'c' ). IF node2 IS BOUND AND node2 IS NOT INITIAL. node3 ?= node2->find_from_name( name = 't' namespace = 'a' ). me->graph->title = node3->get_value( ). ENDIF. ""END node2 ?= node->find_from_name( name = 'autoTitleDeleted' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_autotitledeletedval = ls_prop-val. ""plotArea CASE me->graph_type. WHEN c_graph_bars. node2 ?= node->find_from_name( name = 'barDir' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_bardirval = ls_prop-val. node2 ?= node->find_from_name( name = 'grouping' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_groupingval = ls_prop-val. node2 ?= node->find_from_name( name = 'varyColors' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_varycolorsval = ls_prop-val. ""Load series CALL METHOD node->get_elements_by_tag_name EXPORTING * depth = 0 name = 'ser' * namespace = '' RECEIVING rval = lo_collection. CALL METHOD lo_collection->create_iterator RECEIVING rval = lo_iterator. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. WHILE lo_node IS BOUND. node3 ?= node2->find_from_name( name = 'idx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_idx = ls_prop-val. node3 ?= node2->find_from_name( name = 'order' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_order = ls_prop-val. node3 ?= node2->find_from_name( name = 'invertIfNegative' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_invertifnegative = ls_prop-val. node3 ?= node2->find_from_name( name = 'v' namespace = 'c' ). IF node3 IS BOUND. lv_sername = node3->get_value( ). ENDIF. node3 ?= node2->find_from_name( name = 'strRef' namespace = 'c' ). IF node3 IS BOUND. node4 ?= node3->find_from_name( name = 'f' namespace = 'c' ). lv_label = node4->get_value( ). ENDIF. node3 ?= node2->find_from_name( name = 'numRef' namespace = 'c' ). IF node3 IS BOUND. node4 ?= node3->find_from_name( name = 'f' namespace = 'c' ). lv_value = node4->get_value( ). ENDIF. CALL METHOD lo_barchart->create_serie EXPORTING ip_idx = lv_idx ip_order = lv_order ip_invertifnegative = lv_invertifnegative ip_lbl = lv_label ip_ref = lv_value ip_sername = lv_sername. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. ENDWHILE. ""note: numCache avoided node2 ?= node->find_from_name( name = 'showLegendKey' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_showlegendkeyval = ls_prop-val. node2 ?= node->find_from_name( name = 'showVal' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_showvalval = ls_prop-val. node2 ?= node->find_from_name( name = 'showCatName' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_showcatnameval = ls_prop-val. node2 ?= node->find_from_name( name = 'showSerName' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_showsernameval = ls_prop-val. node2 ?= node->find_from_name( name = 'showPercent' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_showpercentval = ls_prop-val. node2 ?= node->find_from_name( name = 'showBubbleSize' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_showbubblesizeval = ls_prop-val. node2 ?= node->find_from_name( name = 'gapWidth' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_gapwidthval = ls_prop-val. ""Load axes node2 ?= node->find_from_name( name = 'barChart' namespace = 'c' ). CALL METHOD node2->get_elements_by_tag_name EXPORTING * depth = 0 name = 'axId' * namespace = '' RECEIVING rval = lo_collection. CALL METHOD lo_collection->create_iterator RECEIVING rval = lo_iterator. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. WHILE lo_node IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lv_axid = ls_prop-val. IF sy-index EQ 1. ""catAx node2 ?= node->find_from_name( name = 'catAx' namespace = 'c' ). node3 ?= node2->find_from_name( name = 'orientation' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_orientation = ls_prop-val. node3 ?= node2->find_from_name( name = 'delete' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_delete = ls_prop-val. node3 ?= node2->find_from_name( name = 'axPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_axpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'numFmt' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_formatcode = ls_prop-formatcode. lv_sourcelinked = ls_prop-sourcelinked. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_majortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_minortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'tickLblPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_ticklblpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'crossAx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crossax = ls_prop-val. node3 ?= node2->find_from_name( name = 'crosses' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crosses = ls_prop-val. node3 ?= node2->find_from_name( name = 'auto' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_auto = ls_prop-val. node3 ?= node2->find_from_name( name = 'lblAlgn' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_lblalgn = ls_prop-val. node3 ?= node2->find_from_name( name = 'lblOffset' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_lbloffset = ls_prop-val. node3 ?= node2->find_from_name( name = 'noMultiLvlLbl' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_nomultilvllbl = ls_prop-val. CALL METHOD lo_barchart->create_ax EXPORTING ip_axid = lv_axid ip_type = zcl_excel_graph_bars=>c_catax ip_orientation = lv_orientation ip_delete = lv_delete ip_axpos = lv_axpos ip_formatcode = lv_formatcode ip_sourcelinked = lv_sourcelinked ip_majortickmark = lv_majortickmark ip_minortickmark = lv_minortickmark ip_ticklblpos = lv_ticklblpos ip_crossax = lv_crossax ip_crosses = lv_crosses ip_auto = lv_auto ip_lblalgn = lv_lblalgn ip_lbloffset = lv_lbloffset ip_nomultilvllbl = lv_nomultilvllbl. ELSEIF sy-index EQ 2. ""valAx node2 ?= node->find_from_name( name = 'valAx' namespace = 'c' ). node3 ?= node2->find_from_name( name = 'orientation' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_orientation = ls_prop-val. node3 ?= node2->find_from_name( name = 'delete' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_delete = ls_prop-val. node3 ?= node2->find_from_name( name = 'axPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_axpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'numFmt' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_formatcode = ls_prop-formatcode. lv_sourcelinked = ls_prop-sourcelinked. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_majortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_minortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'tickLblPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_ticklblpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'crossAx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crossax = ls_prop-val. node3 ?= node2->find_from_name( name = 'crosses' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crosses = ls_prop-val. node3 ?= node2->find_from_name( name = 'crossBetween' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crossbetween = ls_prop-val. CALL METHOD lo_barchart->create_ax EXPORTING ip_axid = lv_axid ip_type = zcl_excel_graph_bars=>c_valax ip_orientation = lv_orientation ip_delete = lv_delete ip_axpos = lv_axpos ip_formatcode = lv_formatcode ip_sourcelinked = lv_sourcelinked ip_majortickmark = lv_majortickmark ip_minortickmark = lv_minortickmark ip_ticklblpos = lv_ticklblpos ip_crossax = lv_crossax ip_crosses = lv_crosses ip_crossbetween = lv_crossbetween. ENDIF. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. ENDWHILE. WHEN c_graph_pie. node2 ?= node->find_from_name( name = 'varyColors' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_varycolorsval = ls_prop-val. ""Load series CALL METHOD node->get_elements_by_tag_name EXPORTING * depth = 0 name = 'ser' * namespace = '' RECEIVING rval = lo_collection. CALL METHOD lo_collection->create_iterator RECEIVING rval = lo_iterator. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. WHILE lo_node IS BOUND. node3 ?= node2->find_from_name( name = 'idx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_idx = ls_prop-val. node3 ?= node2->find_from_name( name = 'order' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_order = ls_prop-val. node3 ?= node2->find_from_name( name = 'v' namespace = 'c' ). IF node3 IS BOUND. lv_sername = node3->get_value( ). ENDIF. node3 ?= node2->find_from_name( name = 'strRef' namespace = 'c' ). IF node3 IS BOUND. node4 ?= node3->find_from_name( name = 'f' namespace = 'c' ). lv_label = node4->get_value( ). ENDIF. node3 ?= node2->find_from_name( name = 'numRef' namespace = 'c' ). IF node3 IS BOUND. node4 ?= node3->find_from_name( name = 'f' namespace = 'c' ). lv_value = node4->get_value( ). ENDIF. CALL METHOD lo_piechart->create_serie EXPORTING ip_idx = lv_idx ip_order = lv_order ip_lbl = lv_label ip_ref = lv_value ip_sername = lv_sername. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. ENDWHILE. ""note: numCache avoided node2 ?= node->find_from_name( name = 'showLegendKey' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showlegendkeyval = ls_prop-val. node2 ?= node->find_from_name( name = 'showVal' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showvalval = ls_prop-val. node2 ?= node->find_from_name( name = 'showCatName' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showcatnameval = ls_prop-val. node2 ?= node->find_from_name( name = 'showSerName' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showsernameval = ls_prop-val. node2 ?= node->find_from_name( name = 'showPercent' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showpercentval = ls_prop-val. node2 ?= node->find_from_name( name = 'showBubbleSize' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showbubblesizeval = ls_prop-val. node2 ?= node->find_from_name( name = 'showLeaderLines' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_showleaderlinesval = ls_prop-val. node2 ?= node->find_from_name( name = 'firstSliceAng' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_firstsliceangval = ls_prop-val. WHEN c_graph_line. node2 ?= node->find_from_name( name = 'grouping' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_groupingval = ls_prop-val. node2 ?= node->find_from_name( name = 'varyColors' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_varycolorsval = ls_prop-val. ""Load series CALL METHOD node->get_elements_by_tag_name EXPORTING * depth = 0 name = 'ser' * namespace = '' RECEIVING rval = lo_collection. CALL METHOD lo_collection->create_iterator RECEIVING rval = lo_iterator. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. WHILE lo_node IS BOUND. node3 ?= node2->find_from_name( name = 'idx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_idx = ls_prop-val. node3 ?= node2->find_from_name( name = 'order' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_order = ls_prop-val. node3 ?= node2->find_from_name( name = 'symbol' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_symbol = ls_prop-val. node3 ?= node2->find_from_name( name = 'smooth' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_smooth = ls_prop-val. node3 ?= node2->find_from_name( name = 'v' namespace = 'c' ). IF node3 IS BOUND. lv_sername = node3->get_value( ). ENDIF. node3 ?= node2->find_from_name( name = 'strRef' namespace = 'c' ). IF node3 IS BOUND. node4 ?= node3->find_from_name( name = 'f' namespace = 'c' ). lv_label = node4->get_value( ). ENDIF. node3 ?= node2->find_from_name( name = 'numRef' namespace = 'c' ). IF node3 IS BOUND. node4 ?= node3->find_from_name( name = 'f' namespace = 'c' ). lv_value = node4->get_value( ). ENDIF. CALL METHOD lo_linechart->create_serie EXPORTING ip_idx = lv_idx ip_order = lv_order ip_symbol = lv_symbol ip_smooth = lv_smooth ip_lbl = lv_label ip_ref = lv_value ip_sername = lv_sername. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. ENDWHILE. ""note: numCache avoided node2 ?= node->find_from_name( name = 'showLegendKey' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_showlegendkeyval = ls_prop-val. node2 ?= node->find_from_name( name = 'showVal' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_showvalval = ls_prop-val. node2 ?= node->find_from_name( name = 'showCatName' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_showcatnameval = ls_prop-val. node2 ?= node->find_from_name( name = 'showSerName' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_showsernameval = ls_prop-val. node2 ?= node->find_from_name( name = 'showPercent' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_showpercentval = ls_prop-val. node2 ?= node->find_from_name( name = 'showBubbleSize' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_showbubblesizeval = ls_prop-val. node ?= node->find_from_name( name = 'lineChart' namespace = 'c' ). node2 ?= node->find_from_name( name = 'marker' namespace = 'c' depth = '1' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_markerval = ls_prop-val. ENDIF. node2 ?= node->find_from_name( name = 'smooth' namespace = 'c' depth = '1' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_smoothval = ls_prop-val. node ?= ip_chart->if_ixml_node~get_first_child( ). CHECK node IS NOT INITIAL. ""Load axes node2 ?= node->find_from_name( name = 'lineChart' namespace = 'c' ). CALL METHOD node2->get_elements_by_tag_name EXPORTING * depth = 0 name = 'axId' * namespace = '' RECEIVING rval = lo_collection. CALL METHOD lo_collection->create_iterator RECEIVING rval = lo_iterator. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. WHILE lo_node IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lv_axid = ls_prop-val. IF sy-index EQ 1. ""catAx node2 ?= node->find_from_name( name = 'catAx' namespace = 'c' ). node3 ?= node2->find_from_name( name = 'orientation' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_orientation = ls_prop-val. node3 ?= node2->find_from_name( name = 'delete' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_delete = ls_prop-val. node3 ?= node2->find_from_name( name = 'axPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_axpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_majortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_minortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'tickLblPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_ticklblpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'crossAx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crossax = ls_prop-val. node3 ?= node2->find_from_name( name = 'crosses' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crosses = ls_prop-val. node3 ?= node2->find_from_name( name = 'auto' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_auto = ls_prop-val. node3 ?= node2->find_from_name( name = 'lblAlgn' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_lblalgn = ls_prop-val. node3 ?= node2->find_from_name( name = 'lblOffset' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_lbloffset = ls_prop-val. node3 ?= node2->find_from_name( name = 'noMultiLvlLbl' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_nomultilvllbl = ls_prop-val. CALL METHOD lo_linechart->create_ax EXPORTING ip_axid = lv_axid ip_type = zcl_excel_graph_line=>c_catax ip_orientation = lv_orientation ip_delete = lv_delete ip_axpos = lv_axpos ip_formatcode = lv_formatcode ip_sourcelinked = lv_sourcelinked ip_majortickmark = lv_majortickmark ip_minortickmark = lv_minortickmark ip_ticklblpos = lv_ticklblpos ip_crossax = lv_crossax ip_crosses = lv_crosses ip_auto = lv_auto ip_lblalgn = lv_lblalgn ip_lbloffset = lv_lbloffset ip_nomultilvllbl = lv_nomultilvllbl. ELSEIF sy-index EQ 2. ""valAx node2 ?= node->find_from_name( name = 'valAx' namespace = 'c' ). node3 ?= node2->find_from_name( name = 'orientation' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_orientation = ls_prop-val. node3 ?= node2->find_from_name( name = 'delete' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_delete = ls_prop-val. node3 ?= node2->find_from_name( name = 'axPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_axpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'numFmt' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_formatcode = ls_prop-formatcode. lv_sourcelinked = ls_prop-sourcelinked. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_majortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'majorTickMark' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_minortickmark = ls_prop-val. node3 ?= node2->find_from_name( name = 'tickLblPos' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_ticklblpos = ls_prop-val. node3 ?= node2->find_from_name( name = 'crossAx' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crossax = ls_prop-val. node3 ?= node2->find_from_name( name = 'crosses' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crosses = ls_prop-val. node3 ?= node2->find_from_name( name = 'crossBetween' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). lv_crossbetween = ls_prop-val. CALL METHOD lo_linechart->create_ax EXPORTING ip_axid = lv_axid ip_type = zcl_excel_graph_line=>c_valax ip_orientation = lv_orientation ip_delete = lv_delete ip_axpos = lv_axpos ip_formatcode = lv_formatcode ip_sourcelinked = lv_sourcelinked ip_majortickmark = lv_majortickmark ip_minortickmark = lv_minortickmark ip_ticklblpos = lv_ticklblpos ip_crossax = lv_crossax ip_crosses = lv_crosses ip_crossbetween = lv_crossbetween. ENDIF. lo_node = lo_iterator->get_next( ). IF lo_node IS BOUND. node2 ?= lo_node->query_interface( ixml_iid_element ). ENDIF. ENDWHILE. WHEN OTHERS. ENDCASE. ""legend CASE me->graph_type. WHEN c_graph_bars. node2 ?= node->find_from_name( name = 'legendPos' namespace = 'c' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_legendposval = ls_prop-val. ENDIF. node2 ?= node->find_from_name( name = 'overlay' namespace = 'c' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_barchart->ns_overlayval = ls_prop-val. ENDIF. WHEN c_graph_line. node2 ?= node->find_from_name( name = 'legendPos' namespace = 'c' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_legendposval = ls_prop-val. ENDIF. node2 ?= node->find_from_name( name = 'overlay' namespace = 'c' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_linechart->ns_overlayval = ls_prop-val. ENDIF. WHEN c_graph_pie. node2 ?= node->find_from_name( name = 'legendPos' namespace = 'c' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_legendposval = ls_prop-val. ENDIF. node2 ?= node->find_from_name( name = 'overlay' namespace = 'c' ). IF node2 IS BOUND. zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_overlayval = ls_prop-val. ENDIF. node2 ?= node->find_from_name( name = 'pPr' namespace = 'a' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_pprrtl = ls_prop-rtl. node2 ?= node->find_from_name( name = 'endParaRPr' namespace = 'a' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_endpararprlang = ls_prop-lang. WHEN OTHERS. ENDCASE. node2 ?= node->find_from_name( name = 'plotVisOnly' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_plotvisonlyval = ls_prop-val. node2 ?= node->find_from_name( name = 'dispBlanksAs' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_dispblanksasval = ls_prop-val. node2 ?= node->find_from_name( name = 'showDLblsOverMax' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). me->graph->ns_showdlblsovermaxval = ls_prop-val. ""--------------------- node2 ?= node->find_from_name( name = 'pageMargins' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_pagemargins ). me->graph->pagemargins = ls_pagemargins. ENDMETHOD. METHOD pixel2emu. * suppose 96 DPI IF ip_dpi IS SUPPLIED. r_emu = ip_pixel * 914400 / ip_dpi. ELSE. * suppose 96 DPI r_emu = ip_pixel * 914400 / 96. ENDIF. ENDMETHOD. METHOD set_media. IF ip_media IS SUPPLIED. media = ip_media. ENDIF. media_type = ip_media_type. media_source = c_media_source_xstring. IF ip_width IS SUPPLIED. size-width = ip_width. ENDIF. IF ip_height IS SUPPLIED. size-height = ip_height. ENDIF. ENDMETHOD. METHOD set_media_mime. DATA: lv_language TYPE sylangu. io = ip_io. media_source = c_media_source_mime. size-width = ip_width. size-height = ip_height. lv_language = sy-langu. cl_wb_mime_repository=>load_mime( EXPORTING io = ip_io IMPORTING filename = media_name ""mimetype = media_type CHANGING language = lv_language ). SPLIT media_name AT '.' INTO media_name media_type. ENDMETHOD. METHOD set_media_www. DATA: lv_value(20). media_key_www = ip_key. media_source = c_media_source_www. CALL FUNCTION 'WWWPARAMS_READ' EXPORTING relid = media_key_www-relid objid = media_key_www-objid name = 'fileextension' IMPORTING value = lv_value. media_type = lv_value. SHIFT media_type LEFT DELETING LEADING '.'. size-width = ip_width. size-height = ip_height. ENDMETHOD. METHOD set_position. from_loc-col = zcl_excel_common=>convert_column2int( ip_from_col ) - 1. IF ip_coloff IS SUPPLIED. from_loc-col_offset = ip_coloff. ENDIF. from_loc-row = ip_from_row - 1. IF ip_rowoff IS SUPPLIED. from_loc-row_offset = ip_rowoff. ENDIF. anchor = anchor_one_cell. ENDMETHOD. METHOD set_position2. DATA: lv_anchor TYPE zexcel_drawing_anchor. lv_anchor = ip_anchor. IF lv_anchor IS INITIAL. IF ip_to IS NOT INITIAL. lv_anchor = anchor_two_cell. ELSE. lv_anchor = anchor_one_cell. ENDIF. ENDIF. CASE lv_anchor. WHEN anchor_absolute OR anchor_one_cell. CLEAR: me->to_loc. WHEN anchor_two_cell. CLEAR: me->size. ENDCASE. me->from_loc = ip_from. me->to_loc = ip_to. me->anchor = lv_anchor. ENDMETHOD. ENDCLASS. ",13390,True,3716.5230889105856,median "CLASS zcl_abapgit_ajson DEFINITION PUBLIC CREATE PRIVATE . PUBLIC SECTION. INTERFACES zif_abapgit_ajson . ALIASES: exists FOR zif_abapgit_ajson~exists, members FOR zif_abapgit_ajson~members, get FOR zif_abapgit_ajson~get, get_boolean FOR zif_abapgit_ajson~get_boolean, get_integer FOR zif_abapgit_ajson~get_integer, get_number FOR zif_abapgit_ajson~get_number, get_date FOR zif_abapgit_ajson~get_date, get_timestamp FOR zif_abapgit_ajson~get_timestamp, get_string FOR zif_abapgit_ajson~get_string, slice FOR zif_abapgit_ajson~slice, to_abap FOR zif_abapgit_ajson~to_abap, array_to_string_table FOR zif_abapgit_ajson~array_to_string_table. ALIASES: clear FOR zif_abapgit_ajson~clear, set FOR zif_abapgit_ajson~set, set_boolean FOR zif_abapgit_ajson~set_boolean, set_string FOR zif_abapgit_ajson~set_string, set_integer FOR zif_abapgit_ajson~set_integer, set_date FOR zif_abapgit_ajson~set_date, set_timestamp FOR zif_abapgit_ajson~set_timestamp, set_null FOR zif_abapgit_ajson~set_null, delete FOR zif_abapgit_ajson~delete, touch_array FOR zif_abapgit_ajson~touch_array, push FOR zif_abapgit_ajson~push, stringify FOR zif_abapgit_ajson~stringify. ALIASES: mt_json_tree FOR zif_abapgit_ajson~mt_json_tree, keep_item_order FOR zif_abapgit_ajson~keep_item_order, format_datetime FOR zif_abapgit_ajson~format_datetime, freeze FOR zif_abapgit_ajson~freeze. CLASS-METHODS parse IMPORTING !iv_json TYPE string !iv_freeze TYPE abap_bool DEFAULT abap_false !ii_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping OPTIONAL RETURNING VALUE(ro_instance) TYPE REF TO zcl_abapgit_ajson RAISING zcx_abapgit_ajson_error . CLASS-METHODS create_empty IMPORTING !ii_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping OPTIONAL RETURNING VALUE(ro_instance) TYPE REF TO zcl_abapgit_ajson. "" Experimental ! May change CLASS-METHODS create_from IMPORTING !ii_source_json TYPE REF TO zif_abapgit_ajson !ii_filter TYPE REF TO zif_abapgit_ajson_filter OPTIONAL RETURNING VALUE(ro_instance) TYPE REF TO zcl_abapgit_ajson RAISING zcx_abapgit_ajson_error . PROTECTED SECTION. PRIVATE SECTION. TYPES: tty_node_stack TYPE STANDARD TABLE OF REF TO zif_abapgit_ajson=>ty_node WITH DEFAULT KEY. DATA mv_read_only TYPE abap_bool. DATA mi_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping. DATA mv_keep_item_order TYPE abap_bool. DATA mv_format_datetime TYPE abap_bool. METHODS get_item IMPORTING iv_path TYPE string RETURNING VALUE(rv_item) TYPE REF TO zif_abapgit_ajson=>ty_node. METHODS prove_path_exists IMPORTING iv_path TYPE string RETURNING VALUE(rt_node_stack) TYPE tty_node_stack RAISING zcx_abapgit_ajson_error. METHODS delete_subtree IMPORTING iv_path TYPE string iv_name TYPE string RETURNING VALUE(rv_deleted) TYPE abap_bool. ENDCLASS. CLASS zcl_abapgit_ajson IMPLEMENTATION. METHOD create_empty. CREATE OBJECT ro_instance. ro_instance->mi_custom_mapping = ii_custom_mapping. ENDMETHOD. METHOD create_from. DATA lo_filter_runner TYPE REF TO lcl_filter_runner. IF ii_source_json IS NOT BOUND. zcx_abapgit_ajson_error=>raise( 'Source not bound' ). ENDIF. CREATE OBJECT ro_instance. IF ii_filter IS BOUND. CREATE OBJECT lo_filter_runner. lo_filter_runner->run( EXPORTING ii_filter = ii_filter it_source_tree = ii_source_json->mt_json_tree CHANGING ct_dest_tree = ro_instance->mt_json_tree ). ELSE. ro_instance->mt_json_tree = ii_source_json->mt_json_tree. "" Copy keep order and custom mapping ??? ENDIF. ENDMETHOD. METHOD delete_subtree. DATA lv_parent_path TYPE string. DATA lv_parent_path_len TYPE i. FIELD-SYMBOLS LIKE LINE OF mt_json_tree. READ TABLE mt_json_tree ASSIGNING WITH KEY path = iv_path name = iv_name. IF sy-subrc = 0. "" Found ? delete ! IF -children > 0. "" only for objects and arrays lv_parent_path = iv_path && iv_name && '/'. lv_parent_path_len = strlen( lv_parent_path ). LOOP AT mt_json_tree ASSIGNING . IF strlen( -path ) >= lv_parent_path_len AND substring( val = -path len = lv_parent_path_len ) = lv_parent_path. DELETE mt_json_tree INDEX sy-tabix. ENDIF. ENDLOOP. ENDIF. DELETE mt_json_tree WHERE path = iv_path AND name = iv_name. rv_deleted = abap_true. DATA ls_path TYPE zif_abapgit_ajson=>ty_path_name. ls_path = lcl_utils=>split_path( iv_path ). READ TABLE mt_json_tree ASSIGNING WITH KEY path = ls_path-path name = ls_path-name. IF sy-subrc = 0. -children = -children - 1. ENDIF. ENDIF. ENDMETHOD. METHOD get_item. FIELD-SYMBOLS LIKE LINE OF mt_json_tree. DATA ls_path_name TYPE zif_abapgit_ajson=>ty_path_name. ls_path_name = lcl_utils=>split_path( iv_path ). READ TABLE mt_json_tree ASSIGNING WITH KEY path = ls_path_name-path name = ls_path_name-name. IF sy-subrc = 0. GET REFERENCE OF INTO rv_item. ENDIF. ENDMETHOD. METHOD parse. DATA lo_parser TYPE REF TO lcl_json_parser. CREATE OBJECT ro_instance. CREATE OBJECT lo_parser. ro_instance->mt_json_tree = lo_parser->parse( iv_json ). ro_instance->mi_custom_mapping = ii_custom_mapping. IF iv_freeze = abap_true. ro_instance->freeze( ). ENDIF. ENDMETHOD. METHOD prove_path_exists. DATA lt_path TYPE string_table. DATA lr_node LIKE LINE OF rt_node_stack. DATA lr_node_parent LIKE LINE OF rt_node_stack. DATA lv_cur_path TYPE string. DATA lv_cur_name TYPE string. DATA ls_new_node LIKE LINE OF mt_json_tree. SPLIT iv_path AT '/' INTO TABLE lt_path. DELETE lt_path WHERE table_line IS INITIAL. DO. lr_node_parent = lr_node. READ TABLE mt_json_tree REFERENCE INTO lr_node WITH KEY path = lv_cur_path name = lv_cur_name. IF sy-subrc <> 0. "" New node, assume it is always object as it has a named child, use touch_array to init array CLEAR ls_new_node. IF lr_node_parent IS NOT INITIAL. "" if has parent lr_node_parent->children = lr_node_parent->children + 1. IF lr_node_parent->type = zif_abapgit_ajson=>node_type-array. ls_new_node-index = lcl_utils=>validate_array_index( iv_path = lv_cur_path iv_index = lv_cur_name ). ENDIF. ENDIF. ls_new_node-path = lv_cur_path. ls_new_node-name = lv_cur_name. ls_new_node-type = zif_abapgit_ajson=>node_type-object. INSERT ls_new_node INTO TABLE mt_json_tree REFERENCE INTO lr_node. ENDIF. INSERT lr_node INTO rt_node_stack INDEX 1. lv_cur_path = lv_cur_path && lv_cur_name && '/'. READ TABLE lt_path INDEX sy-index INTO lv_cur_name. IF sy-subrc <> 0. EXIT. "" no more segments ENDIF. ENDDO. ASSERT lv_cur_path = iv_path. "" Just in case ENDMETHOD. METHOD zif_abapgit_ajson~array_to_string_table. DATA lv_normalized_path TYPE string. DATA lr_node TYPE REF TO zif_abapgit_ajson=>ty_node. FIELD-SYMBOLS LIKE LINE OF mt_json_tree. lv_normalized_path = lcl_utils=>normalize_path( iv_path ). lr_node = get_item( iv_path ). IF lr_node IS INITIAL. zcx_abapgit_ajson_error=>raise( |Path not found: { iv_path }| ). ENDIF. IF lr_node->type <> zif_abapgit_ajson=>node_type-array. zcx_abapgit_ajson_error=>raise( |Array expected at: { iv_path }| ). ENDIF. LOOP AT mt_json_tree ASSIGNING WHERE path = lv_normalized_path. CASE -type. WHEN zif_abapgit_ajson=>node_type-number OR zif_abapgit_ajson=>node_type-string. APPEND -value TO rt_string_table. WHEN zif_abapgit_ajson=>node_type-null. APPEND '' TO rt_string_table. WHEN zif_abapgit_ajson=>node_type-boolean. DATA lv_tmp TYPE string. IF -value = 'true'. lv_tmp = abap_true. ELSE. CLEAR lv_tmp. ENDIF. APPEND lv_tmp TO rt_string_table. WHEN OTHERS. zcx_abapgit_ajson_error=>raise( |Cannot convert [{ -type }] to string at [{ -path }{ -name }]| ). ENDCASE. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_ajson~clear. IF mv_read_only = abap_true. zcx_abapgit_ajson_error=>raise( 'This json instance is read only' ). ENDIF. CLEAR mt_json_tree. ENDMETHOD. METHOD zif_abapgit_ajson~delete. IF mv_read_only = abap_true. zcx_abapgit_ajson_error=>raise( 'This json instance is read only' ). ENDIF. DATA ls_split_path TYPE zif_abapgit_ajson=>ty_path_name. ls_split_path = lcl_utils=>split_path( iv_path ). delete_subtree( iv_path = ls_split_path-path iv_name = ls_split_path-name ). ri_json = me. ENDMETHOD. METHOD zif_abapgit_ajson~exists. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL. rv_exists = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~format_datetime. mv_format_datetime = abap_true. ri_json = me. ENDMETHOD. METHOD zif_abapgit_ajson~freeze. mv_read_only = abap_true. ENDMETHOD. METHOD zif_abapgit_ajson~get. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL. rv_value = lv_item->value. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_boolean. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS INITIAL OR lv_item->type = zif_abapgit_ajson=>node_type-null. RETURN. ELSEIF lv_item->type = zif_abapgit_ajson=>node_type-boolean. rv_value = boolc( lv_item->value = 'true' ). ELSEIF lv_item->value IS NOT INITIAL. rv_value = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_date. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. DATA lv_y TYPE c LENGTH 4. DATA lv_m TYPE c LENGTH 2. DATA lv_d TYPE c LENGTH 2. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL AND lv_item->type = zif_abapgit_ajson=>node_type-string. FIND FIRST OCCURRENCE OF REGEX '^(\\d{4})-(\\d{2})-(\\d{2})(T|$)' IN lv_item->value SUBMATCHES lv_y lv_m lv_d. CONCATENATE lv_y lv_m lv_d INTO rv_value. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_integer. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL AND lv_item->type = zif_abapgit_ajson=>node_type-number. rv_value = lv_item->value. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_node_type. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL. rv_node_type = lv_item->type. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_number. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL AND lv_item->type = zif_abapgit_ajson=>node_type-number. rv_value = lv_item->value. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_string. DATA lv_item TYPE REF TO zif_abapgit_ajson=>ty_node. lv_item = get_item( iv_path ). IF lv_item IS NOT INITIAL AND lv_item->type <> zif_abapgit_ajson=>node_type-null. rv_value = lv_item->value. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~get_timestamp. DATA lo_to_abap TYPE REF TO lcl_json_to_abap. DATA lr_item TYPE REF TO zif_abapgit_ajson=>ty_node. lr_item = get_item( iv_path ). IF lr_item IS INITIAL. RETURN. ENDIF. CREATE OBJECT lo_to_abap. TRY. rv_value = lo_to_abap->to_timestamp( lr_item->value ). CATCH zcx_abapgit_ajson_error. RETURN. ENDTRY. ENDMETHOD. METHOD zif_abapgit_ajson~keep_item_order. mv_keep_item_order = abap_true. ri_json = me. ENDMETHOD. METHOD zif_abapgit_ajson~members. DATA lv_normalized_path TYPE string. FIELD-SYMBOLS LIKE LINE OF mt_json_tree. lv_normalized_path = lcl_utils=>normalize_path( iv_path ). LOOP AT mt_json_tree ASSIGNING WHERE path = lv_normalized_path. APPEND -name TO rt_members. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_ajson~push. DATA lr_parent TYPE REF TO zif_abapgit_ajson=>ty_node. DATA lr_new_node TYPE REF TO zif_abapgit_ajson=>ty_node. IF mv_read_only = abap_true. zcx_abapgit_ajson_error=>raise( 'This json instance is read only' ). ENDIF. lr_parent = get_item( iv_path ). IF lr_parent IS INITIAL. zcx_abapgit_ajson_error=>raise( |Path [{ iv_path }] does not exist| ). ENDIF. IF lr_parent->type <> zif_abapgit_ajson=>node_type-array. zcx_abapgit_ajson_error=>raise( |Path [{ iv_path }] is not array| ). ENDIF. DATA lt_new_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt. DATA ls_new_path TYPE zif_abapgit_ajson=>ty_path_name. DATA lv_new_index TYPE i. lv_new_index = lr_parent->children + 1. ls_new_path-path = lcl_utils=>normalize_path( iv_path ). ls_new_path-name = |{ lv_new_index }|. lt_new_nodes = lcl_abap_to_json=>convert( iv_keep_item_order = mv_keep_item_order iv_data = iv_val is_prefix = ls_new_path ). READ TABLE lt_new_nodes INDEX 1 REFERENCE INTO lr_new_node. "" assume first record is the array item - not ideal ! ASSERT sy-subrc = 0. lr_new_node->index = lv_new_index. "" update data lr_parent->children = lv_new_index. INSERT LINES OF lt_new_nodes INTO TABLE mt_json_tree. ri_json = me. ENDMETHOD. METHOD zif_abapgit_ajson~set. DATA ls_split_path TYPE zif_abapgit_ajson=>ty_path_name. DATA lr_parent TYPE REF TO zif_abapgit_ajson=>ty_node. DATA lt_node_stack TYPE tty_node_stack. IF mv_read_only = abap_true. zcx_abapgit_ajson_error=>raise( 'This json instance is read only' ). ENDIF. ri_json = me. IF iv_val IS INITIAL AND iv_ignore_empty = abap_true AND iv_node_type IS INITIAL. RETURN. "" nothing to assign ENDIF. IF iv_node_type IS NOT INITIAL AND iv_node_type <> zif_abapgit_ajson=>node_type-boolean AND iv_node_type <> zif_abapgit_ajson=>node_type-null AND iv_node_type <> zif_abapgit_ajson=>node_type-number AND iv_node_type <> zif_abapgit_ajson=>node_type-string. zcx_abapgit_ajson_error=>raise( |Unexpected type { iv_node_type }| ). ENDIF. ls_split_path = lcl_utils=>split_path( iv_path ). IF ls_split_path IS INITIAL. "" Assign root, exceptional processing IF iv_node_type IS NOT INITIAL. mt_json_tree = lcl_abap_to_json=>insert_with_type( iv_format_datetime = mv_format_datetime iv_keep_item_order = mv_keep_item_order iv_data = iv_val iv_type = iv_node_type is_prefix = ls_split_path ii_custom_mapping = mi_custom_mapping ). ELSE. mt_json_tree = lcl_abap_to_json=>convert( iv_format_datetime = mv_format_datetime iv_keep_item_order = mv_keep_item_order iv_data = iv_val is_prefix = ls_split_path ii_custom_mapping = mi_custom_mapping ). ENDIF. RETURN. ENDIF. "" Ensure whole path exists lt_node_stack = prove_path_exists( ls_split_path-path ). READ TABLE lt_node_stack INDEX 1 INTO lr_parent. ASSERT sy-subrc = 0. "" delete if exists with subtree delete_subtree( iv_path = ls_split_path-path iv_name = ls_split_path-name ). "" convert to json DATA lt_new_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt. DATA lv_array_index TYPE i. IF lr_parent->type = zif_abapgit_ajson=>node_type-array. lv_array_index = lcl_utils=>validate_array_index( iv_path = ls_split_path-path iv_index = ls_split_path-name ). ENDIF. IF iv_node_type IS NOT INITIAL. lt_new_nodes = lcl_abap_to_json=>insert_with_type( iv_format_datetime = mv_format_datetime iv_keep_item_order = mv_keep_item_order iv_data = iv_val iv_type = iv_node_type iv_array_index = lv_array_index is_prefix = ls_split_path ii_custom_mapping = mi_custom_mapping ). ELSE. lt_new_nodes = lcl_abap_to_json=>convert( iv_format_datetime = mv_format_datetime iv_keep_item_order = mv_keep_item_order iv_data = iv_val iv_array_index = lv_array_index is_prefix = ls_split_path ii_custom_mapping = mi_custom_mapping ). ENDIF. "" update data IF lines( lt_new_nodes ) > 0. lr_parent->children = lr_parent->children + 1. INSERT LINES OF lt_new_nodes INTO TABLE mt_json_tree. ENDIF. ENDMETHOD. METHOD zif_abapgit_ajson~set_boolean. ri_json = me. DATA lv_bool TYPE abap_bool. lv_bool = boolc( iv_val IS NOT INITIAL ). zif_abapgit_ajson~set( iv_ignore_empty = abap_false iv_path = iv_path iv_val = lv_bool ). ENDMETHOD. METHOD zif_abapgit_ajson~set_date. ri_json = me. DATA lv_val TYPE string. lv_val = lcl_abap_to_json=>format_date( iv_val ). zif_abapgit_ajson~set( iv_ignore_empty = abap_false iv_path = iv_path iv_val = lv_val ). ENDMETHOD. METHOD zif_abapgit_ajson~set_integer. ri_json = me. zif_abapgit_ajson~set( iv_ignore_empty = abap_false iv_path = iv_path iv_val = iv_val ). ENDMETHOD. METHOD zif_abapgit_ajson~set_null. ri_json = me. DATA lv_null_ref TYPE REF TO data. zif_abapgit_ajson~set( iv_ignore_empty = abap_false iv_path = iv_path iv_val = lv_null_ref ). ENDMETHOD. METHOD zif_abapgit_ajson~set_string. ri_json = me. DATA lv_val TYPE string. lv_val = iv_val. zif_abapgit_ajson~set( iv_ignore_empty = abap_false iv_path = iv_path iv_val = lv_val ). ENDMETHOD. METHOD zif_abapgit_ajson~set_timestamp. ri_json = me. DATA lv_timestamp_iso TYPE string. lv_timestamp_iso = lcl_abap_to_json=>format_timestamp( iv_val ). zif_abapgit_ajson~set( iv_ignore_empty = abap_false iv_path = iv_path iv_val = lv_timestamp_iso ). ENDMETHOD. METHOD zif_abapgit_ajson~slice. DATA lo_section TYPE REF TO zcl_abapgit_ajson. DATA ls_item LIKE LINE OF mt_json_tree. DATA lv_normalized_path TYPE string. DATA ls_path_parts TYPE zif_abapgit_ajson=>ty_path_name. DATA lv_path_len TYPE i. CREATE OBJECT lo_section. lv_normalized_path = lcl_utils=>normalize_path( iv_path ). lv_path_len = strlen( lv_normalized_path ). ls_path_parts = lcl_utils=>split_path( lv_normalized_path ). LOOP AT mt_json_tree INTO ls_item. "" TODO potentially improve performance due to sorted tree (all path started from same prefix go in a row) IF strlen( ls_item-path ) >= lv_path_len AND substring( val = ls_item-path len = lv_path_len ) = lv_normalized_path. ls_item-path = substring( val = ls_item-path off = lv_path_len - 1 ). "" less closing '/' INSERT ls_item INTO TABLE lo_section->mt_json_tree. ELSEIF ls_item-path = ls_path_parts-path AND ls_item-name = ls_path_parts-name. CLEAR: ls_item-path, ls_item-name. "" this becomes a new root INSERT ls_item INTO TABLE lo_section->mt_json_tree. ENDIF. ENDLOOP. ri_json = lo_section. ENDMETHOD. METHOD zif_abapgit_ajson~stringify. rv_json = lcl_json_serializer=>stringify( it_json_tree = mt_json_tree iv_keep_item_order = mv_keep_item_order iv_indent = iv_indent ). ENDMETHOD. METHOD zif_abapgit_ajson~touch_array. DATA lr_node TYPE REF TO zif_abapgit_ajson=>ty_node. DATA ls_new_node LIKE LINE OF mt_json_tree. DATA ls_split_path TYPE zif_abapgit_ajson=>ty_path_name. IF mv_read_only = abap_true. zcx_abapgit_ajson_error=>raise( 'This json instance is read only' ). ENDIF. ls_split_path = lcl_utils=>split_path( iv_path ). IF ls_split_path IS INITIAL. "" Assign root, exceptional processing ls_new_node-path = ls_split_path-path. ls_new_node-name = ls_split_path-name. ls_new_node-type = 'array'. INSERT ls_new_node INTO TABLE mt_json_tree. RETURN. ENDIF. IF iv_clear = abap_true. delete_subtree( iv_path = ls_split_path-path iv_name = ls_split_path-name ). ELSE. lr_node = get_item( iv_path ). ENDIF. IF lr_node IS INITIAL. "" Or node was cleared DATA lr_parent TYPE REF TO zif_abapgit_ajson=>ty_node. DATA lt_node_stack TYPE tty_node_stack. lt_node_stack = prove_path_exists( ls_split_path-path ). READ TABLE lt_node_stack INDEX 1 INTO lr_parent. ASSERT sy-subrc = 0. lr_parent->children = lr_parent->children + 1. ls_new_node-path = ls_split_path-path. ls_new_node-name = ls_split_path-name. ls_new_node-type = zif_abapgit_ajson=>node_type-array. INSERT ls_new_node INTO TABLE mt_json_tree. ELSEIF lr_node->type <> zif_abapgit_ajson=>node_type-array. zcx_abapgit_ajson_error=>raise( |Path [{ iv_path }] already used and is not array| ). ENDIF. ri_json = me. ENDMETHOD. METHOD zif_abapgit_ajson~to_abap. DATA lo_to_abap TYPE REF TO lcl_json_to_abap. CLEAR ev_container. CREATE OBJECT lo_to_abap EXPORTING ii_custom_mapping = mi_custom_mapping. lo_to_abap->to_abap( EXPORTING it_nodes = zif_abapgit_ajson~mt_json_tree CHANGING c_container = ev_container ). ENDMETHOD. ENDCLASS. ",6254,False,1473.9187916431727,median "CLASS zcl_abapgit_gui_page_diff DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page CREATE PUBLIC. PUBLIC SECTION. TYPES: BEGIN OF ty_file_diff, path TYPE string, filename TYPE string, obj_type TYPE string, obj_name TYPE string, lstate TYPE char1, rstate TYPE char1, fstate TYPE char1, "" FILE state - Abstraction for shorter ifs o_diff TYPE REF TO zcl_abapgit_diff, changed_by TYPE xubname, type TYPE string, END OF ty_file_diff. TYPES: tt_file_diff TYPE STANDARD TABLE OF ty_file_diff WITH NON-UNIQUE DEFAULT KEY WITH NON-UNIQUE SORTED KEY secondary COMPONENTS path filename. CONSTANTS: BEGIN OF c_fstate, local TYPE char1 VALUE 'L', remote TYPE char1 VALUE 'R', both TYPE char1 VALUE 'B', END OF c_fstate. METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception. METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION. PROTECTED SECTION. DATA mv_unified TYPE abap_bool VALUE abap_true ##NO_TEXT. DATA mo_repo TYPE REF TO zcl_abapgit_repo. DATA mt_diff_files TYPE tt_file_diff . METHODS: get_normalized_fname_with_path IMPORTING is_diff TYPE ty_file_diff RETURNING VALUE(rv_filename) TYPE string, normalize_path IMPORTING iv_path TYPE string RETURNING VALUE(rv_normalized) TYPE string, normalize_filename IMPORTING iv_filename TYPE string RETURNING VALUE(rv_normalized) TYPE string, render_content REDEFINITION, add_menu_end IMPORTING io_menu TYPE REF TO zcl_abapgit_html_toolbar , calculate_diff IMPORTING is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception, add_menu_begin IMPORTING io_menu TYPE REF TO zcl_abapgit_html_toolbar, render_table_head_non_unified IMPORTING io_html TYPE REF TO zcl_abapgit_html is_diff TYPE ty_file_diff, render_beacon_begin_of_row IMPORTING io_html TYPE REF TO zcl_abapgit_html is_diff TYPE ty_file_diff, render_diff_head_after_state IMPORTING io_html TYPE REF TO zcl_abapgit_html is_diff TYPE ty_file_diff, insert_nav RETURNING VALUE(rv_insert_nav) TYPE abap_bool, render_line_split_row IMPORTING io_html TYPE REF TO zcl_abapgit_html iv_filename TYPE string is_diff_line TYPE zif_abapgit_definitions=>ty_diff iv_index TYPE sy-tabix iv_fstate TYPE char1 iv_new TYPE string iv_old TYPE string RAISING zcx_abapgit_exception, build_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar. PRIVATE SECTION. CONSTANTS: BEGIN OF c_actions, toggle_unified TYPE string VALUE 'toggle_unified', END OF c_actions . DATA mt_delayed_lines TYPE zif_abapgit_definitions=>ty_diffs_tt . DATA mv_repo_key TYPE zif_abapgit_persistence=>ty_repo-key . DATA mv_seed TYPE string . "" Unique page id to bind JS sessionStorage METHODS render_diff IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception . METHODS render_diff_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS render_table_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception . METHODS render_beacon IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS render_line_split IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_filename TYPE string !iv_fstate TYPE char1 !iv_index TYPE sy-tabix RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception . METHODS render_line_unified IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff OPTIONAL RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html . METHODS append_diff IMPORTING !it_remote TYPE zif_abapgit_definitions=>ty_files_tt !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !is_status TYPE zif_abapgit_definitions=>ty_result RAISING zcx_abapgit_exception . METHODS is_binary IMPORTING !iv_d1 TYPE xstring !iv_d2 TYPE xstring RETURNING VALUE(rv_yes) TYPE abap_bool . METHODS add_jump_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS add_filter_sub_menu IMPORTING io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_lines IMPORTING is_diff TYPE ty_file_diff RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception. METHODS render_table_head_unified IMPORTING io_html TYPE REF TO zcl_abapgit_html. METHODS render_scripts RETURNING VALUE(ro_html) TYPE REF TO zcl_abapgit_html RAISING zcx_abapgit_exception. METHODS filter_diff_by_files IMPORTING it_files TYPE zif_abapgit_definitions=>ty_stage_tt CHANGING ct_diff_files TYPE tt_file_diff. ENDCLASS. CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION. METHOD add_filter_sub_menu. DATA: lo_sub_filter TYPE REF TO zcl_abapgit_html_toolbar, lt_types TYPE string_table, lt_users TYPE string_table. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files, TYPE string. "" Get unique LOOP AT mt_diff_files ASSIGNING . APPEND -type TO lt_types. APPEND -changed_by TO lt_users. ENDLOOP. SORT lt_types. DELETE ADJACENT DUPLICATES FROM lt_types. SORT lt_users. DELETE ADJACENT DUPLICATES FROM lt_users. IF lines( lt_types ) > 1 OR lines( lt_users ) > 1. CREATE OBJECT lo_sub_filter EXPORTING iv_id = 'diff-filter'. "" File types IF lines( lt_types ) > 1. lo_sub_filter->add( iv_txt = 'TYPE' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_types ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'type' iv_chk = abap_true ). ENDLOOP. ENDIF. "" Changed by IF lines( lt_users ) > 1. lo_sub_filter->add( iv_txt = 'CHANGED BY' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_users ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'changed-by' iv_chk = abap_true ). ENDLOOP. ENDIF. io_menu->add( iv_txt = 'Filter' io_sub = lo_sub_filter ) ##NO_TEXT. ENDIF. ENDMETHOD. METHOD add_jump_sub_menu. DATA: lo_sub_jump TYPE REF TO zcl_abapgit_html_toolbar, lv_jump_target TYPE string. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files. CREATE OBJECT lo_sub_jump EXPORTING iv_id = 'jump'. LOOP AT mt_diff_files ASSIGNING . lv_jump_target = -path && -filename. lo_sub_jump->add( iv_id = |li_jump_{ sy-tabix }| iv_txt = lv_jump_target iv_typ = zif_abapgit_html=>c_action_type-onclick ). ENDLOOP. io_menu->add( iv_txt = 'Jump' io_sub = lo_sub_jump ) ##NO_TEXT. ENDMETHOD. METHOD add_menu_begin. ENDMETHOD. METHOD add_menu_end. io_menu->add( iv_txt = 'Split/Unified view' iv_act = c_actions-toggle_unified ) ##NO_TEXT. ENDMETHOD. METHOD append_diff. DATA: lv_offs TYPE i, ls_r_dummy LIKE LINE OF it_remote ##NEEDED, ls_l_dummy LIKE LINE OF it_local ##NEEDED. FIELD-SYMBOLS: LIKE LINE OF it_remote, LIKE LINE OF it_local, LIKE LINE OF mt_diff_files. READ TABLE it_remote ASSIGNING WITH KEY filename = is_status-filename path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_r_dummy TO . ENDIF. READ TABLE it_local ASSIGNING WITH KEY file-filename = is_status-filename file-path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_l_dummy TO . ENDIF. IF IS INITIAL AND IS INITIAL. zcx_abapgit_exception=>raise( |DIFF: file not found { is_status-filename }| ). ENDIF. APPEND INITIAL LINE TO mt_diff_files ASSIGNING . -path = is_status-path. -filename = is_status-filename. -obj_type = is_status-obj_type. -obj_name = is_status-obj_name. -lstate = is_status-lstate. -rstate = is_status-rstate. IF -lstate IS NOT INITIAL AND -rstate IS NOT INITIAL. -fstate = c_fstate-both. ELSEIF -lstate IS NOT INITIAL. -fstate = c_fstate-local. ELSE. ""rstate IS NOT INITIAL, lstate = empty. -fstate = c_fstate-remote. ENDIF. "" Changed by IF -item-obj_type IS NOT INITIAL. -changed_by = to_lower( zcl_abapgit_objects=>changed_by( -item ) ). ENDIF. IF -changed_by IS INITIAL. -changed_by = to_lower( zcl_abapgit_objects_super=>c_user_unknown ). ENDIF. "" Extension IF -file-filename IS NOT INITIAL. -type = reverse( -file-filename ). ELSE. -type = reverse( -filename ). ENDIF. FIND FIRST OCCURRENCE OF '.' IN -type MATCH OFFSET lv_offs. -type = reverse( substring( val = -type len = lv_offs ) ). IF -type <> 'xml' AND -type <> 'abap'. -type = 'other'. ENDIF. IF -type = 'other' AND is_binary( iv_d1 = -data iv_d2 = -file-data ) = abap_true. -type = 'binary'. ENDIF. "" Diff data IF -type <> 'binary'. IF -fstate = c_fstate-remote. "" Remote file leading changes CREATE OBJECT -o_diff EXPORTING iv_new = -data iv_old = -file-data. ELSE. "" Local leading changes or both were modified CREATE OBJECT -o_diff EXPORTING iv_new = -file-data iv_old = -data. ENDIF. ENDIF. ENDMETHOD. METHOD build_menu. CREATE OBJECT ro_menu. add_menu_begin( ro_menu ). add_jump_sub_menu( ro_menu ). add_filter_sub_menu( ro_menu ). add_menu_end( ro_menu ). ENDMETHOD. METHOD calculate_diff. DATA: lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_status TYPE zif_abapgit_definitions=>ty_results_tt. FIELD-SYMBOLS: LIKE LINE OF lt_status. CLEAR: mt_diff_files. lt_remote = mo_repo->get_files_remote( ). lt_local = mo_repo->get_files_local( ). mo_repo->reset_status( ). lt_status = mo_repo->status( ). IF is_file IS NOT INITIAL. "" Diff for one file READ TABLE lt_status ASSIGNING WITH KEY path = is_file-path filename = is_file-filename. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ELSEIF is_object IS NOT INITIAL. "" Diff for whole object LOOP AT lt_status ASSIGNING WHERE obj_type = is_object-obj_type AND obj_name = is_object-obj_name AND match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ELSE. "" Diff for the whole repo SORT lt_status BY path ASCENDING filename ASCENDING. LOOP AT lt_status ASSIGNING WHERE match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ENDIF. filter_diff_by_files( EXPORTING it_files = it_files CHANGING ct_diff_files = mt_diff_files ). ENDMETHOD. METHOD constructor. DATA: lv_ts TYPE timestamp. super->constructor( ). ms_control-page_title = 'Diff'. mv_unified = zcl_abapgit_persistence_user=>get_instance( )->get_diff_unified( ). mv_repo_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). GET TIME STAMP FIELD lv_ts. mv_seed = |diff{ lv_ts }|. "" Generate based on time ASSERT is_file IS INITIAL OR is_object IS INITIAL. "" just one passed calculate_diff( is_file = is_file is_object = is_object it_files = it_files ). IF lines( mt_diff_files ) = 0. zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ). ENDIF. ms_control-page_menu = build_menu( ). ENDMETHOD. METHOD get_normalized_fname_with_path. rv_filename = normalize_path( is_diff-path ) && `_` && normalize_filename( is_diff-filename ). ENDMETHOD. METHOD insert_nav. ENDMETHOD. METHOD is_binary. FIELD-SYMBOLS LIKE iv_d1. IF iv_d1 IS NOT INITIAL. "" One of them might be new and so empty ASSIGN iv_d1 TO . ELSE. ASSIGN iv_d2 TO . ENDIF. rv_yes = zcl_abapgit_utils=>is_binary( ). ENDMETHOD. METHOD normalize_filename. rv_normalized = replace( val = iv_filename sub = '.' occ = 0 with = '_' ). ENDMETHOD. METHOD normalize_path. rv_normalized = replace( val = iv_path sub = '/' occ = 0 with = '_' ). ENDMETHOD. METHOD render_beacon. DATA: lv_beacon TYPE string, lt_beacons TYPE zif_abapgit_definitions=>ty_string_tt. CREATE OBJECT ro_html. IF is_diff_line-beacon > 0. lt_beacons = is_diff-o_diff->get_beacons( ). READ TABLE lt_beacons INTO lv_beacon INDEX is_diff_line-beacon. ELSE. lv_beacon = '---'. ENDIF. ro_html->add( '' ). ro_html->add( '' ). render_beacon_begin_of_row( io_html = ro_html is_diff = is_diff ). IF mv_unified = abap_true. ro_html->add( '' ). ro_html->add( '' ). ro_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ELSE. ro_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ENDIF. ro_html->add( '' ). ro_html->add( '' ). ENDMETHOD. METHOD render_beacon_begin_of_row. io_html->add( '' ). ENDMETHOD. METHOD render_content. DATA: ls_diff_file LIKE LINE OF mt_diff_files, li_progress TYPE REF TO zif_abapgit_progress. CREATE OBJECT ri_html TYPE zcl_abapgit_html. li_progress = zcl_abapgit_progress=>get_instance( lines( mt_diff_files ) ). ri_html->add( `
` ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( mo_repo ) ). ri_html->add( `
` ). ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_js_error_banner( ) ). LOOP AT mt_diff_files INTO ls_diff_file. li_progress->show( iv_current = sy-tabix iv_text = |Render Diff - { ls_diff_file-filename }| ). ri_html->add( render_diff( ls_diff_file ) ). ENDLOOP. IF sy-subrc <> 0. ri_html->add( |No more diffs| ). ENDIF. ri_html->add( '
' ). register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_diff. CREATE OBJECT ro_html. ro_html->add( |
| ). ""#EC NOTEXT ro_html->add( render_diff_head( is_diff ) ). "" Content IF is_diff-type <> 'binary'. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add( || ). ""#EC NOTEXT ro_html->add( render_table_head( is_diff ) ). ro_html->add( render_lines( is_diff ) ). ro_html->add( '
' ). ""#EC NOTEXT ELSE. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add( 'The content seems to be binary.' ). ""#EC NOTEXT ro_html->add( 'Cannot display as diff.' ). ""#EC NOTEXT ENDIF. ro_html->add( '
' ). ""#EC NOTEXT ro_html->add( '
' ). ""#EC NOTEXT ENDMETHOD. METHOD render_diff_head. DATA: ls_stats TYPE zif_abapgit_definitions=>ty_count, lv_adt_link TYPE string. CREATE OBJECT ro_html. ro_html->add( '
' ). ro_html->add_icon( iv_name = 'chevron-down' iv_hint = 'Collapse/Expand' iv_class = 'cursor-pointer' iv_onclick = 'onDiffCollapse(event)' ). IF is_diff-type <> 'binary'. ls_stats = is_diff-o_diff->stats( ). IF is_diff-fstate = c_fstate-both. "" Merge stats into 'update' if both were changed ls_stats-update = ls_stats-update + ls_stats-insert + ls_stats-delete. CLEAR: ls_stats-insert, ls_stats-delete. ENDIF. ro_html->add( |+ { ls_stats-insert }| ). ro_html->add( |- { ls_stats-delete }| ). ro_html->add( |~ { ls_stats-update }| ). ENDIF. "" no links for nonexistent or deleted objects IF is_diff-lstate IS NOT INITIAL AND is_diff-lstate <> 'D'. lv_adt_link = zcl_abapgit_html=>a( iv_txt = |{ is_diff-path }{ is_diff-filename }| iv_typ = zif_abapgit_html=>c_action_type-sapevent iv_act = |jump?TYPE={ is_diff-obj_type }&NAME={ is_diff-obj_name }| ). ENDIF. IF lv_adt_link IS NOT INITIAL. ro_html->add( |{ lv_adt_link }| ). ELSE. ro_html->add( |{ is_diff-path }{ is_diff-filename }| ). ENDIF. ro_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_diff-lstate iv_rstate = is_diff-rstate ) ). render_diff_head_after_state( io_html = ro_html is_diff = is_diff ). ro_html->add( |Last Changed by: { is_diff-changed_by }| ). ro_html->add( '
' ). ENDMETHOD. METHOD render_diff_head_after_state. IF is_diff-fstate = c_fstate-both AND mv_unified = abap_true. io_html->add( 'Attention: Unified mode' && ' highlighting for MM assumes local file is newer ! ' ). ""#EC NOTEXT ENDIF. ENDMETHOD. METHOD render_lines. DATA: lo_highlighter TYPE REF TO zcl_abapgit_syntax_highlighter, lt_diffs TYPE zif_abapgit_definitions=>ty_diffs_tt, lv_insert_nav TYPE abap_bool, lv_tabix TYPE syst-tabix. FIELD-SYMBOLS LIKE LINE OF lt_diffs. lo_highlighter = zcl_abapgit_syntax_highlighter=>create( is_diff-filename ). CREATE OBJECT ro_html. lt_diffs = is_diff-o_diff->get( ). lv_insert_nav = insert_nav( ). LOOP AT lt_diffs ASSIGNING . lv_tabix = sy-tabix. IF -short = abap_false. lv_insert_nav = abap_true. CONTINUE. ENDIF. IF lv_insert_nav = abap_true. "" Insert separator line with navigation ro_html->add( render_beacon( is_diff_line = is_diff = is_diff ) ). lv_insert_nav = abap_false. ENDIF. IF lo_highlighter IS BOUND. -new = lo_highlighter->process_line( -new ). -old = lo_highlighter->process_line( -old ). ELSE. -new = escape( val = -new format = cl_abap_format=>e_html_attr ). -old = escape( val = -old format = cl_abap_format=>e_html_attr ). ENDIF. CONDENSE -new_num. ""get rid of leading spaces CONDENSE -old_num. IF mv_unified = abap_true. ro_html->add( render_line_unified( is_diff_line = ) ). ELSE. ro_html->add( render_line_split( is_diff_line = iv_filename = get_normalized_fname_with_path( is_diff ) iv_fstate = is_diff-fstate iv_index = lv_tabix ) ). ENDIF. ENDLOOP. IF mv_unified = abap_true. ro_html->add( render_line_unified( ) ). "" Release delayed lines ENDIF. ENDMETHOD. METHOD render_line_split. DATA: lv_new TYPE string, lv_old TYPE string, lv_mark TYPE string, lv_bg TYPE string. CREATE OBJECT ro_html. "" New line lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-insert. lv_bg = ' diff_ins'. lv_mark = `+`. ENDIF. ENDIF. lv_new = || && |{ lv_mark }| && |{ is_diff_line-new }|. "" Old line CLEAR lv_bg. lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-delete. lv_bg = ' diff_del'. lv_mark = `-`. ENDIF. ENDIF. lv_old = || && |{ lv_mark }| && |{ is_diff_line-old }|. "" render line, inverse sides if remote is newer ro_html->add( '' ). ""#EC NOTEXT render_line_split_row( io_html = ro_html iv_filename = iv_filename is_diff_line = is_diff_line iv_index = iv_index iv_fstate = iv_fstate iv_old = lv_old iv_new = lv_new ). ro_html->add( '' ). ""#EC NOTEXT ENDMETHOD. METHOD render_line_split_row. IF iv_fstate = c_fstate-remote. "" Remote file leading changes io_html->add( iv_old ). "" local io_html->add( iv_new ). "" remote ELSE. "" Local leading changes or both were modified io_html->add( iv_new ). "" local io_html->add( iv_old ). "" remote ENDIF. ENDMETHOD. METHOD render_line_unified. FIELD-SYMBOLS LIKE LINE OF mt_delayed_lines. CREATE OBJECT ro_html. "" Release delayed subsequent update lines IF is_diff_line-result <> zif_abapgit_definitions=>c_diff-update. LOOP AT mt_delayed_lines ASSIGNING . ro_html->add( '' ). ""#EC NOTEXT ro_html->add( |-old_num }"">| && || && |-| && |{ -old }| ). ro_html->add( '' ). ""#EC NOTEXT ENDLOOP. LOOP AT mt_delayed_lines ASSIGNING . ro_html->add( '' ). ""#EC NOTEXT ro_html->add( || && |-new_num }"">| && |+| && |{ -new }| ). ro_html->add( '' ). ""#EC NOTEXT ENDLOOP. CLEAR mt_delayed_lines. ENDIF. ro_html->add( '' ). ""#EC NOTEXT CASE is_diff_line-result. WHEN zif_abapgit_definitions=>c_diff-update. APPEND is_diff_line TO mt_delayed_lines. "" Delay output of subsequent updates WHEN zif_abapgit_definitions=>c_diff-insert. ro_html->add( || && || && |+| && |{ is_diff_line-new }| ). WHEN zif_abapgit_definitions=>c_diff-delete. ro_html->add( || && || && |-| && |{ is_diff_line-old }| ). WHEN OTHERS. ""none ro_html->add( || && || && | | && |{ is_diff_line-old }| ). ENDCASE. ro_html->add( '' ). ""#EC NOTEXT ENDMETHOD. METHOD render_scripts. CREATE OBJECT ro_html. ro_html->zif_abapgit_html~set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ro_html->add( 'restoreScrollPosition();' ). ro_html->add( 'var gHelper = new DiffHelper({' ). ro_html->add( | seed: ""{ mv_seed }"",| ). ro_html->add( ' ids: {' ). ro_html->add( ' jump: ""jump"",' ). ro_html->add( ' diffList: ""diff-list"",' ). ro_html->add( ' filterMenu: ""diff-filter"",' ). ro_html->add( ' }' ). ro_html->add( '});' ). ro_html->add( 'addMarginBottom();' ). ro_html->add( 'var gGoJumpPalette = new CommandPalette(enumerateJumpAllFiles, {' ). ro_html->add( ' toggleKey: ""F2"",' ). ro_html->add( ' hotkeyDescription: ""Jump to file ...""' ). ro_html->add( '});' ). "" Feature for selecting ABAP code by column and copy to clipboard ro_html->add( 'var columnSelection = new DiffColumnSelection();' ). ENDMETHOD. METHOD render_table_head. CREATE OBJECT ro_html. ro_html->add( '' ). ro_html->add( '' ). IF mv_unified = abap_true. render_table_head_unified( ro_html ). ELSE. render_table_head_non_unified( io_html = ro_html is_diff = is_diff ). ENDIF. ro_html->add( '' ). ro_html->add( '' ). ENDMETHOD. METHOD render_table_head_non_unified. io_html->add( '' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( 'LOCAL' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( 'REMOTE' ). ""#EC NOTEXT ENDMETHOD. METHOD render_table_head_unified. io_html->add( 'old' ). ""#EC NOTEXT io_html->add( 'new' ). ""#EC NOTEXT io_html->add( '' ). ""#EC NOTEXT io_html->add( 'code' ). ""#EC NOTEXT ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. CASE iv_action. WHEN c_actions-toggle_unified. "" Toggle file diplay mv_unified = zcl_abapgit_persistence_user=>get_instance( )->toggle_diff_unified( ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. super->zif_abapgit_gui_event_handler~on_event( EXPORTING iv_action = iv_action iv_getdata = iv_getdata it_postdata = it_postdata IMPORTING ei_page = ei_page ev_state = ev_state ). ENDCASE. ENDMETHOD. METHOD filter_diff_by_files. FIELD-SYMBOLS: TYPE ty_file_diff. IF lines( it_files ) = 0. RETURN. ENDIF. "" Diff only for specified files LOOP AT ct_diff_files ASSIGNING . READ TABLE it_files TRANSPORTING NO FIELDS WITH KEY file-filename = -filename. IF sy-subrc <> 0. DELETE TABLE ct_diff_files FROM . ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. ",8191,False,1541.0691780634102,median "// Urho3D editor view & camera functions WeakHandle previewCamera; Node@ cameraNode; Camera@ camera; Node@ gridNode; CustomGeometry@ grid; UIElement@ viewportUI; // holds the viewport ui, convienent for clearing and hiding uint setViewportCursor = 0; // used to set cursor in post update uint resizingBorder = 0; // current border that is dragging uint viewportMode = VIEWPORT_SINGLE; int viewportBorderOffset = 2; // used to center borders over viewport seams, should be half of width int viewportBorderWidth = 4; // width of a viewport resize border IntRect viewportArea; // the area where the editor viewport is. if we ever want to have the viewport not take up the whole screen this abstracts that IntRect viewportUIClipBorder = IntRect(27, 60, 0, 0); // used to clip viewport borders, the borders are ugly when going behind the transparent toolbars RenderPath@ renderPath; // Renderpath to use on all views String renderPathName; bool mouseWheelCameraPosition = false; bool contextMenuActionWaitFrame = false; bool cameraFlyMode = true; int hotKeyMode = 0; // used for checking that kind of style manipulation user are prefer (see HotKeysMode) Vector3 lastSelectedNodesCenterPoint = Vector3(0,0,0); // for Blender mode to avoid own origin rotation when no nodes are selected. preserve last center for this WeakHandle lastSelectedNode = null; WeakHandle lastSelectedDrawable = null; WeakHandle lastSelectedComponent = null; bool viewCloser = false; Component@ coloringComponent = null; String coloringTypeName; String coloringPropertyName; Color coloringOldColor; float coloringOldScalar; bool debugRenderDisabled = false; const uint VIEWPORT_BORDER_H = 0x00000001; const uint VIEWPORT_BORDER_H1 = 0x00000002; const uint VIEWPORT_BORDER_H2 = 0x00000004; const uint VIEWPORT_BORDER_V = 0x00000010; const uint VIEWPORT_BORDER_V1 = 0x00000020; const uint VIEWPORT_BORDER_V2 = 0x00000040; const uint VIEWPORT_SINGLE = 0x00000000; const uint VIEWPORT_TOP = 0x00000100; const uint VIEWPORT_BOTTOM = 0x00000200; const uint VIEWPORT_LEFT = 0x00000400; const uint VIEWPORT_RIGHT = 0x00000800; const uint VIEWPORT_TOP_LEFT = 0x00001000; const uint VIEWPORT_TOP_RIGHT = 0x00002000; const uint VIEWPORT_BOTTOM_LEFT = 0x00004000; const uint VIEWPORT_BOTTOM_RIGHT = 0x00008000; // Combinations for easier testing const uint VIEWPORT_BORDER_H_ANY = 0x00000007; const uint VIEWPORT_BORDER_V_ANY = 0x00000070; const uint VIEWPORT_SPLIT_H = 0x0000f300; const uint VIEWPORT_SPLIT_V = 0x0000fc00; const uint VIEWPORT_SPLIT_HV = 0x0000f000; const uint VIEWPORT_TOP_ANY = 0x00003300; const uint VIEWPORT_BOTTOM_ANY = 0x0000c200; const uint VIEWPORT_LEFT_ANY = 0x00005400; const uint VIEWPORT_RIGHT_ANY = 0x0000c800; const uint VIEWPORT_QUAD = 0x0000f000; enum HotKeysMode { HOTKEYS_MODE_STANDARD = 0, HOTKEYS_MODE_BLENDER } enum EditMode { EDIT_MOVE = 0, EDIT_ROTATE, EDIT_SCALE, EDIT_SELECT, EDIT_SPAWN } enum AxisMode { AXIS_WORLD = 0, AXIS_LOCAL } enum SnapScaleMode { SNAP_SCALE_FULL = 0, SNAP_SCALE_HALF, SNAP_SCALE_QUARTER } // Holds info about a viewport such as camera settings and splits up shared resources class ViewportContext { float cameraYaw = 0; float cameraPitch = 0; Camera@ camera; Node@ cameraNode; SoundListener@ soundListener; Viewport@ viewport; bool enabled = false; uint index = 0; uint viewportId = 0; UIElement@ viewportContextUI; UIElement@ statusBar; Text@ cameraPosText; Window@ settingsWindow; LineEdit@ cameraPosX; LineEdit@ cameraPosY; LineEdit@ cameraPosZ; LineEdit@ cameraRotX; LineEdit@ cameraRotY; LineEdit@ cameraRotZ; LineEdit@ cameraZoom; LineEdit@ cameraOrthoSize; CheckBox@ cameraOrthographic; ViewportContext(IntRect viewRect, uint index_, uint viewportId_) { cameraNode = Node(); camera = cameraNode.CreateComponent(""Camera""); camera.fillMode = fillMode; soundListener = cameraNode.CreateComponent(""SoundListener""); viewport = Viewport(editorScene, camera, viewRect, renderPath); index = index_; viewportId = viewportId_; camera.viewMask = 0xffffffff; // It's easier to only have 1 gizmo active this viewport is shared with the gizmo } void ResetCamera() { cameraNode.position = Vector3(0, 5, -10); // Look at the origin so user can see the scene. cameraNode.rotation = Quaternion(Vector3(0, 0, 1), -cameraNode.position); ReacquireCameraYawPitch(); UpdateSettingsUI(); } void ReacquireCameraYawPitch() { cameraYaw = cameraNode.rotation.yaw; cameraPitch = cameraNode.rotation.pitch; } void CreateViewportContextUI() { Font@ font = cache.GetResource(""Font"", ""Fonts/Anonymous Pro.ttf""); viewportContextUI = UIElement(); viewportUI.AddChild(viewportContextUI); viewportContextUI.SetPosition(viewport.rect.left, viewport.rect.top); viewportContextUI.SetFixedSize(viewport.rect.width, viewport.rect.height); viewportContextUI.clipChildren = true; statusBar = BorderImage(""ToolBar""); statusBar.style = ""EditorToolBar""; viewportContextUI.AddChild(statusBar); statusBar.SetLayout(LM_HORIZONTAL); statusBar.SetAlignment(HA_LEFT, VA_BOTTOM); statusBar.layoutSpacing = 4; statusBar.opacity = uiMaxOpacity; Button@ settingsButton = CreateSmallToolBarButton(""Settings""); statusBar.AddChild(settingsButton); cameraPosText = Text(); statusBar.AddChild(cameraPosText); cameraPosText.SetFont(font, 11); cameraPosText.color = Color(1, 1, 0); cameraPosText.textEffect = TE_SHADOW; cameraPosText.priority = -100; settingsWindow = LoadEditorUI(""UI/EditorViewport.xml""); settingsWindow.opacity = uiMaxOpacity; settingsWindow.visible = false; viewportContextUI.AddChild(settingsWindow); cameraPosX = settingsWindow.GetChild(""PositionX"", true); cameraPosY = settingsWindow.GetChild(""PositionY"", true); cameraPosZ = settingsWindow.GetChild(""PositionZ"", true); cameraRotX = settingsWindow.GetChild(""RotationX"", true); cameraRotY = settingsWindow.GetChild(""RotationY"", true); cameraRotZ = settingsWindow.GetChild(""RotationZ"", true); cameraOrthographic = settingsWindow.GetChild(""Orthographic"", true); cameraZoom = settingsWindow.GetChild(""Zoom"", true); cameraOrthoSize = settingsWindow.GetChild(""OrthoSize"", true); SubscribeToEvent(cameraPosX, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraPosY, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraPosZ, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraRotX, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraRotY, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraRotZ, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraZoom, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraOrthoSize, ""TextChanged"", ""HandleSettingsLineEditTextChange""); SubscribeToEvent(cameraOrthographic, ""Toggled"", ""HandleOrthographicToggled""); SubscribeToEvent(settingsButton, ""Released"", ""ToggleViewportSettingsWindow""); SubscribeToEvent(settingsWindow.GetChild(""ResetCamera"", true), ""Released"", ""ResetCamera""); SubscribeToEvent(settingsWindow.GetChild(""CopyTransform"", true), ""Released"", ""HandleCopyTransformClicked""); SubscribeToEvent(settingsWindow.GetChild(""CloseButton"", true), ""Released"", ""CloseViewportSettingsWindow""); SubscribeToEvent(settingsWindow.GetChild(""Refresh"", true), ""Released"", ""UpdateSettingsUI""); HandleResize(); } void HandleResize() { viewportContextUI.SetPosition(viewport.rect.left, viewport.rect.top); viewportContextUI.SetFixedSize(viewport.rect.width, viewport.rect.height); if (viewport.rect.left < 34) { statusBar.layoutBorder = IntRect(34 - viewport.rect.left, 4, 4, 8); IntVector2 pos = settingsWindow.position; pos.x = 32 - viewport.rect.left; settingsWindow.position = pos; } else { statusBar.layoutBorder = IntRect(8, 4, 4, 8); IntVector2 pos = settingsWindow.position; pos.x = 5; settingsWindow.position = pos; } statusBar.SetFixedSize(viewport.rect.width, 22); } void ToggleOrthographic() { SetOrthographic(!camera.orthographic); } void SetOrthographic(bool orthographic) { camera.orthographic = orthographic; UpdateSettingsUI(); } void Update(float timeStep) { Vector3 cameraPos = cameraNode.position; String xText(cameraPos.x); String yText(cameraPos.y); String zText(cameraPos.z); xText.Resize(8); yText.Resize(8); zText.Resize(8); cameraPosText.text = String( ""Pos: "" + xText + "" "" + yText + "" "" + zText + "" Zoom: "" + camera.zoom); cameraPosText.size = cameraPosText.minSize; } void ToggleViewportSettingsWindow() { if (settingsWindow.visible) CloseViewportSettingsWindow(); else OpenViewportSettingsWindow(); } void OpenViewportSettingsWindow() { UpdateSettingsUI(); /* settingsWindow.position = */ settingsWindow.visible = true; settingsWindow.BringToFront(); } void CloseViewportSettingsWindow() { settingsWindow.visible = false; } void UpdateSettingsUI() { cameraPosX.text = String(Floor(cameraNode.position.x * 1000) / 1000); cameraPosY.text = String(Floor(cameraNode.position.y * 1000) / 1000); cameraPosZ.text = String(Floor(cameraNode.position.z * 1000) / 1000); cameraRotX.text = String(Floor(cameraNode.rotation.pitch * 1000) / 1000); cameraRotY.text = String(Floor(cameraNode.rotation.yaw * 1000) / 1000); cameraRotZ.text = String(Floor(cameraNode.rotation.roll * 1000) / 1000); cameraZoom.text = String(Floor(camera.zoom * 1000) / 1000); cameraOrthoSize.text = String(Floor(camera.orthoSize * 1000) / 1000); cameraOrthographic.checked = camera.orthographic; } void HandleOrthographicToggled(StringHash eventType, VariantMap& eventData) { SetOrthographic(cameraOrthographic.checked); } void HandleSettingsLineEditTextChange(StringHash eventType, VariantMap& eventData) { LineEdit@ element = eventData[""Element""].GetPtr(); if (element.text == """") return; if (element is cameraRotX || element is cameraRotY || element is cameraRotZ) { Vector3 euler = cameraNode.rotation.eulerAngles; if (element is cameraRotX) euler.x = element.text.ToFloat(); else if (element is cameraRotY) euler.y = element.text.ToFloat(); else if (element is cameraRotZ) euler.z = element.text.ToFloat(); cameraNode.rotation = Quaternion(euler); } else if (element is cameraPosX || element is cameraPosY || element is cameraPosZ) { Vector3 pos = cameraNode.position; if (element is cameraPosX) pos.x = element.text.ToFloat(); else if (element is cameraPosY) pos.y = element.text.ToFloat(); else if (element is cameraPosZ) pos.z = element.text.ToFloat(); cameraNode.position = pos; } else if (element is cameraZoom) camera.zoom = element.text.ToFloat(); else if (element is cameraOrthoSize) camera.orthoSize = element.text.ToFloat(); } void HandleCopyTransformClicked(StringHash eventType, VariantMap& eventData) { if (editNode !is null) { editNode.position = cameraNode.position; editNode.rotation = cameraNode.rotation; } } } Array viewports; ViewportContext@ activeViewport; Text@ editorModeText; Text@ renderStatsText; Text@ modelInfoText; EditMode editMode = EDIT_MOVE; AxisMode axisMode = AXIS_WORLD; FillMode fillMode = FILL_SOLID; SnapScaleMode snapScaleMode = SNAP_SCALE_FULL; float viewNearClip = 0.1; float viewFarClip = 1000.0; float viewFov = 45.0; float cameraBaseSpeed = 10; float cameraBaseRotationSpeed = 0.2; float cameraShiftSpeedMultiplier = 5; float moveStep = 0.5; float rotateStep = 5; float scaleStep = 0.1; float snapScale = 1.0; bool limitRotation = false; bool moveSnap = false; bool rotateSnap = false; bool scaleSnap = false; bool renderingDebug = false; bool physicsDebug = false; bool octreeDebug = false; int pickMode = PICK_GEOMETRIES; bool orbiting = false; enum MouseOrbitMode { ORBIT_RELATIVE = 0, ORBIT_WRAP } bool toggledMouseLock = false; int mouseOrbitMode = ORBIT_RELATIVE; bool mmbPanMode = false; enum NewNodeMode { NEW_NODE_CAMERA_DIST = 0, NEW_NODE_IN_CENTER, NEW_NODE_RAYCAST } float newNodeDistance = 20; int newNodeMode = NEW_NODE_CAMERA_DIST; bool showGrid = true; bool grid2DMode = false; uint gridSize = 16; uint gridSubdivisions = 3; float gridScale = 8.0; Color gridColor(0.1, 0.1, 0.1); Color gridSubdivisionColor(0.05, 0.05, 0.05); Color gridXColor(0.5, 0.1, 0.1); Color gridYColor(0.1, 0.5, 0.1); Color gridZColor(0.1, 0.1, 0.5); Array pickModeDrawableFlags = { DRAWABLE_GEOMETRY, DRAWABLE_LIGHT, DRAWABLE_ZONE }; Array editModeText = { ""Move"", ""Rotate"", ""Scale"", ""Select"", ""Spawn"" }; Array axisModeText = { ""World"", ""Local"" }; Array pickModeText = { ""Geometries"", ""Lights"", ""Zones"", ""Rigidbodies"", ""UI-elements"" }; Array fillModeText = { ""Solid"", ""Wire"", ""Point"" }; void SetRenderPath(const String&in newRenderPathName) { renderPath = null; renderPathName = newRenderPathName.Trimmed(); if (renderPathName.length > 0) { File@ file = cache.GetFile(renderPathName); if (file !is null) { XMLFile@ xml = XMLFile(); if (xml.Load(file)) { renderPath = RenderPath(); if (!renderPath.Load(xml)) renderPath = null; } } } // If renderPath is null, the engine default will be used for (uint i = 0; i < renderer.numViewports; ++i) renderer.viewports[i].renderPath = renderPath; if (materialPreview !is null && materialPreview.viewport !is null) materialPreview.viewport.renderPath = renderPath; if (particleEffectPreview !is null && particleEffectPreview.viewport !is null) particleEffectPreview.viewport.renderPath = renderPath; } void CreateCamera() { // Set the initial viewport rect viewportArea = IntRect(0, 0, graphics.width, graphics.height); SetViewportMode(viewportMode); SetActiveViewport(viewports[0]); // Note: the camera is not inside the scene, so that it is not listed, and does not get deleted ResetCamera(); // Set initial renderpath if defined SetRenderPath(renderPathName); } // Create any UI associated with changing the editor viewports void CreateViewportUI() { if (viewportUI is null) { viewportUI = UIElement(); ui.root.AddChild(viewportUI); } viewportUI.SetFixedSize(viewportArea.width, viewportArea.height); viewportUI.position = IntVector2(viewportArea.top, viewportArea.left); viewportUI.clipChildren = true; viewportUI.clipBorder = viewportUIClipBorder; viewportUI.RemoveAllChildren(); viewportUI.priority = -2000; Array borders; IntRect top; IntRect bottom; IntRect left; IntRect right; IntRect topLeft; IntRect topRight; IntRect bottomLeft; IntRect bottomRight; for (uint i = 0; i < viewports.length; ++i) { ViewportContext@ vc = viewports[i]; vc.CreateViewportContextUI(); if (vc.viewportId & VIEWPORT_TOP > 0) top = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_BOTTOM > 0) bottom = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_LEFT > 0) left = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_RIGHT > 0) right = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_TOP_LEFT > 0) topLeft = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_TOP_RIGHT > 0) topRight = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_BOTTOM_LEFT > 0) bottomLeft = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_BOTTOM_RIGHT > 0) bottomRight = vc.viewport.rect; } // Creates resize borders based on the mode set if (viewportMode == VIEWPORT_QUAD) // independent borders for quad isn't easy { borders.Push(CreateViewportDragBorder(VIEWPORT_BORDER_V, topLeft.right - viewportBorderOffset, topLeft.top, viewportBorderWidth, viewportArea.height)); borders.Push(CreateViewportDragBorder(VIEWPORT_BORDER_H, topLeft.left, topLeft.bottom-viewportBorderOffset, viewportArea.width, viewportBorderWidth)); } else { // Figures what borders to create based on mode if (viewportMode & (VIEWPORT_LEFT|VIEWPORT_RIGHT) > 0) { borders.Push( viewportMode & VIEWPORT_LEFT > 0 ? CreateViewportDragBorder(VIEWPORT_BORDER_V, left.right-viewportBorderOffset, left.top, viewportBorderWidth, left.height) : CreateViewportDragBorder(VIEWPORT_BORDER_V, right.left-viewportBorderOffset, right.top, viewportBorderWidth, right.height) ); } else { if (viewportMode & (VIEWPORT_TOP_LEFT|VIEWPORT_TOP_RIGHT) > 0) borders.Push(CreateViewportDragBorder(VIEWPORT_BORDER_V1, topLeft.right-viewportBorderOffset, topLeft.top, viewportBorderWidth, topLeft.height)); if (viewportMode & (VIEWPORT_BOTTOM_LEFT|VIEWPORT_BOTTOM_RIGHT) > 0) borders.Push(CreateViewportDragBorder(VIEWPORT_BORDER_V2, bottomLeft.right-viewportBorderOffset, bottomLeft.top, viewportBorderWidth, bottomLeft.height)); } if (viewportMode & (VIEWPORT_TOP|VIEWPORT_BOTTOM) > 0) { borders.Push( viewportMode & VIEWPORT_TOP > 0 ? CreateViewportDragBorder(VIEWPORT_BORDER_H, top.left, top.bottom-viewportBorderOffset, top.width, viewportBorderWidth) : CreateViewportDragBorder(VIEWPORT_BORDER_H, bottom.left, bottom.top-viewportBorderOffset, bottom.width, viewportBorderWidth) ); } else { if (viewportMode & (VIEWPORT_TOP_LEFT|VIEWPORT_BOTTOM_LEFT) > 0) borders.Push(CreateViewportDragBorder(VIEWPORT_BORDER_H1, topLeft.left, topLeft.bottom-viewportBorderOffset, topLeft.width, viewportBorderWidth)); if (viewportMode & (VIEWPORT_TOP_RIGHT|VIEWPORT_BOTTOM_RIGHT) > 0) borders.Push(CreateViewportDragBorder(VIEWPORT_BORDER_H2, topRight.left, topRight.bottom-viewportBorderOffset, topRight.width, viewportBorderWidth)); } } } BorderImage@ CreateViewportDragBorder(uint value, int posX, int posY, int sizeX, int sizeY) { BorderImage@ border = BorderImage(); viewportUI.AddChild(border); border.name = ""border""; border.style = ""ViewportBorder""; border.vars[""VIEWMODE""] = value; border.SetFixedSize(sizeX, sizeY); // relevant size gets set by viewport later border.position = IntVector2(posX, posY); border.opacity = uiMaxOpacity; SubscribeToEvent(border, ""DragMove"", ""HandleViewportBorderDragMove""); SubscribeToEvent(border, ""DragEnd"", ""HandleViewportBorderDragEnd""); return border; } void SetFillMode(FillMode fillMode_) { fillMode = fillMode_; for (uint i = 0; i < viewports.length; ++i) viewports[i].camera.fillMode = fillMode_; } // Sets the viewport mode void SetViewportMode(uint mode = VIEWPORT_SINGLE) { // Remember old viewport positions Array cameraPositions; Array cameraRotations; for (uint i = 0; i < viewports.length; ++i) { cameraPositions.Push(viewports[i].cameraNode.position); cameraRotations.Push(viewports[i].cameraNode.rotation); } viewports.Clear(); viewportMode = mode; // Always have quad a { uint viewport = 0; ViewportContext@ vc = ViewportContext( IntRect( 0, 0, mode & (VIEWPORT_LEFT|VIEWPORT_TOP_LEFT) > 0 ? viewportArea.width / 2 : viewportArea.width, mode & (VIEWPORT_TOP|VIEWPORT_TOP_LEFT) > 0 ? viewportArea.height / 2 : viewportArea.height), viewports.length + 1, viewportMode & (VIEWPORT_TOP|VIEWPORT_LEFT|VIEWPORT_TOP_LEFT) ); viewports.Push(vc); } uint topRight = viewportMode & (VIEWPORT_RIGHT|VIEWPORT_TOP_RIGHT); if (topRight > 0) { ViewportContext@ vc = ViewportContext( IntRect( viewportArea.width/2, 0, viewportArea.width, mode & VIEWPORT_TOP_RIGHT > 0 ? viewportArea.height / 2 : viewportArea.height), viewports.length + 1, topRight ); viewports.Push(vc); } uint bottomLeft = viewportMode & (VIEWPORT_BOTTOM|VIEWPORT_BOTTOM_LEFT); if (bottomLeft > 0) { ViewportContext@ vc = ViewportContext( IntRect( 0, viewportArea.height / 2, mode & (VIEWPORT_BOTTOM_LEFT) > 0 ? viewportArea.width / 2 : viewportArea.width, viewportArea.height), viewports.length + 1, bottomLeft ); viewports.Push(vc); } uint bottomRight = viewportMode & (VIEWPORT_BOTTOM_RIGHT); if (bottomRight > 0) { ViewportContext@ vc = ViewportContext( IntRect( viewportArea.width / 2, viewportArea.height / 2, viewportArea.width, viewportArea.height), viewports.length + 1, bottomRight ); viewports.Push(vc); } renderer.numViewports = viewports.length; for (uint i = 0; i < viewports.length; ++i) renderer.viewports[i] = viewports[i].viewport; // Restore camera positions as applicable. Default new viewports to the last camera position if (cameraPositions.length > 0) { for (uint i = 0; i < viewports.length; ++i) { uint src = i; if (src >= cameraPositions.length) src = cameraPositions.length - 1; viewports[i].cameraNode.position = cameraPositions[src]; viewports[i].cameraNode.rotation = cameraRotations[src]; } } ReacquireCameraYawPitch(); UpdateViewParameters(); UpdateCameraPreview(); CreateViewportUI(); } // Create a preview viewport if a camera component is selected void UpdateCameraPreview() { previewCamera = null; StringHash cameraType(""Camera""); for (uint i = 0; i < selectedComponents.length; ++i) { if (selectedComponents[i].type == cameraType) { // Take the first encountered camera previewCamera = selectedComponents[i]; break; } } // Also try nodes if not found from components if (previewCamera.Get() is null) { for (uint i = 0; i < selectedNodes.length; ++i) { previewCamera = selectedNodes[i].GetComponent(""Camera""); if (previewCamera.Get() !is null) break; } } // Remove extra viewport if it exists and no camera is selected if (previewCamera.Get() is null) { if (renderer.numViewports > viewports.length) renderer.numViewports = viewports.length; } else { if (renderer.numViewports < viewports.length + 1) renderer.numViewports = viewports.length + 1; int previewWidth = graphics.width / 4; int previewHeight = previewWidth * 9 / 16; int previewX = graphics.width - 10 - previewWidth; int previewY = graphics.height - 30 - previewHeight; Viewport@ previewView = Viewport(); previewView.scene = editorScene; previewView.camera = previewCamera.Get(); previewView.rect = IntRect(previewX, previewY, previewX + previewWidth, previewY + previewHeight); previewView.renderPath = renderPath; renderer.viewports[viewports.length] = previewView; } } void HandleViewportBorderDragMove(StringHash eventType, VariantMap& eventData) { UIElement@ dragBorder = eventData[""Element""].GetPtr(); if (dragBorder is null) return; uint hPos; uint vPos; // Moves border to new cursor position, restricts motion to 1 axis, and keeps borders within view area if (resizingBorder & VIEWPORT_BORDER_V_ANY > 0) { hPos = Clamp(ui.cursorPosition.x, 150, viewportArea.width-150); vPos = dragBorder.position.y; dragBorder.position = IntVector2(hPos, vPos); } if (resizingBorder & VIEWPORT_BORDER_H_ANY > 0) { vPos = Clamp(ui.cursorPosition.y, 150, viewportArea.height-150); hPos = dragBorder.position.x; dragBorder.position = IntVector2(hPos, vPos); } // Move all dependent borders Array borders = viewportUI.GetChildren(); for (uint i = 0; i < borders.length; ++i) { BorderImage@ border = borders[i]; if (border is null || border is dragBorder || border.name != ""border"") continue; uint borderViewMode = border.vars[""VIEWMODE""].GetUInt(); if (resizingBorder == VIEWPORT_BORDER_H) { if (borderViewMode == VIEWPORT_BORDER_V1) { border.SetFixedHeight(vPos); } else if (borderViewMode == VIEWPORT_BORDER_V2) { border.position = IntVector2(border.position.x, vPos); border.SetFixedHeight(viewportArea.height - vPos); } } else if (resizingBorder == VIEWPORT_BORDER_V) { if (borderViewMode == VIEWPORT_BORDER_H1) { border.SetFixedWidth(hPos); } else if (borderViewMode == VIEWPORT_BORDER_H2) { border.position = IntVector2(hPos, border.position.y); border.SetFixedWidth(viewportArea.width - hPos); } } } } void HandleViewportBorderDragEnd(StringHash eventType, VariantMap& eventData) { // Sets the new viewports by checking all the dependencies Array children = viewportUI.GetChildren(); Array borders; BorderImage@ borderV; BorderImage@ borderV1; BorderImage@ borderV2; BorderImage@ borderH; BorderImage@ borderH1; BorderImage@ borderH2; for (uint i = 0; i < children.length; ++i) { if (children[i].name == ""border"") { BorderImage@ border = children[i]; uint mode = border.vars[""VIEWMODE""].GetUInt(); if (mode == VIEWPORT_BORDER_V) borderV = border; else if (mode == VIEWPORT_BORDER_V1) borderV1 = border; else if (mode == VIEWPORT_BORDER_V2) borderV2 = border; else if (mode == VIEWPORT_BORDER_H) borderH = border; else if (mode == VIEWPORT_BORDER_H1) borderH1 = border; else if (mode == VIEWPORT_BORDER_H2) borderH2 = border; } } IntRect top; IntRect bottom; IntRect left; IntRect right; IntRect topLeft; IntRect topRight; IntRect bottomLeft; IntRect bottomRight; for (uint i = 0; i < viewports.length; ++i) { ViewportContext@ vc = viewports[i]; if (vc.viewportId & VIEWPORT_TOP > 0) top = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_BOTTOM > 0) bottom = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_LEFT > 0) left = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_RIGHT > 0) right = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_TOP_LEFT > 0) topLeft = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_TOP_RIGHT > 0) topRight = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_BOTTOM_LEFT > 0) bottomLeft = vc.viewport.rect; else if (vc.viewportId & VIEWPORT_BOTTOM_RIGHT > 0) bottomRight = vc.viewport.rect; } if (borderV !is null) { if (viewportMode & VIEWPORT_LEFT > 0) left.right = borderV.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_TOP_LEFT > 0) topLeft.right = borderV.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_TOP_RIGHT > 0) topRight.left = borderV.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_RIGHT > 0) right.left = borderV.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_LEFT > 0) bottomLeft.right = borderV.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_RIGHT > 0) bottomRight.left = borderV.position.x + viewportBorderOffset; } else { if (borderV1 !is null) { if (viewportMode & VIEWPORT_TOP_LEFT > 0) topLeft.right = borderV1.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_TOP_RIGHT > 0) topRight.left = borderV1.position.x + viewportBorderOffset; } if (borderV2 !is null) { if (viewportMode & VIEWPORT_BOTTOM_LEFT > 0) bottomLeft.right = borderV2.position.x + viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_RIGHT > 0) bottomRight.left = borderV2.position.x + viewportBorderOffset; } } if (borderH !is null) { if (viewportMode & VIEWPORT_TOP > 0) top.bottom = borderH.position.y + viewportBorderOffset; if (viewportMode & VIEWPORT_TOP_LEFT > 0) topLeft.bottom = borderH.position.y + viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_LEFT > 0) bottomLeft.top = borderH.position.y + viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM > 0) bottom.top = borderH.position.y + viewportBorderOffset; if (viewportMode & VIEWPORT_TOP_RIGHT > 0) topRight.bottom = borderH.position.y + viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_RIGHT > 0) bottomRight.top = borderH.position.y + viewportBorderOffset; } else { if (borderH1 !is null) { if (viewportMode & VIEWPORT_TOP_LEFT > 0) topLeft.bottom = borderH1.position.y+viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_LEFT > 0) bottomLeft.top = borderH1.position.y+viewportBorderOffset; } if (borderH2 !is null) { if (viewportMode & VIEWPORT_TOP_RIGHT > 0) topRight.bottom = borderH2.position.y+viewportBorderOffset; if (viewportMode & VIEWPORT_BOTTOM_RIGHT > 0) bottomRight.top = borderH2.position.y+viewportBorderOffset; } } // Applies the calculated changes for (uint i = 0; i < viewports.length; ++i) { ViewportContext@ vc = viewports[i]; if (vc.viewportId & VIEWPORT_TOP > 0) vc.viewport.rect = top; else if (vc.viewportId & VIEWPORT_BOTTOM > 0) vc.viewport.rect = bottom; else if (vc.viewportId & VIEWPORT_LEFT > 0) vc.viewport.rect = left; else if (vc.viewportId & VIEWPORT_RIGHT > 0) vc.viewport.rect = right; else if (vc.viewportId & VIEWPORT_TOP_LEFT > 0) vc.viewport.rect = topLeft; else if (vc.viewportId & VIEWPORT_TOP_RIGHT > 0) vc.viewport.rect = topRight; else if (vc.viewportId & VIEWPORT_BOTTOM_LEFT > 0) vc.viewport.rect = bottomLeft; else if (vc.viewportId & VIEWPORT_BOTTOM_RIGHT > 0) vc.viewport.rect = bottomRight; vc.HandleResize(); } // End drag state resizingBorder = 0; setViewportCursor = 0; } void SetViewportCursor() { if (setViewportCursor & VIEWPORT_BORDER_V_ANY > 0) ui.cursor.shape = CS_RESIZEHORIZONTAL; else if (setViewportCursor & VIEWPORT_BORDER_H_ANY > 0) ui.cursor.shape = CS_RESIZEVERTICAL; } void SetActiveViewport(ViewportContext@ context) { // Sets the global variables to the current context @cameraNode = context.cameraNode; @camera = context.camera; @audio.listener = context.soundListener; // Camera is created before gizmo, this gets called again after UI is created if (gizmo !is null) gizmo.viewMask = camera.viewMask; @activeViewport = context; // If a mode is changed while in a drag or hovering over a border these can get out of sync resizingBorder = 0; setViewportCursor = 0; } void ResetCamera() { for (uint i = 0; i < viewports.length; ++i) viewports[i].ResetCamera(); } void ReacquireCameraYawPitch() { for (uint i = 0; i < viewports.length; ++i) viewports[i].ReacquireCameraYawPitch(); } void UpdateViewParameters() { for (uint i = 0; i < viewports.length; ++i) { viewports[i].camera.nearClip = viewNearClip; viewports[i].camera.farClip = viewFarClip; viewports[i].camera.fov = viewFov; } } void CreateGrid() { if (gridNode !is null) gridNode.Remove(); gridNode = Node(); gridNode.name = ""EditorGrid""; grid = gridNode.CreateComponent(""CustomGeometry""); grid.numGeometries = 1; grid.material = cache.GetResource(""Material"", ""Materials/VColUnlit.xml""); grid.viewMask = 0x80000000; // Editor raycasts use viewmask 0x7fffffff grid.occludee = false; UpdateGrid(); } void HideGrid() { if (grid !is null) grid.enabled = false; } void ShowGrid() { if (grid !is null) { grid.enabled = true; if (editorScene.octree !is null) editorScene.octree.AddManualDrawable(grid); } } void UpdateGrid(bool updateGridGeometry = true) { showGrid ? ShowGrid() : HideGrid(); gridNode.scale = Vector3(gridScale, gridScale, gridScale); if (!updateGridGeometry) return; uint size = uint(Floor(gridSize / 2) * 2); float halfSizeScaled = size / 2; float scale = 1.0; uint subdivisionSize = uint(Pow(2.0f, float(gridSubdivisions))); if (subdivisionSize > 0) { size *= subdivisionSize; scale /= subdivisionSize; } uint halfSize = size / 2; grid.BeginGeometry(0, LINE_LIST); float lineOffset = -halfSizeScaled; for (uint i = 0; i <= size; ++i) { bool lineCenter = i == halfSize; bool lineSubdiv = !Equals(Mod(i, subdivisionSize), 0.0); if (!grid2DMode) { grid.DefineVertex(Vector3(lineOffset, 0.0, halfSizeScaled)); grid.DefineColor(lineCenter ? gridZColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); grid.DefineVertex(Vector3(lineOffset, 0.0, -halfSizeScaled)); grid.DefineColor(lineCenter ? gridZColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); grid.DefineVertex(Vector3(-halfSizeScaled, 0.0, lineOffset)); grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); grid.DefineVertex(Vector3(halfSizeScaled, 0.0, lineOffset)); grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); } else { grid.DefineVertex(Vector3(lineOffset, halfSizeScaled, 0.0)); grid.DefineColor(lineCenter ? gridYColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); grid.DefineVertex(Vector3(lineOffset, -halfSizeScaled, 0.0)); grid.DefineColor(lineCenter ? gridYColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); grid.DefineVertex(Vector3(-halfSizeScaled, lineOffset, 0.0)); grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); grid.DefineVertex(Vector3(halfSizeScaled, lineOffset, 0.0)); grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor)); } lineOffset += scale; } grid.Commit(); } void CreateStatsBar() { editorModeText = Text(); ui.root.AddChild(editorModeText); renderStatsText = Text(); ui.root.AddChild(renderStatsText); modelInfoText = Text(); ui.root.AddChild(modelInfoText); } void SetupStatsBarText(Text@ text, Font@ font, int x, int y, HorizontalAlignment hAlign, VerticalAlignment vAlign) { text.position = IntVector2(x, y); text.horizontalAlignment = hAlign; text.verticalAlignment = vAlign; text.SetFont(font, 11); text.color = Color(1, 1, 0); text.textEffect = TE_SHADOW; text.priority = -100; } void UpdateStats(float timeStep) { String adding = """"; // Todo: add localization if (hotKeyMode == HOTKEYS_MODE_BLENDER) adding = localization.Get("" CameraFlyMode: "") + (cameraFlyMode ? ""True"" : ""False""); editorModeText.text = String( localization.Get(""Mode: "") + localization.Get(editModeText[editMode]) + localization.Get("" Axis: "") + localization.Get(axisModeText[axisMode]) + localization.Get("" Pick: "") + localization.Get(pickModeText[pickMode]) + localization.Get("" Fill: "") + localization.Get(fillModeText[fillMode]) + localization.Get("" Updates: "") + (runUpdate ? localization.Get(""Running"") : localization.Get(""Paused"") + adding)); renderStatsText.text = String( localization.Get(""Tris: "") + renderer.numPrimitives + localization.Get("" Batches: "") + renderer.numBatches + localization.Get("" Lights: "") + renderer.numLights[true] + localization.Get("" Shadowmaps: "") + renderer.numShadowMaps[true] + localization.Get("" Occluders: "") + renderer.numOccluders[true]); editorModeText.size = editorModeText.minSize; renderStatsText.size = renderStatsText.minSize; // Relayout stats bar Font@ font = cache.GetResource(""Font"", ""Fonts/Anonymous Pro.ttf""); if (graphics.width >= editorModeText.size.x + renderStatsText.size.x + 45) { SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP); SetupStatsBarText(renderStatsText, font, -4, 64, HA_RIGHT, VA_TOP); SetupStatsBarText(modelInfoText, font, 35, 88, HA_LEFT, VA_TOP); } else { SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP); SetupStatsBarText(renderStatsText, font, 35, 78, HA_LEFT, VA_TOP); SetupStatsBarText(modelInfoText, font, 35, 102, HA_LEFT, VA_TOP); } } void UpdateViewports(float timeStep) { for(uint i = 0; i < viewports.length; ++i) { ViewportContext@ viewportContext = viewports[i]; viewportContext.Update(timeStep); } } void SetMouseMode(bool enable) { if (enable) { if (mouseOrbitMode == ORBIT_RELATIVE) { input.mouseMode = MM_RELATIVE; ui.cursor.visible = false; } else if (mouseOrbitMode == ORBIT_WRAP) input.mouseMode = MM_WRAP; } else { input.mouseMode = MM_ABSOLUTE; ui.cursor.visible = true; } } void SetMouseLock() { toggledMouseLock = true; SetMouseMode(true); FadeUI(); } void ReleaseMouseLock() { if (toggledMouseLock) { toggledMouseLock = false; SetMouseMode(false); } } void UpdateView(float timeStep) { if (ui.HasModalElement() || ui.focusElement !is null) { ReleaseMouseLock(); return; } // Check for camara fly mode if (hotKeyMode == HOTKEYS_MODE_BLENDER) { if (input.keyDown[KEY_LSHIFT] && input.keyPress[KEY_F]) { cameraFlyMode = !cameraFlyMode; } } // Move camera float speedMultiplier = 1.0; if (input.keyDown[KEY_LSHIFT]) speedMultiplier = cameraShiftSpeedMultiplier; if (!input.keyDown[KEY_LCTRL] && !input.keyDown[KEY_LALT]) { if (hotKeyMode == HOTKEYS_MODE_STANDARD || (hotKeyMode == HOTKEYS_MODE_BLENDER && cameraFlyMode && !input.keyDown[KEY_LSHIFT])) { if (input.keyDown['W'] || input.keyDown[KEY_UP]) { cameraNode.Translate(Vector3(0, 0, cameraBaseSpeed) * timeStep * speedMultiplier); FadeUI(); } if (input.keyDown['S'] || input.keyDown[KEY_DOWN]) { cameraNode.Translate(Vector3(0, 0, -cameraBaseSpeed) * timeStep * speedMultiplier); FadeUI(); } if (input.keyDown['A'] || input.keyDown[KEY_LEFT]) { cameraNode.Translate(Vector3(-cameraBaseSpeed, 0, 0) * timeStep * speedMultiplier); FadeUI(); } if (input.keyDown['D'] || input.keyDown[KEY_RIGHT]) { cameraNode.Translate(Vector3(cameraBaseSpeed, 0, 0) * timeStep * speedMultiplier); FadeUI(); } if (input.keyDown['E'] || input.keyDown[KEY_PAGEUP]) { cameraNode.Translate(Vector3(0, cameraBaseSpeed, 0) * timeStep * speedMultiplier, TS_WORLD); FadeUI(); } if (input.keyDown['Q'] || input.keyDown[KEY_PAGEDOWN]) { cameraNode.Translate(Vector3(0, -cameraBaseSpeed, 0) * timeStep * speedMultiplier, TS_WORLD); FadeUI(); } } } if (input.mouseMoveWheel != 0 && ui.GetElementAt(ui.cursor.position) is null) { if (hotKeyMode == HOTKEYS_MODE_STANDARD) { if (mouseWheelCameraPosition) { cameraNode.Translate(Vector3(0, 0, -cameraBaseSpeed) * -input.mouseMoveWheel*20 * timeStep * speedMultiplier); } else { float zoom = camera.zoom + -input.mouseMoveWheel *.1 * speedMultiplier; camera.zoom = Clamp(zoom, .1, 30); } } else if (hotKeyMode == HOTKEYS_MODE_BLENDER) { if (mouseWheelCameraPosition && !camera.orthographic) { if (input.keyDown[KEY_LSHIFT]) cameraNode.Translate(Vector3(0, -cameraBaseSpeed, 0) * -input.mouseMoveWheel*20* timeStep * speedMultiplier); else if (input.keyDown[KEY_LCTRL]) cameraNode.Translate(Vector3(-cameraBaseSpeed,0, 0) * -input.mouseMoveWheel*20 * timeStep * speedMultiplier); else { Vector3 center = SelectedNodesCenterPoint(); float distance = (cameraNode.worldPosition - center).length; float ratio = distance / 40.0f; float factor = ratio < 1.0f ? ratio : 1.0f; cameraNode.Translate(Vector3(0, 0, -cameraBaseSpeed) * -input.mouseMoveWheel*40*factor*timeStep*speedMultiplier); } } else { if (input.keyDown[KEY_LSHIFT]) { cameraNode.Translate(Vector3(0, -cameraBaseSpeed, 0) * -input.mouseMoveWheel*20* timeStep * speedMultiplier); } else if (input.keyDown[KEY_LCTRL]) { cameraNode.Translate(Vector3(-cameraBaseSpeed,0, 0) * -input.mouseMoveWheel*20 * timeStep * speedMultiplier); } else { if (input.qualifierDown[QUAL_ALT]) { float zoom = camera.zoom + -input.mouseMoveWheel *.1 * speedMultiplier; camera.zoom = Clamp(zoom, .1, 30); } else { cameraNode.Translate(Vector3(0, 0, -cameraBaseSpeed) * -input.mouseMoveWheel*20 * timeStep * speedMultiplier); } } } } } if (input.keyDown[KEY_HOME]) { if (selectedNodes.length > 0 || selectedComponents.length > 0) { Quaternion q = Quaternion(activeViewport.cameraPitch, activeViewport.cameraYaw, 0); Vector3 centerPoint = SelectedNodesCenterPoint(); Vector3 d = cameraNode.worldPosition - centerPoint; cameraNode.worldPosition = centerPoint - q * Vector3(0.0, 0.0,10); } } // Rotate/orbit/pan camera bool changeCamViewButton = false; if (hotKeyMode == HOTKEYS_MODE_STANDARD) changeCamViewButton = input.mouseButtonDown[MOUSEB_RIGHT] || input.mouseButtonDown[MOUSEB_MIDDLE]; else if (hotKeyMode == HOTKEYS_MODE_BLENDER) { changeCamViewButton = input.mouseButtonDown[MOUSEB_MIDDLE] || cameraFlyMode; if (input.mouseButtonPress[MOUSEB_RIGHT] || input.keyDown[KEY_ESC]) cameraFlyMode = false; } if (changeCamViewButton) { SetMouseLock(); IntVector2 mouseMove = input.mouseMove; if (mouseMove.x != 0 || mouseMove.y != 0) { bool panTheCamera = false; if (hotKeyMode == HOTKEYS_MODE_STANDARD) { if (input.mouseButtonDown[MOUSEB_MIDDLE]) { if (mmbPanMode) panTheCamera = !input.keyDown[KEY_LSHIFT]; else panTheCamera = input.keyDown[KEY_LSHIFT]; } } else if (hotKeyMode == HOTKEYS_MODE_BLENDER) { if (!cameraFlyMode) panTheCamera = input.keyDown[KEY_LSHIFT]; } if (panTheCamera) cameraNode.Translate(Vector3(-mouseMove.x, mouseMove.y, 0) * timeStep * cameraBaseSpeed * 0.5); else { activeViewport.cameraYaw += mouseMove.x * cameraBaseRotationSpeed; activeViewport.cameraPitch += mouseMove.y * cameraBaseRotationSpeed; if (limitRotation) activeViewport.cameraPitch = Clamp(activeViewport.cameraPitch, -90.0, 90.0); Quaternion q = Quaternion(activeViewport.cameraPitch, activeViewport.cameraYaw, 0); cameraNode.rotation = q; if (hotKeyMode == HOTKEYS_MODE_STANDARD) { if (input.mouseButtonDown[MOUSEB_MIDDLE] && (selectedNodes.length > 0 || selectedComponents.length > 0)) { Vector3 centerPoint = SelectedNodesCenterPoint(); Vector3 d = cameraNode.worldPosition - centerPoint; cameraNode.worldPosition = centerPoint - q * Vector3(0.0, 0.0, d.length); orbiting = true; } } else if (hotKeyMode == HOTKEYS_MODE_BLENDER) { if (input.mouseButtonDown[MOUSEB_MIDDLE]) { Vector3 centerPoint = Vector3(0,0,0); if ((selectedNodes.length > 0 || selectedComponents.length > 0)) centerPoint = SelectedNodesCenterPoint(); else centerPoint = lastSelectedNodesCenterPoint; Vector3 d = cameraNode.worldPosition - centerPoint; cameraNode.worldPosition = centerPoint - q * Vector3(0.0, 0.0, d.length); orbiting = true; } } } } } else ReleaseMouseLock(); if (orbiting && !input.mouseButtonDown[MOUSEB_MIDDLE]) orbiting = false; if (hotKeyMode == HOTKEYS_MODE_BLENDER) { if (viewCloser && lastSelectedDrawable.Get() !is null) { SetMouseLock(); BoundingBox bb; Vector3 centerPoint; if (selectedNodes.length <= 1) { Drawable@ drawable = lastSelectedDrawable.Get(); if (drawable !is null) { bb = drawable.boundingBox; centerPoint = drawable.node.worldPosition; } } else { for (uint i = 0; i < selectedNodes.length; i++) { bb.Merge(selectedNodes[i].position); } centerPoint = SelectedNodesCenterPoint(); } float distance = bb.size.length; if (camera.orthographic) // if we use viewCloser for 2D get current distance to avoid near clip distance = cameraNode.worldPosition.length; Quaternion q = Quaternion(activeViewport.cameraPitch, activeViewport.cameraYaw, 0); cameraNode.rotation = q; cameraNode.worldPosition = centerPoint - cameraNode.worldDirection * distance; // ReacquireCameraYawPitch(); viewCloser = false; } else viewCloser = false; } // Move/rotate/scale object if (hotKeyMode == HOTKEYS_MODE_BLENDER) // force to select component node for manipulation if selected only component and not his node { if ((editMode != EDIT_SELECT && editNodes.empty) && lastSelectedComponent.Get() !is null) { if (lastSelectedComponent.Get() !is null) { Component@ component = lastSelectedComponent.Get(); SelectNode(component.node, false); } } } if (!editNodes.empty && editMode != EDIT_SELECT && input.keyDown[KEY_LCTRL]) { Vector3 adjust(0, 0, 0); if (input.keyDown[KEY_UP]) adjust.z = 1; if (input.keyDown[KEY_DOWN]) adjust.z = -1; if (input.keyDown[KEY_LEFT]) adjust.x = -1; if (input.keyDown[KEY_RIGHT]) adjust.x = 1; if (input.keyDown[KEY_PAGEUP]) adjust.y = 1; if (input.keyDown[KEY_PAGEDOWN]) adjust.y = -1; if (editMode == EDIT_SCALE) { if (input.keyDown[KEY_KP_PLUS]) adjust = Vector3(1, 1, 1); if (input.keyDown[KEY_KP_MINUS]) adjust = Vector3(-1, -1, -1); } if (adjust == Vector3(0, 0, 0)) return; bool moved = false; adjust *= timeStep * 10; switch (editMode) { case EDIT_MOVE: if (!moveSnap) moved = MoveNodes(adjust * moveStep); break; case EDIT_ROTATE: if (!rotateSnap) moved = RotateNodes(adjust * rotateStep); break; case EDIT_SCALE: if (!scaleSnap) moved = ScaleNodes(adjust * scaleStep); break; } if (moved) UpdateNodeAttributes(); } // If not dragging if (resizingBorder == 0) { UIElement@ uiElement = ui.GetElementAt(ui.cursorPosition); if (uiElement !is null && uiElement.vars.Contains(""VIEWMODE"")) { setViewportCursor = uiElement.vars[""VIEWMODE""].GetUInt(); if (input.mouseButtonDown[MOUSEB_LEFT]) resizingBorder = setViewportCursor; } } } void SteppedObjectManipulation(int key) { if (editNodes.empty || editMode == EDIT_SELECT) return; // Do not react in non-snapped mode, because that is handled in frame update if (editMode == EDIT_MOVE && !moveSnap) return; if (editMode == EDIT_ROTATE && !rotateSnap) return; if (editMode == EDIT_SCALE && !scaleSnap) return; Vector3 adjust(0, 0, 0); if (key == KEY_UP) adjust.z = 1; if (key == KEY_DOWN) adjust.z = -1; if (key == KEY_LEFT) adjust.x = -1; if (key == KEY_RIGHT) adjust.x = 1; if (key == KEY_PAGEUP) adjust.y = 1; if (key == KEY_PAGEDOWN) adjust.y = -1; if (editMode == EDIT_SCALE) { if (key == KEY_KP_PLUS) adjust = Vector3(1, 1, 1); if (key == KEY_KP_MINUS) adjust = Vector3(-1, -1, -1); } if (adjust == Vector3(0, 0, 0)) return; bool moved = false; switch (editMode) { case EDIT_MOVE: moved = MoveNodes(adjust); break; case EDIT_ROTATE: { float rotateStepScaled = rotateStep * snapScale; moved = RotateNodes(adjust * rotateStepScaled); } break; case EDIT_SCALE: { float scaleStepScaled = scaleStep * snapScale; moved = ScaleNodes(adjust * scaleStepScaled); } break; } if (moved) UpdateNodeAttributes(); } void HandlePostRenderUpdate() { DebugRenderer@ debug = editorScene.debugRenderer; if (debug is null || orbiting || debugRenderDisabled) return; // Visualize the currently selected nodes for (uint i = 0; i < selectedNodes.length; ++i) DrawNodeDebug(selectedNodes[i], debug); // Visualize the currently selected components for (uint i = 0; i < selectedComponents.length; ++i) selectedComponents[i].DrawDebugGeometry(debug, false); // Visualize the currently selected UI-elements for (uint i = 0; i < selectedUIElements.length; ++i) ui.DebugDraw(selectedUIElements[i]); if (renderingDebug) renderer.DrawDebugGeometry(false); if (physicsDebug && editorScene.physicsWorld !is null) editorScene.physicsWorld.DrawDebugGeometry(true); if (octreeDebug && editorScene.octree !is null) editorScene.octree.DrawDebugGeometry(true); if (setViewportCursor | resizingBorder > 0) { SetViewportCursor(); if (resizingBorder == 0) setViewportCursor = 0; } ViewRaycast(false); } void DrawNodeDebug(Node@ node, DebugRenderer@ debug, bool drawNode = true) { if (drawNode) debug.AddNode(node, 1.0, false); // Exception for the scene to avoid bringing the editor to its knees: drawing either the whole hierarchy or the subsystem- // components can have a large performance hit. Also do not draw terrain child nodes due to their large amount // (TerrainPatch component itself draws nothing as debug geometry) if (node !is editorScene && node.GetComponent(""Terrain"") is null) { for (uint j = 0; j < node.numComponents; ++j) node.components[j].DrawDebugGeometry(debug, false); // To avoid cluttering the view, do not draw the node axes for child nodes for (uint k = 0; k < node.numChildren; ++k) DrawNodeDebug(node.children[k], debug, false); } } void ViewMouseMove() { // setting mouse position based on mouse position if (ui.IsDragging()) { } else if (ui.focusElement !is null || input.mouseButtonDown[MOUSEB_LEFT|MOUSEB_MIDDLE|MOUSEB_RIGHT]) return; IntVector2 pos = ui.cursor.position; for (uint i = 0; i < viewports.length; ++i) { ViewportContext@ vc = viewports[i]; if (vc !is activeViewport && vc.viewport.rect.IsInside(pos) == INSIDE) SetActiveViewport(vc); } } void ViewMouseClick() { ViewRaycast(true); } Ray GetActiveViewportCameraRay() { IntRect view = activeViewport.viewport.rect; return camera.GetScreenRay( float(ui.cursorPosition.x - view.left) / view.width, float(ui.cursorPosition.y - view.top) / view.height ); } void ViewMouseClickEnd() { // checks to close open popup windows IntVector2 pos = ui.cursorPosition; if (contextMenu !is null && contextMenu.enabled) { if (contextMenuActionWaitFrame) contextMenuActionWaitFrame = false; else { if (!contextMenu.IsInside(pos, true)) CloseContextMenu(); } } if (quickMenu !is null && quickMenu.enabled) { bool enabled = quickMenu.IsInside(pos, true); quickMenu.enabled = enabled; quickMenu.visible = enabled; } } void ViewRaycast(bool mouseClick) { // Ignore if UI has modal element if (ui.HasModalElement()) return; // Ignore if mouse is grabbed by other operation if (input.mouseGrabbed) return; IntVector2 pos = ui.cursorPosition; UIElement@ elementAtPos = ui.GetElementAt(pos, pickMode != PICK_UI_ELEMENTS); if (editMode == EDIT_SPAWN) { if(mouseClick && input.mouseButtonPress[MOUSEB_LEFT] && elementAtPos is null) SpawnObject(); return; } // Do not raycast / change selection if hovering over the gizmo if (IsGizmoSelected()) return; DebugRenderer@ debug = editorScene.debugRenderer; if (pickMode == PICK_UI_ELEMENTS) { bool leftClick = mouseClick && input.mouseButtonPress[MOUSEB_LEFT]; bool multiselect = input.qualifierDown[QUAL_CTRL]; // Only interested in user-created UI elements if (elementAtPos !is null && elementAtPos !is editorUIElement && elementAtPos.GetElementEventSender() is editorUIElement) { ui.DebugDraw(elementAtPos); if (leftClick) SelectUIElement(elementAtPos, multiselect); } // If clicked on emptiness in non-multiselect mode, clear the selection else if (leftClick && !multiselect && ui.GetElementAt(pos) is null) hierarchyList.ClearSelection(); return; } // Do not raycast / change selection if hovering over a UI element when not in PICK_UI_ELEMENTS Mode if (elementAtPos !is null) return; Ray cameraRay = GetActiveViewportCameraRay(); Component@ selectedComponent; if (pickMode < PICK_RIGIDBODIES) { if (editorScene.octree is null) return; RayQueryResult result = editorScene.octree.RaycastSingle(cameraRay, RAY_TRIANGLE, camera.farClip, pickModeDrawableFlags[pickMode], 0x7fffffff); if (result.drawable !is null) { Drawable@ drawable = result.drawable; // for actual last selected node or component in both modes if (hotKeyMode == HOTKEYS_MODE_STANDARD) { if (input.mouseButtonDown[MOUSEB_LEFT]) { lastSelectedNode = drawable.node; lastSelectedDrawable = drawable; lastSelectedComponent = drawable; } } else if (hotKeyMode == HOTKEYS_MODE_BLENDER) { if (input.mouseButtonDown[MOUSEB_RIGHT]) { lastSelectedNode = drawable.node; lastSelectedDrawable = drawable; lastSelectedComponent = drawable; } } // If selecting a terrain patch, select the parent terrain instead if (drawable.typeName != ""TerrainPatch"") { selectedComponent = drawable; if (debug !is null) { debug.AddNode(drawable.node, 1.0, false); drawable.DrawDebugGeometry(debug, false); } } else if (drawable.node.parent !is null) selectedComponent = drawable.node.parent.GetComponent(""Terrain""); } } else { if (editorScene.physicsWorld is null) return; // If we are not running the actual physics update, refresh collisions before raycasting if (!runUpdate) editorScene.physicsWorld.UpdateCollisions(); PhysicsRaycastResult result = editorScene.physicsWorld.RaycastSingle(cameraRay, camera.farClip); if (result.body !is null) { RigidBody@ body = result.body; if (debug !is null) { debug.AddNode(body.node, 1.0, false); body.DrawDebugGeometry(debug, false); } selectedComponent = body; } } bool multiselect = false; bool componentSelectQualifier = false; bool mouseButtonPressRL = false; if (hotKeyMode == HOTKEYS_MODE_STANDARD) { mouseButtonPressRL = input.mouseButtonPress[MOUSEB_LEFT]; componentSelectQualifier = input.qualifierDown[QUAL_SHIFT]; multiselect = input.qualifierDown[QUAL_CTRL]; } else if (hotKeyMode == HOTKEYS_MODE_BLENDER) { mouseButtonPressRL = input.mouseButtonPress[MOUSEB_RIGHT]; componentSelectQualifier = input.qualifierDown[QUAL_CTRL]; multiselect = input.qualifierDown[QUAL_SHIFT]; } if (mouseClick && mouseButtonPressRL) { if (selectedComponent !is null) { if (componentSelectQualifier) { // If we are selecting components, but have nodes in existing selection, do not multiselect to prevent confusion if (!selectedNodes.empty) multiselect = false; SelectComponent(selectedComponent, multiselect); } else { // If we are selecting nodes, but have components in existing selection, do not multiselect to prevent confusion if (!selectedComponents.empty) multiselect = false; SelectNode(selectedComponent.node, multiselect); } } else { // If clicked on emptiness in non-multiselect mode, clear the selection if (!multiselect) SelectComponent(null, false); } } } Vector3 GetNewNodePosition(bool raycastToMouse = false) { if (newNodeMode == NEW_NODE_IN_CENTER) return Vector3(0, 0, 0); if (newNodeMode == NEW_NODE_RAYCAST) { Ray cameraRay = raycastToMouse ? GetActiveViewportCameraRay() : camera.GetScreenRay(0.5, 0.5); Vector3 position, normal; if (GetSpawnPosition(cameraRay, camera.farClip, position, normal, 0, false)) return position; } return cameraNode.worldPosition + cameraNode.worldRotation * Vector3(0, 0, newNodeDistance); } int GetShadowResolution() { if (!renderer.drawShadows) return 0; int level = 1; int res = renderer.shadowMapSize; while (res > 512) { res >>= 1; ++level; } if (level > 3) level = 3; return level; } void SetShadowResolution(int level) { if (level <= 0) { renderer.drawShadows = false; return; } else { renderer.drawShadows = true; renderer.shadowMapSize = 256 << level; } } void ToggleRenderingDebug() { renderingDebug = !renderingDebug; } void TogglePhysicsDebug() { physicsDebug = !physicsDebug; } void ToggleOctreeDebug() { octreeDebug = !octreeDebug; } bool StopTestAnimation() { testAnimState = null; return true; } void LocateNode(Node@ node) { if (node is null || node is editorScene) return; Vector3 center = node.worldPosition; float distance = newNodeDistance; for (uint i = 0; i < node.numComponents; ++i) { // Determine view distance from drawable component's bounding box. Skip skybox, as its box is very large, as well as lights Drawable@ drawable = cast(node.components[i]); if (drawable !is null && cast(drawable) is null && cast(drawable) is null) { BoundingBox box = drawable.worldBoundingBox; center = box.center; // Ensure the object fits on the screen distance = Max(distance, newNodeDistance + box.size.length); break; } } if (distance > viewFarClip) distance = viewFarClip; cameraNode.worldPosition = center - cameraNode.worldDirection * distance; } Vector3 SelectedNodesCenterPoint() { Vector3 centerPoint; uint count = selectedNodes.length; for (uint i = 0; i < selectedNodes.length; ++i) centerPoint += selectedNodes[i].worldPosition; for (uint i = 0; i < selectedComponents.length; ++i) { Drawable@ drawable = cast(selectedComponents[i]); count++; if (drawable !is null) centerPoint += drawable.node.LocalToWorld(drawable.boundingBox.center); else centerPoint += selectedComponents[i].node.worldPosition; } if (count > 0) { lastSelectedNodesCenterPoint = centerPoint / count; return centerPoint / count; } else { lastSelectedNodesCenterPoint = centerPoint; return centerPoint; } } Drawable@ GetDrawableAtMousePostion() { IntVector2 pos = ui.cursorPosition; Ray cameraRay = camera.GetScreenRay(float(pos.x) / activeViewport.viewport.rect.width, float(pos.y) / activeViewport.viewport.rect.height); if (editorScene.octree is null) return null; RayQueryResult result = editorScene.octree.RaycastSingle(cameraRay, RAY_TRIANGLE, camera.farClip, DRAWABLE_GEOMETRY, 0x7fffffff); return result.drawable; } void HandleBeginViewUpdate(StringHash eventType, VariantMap& eventData) { // Hide gizmo, grid and debug icons from any camera other then active viewport if (eventData[""Camera""].GetPtr() !is camera) { if (gizmo !is null) gizmo.viewMask = 0; } if (eventData[""Camera""].GetPtr() is previewCamera.Get()) { suppressSceneChanges = true; if (grid !is null) grid.viewMask = 0; if (debugIconsNode !is null) debugIconsNode.enabled = false; suppressSceneChanges = false; } } void HandleEndViewUpdate(StringHash eventType, VariantMap& eventData) { // Restore gizmo and grid after camera view update if (eventData[""Camera""].GetPtr() !is camera) { if (gizmo !is null) gizmo.viewMask = 0x80000000; } if (eventData[""Camera""].GetPtr() is previewCamera.Get()) { suppressSceneChanges = true; if (grid !is null) grid.viewMask = 0x80000000; if (debugIconsNode !is null) debugIconsNode.enabled = true; suppressSceneChanges = false; } } bool debugWasEnabled = true; void HandleBeginViewRender(StringHash eventType, VariantMap& eventData) { // Hide debug geometry from preview camera if (eventData[""Camera""].GetPtr() is previewCamera.Get()) { DebugRenderer@ debug = editorScene.GetComponent(""DebugRenderer""); if (debug !is null) { suppressSceneChanges = true; // Do not want UI update now debugWasEnabled = debug.enabled; debug.enabled = false; suppressSceneChanges = false; } } } void HandleEndViewRender(StringHash eventType, VariantMap& eventData) { // Restore debug geometry after preview camera render if (eventData[""Camera""].GetPtr() is previewCamera.Get()) { DebugRenderer@ debug = editorScene.GetComponent(""DebugRenderer""); if (debug !is null) { suppressSceneChanges = true; // Do not want UI update now debug.enabled = debugWasEnabled; suppressSceneChanges = false; } } }",16365,True,2665.0900940715183,median "*""* use this source file for your ABAP unit test classes CLASS ltc_main DEFINITION DEFERRED. CLASS ltc_action DEFINITION DEFERRED. CLASS ltc_first_sets DEFINITION DEFERRED. CLASS zcl_ctxfreegram2 DEFINITION LOCAL FRIENDS ltc_main ltc_action ltc_first_sets. *CLASS lcl_non_terminal DEFINITION FRIENDS ltc_main. CLASS ltc_main DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. METHODS missing_start_rule FOR TESTING. METHODS lhs_not_bound FOR TESTING. METHODS start_rule_twice FOR TESTING. METHODS unique_rule_one_character FOR TESTING. METHODS unique_rule_two_characters FOR TESTING. METHODS optional FOR TESTING. METHODS recursive_rule FOR TESTING. METHODS item_sets_transitions FOR TESTING. METHODS circular_1 FOR TESTING. METHODS circular_2 FOR TESTING. METHODS test FOR TESTING. METHODS test2 FOR TESTING. ENDCLASS. CLASS ltc_main IMPLEMENTATION. METHOD missing_start_rule. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * TRY. * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( ) ). * CATCH zcx_ctxfreegram INTO DATA(lx). * ENDTRY. * * IF lx IS NOT BOUND OR lx->error <> zcx_ctxfreegram=>c_error-missing_start_rule. * cl_abap_unit_assert=>fail( msg = 'Exception ""start rule missing"" expected' ). * ENDIF. ENDMETHOD. METHOD lhs_not_bound. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * TRY. * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( ( ) ) ). * CATCH zcx_ctxfreegram INTO DATA(lx). * ENDTRY. * * IF lx IS NOT BOUND OR lx->error <> zcx_ctxfreegram=>c_error-lhs_element_not_bound. * cl_abap_unit_assert=>fail( msg = 'Exception ""missing LHS"" expected' ). * ENDIF. ENDMETHOD. METHOD start_rule_twice. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * TRY. * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( * ( lhs = start ) * ( lhs = start ) ) ). * CATCH zcx_ctxfreegram INTO DATA(lx). * ENDTRY. * * IF lx IS NOT BOUND OR lx->error <> zcx_ctxfreegram=>c_error-start_rule_must_appear_once. * cl_abap_unit_assert=>fail( msg = 'Exception ""start rule must appear once"" expected' ). * ENDIF. ENDMETHOD. METHOD unique_rule_one_character. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * DATA(letter_a) = factory->new_terminal( 'a' ). * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( * ( lhs = start rhs = letter_a ) ) ). * * DATA(itemsets) = grammar->render_itemsets( ). * DATA(transitions) = grammar->render_transitions( ). * DATA(action_goto_tables) = grammar->render_action_goto_tables( ). * * cl_abap_unit_assert=>assert_equals( act = itemsets exp = * |* Item set 1:\\n| & * |** Item kernel: start = ◆ 'a'\\n| & * |* Item set 2:\\n| & * |** Item kernel: start = 'a' ◆\\n| ). * cl_abap_unit_assert=>assert_equals( act = transitions exp = * | '$' 'a' start \\n| & * |1 2 \\n| & * |2 \\n| ). * cl_abap_unit_assert=>assert_equals( act = action_goto_tables exp = * | '$' 'a' start \\n| & * |1 s2 \\n| & * |2 acc \\n| ). ENDMETHOD. METHOD unique_rule_two_characters. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * DATA(letter_a) = factory->new_terminal( 'a' ). * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( * ( lhs = start rhs = factory->new_sequence( VALUE #( ( letter_a ) ( letter_a ) ) ) ) ) ). * * DATA(itemsets) = grammar->render_itemsets( ). * DATA(transitions) = grammar->render_transitions( ). * DATA(action_goto_tables) = grammar->render_action_goto_tables( ). * * cl_abap_unit_assert=>assert_equals( act = itemsets exp = * |* Item set 1:\\n| & * |** Item kernel: start = ◆ 'a' 'a'\\n| & * |* Item set 2:\\n| & * |** Item kernel: start = 'a' ◆ 'a'\\n| & * |* Item set 3:\\n| & * |** Item kernel: start = 'a' 'a' ◆\\n| ). * cl_abap_unit_assert=>assert_equals( act = transitions exp = * | '$' 'a' start \\n| & * |1 2 \\n| & * |2 3 \\n| & * |3 \\n| ). * cl_abap_unit_assert=>assert_equals( act = action_goto_tables exp = * | '$' 'a' start \\n| & * |1 s2 \\n| & * |2 s3 \\n| & * |3 acc \\n| ). ENDMETHOD. METHOD optional. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * DATA(optional) = factory->new_nonterminal( 'optional' ). * DATA(letter_a) = factory->new_terminal( 'a' ). * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( * ( lhs = start rhs = optional ) * ( lhs = optional rhs = letter_a ) * ( lhs = optional ) ) ). * * DATA(itemsets) = grammar->render_itemsets( ). * DATA(transitions) = grammar->render_transitions( ). * DATA(action_goto_tables) = grammar->render_action_goto_tables( ). * * cl_abap_unit_assert=>assert_equals( act = itemsets exp = * |* Item set 1:\\n| & * |** Item kernel: start = ◆ 'a' 'a'\\n| & * |* Item set 2:\\n| & * |** Item kernel: start = 'a' ◆ 'a'\\n| & * |* Item set 3:\\n| & * |** Item kernel: start = 'a' 'a' ◆\\n| ). * cl_abap_unit_assert=>assert_equals( act = transitions exp = * | '$' 'a' start \\n| & * |1 2 \\n| & * |2 3 \\n| & * |3 \\n| ). * cl_abap_unit_assert=>assert_equals( act = action_goto_tables exp = * | '$' 'a' start \\n| & * |1 s2 \\n| & * |2 s3 \\n| & * |3 acc \\n| ). ENDMETHOD. METHOD recursive_rule. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * TRY. * DATA(grammar) = NEW zcl_ctxfreegram2( start_rule = start rules = VALUE #( ( lhs = start rhs = start ) ) ). * CATCH zcx_ctxfreegram INTO DATA(lx). * ENDTRY. * * IF lx IS NOT BOUND OR lx->error <> zcx_ctxfreegram=>c_error-missing_start_rule. * cl_abap_unit_assert=>fail( msg = 'Exception ""start rule missing"" expected' ). * ENDIF. * **cl_abap_unit_assert=>assert_equals( act = act exp = exp msg = 'msg' ). ENDMETHOD. METHOD circular_1. DATA(grammar) = NEW zcl_ctxfreegram2( ). grammar->load_rules( rules = VALUE #( LET start = NEW lcl_non_terminal( 'start' ) IN ( NEW lcl_rule( lhs = start rhs = VALUE #( ( start ) ) ) ) ) ). TRY. grammar->create_first_sets( ). cl_abap_unit_assert=>fail( msg = 'should have failed' ). CATCH zcx_ctxfreegram INTO DATA(lx). cl_abap_unit_assert=>assert_equals( act = lx->error exp = lx->c_error-rules_circular_reference ). ENDTRY. ENDMETHOD. METHOD circular_2. DATA(grammar) = NEW zcl_ctxfreegram2( ). grammar->load_rules( rules = VALUE #( LET start = NEW lcl_non_terminal( 'start' ) e = NEW lcl_non_terminal( 'E' ) IN ( NEW lcl_rule( lhs = start rhs = VALUE #( ( e ) ) ) ) ( NEW lcl_rule( lhs = e rhs = VALUE #( ( start ) ) ) ) ) ). TRY. grammar->create_first_sets( ). cl_abap_unit_assert=>fail( msg = 'should have failed' ). CATCH zcx_ctxfreegram INTO DATA(lx). cl_abap_unit_assert=>assert_equals( act = lx->error exp = lx->c_error-rules_circular_reference ). ENDTRY. ENDMETHOD. METHOD item_sets_transitions. * DATA(factory) = NEW zcl_ctxfreegram_factory( ). DATA(grammar) = NEW zcl_ctxfreegram2( ). grammar->load_rules( rules = VALUE #( LET start = NEW lcl_non_terminal( 'start' ) e = NEW lcl_non_terminal( 'E' ) b = NEW lcl_non_terminal( 'B' ) star = NEW lcl_terminal( '*' ) plus = NEW lcl_terminal( '+' ) _0 = NEW lcl_terminal( '0' ) _1 = NEW lcl_terminal( '1' ) IN ( NEW lcl_rule( lhs = start rhs = VALUE #( ( e ) ) ) ) ( NEW lcl_rule( lhs = e rhs = VALUE #( ( e ) ( star ) ( b ) ) ) ) ( NEW lcl_rule( lhs = e rhs = VALUE #( ( e ) ( plus ) ( b ) ) ) ) ( NEW lcl_rule( lhs = e rhs = VALUE #( ( b ) ) ) ) ( NEW lcl_rule( lhs = b rhs = VALUE #( ( _0 ) ) ) ) ( NEW lcl_rule( lhs = b rhs = VALUE #( ( _1 ) ) ) ) ) ). grammar->create_item_set_transit_tables( ). DATA(item_sets) = grammar->render_item_sets( ). cl_abap_unit_assert=>assert_equals( act = item_sets exp = |* Item set 1:\\n| & |** Item kernel: start = ◆ E\\n| & |** Item closure: E = ◆ E '*' B\\n| & |** Item closure: E = ◆ E '+' B\\n| & |** Item closure: E = ◆ B\\n| & |** Item closure: B = ◆ '0'\\n| & |** Item closure: B = ◆ '1'\\n| & |* Item set 2:\\n| & |** Item kernel: start = E ◆\\n| & |** Item kernel: E = E ◆ '*' B\\n| & |** Item kernel: E = E ◆ '+' B\\n| & |* Item set 3:\\n| & |** Item kernel: E = B ◆\\n| & |* Item set 4:\\n| & |** Item kernel: B = '0' ◆\\n| & |* Item set 5:\\n| & |** Item kernel: B = '1' ◆\\n| & |* Item set 6:\\n| & |** Item kernel: E = E '*' ◆ B\\n| & |** Item closure: B = ◆ '0'\\n| & |** Item closure: B = ◆ '1'\\n| & |* Item set 7:\\n| & |** Item kernel: E = E '+' ◆ B\\n| & |** Item closure: B = ◆ '0'\\n| & |** Item closure: B = ◆ '1'\\n| & |* Item set 8:\\n| & |** Item kernel: E = E '*' B ◆\\n| & |* Item set 9:\\n| & |** Item kernel: E = E '+' B ◆\\n| ). DATA(transitions) = grammar->render_transitions( ). cl_abap_unit_assert=>assert_equals( act = transitions exp = | '*' '+' '0' '1' E B \\n| & |1 4 5 2 3 \\n| & |2 6 7 \\n| & |3 \\n| & |4 \\n| & |5 \\n| & |6 4 5 8 \\n| & |7 4 5 9 \\n| & |8 \\n| & |9 \\n| ). grammar->create_first_sets( ). DATA(first_sets) = grammar->render_first_sets( ). cl_abap_unit_assert=>assert_equals( act = first_sets exp = |NON_TERMINAL T_1 T_2 \\n| & |B '0' '1' \\n| & |E '0' '1' \\n| & |start '0' '1' \\n| ). grammar->create_follow_sets( ). DATA(follow_sets) = grammar->render_follow_sets( ). cl_abap_unit_assert=>assert_equals( act = follow_sets exp = |SYMBOL T_1 T_2 T_3 \\n| & |start 'EOF' \\n| & |E 'EOF' '*' '+' \\n| & |B 'EOF' '*' '+' \\n| & |'0' 'EOF' '*' '+' \\n| & |'1' 'EOF' '*' '+' \\n| & |'*' '0' '1' \\n| & |'+' '0' '1' \\n| ). ENDMETHOD. METHOD test. * "" start: E * "" E: E '*' B * "" E: E '+' B * "" E: B * "" B: '0' * "" B: '1' * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * DATA(e) = factory->new_nonterminal( 'E' ). * DATA(b) = factory->new_nonterminal( 'B' ). * DATA(star) = factory->new_terminal( '*' ). * DATA(plus) = factory->new_terminal( '+' ). * DATA(_0) = factory->new_terminal( '0' ). * DATA(_1) = factory->new_terminal( '1' ). * * DATA(grammar) = NEW zcl_ctxfreegram2( * start_rule = start * rules = VALUE #( * ( lhs = start rhs = e ) * ( lhs = e rhs = factory->new_sequence( VALUE #( ( e ) ( star ) ( b ) ) ) ) * ( lhs = e rhs = factory->new_sequence( VALUE #( ( e ) ( plus ) ( b ) ) ) ) * ( lhs = e rhs = b ) * ( lhs = b rhs = _0 ) * ( lhs = b rhs = _1 ) ) ). * * DATA(itemsets) = grammar->render_itemsets( ). * DATA(transitions) = grammar->render_transitions( ). * DATA(action_goto_tables) = grammar->render_action_goto_tables( ). * * DATA(output) = grammar->render_rules( ) && |\\n\\n| && grammar->render_action_goto_tables( ). ENDMETHOD. METHOD test2. * "" start: while * "" while: 'while' condition * "" condition: variable '=' number * "" variable: 'regex:[a-zA-Z_][a-zA-Z_0-9]*' * "" number: 'regex:[0-9][0-9]*' * * DATA(factory) = NEW zcl_ctxfreegram_factory( ). * DATA(start) = factory->new_nonterminal( 'start' ). * DATA(while) = factory->new_nonterminal( 'while' ). * DATA(condition) = factory->new_nonterminal( 'condition' ). * DATA(_while) = factory->new_terminal( 'while' ). * DATA(variable) = factory->new_nonterminal( 'variable' ). * DATA(variable_regex) = factory->new_terminal_regex( '[a-zA-Z_][a-zA-Z_0-9]*' ). * DATA(equal) = factory->new_terminal( '=' ). * DATA(number) = factory->new_nonterminal( 'number' ). * DATA(number_regex) = factory->new_terminal_regex( '[0-9][0-9]*' ). * * DATA(grammar) = NEW zcl_ctxfreegram2( * start_rule = start * rules = VALUE #( * ( lhs = start rhs = while ) * ( lhs = while rhs = factory->new_sequence( VALUE #( ( _while ) ( condition ) ) ) ) * ( lhs = condition rhs = factory->new_sequence( VALUE #( ( variable ) ( equal ) ( number ) ) ) ) * ( lhs = variable rhs = variable_regex ) * ( lhs = number rhs = number_regex ) ) ). * * DATA(itemsets) = grammar->render_itemsets( ). * DATA(transitions) = grammar->render_transitions( ). * DATA(action_goto_tables) = grammar->render_action_goto_tables( ). ENDMETHOD. ENDCLASS. CLASS ltc_first_sets DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PUBLIC SECTION. METHODS test FOR TESTING. ENDCLASS. CLASS ltc_first_sets IMPLEMENTATION. METHOD test. * data(grammar) = new zcl_ctxfreegram2( ). ** grammar->dataprovider = new ltcl_dataprovider( ). *data(transitions) = VALUE ty_xx( * ( ) ). *data(item_sets) = VALUE ty_xx( * ( ) ). *data(action_table) = grammar->create_action_table( item_sets = item_sets transitions = transitions ). ENDMETHOD. ENDCLASS. CLASS ltc_action DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PUBLIC SECTION. METHODS test FOR TESTING. ENDCLASS. CLASS ltc_action IMPLEMENTATION. METHOD test. * data(grammar) = new zcl_ctxfreegram2( ). ** grammar->dataprovider = new ltcl_dataprovider( ). *data(transitions) = VALUE ty_xx( * ( ) ). *data(item_sets) = VALUE ty_xx( * ( ) ). *data(action_table) = grammar->create_action_table( item_sets = item_sets transitions = transitions ). * "" Part 1 of action determination = list of SHIFT * "" SIMPLEST WAY : VIA THE TRANSITION TABLE * "" (maybe this other solution : * "" - there's no SHIFT if dot is at the end of RHS * "" - If dot is not at the end of RHS: * "" - if symbol at dot is a terminal, it's this terminal * "" - if it's a nonterminal, there's a shift for all symbols of the First Set of this nonterminal except ""$"" * "" ) * LOOP AT aut_transition ASSIGNING * WHERE s_symbol-type = zcl_ctxfreegram=>lcs_symbol_type-terminal. * APPEND INITIAL LINE TO aut_action ASSIGNING . * -state = -itemset_index. * -terminal_index = -s_symbol-index. * -action = lcs_action-shift. * -index = -goto_itemset_index. * ENDLOOP. * * "" Part 2 of action determination = list of REDUCE * "" - if the dot is at the end of RHS * "" - there's no REDUCE * "" - else * "" - if symbol at dot is a terminal, it's REDUCE of this terminal * "" - if it's a nonterminal, take all symbols of the First Set of this nonterminal except ""$"" * LOOP AT aut_itemset ASSIGNING . * LOOP AT -t_item ASSIGNING * WHERE type = lcs_item_type-kernel * AND s_dot_symbol-type = zcl_ctxfreegram=>lcs_symbol_type-nonterminal. * LOOP AT aut_rule ASSIGNING * WHERE lhs_nonterm_index = -s_dot_symbol-index * AND t_symbol IS INITIAL. * EXIT. * ENDLOOP. * IF sy-subrc = 0 AND 0 = lines( -t_symbol ). * LOOP AT aut_follow_set ASSIGNING WHERE symbol = -s_dot_symbol. * LOOP AT -t_follow_symbol ASSIGNING . * APPEND INITIAL LINE TO aut_action ASSIGNING . * -state = -index. * -terminal_index = -index. * -action = lcs_action-reduce. * -index = -index. * ENDLOOP. * ENDLOOP. * ENDIF. * ENDLOOP. * * LOOP AT -t_item ASSIGNING * WHERE type = lcs_item_type-kernel * AND dot_at_the_end = abap_true. * READ TABLE aut_follow_set ASSIGNING * WITH KEY symbol-type = zcl_ctxfreegram=>lcs_symbol_type-nonterminal * symbol-index = -lhs_nonterm_index. * ASSERT sy-subrc = 0. * LOOP AT -t_follow_symbol ASSIGNING . * APPEND INITIAL LINE TO aut_action ASSIGNING . * -state = -index. * -terminal_index = -index. * IF -rule_index = 1. * -action = lcs_action-accept. * -index = 0. * ELSE. * -action = lcs_action-reduce. * -index = -rule_index. * ENDIF. * ENDLOOP. * ENDLOOP. * ENDLOOP. * * "" if both SHIFT and reduce are possible, then keep SHIFT * LOOP AT aut_action ASSIGNING WHERE action = lcs_action-reduce. * READ TABLE aut_action WITH KEY state = -state * terminal_index = -terminal_index * action = lcs_action-shift * TRANSPORTING NO FIELDS. * IF sy-subrc = 0. * DELETE aut_action. * ENDIF. * ENDLOOP. ENDMETHOD. ENDCLASS. ",5552,False,1057.5928870300272,median "package syncomps.interfaces.graphics { import flash.events.EventDispatcher; import flash.display.IBitmapDrawable; import flash.display.DisplayObject; import flash.display.Stage; import flash.display.DisplayObjectContainer; import flash.events.IEventDispatcher; import flash.geom.Rectangle; import flash.geom.Transform; import flash.geom.Point; import flash.display.LoaderInfo; import flash.accessibility.AccessibilityProperties; import flash.geom.Vector3D; import flash.display.Shader; import flash.geom.Matrix; /** * [broadcast event] Dispatched when the display list is about to be updated and rendered. * @eventType flash.events.Event.RENDER */ [Event(name=""render"", type=""flash.events.Event"")] /** * Dispatched when a display object is about to be removed from the display list, * either directly or through the removal of a sub tree in which the display object is contained. * @eventType flash.events.Event.REMOVED_FROM_STAGE */ [Event(name=""removedFromStage"", type=""flash.events.Event"")] /** * Dispatched when a display object is about to be removed from the display list. * @eventType flash.events.Event.REMOVED */ [Event(name=""removed"", type=""flash.events.Event"")] /** * [broadcast event] Dispatched when the playhead is exiting the current frame. * @eventType flash.events.Event.EXIT_FRAME */ [Event(name=""exitFrame"", type=""flash.events.Event"")] /** * [broadcast event] Dispatched after the constructors of frame display objects have run but before frame scripts have run. * @eventType flash.events.Event.FRAME_CONSTRUCTED */ [Event(name=""frameConstructed"", type=""flash.events.Event"")] /** * [broadcast event] Dispatched when the playhead is entering a new * frame. * @eventType flash.events.Event.ENTER_FRAME */ [Event(name=""enterFrame"", type=""flash.events.Event"")] /** * Dispatched when a display object is added to the on stage display list, * either directly or through the addition of a sub tree in which the display object is contained. * @eventType flash.events.Event.ADDED_TO_STAGE */ [Event(name=""addedToStage"", type=""flash.events.Event"")] /** * Dispatched when a display object is added to the display list. * @eventType flash.events.Event.ADDED */ [Event(name=""added"", type=""flash.events.Event"")] /** * The DisplayObject class is the base class for all objects that can be placed on * the display list. The display list manages all objects displayed in the Flash runtimes. * Use the DisplayObjectContainer class to arrange the display objects in the display list. * DisplayObjectContainer objects can have child display objects, while other display objects, such as * Shape and TextField objects, are ""leaf"" nodes that have only parents and siblings, no children. * *

The DisplayObject class supports basic functionality like the x and y position of * an object, as well as more advanced properties of the object such as its transformation matrix. *

DisplayObject is an abstract base class; therefore, you cannot call DisplayObject directly. Invoking * new DisplayObject() throws an ArgumentError exception.

All display objects inherit from the DisplayObject class.

The DisplayObject class itself does not include any APIs for rendering content onscreen. * For that reason, if you want create a custom subclass of the DisplayObject class, you will want * to extend one of its subclasses that do have APIs for rendering content onscreen, * such as the Shape, Sprite, Bitmap, SimpleButton, TextField, or MovieClip class.

The DisplayObject class contains several broadcast events. Normally, the target * of any particular event is a specific DisplayObject instance. For example, * the target of an added event is the specific DisplayObject instance * that was added to the display list. Having a single target restricts the placement of * event listeners to that target and in some cases the target's ancestors on the display list. * With broadcast events, however, the target is not a specific DisplayObject instance, * but rather all DisplayObject instances, including those that are not on the display list. * This means that you can add a listener to any DisplayObject instance to listen for broadcast events. * In addition to the broadcast events listed in the DisplayObject class's Events table, * the DisplayObject class also inherits two broadcast events from the EventDispatcher * class: activate and deactivate.

Some properties previously used in the ActionScript 1.0 and 2.0 MovieClip, TextField, and Button * classes (such as _alpha, _height, _name, _width, * _x, _y, and others) have equivalents in the ActionScript 3.0 * DisplayObject class that are renamed so that they no longer begin with the underscore (_) character.

For more information, see the ""Display Programming"" chapter of the ActionScript 3.0 Developer's Guide.

* * EXAMPLE: * * The following example uses the DisplayObjectExample class to * draw an orange square in the corner of the Stage and then respond to events by displaying text * information for each event. This task is accomplished by performing the following steps: *
  1. Class properties are declared for the color and size of the square.
  2. The constructor calls the draw() method, which draws an orange square on * the Stage at the default coordinates of x = 0, y = 0.
  3. The following event listener methods are attached to the square: *
    • addedHandler() listens for added events, dispatched when the * square is added to the display list.
    • enterFrameHandler() listens for enterFrame events, which have no * real meaning in this example.
    • removedHandler() listens for removed events, dispatched when * the square is removed from the display list, which happens when the square is clicked.
    • clickHandler() listens for click events, dispatched when the * orange square is clicked.
    • renderHandler() listens for render events after the display * list is updated.
* * package { * import flash.display.Sprite; * * public class DisplayObjectExample extends Sprite { * function DisplayObjectExample() { * var child:CustomDisplayObject = new CustomDisplayObject(); * addChild(child); * } * } * } * * import flash.display.DisplayObject; * import flash.display.Sprite; * import flash.display.Stage; * import flash.display.StageAlign; * import flash.display.StageScaleMode; * import flash.events.*; * * class CustomDisplayObject extends Sprite { * private var bgColor:uint = 0xFFCC00; * private var size:uint = 80; * * function CustomDisplayObject() { * draw(); * addEventListener(Event.ADDED, addedHandler); * addEventListener(Event.ENTER_FRAME, enterFrameHandler); * addEventListener(Event.REMOVED, removedHandler); * addEventListener(MouseEvent.CLICK, clickHandler); * addEventListener(Event.RENDER, renderHandler); * } * * private function draw():void { * graphics.beginFill(bgColor); * graphics.drawRect(0, 0, size, size); * graphics.endFill(); * } * * private function clickHandler(event:MouseEvent):void { * trace(""clickHandler: "" + event); * parent.removeChild(this); * } * * private function addedHandler(event:Event):void { * trace(""addedHandler: "" + event); * stage.scaleMode = StageScaleMode.NO_SCALE; * stage.align = StageAlign.TOP_LEFT; * stage.addEventListener(""resize"", resizeHandler); * } * * private function enterFrameHandler(event:Event):void { * trace(""enterFrameHandler: "" + event); * removeEventListener(""enterFrame"", enterFrameHandler); * } * * private function removedHandler(event:Event):void { * trace(""removedHandler: "" + event); * stage.removeEventListener(""resize"", resizeHandler); * } * * private function renderHandler(event:Event):void { * trace(""renderHandler: "" + event); * } * * private function resizeHandler(event:Event):void { * trace(""resizeHandler: "" + event); * } * } * * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ public interface IDisplayObject extends IEventDispatcher, IBitmapDrawable { /** * The current accessibility options for this display object. If you modify the accessibilityProperties * property or any of the fields within accessibilityProperties, you must call * the Accessibility.updateProperties() method to make your changes take effect. * * Note: For an object created in the Flash authoring environment, the value of accessibilityProperties * is prepopulated with any information you entered in the Accessibility panel for * that object. * @langversion 3.0 * @playerversion Flash 9 */ function get accessibilityProperties () : flash.accessibility.AccessibilityProperties; function set accessibilityProperties (value:AccessibilityProperties) : void; /** * Indicates the alpha transparency value of the object specified. * Valid values are 0 (fully transparent) to 1 (fully opaque). * The default value is 1. Display objects with alpha * set to 0 are active, even though they are invisible. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get alpha () : Number; function set alpha (value:Number) : void; /** * A value from the BlendMode class that specifies which blend mode to use. * A bitmap can be drawn internally in two ways. If you have a blend mode enabled or an * external clipping mask, the bitmap is drawn by adding a bitmap-filled square shape to the vector * render. If you attempt to set this property to an invalid value, Flash runtimes set the value * to BlendMode.NORMAL. * * The blendMode property affects each pixel of the display object. * Each pixel is composed of three constituent * colors (red, green, and blue), and each constituent color has a value between 0x00 and 0xFF. * Flash Player or Adobe AIR compares each constituent color of one pixel in the movie clip with * the corresponding color of the pixel in the background. For example, if blendMode * is set to BlendMode.LIGHTEN, Flash Player or Adobe AIR compares the red value of the display object with * the red value of the background, and uses the lighter of the two as the * value for the red component of the displayed color.The following table describes the blendMode settings. * The BlendMode class defines string values you can use. * The illustrations in the table show blendMode values applied to a circular * display object (2) superimposed on another display object (1).BlendMode ConstantIllustrationDescriptionBlendMode.NORMALThe display object appears in front of the background. Pixel values of the display object * override those of the background. Where the display object is transparent, the background is * visible.BlendMode.LAYERForces the creation of a transparency group for the display object. This means that the display * object is pre-composed in a temporary buffer before it is processed further. This is done * automatically if the display object is pre-cached using bitmap caching or if the display object is * a display object container with at least one child object with a blendMode * setting other than BlendMode.NORMAL. Not supported under GPU rendering. * BlendMode.MULTIPLYMultiplies the values of the display object constituent colors by the colors of the background color, * and then normalizes by dividing by 0xFF, * resulting in darker colors. This setting is commonly used for shadows and depth effects. * * For example, if a constituent color (such as red) of one pixel in the display object and the * corresponding color of the pixel in the background both have the value 0x88, the multiplied * result is 0x4840. Dividing by 0xFF yields a value of 0x48 for that constituent color, * which is a darker shade than the color of the display object or the color of the background.BlendMode.SCREENMultiplies the complement (inverse) of the display object color by the complement of the background * color, resulting in a bleaching effect. This setting is commonly used for highlights or to remove black * areas of the display object.BlendMode.LIGHTENSelects the lighter of the constituent colors of the display object and the color of the background (the * colors with the larger values). This setting is commonly used for superimposing type. * * For example, if the display object has a pixel with an RGB value of 0xFFCC33, and the background * pixel has an RGB value of 0xDDF800, the resulting RGB value for the displayed pixel is * 0xFFF833 (because 0xFF > 0xDD, 0xCC < 0xF8, and 0x33 > 0x00 = 33). Not supported under GPU rendering.BlendMode.DARKENSelects the darker of the constituent colors of the display object and the colors of the * background (the colors with the smaller values). This setting is commonly used for superimposing type. * * For example, if the display object has a pixel with an RGB value of 0xFFCC33, and the background * pixel has an RGB value of 0xDDF800, the resulting RGB value for the displayed pixel is * 0xDDCC00 (because 0xFF > 0xDD, 0xCC < 0xF8, and 0x33 > 0x00 = 33). Not supported under GPU rendering.BlendMode.DIFFERENCECompares the constituent colors of the display object with the colors of its background, and subtracts * the darker of the values of the two constituent colors from the lighter value. This setting is commonly * used for more vibrant colors. * * For example, if the display object has a pixel with an RGB value of 0xFFCC33, and the background * pixel has an RGB value of 0xDDF800, the resulting RGB value for the displayed pixel is * 0x222C33 (because 0xFF - 0xDD = 0x22, 0xF8 - 0xCC = 0x2C, and 0x33 - 0x00 = 0x33).BlendMode.ADDAdds the values of the constituent colors of the display object to the colors of its background, applying a * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between * two objects. * * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background * pixel has an RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is * 0xFFC833 (because 0xAA + 0xDD > 0xFF, 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33).BlendMode.SUBTRACTSubtracts the values of the constituent colors in the display object from the values of the * background color, applying a floor of 0. This setting is commonly used for animating a * darkening dissolve between two objects. * * For example, if the display object has a pixel with an RGB value of 0xAA2233, and the background * pixel has an RGB value of 0xDDA600, the resulting RGB value for the displayed pixel is * 0x338400 (because 0xDD - 0xAA = 0x33, 0xA6 - 0x22 = 0x84, and 0x00 - 0x33 < 0x00).BlendMode.INVERTInverts the background.BlendMode.ALPHAApplies the alpha value of each pixel of the display object to the background. * This requires the blendMode setting of the parent display object to be set to * BlendMode.LAYER. * For example, in the illustration, the parent display object, which is a white background, * has blendMode = BlendMode.LAYER. Not supported under GPU rendering.BlendMode.ERASEErases the background based on the alpha value of the display object. This requires the * blendMode of the parent display object to be set to * BlendMode.LAYER. For example, in the * illustration, the parent display object, which is a white background, has * blendMode = BlendMode.LAYER. Not supported under GPU rendering.BlendMode.OVERLAYAdjusts the color of each pixel based on the darkness of the background. * If the background is lighter than 50% gray, the display object and background colors are * screened, which results in a lighter color. If the background is darker than 50% gray, * the colors are multiplied, which results in a darker color. * This setting is commonly used for shading effects. Not supported under GPU rendering.BlendMode.HARDLIGHTAdjusts the color of each pixel based on the darkness of the display object. * If the display object is lighter than 50% gray, the display object and background colors are * screened, which results in a lighter color. If the display object is darker than 50% gray, * the colors are multiplied, which results in a darker color. * This setting is commonly used for shading effects. Not supported under GPU rendering.BlendMode.SHADERN/AAdjusts the color using a custom shader routine. The shader that is used is specified * as the Shader instance assigned to the blendShader property. Setting the * blendShader property of a display object to a Shader instance * automatically sets the display object's blendMode property to * BlendMode.SHADER. If the blendMode property is set to * BlendMode.SHADER without first setting the blendShader property, * the blendMode property is set to BlendMode.NORMAL. Not supported under GPU rendering. * @langversion 3.0 * @playerversion Flash 9 */ function get blendMode () : String; function set blendMode (value:String) : void; /** * Sets a shader that is used for blending the foreground and background. When the * blendMode property is set to BlendMode.SHADER, the specified * Shader is used to create the blend mode output for the display object. * * Setting the blendShader property of a display object to a Shader instance * automatically sets the display object's blendMode property to * BlendMode.SHADER. If the blendShader property is set (which sets the * blendMode property to BlendMode.SHADER), then the value of the * blendMode property is changed, the blend mode can be reset to use the blend * shader simply by setting the blendMode property to BlendMode.SHADER. * The blendShader property does not need to be set again except to change the * shader that's used for the blend mode.The Shader assigned to the blendShader property must specify at least two * image4 inputs. The inputs do not need to be specified in code using the * associated ShaderInput objects' input properties. The background display object * is automatically * used as the first input (the input with index 0). The foreground display object * is used as the second input (the input with index 1). A shader used as a blend * shader can specify more than two inputs. In that case, any additional input must be specified * by setting its ShaderInput instance's input property.When you assign a Shader instance to this property the shader is copied internally. The * blend operation uses that internal copy, not a reference to the original shader. Any changes * made to the shader, such as changing a parameter value, input, or bytecode, are not applied * to the copied shader that's used for the blend mode. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @throws ArgumentError When the shader output type is not compatible with this operation * (the shader must specify a pixel4 * output). * @throws ArgumentError When the shader specifies fewer than two image inputs or the first * two inputs are not image4 inputs. * @throws ArgumentError When the shader specifies an image input that isn't provided. * @throws ArgumentError When a ByteArray or Vector. instance is used as * an input and the width * and height properties aren't specified for the * ShaderInput, or the specified values don't match the amount of * data in the input object. See the ShaderInput.input * property for more information. */ function set blendShader (value:Shader) : void; /** * If set to true, Flash runtimes cache an internal bitmap representation of the * display object. This caching can increase performance for display objects that contain complex * vector content. * * All vector data for a display object that has a cached bitmap is drawn to the bitmap * instead of the main display. If cacheAsBitmapMatrix is null or unsupported, * the bitmap is then copied to the main display as unstretched, unrotated pixels snapped to * the nearest pixel boundaries. Pixels are mapped 1 to 1 with * the parent object. If the bounds of the bitmap change, the bitmap is recreated instead * of being stretched.If cacheAsBitmapMatrix is non-null and supported, the object is drawn to the off-screen bitmap * using that matrix and the stretched and/or rotated results of that rendering are used * to draw the object to the main display.No internal bitmap is created unless the cacheAsBitmap property is set to * true.After you set the cacheAsBitmap property to true, * the rendering does not change, however the display object performs pixel snapping * automatically. The animation speed can be significantly faster depending * on the complexity of the vector content. * The cacheAsBitmap property is automatically set to true * whenever you apply a filter to a display object (when its filter array is not empty), * and if a display object has a filter applied to it, cacheAsBitmap is reported as * true for that display object, even if you set the property to false. * If you clear all filters for a display object, the cacheAsBitmap setting changes to * what it was last set to.A display object does not use a bitmap even if the cacheAsBitmap * property is set to true and instead renders from vector data in the following cases:The bitmap is too large. * In AIR 1.5 and Flash Player 10, the maximum size for a bitmap image is 8,191 pixels in width or height, * and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a bitmap image is 8,191 pixels * wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier, the limitation is * is 2880 pixels in height and 2,880 pixels in width.The bitmap fails to allocate (out of memory error). The cacheAsBitmap property is best used with movie clips that have * mostly static content and that do not scale and rotate frequently. With such movie * clips, cacheAsBitmap can lead to performance increases when the * movie clip is translated (when its x and y position is changed). * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get cacheAsBitmap () : Boolean; function set cacheAsBitmap (value:Boolean) : void; /** * If non-null, this Matrix object defines how a display object is rendered when * cacheAsBitmap is set to true. The application uses * this matrix as a transformation matrix that is applied when rendering the bitmap version of * the display object. * * AIR profile support: This feature is supported * on mobile devices, but it is not supported on desktop operating systems. It also has * limited support on AIR for TV devices. * Specifically, on AIR for TV devices, supported transformations include scaling and translation, * but not rotation and skewing. See * * AIR Profile Support for more information regarding API support across multiple profiles.With cacheAsBitmapMatrix set, the application retains a cached * bitmap image across various 2D transformations, including translation, rotation, * and scaling. If the application uses hardware acceleration, the object will * be stored in video memory as a texture. This allows the GPU to apply * the supported transformations to the object. The GPU * can perform these transformations faster than the CPU.To use the hardware acceleration, set Rendering to GPU in * the General tab of the iPhone Settings dialog box in Flash Professional CS5. * Or set the renderMode property to gpu in the * application descriptor file. Note that AIR for TV devices automatically * use hardware acceleration if it is available.For example, the following code sends an untransformed bitmap representation * of the display object to the GPU: * * matrix:Matrix = new Matrix(); // creates an identity matrix * mySprite.cacheAsBitmapMatrix = matrix; * mySprite.cacheAsBitmap = true; * * Usually, the identity matrix (new Matrix()) suffices. However, * you can use another matrix, such as a scaled-down matrix, to upload * a different bitmap to the GPU. For example, the following example applies * a cacheAsBitmapMatrix matrix that is scaled by 0.5 on the x and y axes. * The bitmap object that the GPU uses is smaller, however the GPU adjusts * its size to match the transform.matrix property of the display object: * * matrix:Matrix = new Matrix(); // creates an identity matrix * matrix.scale(0.5, 0.5); // scales the matrix * mySprite.cacheAsBitmapMatrix = matrix; * mySprite.cacheAsBitmap = true; * * Generally, you should choose to use a matrix that transforms the display object * to the size that it will appear in the application. For example, if * your application displays the bitmap version of the sprite scaled down by a half, * use a matrix that scales down by a half. If you application will display * the sprite larger than its current dimensions, use a matrix that * scales up by that factor.Note: The cacheAsBitmapMatrix property * is suitable for 2D transformations. If you need to apply transformations in 3D, * you may do so by setting a 3D property of the object and manipulating its * transform.matrix3D property. If the application is packaged * using GPU mode, this allows the 3D transforms to be applied to * the object by the GPU. The cacheAsBitmapMatrix is ignored * for 3D objects. * @langversion 3.0 * @playerversion AIR 2.0 */ function get cacheAsBitmapMatrix () : flash.geom.Matrix; function set cacheAsBitmapMatrix (value:Matrix) : void; /** * An indexed array that contains each filter object currently associated with the display object. * The flash.filters package contains several classes that define specific filters you can * use. * * Filters can be applied in Flash Professional at design time, or at run time by using * ActionScript code. To apply a filter by using ActionScript, you must make a temporary copy of the * entire filters array, modify the temporary array, then assign the value * of the temporary array back to the filters array. You cannot directly * add a new filter object to the filters array.To add a filter by using ActionScript, perform the following steps (assume that the * target display object is named myDisplayObject):Create a new filter object by using the constructor method of your chosen filter * class.Assign the value of the myDisplayObject.filters array to a temporary array, such * as one named myFilters.Add the new filter object to the myFilters temporary array.Assign the value of the temporary array to the myDisplayObject.filters array.If the filters array is undefined, you do not need to use a temporary array. * Instead, you can directly assign an array literal that contains one or more filter objects that * you create. The first example in the Examples section adds a drop shadow filter by using * code that handles both defined and undefined filters arrays.To modify an existing filter object, * you must use the technique of modifying a copy of the filters array:Assign the value of the filters array to a temporary array, such as one * named myFilters.Modify the property by using the temporary array, myFilters. For example, * to set the quality property of the first filter in the array, you could use the * following code: myFilters[0].quality = 1;Assign the value of the temporary array to the filters array.At load time, if a display object has an associated filter, it is marked to cache itself as a * transparent bitmap. From this point forward, as long as the display object has a valid filter list, * the player caches the display object as a bitmap. This source bitmap is used as a source * image for the filter effects. Each display object usually has two bitmaps: one with the * original unfiltered source display object and another for the final image after filtering. * The final image is used when rendering. As long as the display object does not * change, the final image does not need updating.The flash.filters package includes classes for filters. For example, to create a DropShadow * filter, you would write: * * * import flash.filters.DropShadowFilter * var myFilter:DropShadowFilter = new DropShadowFilter (distance, angle, color, alpha, blurX, blurY, quality, inner, knockout) * * * You can use the is operator to determine the type of filter assigned to * each index position in the filter array. For example, the following code shows * how to determine the position of the first filter in the filters array that * is a DropShadowFilter: * * * * import flash.text.TextField; * import flash.filters.~~; * var tf:TextField = new TextField(); * var filter1:DropShadowFilter = new DropShadowFilter(); * var filter2:GradientGlowFilter = new GradientGlowFilter(); * tf.filters = [filter1, filter2]; * * tf.text = ""DropShadow index: "" + filterPosition(tf, DropShadowFilter).toString(); // 0 * addChild(tf) * * function filterPosition(displayObject:DisplayObject, filterClass:Class):int { * for (var i:uint = 0; i < displayObject.filters.length; i++) { * if (displayObject.filters[i] is filterClass) { * return i; * } * } * return -1; * } * * * Note: Since you cannot directly add a new filter object to the * DisplayObject.filters array, the following code has no * effect on the target display object, named myDisplayObject: * * * myDisplayObject.filters.push(myDropShadow); * * * @langversion 3.0 * @playerversion Flash 9 * @throws ArgumentError When filters includes a ShaderFilter and the shader * output type is not compatible with this operation * (the shader must specify a pixel4 * output). * @throws ArgumentError When filters includes a ShaderFilter and the shader * doesn't specify any image input or the first * input is not an image4 input. * @throws ArgumentError When filters includes a ShaderFilter and the shader * specifies an image input that isn't provided. * @throws ArgumentError When filters includes a ShaderFilter, a * ByteArray or Vector. instance as * a shader input, and the width * and height properties aren't specified for the * ShaderInput object, or the specified values don't match the amount of * data in the input data. See the ShaderInput.input * property for more information. */ function get filters () : Array; function set filters (value:Array) : void; /** * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the content of the display object. * When you set the height property, the scaleY property is adjusted accordingly, as shown in the * following code: * * * * var rect:Shape = new Shape(); * rect.graphics.beginFill(0xFF0000); * rect.graphics.drawRect(0, 0, 100, 100); * trace(rect.scaleY) // 1; * rect.height = 200; * trace(rect.scaleY) // 2; * * Except for TextField and Video objects, a display object with no content (such as an empty sprite) has a height * of 0, even if you try to set height to a different value. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get height () : Number; function set height (value:Number) : void; /** * Returns a LoaderInfo object containing information about loading the file * to which this display object belongs. The loaderInfo property is defined only * for the root display object of a SWF file or for a loaded Bitmap (not for a Bitmap that is drawn * with ActionScript). To find the loaderInfo object associated with the SWF file that contains * a display object named myDisplayObject, use myDisplayObject.root.loaderInfo. * * A large SWF file can monitor its download by calling * this.root.loaderInfo.addEventListener(Event.COMPLETE, func). * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get loaderInfo () : flash.display.LoaderInfo; /** * The calling display object is masked by the specified mask object. * To ensure that masking works when the Stage is scaled, the mask display object * must be in an active part of the display list. The mask object itself is not drawn. * Set mask to null to remove the mask. * * To be able to scale a mask object, it must be on the display list. To be able to drag a mask Sprite object * (by calling its startDrag() method), it must be on the display list. To call the * startDrag() method for a mask sprite based on a mouseDown event * being dispatched by the sprite, set the sprite's buttonMode property to true.When display objects are cached by setting the cacheAsBitmap property to * true an the cacheAsBitmapMatrix property to a Matrix object, * both the mask and the display object being masked must be part of the same cached * bitmap. Thus, if the display object is cached, then the mask must be a child of the display object. * If an ancestor of the display object on the display list is cached, then the mask must be a child of * that ancestor or one of its descendents. If more than one ancestor of the masked object is cached, * then the mask must be a descendent of the cached container closest to the masked object in the display list.Note: A single mask object cannot be used to mask more than one calling display object. * When the mask is assigned to a second display object, it is removed as the mask of the first * object, and that object's mask property becomes null. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get mask () : flash.display.DisplayObject; function set mask (value:DisplayObject) : void; function get metaData () : Object; function set metaData (data:Object) : void; /** * Indicates the x coordinate of the mouse or user input device position, in pixels. * * Note: For a DisplayObject that has been rotated, the returned x coordinate will reflect the * non-rotated object. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get mouseX () : Number; /** * Indicates the y coordinate of the mouse or user input device position, in pixels. * * Note: For a DisplayObject that has been rotated, the returned y coordinate will reflect the * non-rotated object. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get mouseY () : Number; /** * Indicates the instance name of the DisplayObject. The object can be identified in * the child list of its parent display object container by calling the * getChildByName() method of the display object container. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @throws IllegalOperationError If you are attempting to set this property on an object that was * placed on the timeline in the Flash authoring tool. */ function get name () : String; function set name (value:String) : void; /** * Specifies whether the display object is opaque with a certain background color. * A transparent bitmap contains alpha * channel data and is drawn transparently. An opaque bitmap has no alpha channel (and renders faster * than a transparent bitmap). If the bitmap is opaque, you specify its own background color to use. * * If set to a number value, the surface is opaque (not transparent) with the RGB background * color that the number specifies. If set to null (the default value), the display * object has a transparent background.The opaqueBackground property is intended mainly for use with the * cacheAsBitmap property, for rendering optimization. For display objects in which the * cacheAsBitmap property is set to true, setting opaqueBackground can * improve rendering performance.The opaque background region is not matched when calling the hitTestPoint() * method with the shapeFlag parameter set to true.The opaque background region does not respond to mouse events. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get opaqueBackground () : Object; function set opaqueBackground (value:Object) : void; /** * Indicates the DisplayObjectContainer object that contains this display object. Use the parent * property to specify a relative path to display objects that are above the * current display object in the display list hierarchy. * * You can use parent to move up multiple levels in the display list as in the following: * * * this.parent.parent.alpha = 20; * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @throws SecurityError The parent display object belongs to a security sandbox * to which you do not have access. You can avoid this situation by having * the parent movie call the Security.allowDomain() method. */ function get parent () : flash.display.DisplayObjectContainer; /** * For a display object in a loaded SWF file, the root property is the * top-most display object in the portion of the display list's tree structure represented by that SWF file. * For a Bitmap object representing a loaded image file, the root property is the Bitmap object * itself. For the instance of the main class of the first SWF file loaded, the root property is the * display object itself. The root property of the Stage object is the Stage object itself. The root * property is set to null for any display object that has not been added to the display list, unless * it has been added to a display object container that is off the display list but that is a child of the * top-most display object in a loaded SWF file. * * For example, if you create a new Sprite object by calling the Sprite() constructor method, * its root property is null until you add it to the display list (or to a display * object container that is off the display list but that is a child of the top-most display object in a SWF file).For a loaded SWF file, even though the Loader object used to load the file may not be on the display list, * the top-most display object in the SWF file has its root property set to itself. The Loader object * does not have its root property set until it is added as a child of a display object for which the * root property is set. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get root () : flash.display.DisplayObject; /** * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from 0 to 180 represent * clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or * subtracted from 360 to obtain a value within the range. For example, the statement my_video.rotation = 450 is the * same as my_video.rotation = 90. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get rotation () : Number; function set rotation (value:Number) : void; /** * Indicates the x-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. Values from 0 to 180 represent * clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or * subtracted from 360 to obtain a value within the range. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ function get rotationX () : Number; function set rotationX (value:Number) : void; /** * Indicates the y-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. Values from 0 to 180 represent * clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or * subtracted from 360 to obtain a value within the range. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ function get rotationY () : Number; function set rotationY (value:Number) : void; /** * Indicates the z-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. Values from 0 to 180 represent * clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or * subtracted from 360 to obtain a value within the range. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ function get rotationZ () : Number; function set rotationZ (value:Number) : void; /** * The current scaling grid that is in effect. If set to null, * the entire display object is scaled normally when any scale transformation is * applied. * * When you define the scale9Grid property, the display object is divided into a * grid with nine regions based on the scale9Grid rectangle, which defines the * center region of the grid. The eight other regions of the grid are the following areas: The upper-left corner outside of the rectangleThe area above the rectangle The upper-right corner outside of the rectangleThe area to the left of the rectangleThe area to the right of the rectangleThe lower-left corner outside of the rectangleThe area below the rectangleThe lower-right corner outside of the rectangleYou can think of the eight regions outside of the center (defined by the rectangle) * as being like a picture frame that has special rules applied to it when scaled.When the scale9Grid property is set and a display object is scaled, all text and * gradients are scaled normally; however, for other types of objects the following rules apply:Content in the center region is scaled normally. Content in the corners is not scaled. Content in the top and bottom regions is scaled horizontally only. Content in the * left and right regions is scaled vertically only.All fills (including bitmaps, video, and gradients) are stretched to fit their shapes.If a display object is rotated, all subsequent scaling is normal (and the * scale9Grid property is ignored).For example, consider the following display object and a rectangle that is applied as the display * object's scale9Grid:The display object.The red rectangle shows the scale9Grid.When the display object is scaled or stretched, the objects within the rectangle scale * normally, but the objects outside of the rectangle scale according to the * scale9Grid rules:Scaled to 75%:Scaled to 50%:Scaled to 25%:Stretched horizontally 150%: A common use for setting scale9Grid is to set up a display object to be used * as a component, in which edge regions retain the same width when the component is scaled. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @maelexample The following creates a movie clip that contains a 20-pixel line (which forms a border) * and a gradient fill. The movie clip scales based on the mouse position, and because of the * scale9Grid set for the movie clip, the thickness of the 20-pixel line does not * vary when the clip scales (although the gradient in the movie clip does scale): * * * import flash.geom.Rectangle; * import flash.geom.Matrix; * * this.createEmptyMovieClip(""my_mc"", this.getNextHighestDepth()); * * var grid:Rectangle = new Rectangle(20, 20, 260, 260); * my_mc.scale9Grid = grid ; * * my_mc._x = 50; * my_mc._y = 50; * * function onMouseMove() * { * my_mc._width = _xmouse; * my_mc._height = _ymouse; * } * * my_mc.lineStyle(20, 0xff3333, 100); * var gradient_matrix:Matrix = new Matrix(); * gradient_matrix.createGradientBox(15, 15, Math.PI, 10, 10); * my_mc.beginGradientFill(""radial"", [0xffff00, 0x0000ff], * [100, 100], [0, 0xFF], gradient_matrix, * ""reflect"", ""RGB"", 0.9); * my_mc.moveTo(0, 0); * my_mc.lineTo(0, 300); * my_mc.lineTo(300, 300); * my_mc.lineTo(300, 0); * my_mc.lineTo(0, 0); * my_mc.endFill(); * * @throws ArgumentError If you pass an invalid argument to the method. */ function get scale9Grid () : flash.geom.Rectangle; function set scale9Grid (innerRectangle:Rectangle) : void; /** * Indicates the horizontal scale (percentage) of the object as applied from the registration point. The default * registration point is (0,0). 1.0 equals 100% scale. * * Scaling the local coordinate system changes the x and y property values, which are defined in * whole pixels. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get scaleX () : Number; function set scaleX (value:Number) : void; /** * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. The * default registration point is (0,0). 1.0 is 100% scale. * * Scaling the local coordinate system changes the x and y property values, which are defined in * whole pixels. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get scaleY () : Number; function set scaleY (value:Number) : void; /** * Indicates the depth scale (percentage) of an object as applied from the registration point of the object. The * default registration point is (0,0). 1.0 is 100% scale. * * Scaling the local coordinate system changes the x, y and z property values, which are defined in * whole pixels. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 */ function get scaleZ () : Number; function set scaleZ (value:Number) : void; /** * The scroll rectangle bounds of the display object. * The display object is cropped to the size * defined by the rectangle, and it scrolls within the rectangle when you change the * x and y properties of the scrollRect object. * * The properties of the scrollRect Rectangle object use the display object's coordinate space * and are scaled just like the overall display object. The corner bounds of the cropped window on the scrolling * display object are the origin of the display object (0,0) and the point defined by the * width and height of the rectangle. They are not centered around the origin, but * use the origin to define the upper-left corner of the area. A scrolled display object always * scrolls in whole pixel increments. You can scroll an object left and right by setting the x property of the * scrollRect Rectangle object. You can scroll an object up and down by setting * the y property of the scrollRect Rectangle object. If the display object * is rotated 90° and you scroll it left and right, the display object actually scrolls up and down.Note that changes to the scrollRect property are only processed when the object is rendered. * Thus methods like localToGlobal may not produce the expected result if called immediately * after modifying scrollRect.Note: Starting with Flash Player 11.4/AIR 3.4, negative values for the width or the height of the rectangle * are changed to 0. * @langversion 3.0 * @playerversion Flash 9 */ function get scrollRect () : flash.geom.Rectangle; function set scrollRect (value:Rectangle) : void; /** * The Stage of the display object. A Flash runtime application has only one Stage object. * For example, you can create and load multiple display objects into the display list, and the * stage property of each display object refers to the same Stage object (even if the * display object belongs to a loaded SWF file). * * If a display object is not added to the display list, its stage property is set to * null. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get stage () : flash.display.Stage; /** * An object with properties pertaining to a display object's matrix, color transform, and pixel bounds. * The specific properties — matrix, colorTransform, and three read-only properties * (concatenatedMatrix, concatenatedColorTransform, * and pixelBounds) — are described in the entry for the Transform class. * * Each of the transform object's properties is itself an object. This concept is important because the only * way to set new values for the matrix or colorTransform objects is to create a new object and copy that * object into the transform.matrix or transform.colorTransform property.For example, to increase the tx value of a display object's matrix, you must make a * copy of the entire matrix object, then copy the new object into the matrix property of the transform * object: * var myMatrix:Matrix = myDisplayObject.transform.matrix; * myMatrix.tx += 10; * myDisplayObject.transform.matrix = myMatrix; * You cannot directly set the tx property. The following code has * no effect on myDisplayObject: * myDisplayObject.transform.matrix.tx += 10; * You can also copy an entire transform object and assign it to another * display object's transform property. For example, the following code * copies the entire transform object from myOldDisplayObj to * myNewDisplayObj:myNewDisplayObj.transform = myOldDisplayObj.transform;The resulting display object, myNewDisplayObj, now has the same values for its * matrix, color transform, and pixel bounds as the old display object, myOldDisplayObj.Note that AIR for TV devices use hardware acceleration, if it is available, for color transforms. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get transform () : flash.geom.Transform; function set transform (value:Transform) : void; /** * Whether or not the display object is visible. Display objects that are not visible * are disabled. For example, if visible=false for an InteractiveObject instance, * it cannot be clicked. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get visible () : Boolean; function set visible (value:Boolean) : void; /** * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content of the display object. * When you set the width property, the scaleX property is adjusted accordingly, as shown in the * following code: * * * * var rect:Shape = new Shape(); * rect.graphics.beginFill(0xFF0000); * rect.graphics.drawRect(0, 0, 100, 100); * trace(rect.scaleX) // 1; * rect.width = 200; * trace(rect.scaleX) // 2; * * Except for TextField and Video objects, a display object with no content (such as an empty sprite) has a width * of 0, even if you try to set width to a different value. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get width () : Number; function set width (value:Number) : void; /** * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of * the parent DisplayObjectContainer. If the object is inside a DisplayObjectContainer that has * transformations, it is in the local coordinate system of the enclosing DisplayObjectContainer. * Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the DisplayObjectContainer's * children inherit a coordinate system that is rotated 90° counterclockwise. * The object's coordinates refer to the registration point position. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get x () : Number; function set x (value:Number) : void; /** * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of * the parent DisplayObjectContainer. If the object is inside a DisplayObjectContainer that has * transformations, it is in the local coordinate system of the enclosing DisplayObjectContainer. * Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the DisplayObjectContainer's * children inherit a coordinate system that is rotated 90° counterclockwise. * The object's coordinates refer to the registration point position. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function get y () : Number; function set y (value:Number) : void; /** * Indicates the z coordinate position along the z-axis of the DisplayObject * instance relative to the 3D parent container. The z property is used for * 3D coordinates, not screen or pixel coordinates. * When you set a z property for a display object to something other than the default * value of 0, a corresponding Matrix3D object is automatically created. for adjusting a * display object's position and orientation * in three dimensions. When working with the z-axis, * the existing behavior of x and y properties changes from screen or pixel coordinates to * positions relative to the 3D parent container.For example, a child of the _root at position x = 100, y = 100, z = 200 * is not drawn at pixel location (100,100). The child is drawn wherever the 3D projection * calculation puts it. The calculation is: (x~~cameraFocalLength/cameraRelativeZPosition, y~~cameraFocalLength/cameraRelativeZPosition) * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 */ function get z () : Number; function set z (value:Number) : void; /** * Returns a rectangle that defines the area of the display object relative to the coordinate system * of the targetCoordinateSpace object. * Consider the following code, which shows how the rectangle returned can vary depending on the * targetCoordinateSpace parameter that you pass to the method: * * * * var container:Sprite = new Sprite(); * container.x = 100; * container.y = 100; * this.addChild(container); * var contents:Shape = new Shape(); * contents.graphics.drawCircle(0,0,100); * container.addChild(contents); * trace(contents.getBounds(container)); * // (x=-100, y=-100, w=200, h=200) * trace(contents.getBounds(this)); * // (x=0, y=0, w=200, h=200) * * * Note: Use the localToGlobal() and * globalToLocal() methods to convert the display object's local coordinates * to display coordinates, or display coordinates to local coordinates, respectively.The getBounds() method is similar to the getRect() method; * however, the Rectangle returned by the getBounds() method includes any strokes * on shapes, whereas the Rectangle returned by the getRect() method does not. * For an example, see the description of the getRect() method. * @param targetCoordinateSpace The display object that defines the coordinate system to use. * @return The rectangle that defines the area of the display object relative to * the targetCoordinateSpace object's coordinate system. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function getBounds (targetCoordinateSpace:DisplayObject) : flash.geom.Rectangle; /** * Returns a rectangle that defines the boundary of the display object, * based on the coordinate system defined by the targetCoordinateSpace * parameter, excluding any strokes on shapes. The values that the getRect() method * returns are the same or smaller than those returned by the getBounds() method. * * Note: Use localToGlobal() and globalToLocal() methods * to convert the display object's local coordinates to Stage coordinates, or Stage coordinates to * local coordinates, respectively. * @param targetCoordinateSpace The display object that defines the coordinate system to use. * @return The rectangle that defines the area of the display object relative to * the targetCoordinateSpace object's coordinate system. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function getRect (targetCoordinateSpace:DisplayObject) : flash.geom.Rectangle; /** * Converts the point object from the Stage (global) coordinates * to the display object's (local) coordinates. * * To use this method, first create an instance of the Point class. The * x and y values that you assign represent global coordinates because they * relate to the origin (0,0) of the main display area. Then pass the Point instance * as the parameter to the globalToLocal() method. The method returns a new Point object with * x and y values that relate to the origin of the display object * instead of the origin of the Stage. * @param point An object created with the Point class. The Point object * specifies the x and y coordinates as properties. * @return A Point object with coordinates relative to the display object. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function globalToLocal (point:Point) : flash.geom.Point; /** * Converts a two-dimensional point from the Stage (global) coordinates to a * three-dimensional display object's (local) coordinates. * * To use this method, first create an instance of the Point class. * The x and y values that you assign to the Point object represent global * coordinates because they are relative to the origin (0,0) of the main display area. * Then pass the Point object to the globalToLocal3D() * method as the point parameter. The method returns three-dimensional * coordinates as a Vector3D object containing x, y, and * z values that are relative to the origin * of the three-dimensional display object. * @param point A two dimensional Point object representing global x and y coordinates. * @return A Vector3D object with coordinates relative to the three-dimensional * display object. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ function globalToLocal3D (point:Point) : flash.geom.Vector3D; /** * Evaluates the bounding box of the display object to see if it overlaps or intersects with the * bounding box of the obj display object. * @param obj The display object to test against. * @return true if the bounding boxes of the display objects intersect; false if not. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function hitTestObject (obj:DisplayObject) : Boolean; /** * Evaluates the display object to see if it overlaps or intersects with the * point specified by the x and y parameters. * The x and y parameters specify a point in the * coordinate space of the Stage, not the display object container that contains the * display object (unless that display object container is the Stage). * @param x The x coordinate to test against this object. * @param y The y coordinate to test against this object. * @param shapeFlag Whether to check against the actual pixels of the object (true) * or the bounding box (false). * @return true if the display object overlaps or intersects with the specified point; * false otherwise. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function hitTestPoint (x:Number, y:Number, shapeFlag:Boolean=false) : Boolean; /** * Converts a three-dimensional point of the three-dimensional display * object's (local) coordinates to a two-dimensional point in the Stage (global) coordinates. * * For example, you can only use two-dimensional coordinates (x,y) to * draw with the display.Graphics methods. To draw a three-dimensional * object, you need to map the three-dimensional coordinates of a * display object to two-dimensional coordinates. First, create an instance of * the Vector3D class that holds the x-, y-, and z- coordinates of the three-dimensional * display object. Then pass the Vector3D object to the local3DToGlobal() * method as the point3d parameter. The method returns a two-dimensional Point * object that can be used * with the Graphics API to draw the three-dimensional object. * @param point3d A Vector3D object containing either a three-dimensional point or * the coordinates of the three-dimensional display object. * @return A two-dimensional point representing a three-dimensional point * in two-dimensional space. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ function local3DToGlobal (point3d:Vector3D) : flash.geom.Point; /** * Converts the point object from the display object's (local) coordinates to the * Stage (global) coordinates. * * This method allows you to convert any given x and y coordinates from * values that are relative to the origin (0,0) of a specific display object (local coordinates) * to values that are relative to the origin of the Stage (global coordinates).To use this method, first create an instance of the Point class. The * x and y values that you assign represent local coordinates because they * relate to the origin of the display object.You then pass the Point instance that you created as the parameter to * the localToGlobal() method. The method returns a new Point object with * x and y values that relate to the origin of the Stage * instead of the origin of the display object. * @param point The name or identifier of a point created with the Point class, specifying the * x and y coordinates as properties. * @return A Point object with coordinates relative to the Stage. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ function localToGlobal (point:Point) : flash.geom.Point; } }",16155,True,2870.2301224733174,median "CLASS zcl_abapgit_repo DEFINITION PUBLIC ABSTRACT CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_repo. ALIASES ms_data FOR zif_abapgit_repo~ms_data. ALIASES: get_key FOR zif_abapgit_repo~get_key, get_name FOR zif_abapgit_repo~get_name, is_offline FOR zif_abapgit_repo~is_offline, get_package FOR zif_abapgit_repo~get_package, get_files_local FOR zif_abapgit_repo~get_files_local, get_files_remote FOR zif_abapgit_repo~get_files_remote, get_local_settings FOR zif_abapgit_repo~get_local_settings, refresh FOR zif_abapgit_repo~refresh. METHODS constructor IMPORTING !is_data TYPE zif_abapgit_persistence=>ty_repo . METHODS bind_listener IMPORTING !ii_listener TYPE REF TO zif_abapgit_repo_listener . METHODS deserialize_checks RETURNING VALUE(rs_checks) TYPE zif_abapgit_definitions=>ty_deserialize_checks RAISING zcx_abapgit_exception . METHODS delete_checks RETURNING VALUE(rs_checks) TYPE zif_abapgit_definitions=>ty_delete_checks RAISING zcx_abapgit_exception . METHODS get_local_checksums_per_file RETURNING VALUE(rt_checksums) TYPE zif_abapgit_definitions=>ty_file_signatures_tt . METHODS get_dot_abapgit RETURNING VALUE(ro_dot_abapgit) TYPE REF TO zcl_abapgit_dot_abapgit . METHODS set_dot_abapgit IMPORTING !io_dot_abapgit TYPE REF TO zcl_abapgit_dot_abapgit RAISING zcx_abapgit_exception . METHODS get_dot_apack RETURNING VALUE(ro_dot_apack) TYPE REF TO zcl_abapgit_apack_reader . METHODS get_data_config RETURNING VALUE(ri_config) TYPE REF TO zif_abapgit_data_config RAISING zcx_abapgit_exception . METHODS deserialize IMPORTING !is_checks TYPE zif_abapgit_definitions=>ty_deserialize_checks !ii_log TYPE REF TO zif_abapgit_log RAISING zcx_abapgit_exception . METHODS update_local_checksums IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_file_signatures_tt RAISING zcx_abapgit_exception . METHODS rebuild_local_checksums RAISING zcx_abapgit_exception . METHODS find_remote_dot_abapgit RETURNING VALUE(ro_dot) TYPE REF TO zcl_abapgit_dot_abapgit RAISING zcx_abapgit_exception . METHODS set_files_remote IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_files_tt . METHODS set_local_settings IMPORTING !is_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings RAISING zcx_abapgit_exception . METHODS has_remote_source ABSTRACT RETURNING VALUE(rv_yes) TYPE abap_bool . METHODS status IMPORTING !ii_log TYPE REF TO zif_abapgit_log OPTIONAL RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . METHODS switch_repo_type IMPORTING !iv_offline TYPE abap_bool RAISING zcx_abapgit_exception . METHODS create_new_log IMPORTING !iv_title TYPE string OPTIONAL RETURNING VALUE(ri_log) TYPE REF TO zif_abapgit_log . METHODS get_log RETURNING VALUE(ri_log) TYPE REF TO zif_abapgit_log . METHODS refresh_local_object IMPORTING !iv_obj_type TYPE tadir-object !iv_obj_name TYPE tadir-obj_name RAISING zcx_abapgit_exception . METHODS refresh_local_objects RAISING zcx_abapgit_exception . METHODS reset_status . METHODS get_unsupported_objects_local RETURNING VALUE(rt_objects) TYPE zif_abapgit_definitions=>ty_items_tt RAISING zcx_abapgit_exception . PROTECTED SECTION. DATA mt_local TYPE zif_abapgit_definitions=>ty_files_item_tt . DATA mt_remote TYPE zif_abapgit_definitions=>ty_files_tt . DATA mv_request_local_refresh TYPE abap_bool . DATA mv_request_remote_refresh TYPE abap_bool . DATA mt_status TYPE zif_abapgit_definitions=>ty_results_tt . DATA mi_log TYPE REF TO zif_abapgit_log . DATA mi_listener TYPE REF TO zif_abapgit_repo_listener . DATA mo_apack_reader TYPE REF TO zcl_abapgit_apack_reader . DATA mi_data_config TYPE REF TO zif_abapgit_data_config . METHODS find_remote_dot_apack RETURNING VALUE(ro_dot) TYPE REF TO zcl_abapgit_apack_reader RAISING zcx_abapgit_exception . METHODS set_dot_apack IMPORTING !io_dot_apack TYPE REF TO zcl_abapgit_apack_reader RAISING zcx_abapgit_exception . METHODS set IMPORTING !it_checksums TYPE zif_abapgit_persistence=>ty_local_checksum_tt OPTIONAL !iv_url TYPE zif_abapgit_persistence=>ty_repo-url OPTIONAL !iv_branch_name TYPE zif_abapgit_persistence=>ty_repo-branch_name OPTIONAL !iv_selected_commit TYPE zif_abapgit_persistence=>ty_repo-selected_commit OPTIONAL !iv_head_branch TYPE zif_abapgit_persistence=>ty_repo-head_branch OPTIONAL !iv_offline TYPE zif_abapgit_persistence=>ty_repo-offline OPTIONAL !is_dot_abapgit TYPE zif_abapgit_persistence=>ty_repo-dot_abapgit OPTIONAL !is_local_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings OPTIONAL !iv_deserialized_at TYPE zif_abapgit_persistence=>ty_repo-deserialized_at OPTIONAL !iv_deserialized_by TYPE zif_abapgit_persistence=>ty_repo-deserialized_by OPTIONAL !iv_switched_origin TYPE zif_abapgit_persistence=>ty_repo-switched_origin OPTIONAL RAISING zcx_abapgit_exception . METHODS reset_remote . PRIVATE SECTION. METHODS get_local_checksums RETURNING VALUE(rt_checksums) TYPE zif_abapgit_persistence=>ty_local_checksum_tt . METHODS notify_listener IMPORTING !is_change_mask TYPE zif_abapgit_persistence=>ty_repo_meta_mask RAISING zcx_abapgit_exception . METHODS update_last_deserialize RAISING zcx_abapgit_exception . METHODS check_for_restart . METHODS check_write_protect RAISING zcx_abapgit_exception . METHODS check_language RAISING zcx_abapgit_exception . METHODS remove_non_code_related_files CHANGING !ct_local_files TYPE zif_abapgit_definitions=>ty_files_item_tt . METHODS compare_with_remote_checksum IMPORTING !it_remote_files TYPE zif_abapgit_definitions=>ty_files_tt !is_local_file TYPE zif_abapgit_definitions=>ty_file_item-file CHANGING !cs_checksum TYPE zif_abapgit_persistence=>ty_local_checksum . ENDCLASS. CLASS ZCL_ABAPGIT_REPO IMPLEMENTATION. METHOD bind_listener. mi_listener = ii_listener. ENDMETHOD. METHOD check_for_restart. CONSTANTS: lc_abapgit_prog TYPE progname VALUE `ZABAPGIT`. "" If abapGit was used to update itself, then restart to avoid LOAD_PROGRAM_&_MISMATCH dumps "" because abapGit code was changed at runtime IF zcl_abapgit_ui_factory=>get_frontend_services( )->gui_is_available( ) = abap_true AND zcl_abapgit_url=>is_abapgit_repo( ms_data-url ) = abap_true AND sy-batch = abap_false AND sy-cprog = lc_abapgit_prog. IF zcl_abapgit_persist_factory=>get_settings( )->read( )->get_show_default_repo( ) = abap_false. MESSAGE 'abapGit was updated and will restart itself' TYPE 'I'. ENDIF. SUBMIT (sy-cprog). ENDIF. ENDMETHOD. METHOD check_language. DATA lv_main_language TYPE spras. "" assumes find_remote_dot_abapgit has been called before lv_main_language = get_dot_abapgit( )->get_main_language( ). IF lv_main_language <> sy-langu. zcx_abapgit_exception=>raise( |Current login language | && |'{ zcl_abapgit_convert=>conversion_exit_isola_output( sy-langu ) }'| && | does not match main language | && |'{ zcl_abapgit_convert=>conversion_exit_isola_output( lv_main_language ) }'.| && | Select 'Advanced' > 'Open in Main Language'| ). ENDIF. ENDMETHOD. METHOD check_write_protect. IF get_local_settings( )-write_protected = abap_true. zcx_abapgit_exception=>raise( 'Cannot deserialize. Local code is write-protected by repo config' ). ENDIF. ENDMETHOD. METHOD compare_with_remote_checksum. FIELD-SYMBOLS: LIKE LINE OF it_remote_files, LIKE LINE OF cs_checksum-files. READ TABLE it_remote_files ASSIGNING WITH KEY path = is_local_file-path filename = is_local_file-filename BINARY SEARCH. IF sy-subrc <> 0. "" Ignore new local ones RETURN. ENDIF. APPEND INITIAL LINE TO cs_checksum-files ASSIGNING . MOVE-CORRESPONDING is_local_file TO . "" If hashes are equal -> local sha1 is OK "" Else if R-branch is ahead -> assume changes were remote, state - local sha1 "" Else (branches equal) -> assume changes were local, state - remote sha1 IF is_local_file-sha1 <> -sha1. -sha1 = -sha1. ENDIF. ENDMETHOD. METHOD constructor. ASSERT NOT is_data-key IS INITIAL. ms_data = is_data. mv_request_remote_refresh = abap_true. ENDMETHOD. METHOD create_new_log. CREATE OBJECT mi_log TYPE zcl_abapgit_log. mi_log->set_title( iv_title ). ri_log = mi_log. ENDMETHOD. METHOD delete_checks. DATA: li_package TYPE REF TO zif_abapgit_sap_package. li_package = zcl_abapgit_factory=>get_sap_package( get_package( ) ). rs_checks-transport-required = li_package->are_changes_recorded_in_tr_req( ). ENDMETHOD. METHOD deserialize. DATA: lt_updated_files TYPE zif_abapgit_definitions=>ty_file_signatures_tt, lt_result TYPE zif_abapgit_data_deserializer=>ty_results, lx_error TYPE REF TO zcx_abapgit_exception. find_remote_dot_abapgit( ). find_remote_dot_apack( ). check_write_protect( ). check_language( ). IF is_checks-requirements-met = zif_abapgit_definitions=>c_no AND is_checks-requirements-decision IS INITIAL. zcx_abapgit_exception=>raise( 'Requirements not met and undecided' ). ENDIF. IF is_checks-dependencies-met = zif_abapgit_definitions=>c_no. zcx_abapgit_exception=>raise( 'APACK dependencies not met' ). ENDIF. IF is_checks-transport-required = abap_true AND is_checks-transport-transport IS INITIAL. zcx_abapgit_exception=>raise( |No transport request was supplied| ). ENDIF. "" Deserialize objects TRY. lt_updated_files = zcl_abapgit_objects=>deserialize( io_repo = me is_checks = is_checks ii_log = ii_log ). CATCH zcx_abapgit_exception INTO lx_error. "" Ensure to reset default transport request task zcl_abapgit_default_transport=>get_instance( )->reset( ). refresh( iv_drop_log = abap_false ). RAISE EXCEPTION lx_error. ENDTRY. APPEND get_dot_abapgit( )->get_signature( ) TO lt_updated_files. update_local_checksums( lt_updated_files ). "" Deserialize data (no save to database, just test for now) lt_result = zcl_abapgit_data_factory=>get_deserializer( )->deserialize( ii_config = get_data_config( ) it_files = get_files_remote( ) ). CLEAR: mt_local. update_last_deserialize( ). reset_status( ). COMMIT WORK AND WAIT. check_for_restart( ). ENDMETHOD. METHOD deserialize_checks. DATA: lt_requirements TYPE zif_abapgit_dot_abapgit=>ty_requirement_tt, lt_dependencies TYPE zif_abapgit_apack_definitions=>ty_dependencies. find_remote_dot_abapgit( ). find_remote_dot_apack( ). check_write_protect( ). check_language( ). rs_checks = zcl_abapgit_objects=>deserialize_checks( me ). lt_requirements = get_dot_abapgit( )->get_data( )-requirements. rs_checks-requirements-met = zcl_abapgit_requirement_helper=>is_requirements_met( lt_requirements ). lt_dependencies = get_dot_apack( )->get_manifest_descriptor( )-dependencies. rs_checks-dependencies-met = zcl_abapgit_apack_helper=>are_dependencies_met( lt_dependencies ). ENDMETHOD. METHOD find_remote_dot_abapgit. FIELD-SYMBOLS: LIKE LINE OF mt_remote. get_files_remote( ). READ TABLE mt_remote ASSIGNING WITH KEY file_path COMPONENTS path = zif_abapgit_definitions=>c_root_dir filename = zif_abapgit_definitions=>c_dot_abapgit. IF sy-subrc = 0. ro_dot = zcl_abapgit_dot_abapgit=>deserialize( -data ). set_dot_abapgit( ro_dot ). COMMIT WORK AND WAIT. "" to release lock ENDIF. ENDMETHOD. METHOD find_remote_dot_apack. FIELD-SYMBOLS: LIKE LINE OF mt_remote. get_files_remote( ). READ TABLE mt_remote ASSIGNING WITH KEY file_path COMPONENTS path = zif_abapgit_definitions=>c_root_dir filename = zif_abapgit_apack_definitions=>c_dot_apack_manifest. IF sy-subrc = 0. ro_dot = zcl_abapgit_apack_reader=>deserialize( iv_package_name = ms_data-package iv_xstr = -data ). set_dot_apack( ro_dot ). ENDIF. ENDMETHOD. METHOD get_data_config. FIELD-SYMBOLS: LIKE LINE OF mt_remote. IF mi_data_config IS BOUND. ri_config = mi_data_config. RETURN. ENDIF. get_files_remote( ). CREATE OBJECT ri_config TYPE zcl_abapgit_data_config. mi_data_config = ri_config. READ TABLE mt_remote ASSIGNING WITH KEY file_path COMPONENTS path = zif_abapgit_data_config=>c_default_path. IF sy-subrc = 0. ri_config->from_json( mt_remote ). ENDIF. ENDMETHOD. METHOD get_dot_abapgit. CREATE OBJECT ro_dot_abapgit EXPORTING is_data = ms_data-dot_abapgit. ENDMETHOD. METHOD get_dot_apack. IF mo_apack_reader IS NOT BOUND. mo_apack_reader = zcl_abapgit_apack_reader=>create_instance( ms_data-package ). ENDIF. ro_dot_apack = mo_apack_reader. ENDMETHOD. METHOD get_files_local. DATA lo_serialize TYPE REF TO zcl_abapgit_serialize. DATA lt_filter TYPE zif_abapgit_definitions=>ty_tadir_tt. "" Serialization happened before and no refresh request IF lines( mt_local ) > 0 AND mv_request_local_refresh = abap_false. rt_files = mt_local. RETURN. ENDIF. CREATE OBJECT lo_serialize EXPORTING io_dot_abapgit = get_dot_abapgit( ) is_local_settings = get_local_settings( ). IF ii_obj_filter IS NOT INITIAL. lt_filter = ii_obj_filter->get_filter( ). ENDIF. rt_files = lo_serialize->files_local( iv_package = get_package( ) ii_data_config = get_data_config( ) ii_log = ii_log it_filter = lt_filter ). mt_local = rt_files. mv_request_local_refresh = abap_false. "" Fulfill refresh ENDMETHOD. METHOD get_files_remote. DATA lt_filter TYPE zif_abapgit_definitions=>ty_tadir_tt. DATA lr_filter TYPE REF TO zcl_abapgit_repo_filter. rt_files = mt_remote. IF ii_obj_filter IS NOT INITIAL. lt_filter = ii_obj_filter->get_filter( ). CREATE OBJECT lr_filter. lr_filter->apply_object_filter( EXPORTING it_filter = lt_filter io_dot = get_dot_abapgit( ) iv_devclass = get_package( ) CHANGING ct_files = rt_files ). ENDIF. ENDMETHOD. METHOD get_key. rv_key = ms_data-key. ENDMETHOD. METHOD get_local_checksums. rt_checksums = ms_data-local_checksums. ENDMETHOD. METHOD get_local_checksums_per_file. FIELD-SYMBOLS LIKE LINE OF ms_data-local_checksums. LOOP AT ms_data-local_checksums ASSIGNING . APPEND LINES OF -files TO rt_checksums. ENDLOOP. ENDMETHOD. METHOD get_local_settings. rs_settings = ms_data-local_settings. ENDMETHOD. METHOD get_log. ri_log = mi_log. ENDMETHOD. METHOD get_name. rv_name = ms_data-local_settings-display_name. ENDMETHOD. METHOD get_package. rv_package = ms_data-package. ENDMETHOD. METHOD get_unsupported_objects_local. DATA: lt_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt, lt_supported_types TYPE zcl_abapgit_objects=>ty_types_tt. FIELD-SYMBOLS: LIKE LINE OF lt_tadir, LIKE LINE OF rt_objects. lt_tadir = zcl_abapgit_factory=>get_tadir( )->read( iv_package = ms_data-package iv_ignore_subpackages = ms_data-local_settings-ignore_subpackages iv_only_local_objects = ms_data-local_settings-only_local_objects io_dot = get_dot_abapgit( ) ). lt_supported_types = zcl_abapgit_objects=>supported_list( ). LOOP AT lt_tadir ASSIGNING . READ TABLE lt_supported_types WITH KEY table_line = -object TRANSPORTING NO FIELDS. IF sy-subrc <> 0. APPEND INITIAL LINE TO rt_objects ASSIGNING . MOVE-CORRESPONDING TO . -obj_type = -object. ENDIF. ENDLOOP. ENDMETHOD. METHOD is_offline. rv_offline = ms_data-offline. ENDMETHOD. METHOD notify_listener. DATA ls_meta_slug TYPE zif_abapgit_persistence=>ty_repo_xml. IF mi_listener IS BOUND. MOVE-CORRESPONDING ms_data TO ls_meta_slug. mi_listener->on_meta_change( iv_key = ms_data-key is_meta = ls_meta_slug is_change_mask = is_change_mask ). ENDIF. ENDMETHOD. METHOD rebuild_local_checksums. DATA: lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, ls_last_item TYPE zif_abapgit_definitions=>ty_item, lt_checksums TYPE zif_abapgit_persistence=>ty_local_checksum_tt. FIELD-SYMBOLS: LIKE LINE OF lt_checksums, LIKE LINE OF lt_local. lt_local = get_files_local( ). remove_non_code_related_files( CHANGING ct_local_files = lt_local ). lt_remote = get_files_remote( ). SORT lt_remote BY path filename. LOOP AT lt_local ASSIGNING . IF ls_last_item <> -item OR sy-tabix = 1. "" First or New item reached ? APPEND INITIAL LINE TO lt_checksums ASSIGNING . -item = -item. ls_last_item = -item. ENDIF. compare_with_remote_checksum( EXPORTING it_remote_files = lt_remote is_local_file = -file CHANGING cs_checksum = ). ENDLOOP. set( it_checksums = lt_checksums ). reset_status( ). ENDMETHOD. METHOD refresh. mv_request_local_refresh = abap_true. reset_remote( ). IF iv_drop_log = abap_true. CLEAR mi_log. ENDIF. IF iv_drop_cache = abap_true. CLEAR mt_local. ENDIF. ENDMETHOD. METHOD refresh_local_object. DATA: ls_tadir TYPE zif_abapgit_definitions=>ty_tadir, lt_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt, lt_new_local_files TYPE zif_abapgit_definitions=>ty_files_item_tt, lo_serialize TYPE REF TO zcl_abapgit_serialize. lt_tadir = zcl_abapgit_factory=>get_tadir( )->read( iv_package = ms_data-package io_dot = get_dot_abapgit( ) ). DELETE mt_local WHERE item-obj_type = iv_obj_type AND item-obj_name = iv_obj_name. READ TABLE lt_tadir INTO ls_tadir WITH KEY object = iv_obj_type obj_name = iv_obj_name. IF sy-subrc <> 0 OR ls_tadir-delflag = abap_true. "" object doesn't exist anymore, nothing todo here RETURN. ENDIF. CLEAR lt_tadir. INSERT ls_tadir INTO TABLE lt_tadir. CREATE OBJECT lo_serialize. lt_new_local_files = lo_serialize->serialize( iv_package = ms_data-package it_tadir = lt_tadir ). INSERT LINES OF lt_new_local_files INTO TABLE mt_local. ENDMETHOD. METHOD refresh_local_objects. mv_request_local_refresh = abap_true. get_files_local( ). ENDMETHOD. METHOD remove_non_code_related_files. DELETE ct_local_files WHERE item IS INITIAL AND NOT ( file-path = zif_abapgit_definitions=>c_root_dir AND file-filename = zif_abapgit_definitions=>c_dot_abapgit ). SORT ct_local_files BY item. ENDMETHOD. METHOD reset_remote. CLEAR mt_remote. mv_request_remote_refresh = abap_true. reset_status( ). ENDMETHOD. METHOD reset_status. CLEAR mt_status. ENDMETHOD. METHOD set. * TODO: refactor, maybe use zcl_abapgit_string_map ? DATA: ls_mask TYPE zif_abapgit_persistence=>ty_repo_meta_mask. ASSERT it_checksums IS SUPPLIED OR iv_url IS SUPPLIED OR iv_branch_name IS SUPPLIED OR iv_selected_commit IS SUPPLIED OR iv_head_branch IS SUPPLIED OR iv_offline IS SUPPLIED OR is_dot_abapgit IS SUPPLIED OR is_local_settings IS SUPPLIED OR iv_deserialized_by IS SUPPLIED OR iv_deserialized_at IS SUPPLIED OR iv_switched_origin IS SUPPLIED. IF it_checksums IS SUPPLIED. ms_data-local_checksums = it_checksums. ls_mask-local_checksums = abap_true. ENDIF. IF iv_url IS SUPPLIED. ms_data-url = iv_url. ls_mask-url = abap_true. ENDIF. IF iv_branch_name IS SUPPLIED. ms_data-branch_name = iv_branch_name. ls_mask-branch_name = abap_true. ENDIF. IF iv_selected_commit IS SUPPLIED. ms_data-selected_commit = iv_selected_commit. ls_mask-selected_commit = abap_true. ENDIF. IF iv_head_branch IS SUPPLIED. ms_data-head_branch = iv_head_branch. ls_mask-head_branch = abap_true. ENDIF. IF iv_offline IS SUPPLIED. ms_data-offline = iv_offline. ls_mask-offline = abap_true. ENDIF. IF is_dot_abapgit IS SUPPLIED. ms_data-dot_abapgit = is_dot_abapgit. ls_mask-dot_abapgit = abap_true. ENDIF. IF is_local_settings IS SUPPLIED. ms_data-local_settings = is_local_settings. ls_mask-local_settings = abap_true. ENDIF. IF iv_deserialized_at IS SUPPLIED OR iv_deserialized_by IS SUPPLIED. ms_data-deserialized_at = iv_deserialized_at. ms_data-deserialized_by = iv_deserialized_by. ls_mask-deserialized_at = abap_true. ls_mask-deserialized_by = abap_true. ENDIF. IF iv_switched_origin IS SUPPLIED. ms_data-switched_origin = iv_switched_origin. ls_mask-switched_origin = abap_true. ENDIF. notify_listener( ls_mask ). ENDMETHOD. METHOD set_dot_abapgit. set( is_dot_abapgit = io_dot_abapgit->get_data( ) ). ENDMETHOD. METHOD set_dot_apack. get_dot_apack( ). mo_apack_reader->set_manifest_descriptor( io_dot_apack->get_manifest_descriptor( ) ). ENDMETHOD. METHOD set_files_remote. mt_remote = it_files. mv_request_remote_refresh = abap_false. ENDMETHOD. METHOD set_local_settings. set( is_local_settings = is_settings ). ENDMETHOD. METHOD status. IF lines( mt_status ) = 0. mt_status = zcl_abapgit_file_status=>status( io_repo = me ii_log = ii_log ). ENDIF. rt_results = mt_status. ENDMETHOD. METHOD switch_repo_type. IF iv_offline = ms_data-offline. zcx_abapgit_exception=>raise( |Cannot switch_repo_type, offline already = ""{ ms_data-offline }""| ). ENDIF. IF iv_offline = abap_true. "" On-line -> OFFline set( iv_url = zcl_abapgit_url=>name( ms_data-url ) iv_branch_name = '' iv_selected_commit = '' iv_head_branch = '' iv_offline = abap_true ). ELSE. "" OFFline -> On-line set( iv_offline = abap_false ). ENDIF. ENDMETHOD. METHOD update_last_deserialize. DATA: lv_deserialized_at TYPE zif_abapgit_persistence=>ty_repo-deserialized_at, lv_deserialized_by TYPE zif_abapgit_persistence=>ty_repo-deserialized_by. GET TIME STAMP FIELD lv_deserialized_at. lv_deserialized_by = sy-uname. set( iv_deserialized_at = lv_deserialized_at iv_deserialized_by = lv_deserialized_by ). ENDMETHOD. METHOD update_local_checksums. "" ASSUMTION: SHA1 in param is actual and correct. "" Push fills it from local files before pushing, deserialize from remote "" If this is not true that there is an error somewhere but not here DATA: lt_checksums TYPE zif_abapgit_persistence=>ty_local_checksum_tt, lt_files_idx TYPE zif_abapgit_definitions=>ty_file_signatures_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lv_chks_row TYPE i, lv_file_row TYPE i. FIELD-SYMBOLS: LIKE LINE OF lt_checksums, LIKE LINE OF -files, LIKE LINE OF lt_local, LIKE LINE OF it_files. lt_checksums = get_local_checksums( ). lt_files_idx = it_files. SORT lt_files_idx BY path filename. "" Sort for binary search "" Loop through current chacksum state, update sha1 for common files LOOP AT lt_checksums ASSIGNING . lv_chks_row = sy-tabix. LOOP AT -files ASSIGNING . lv_file_row = sy-tabix. READ TABLE lt_files_idx ASSIGNING WITH KEY path = -path filename = -filename BINARY SEARCH. CHECK sy-subrc = 0. "" Missing in param table, skip IF -sha1 IS INITIAL. "" Empty input sha1 is a deletion marker DELETE -files INDEX lv_file_row. ELSE. -sha1 = -sha1. "" Update sha1 CLEAR -sha1. "" Mark as processed ENDIF. ENDLOOP. IF lines( -files ) = 0. "" Remove empty objects DELETE lt_checksums INDEX lv_chks_row. ENDIF. ENDLOOP. DELETE lt_files_idx WHERE sha1 IS INITIAL. "" Remove processed IF lines( lt_files_idx ) > 0. lt_local = get_files_local( ). SORT lt_local BY file-path file-filename. "" Sort for binary search ENDIF. "" Add new files - not deleted and not marked as processed above LOOP AT lt_files_idx ASSIGNING . READ TABLE lt_local ASSIGNING WITH KEY file-path = -path file-filename = -filename BINARY SEARCH. IF sy-subrc <> 0. * if the deserialization fails, the local file might not be there CONTINUE. ENDIF. READ TABLE lt_checksums ASSIGNING "" TODO Optimize WITH KEY item = -item. IF sy-subrc > 0. APPEND INITIAL LINE TO lt_checksums ASSIGNING . -item = -item. ENDIF. APPEND TO -files. ENDLOOP. SORT lt_checksums BY item. set( it_checksums = lt_checksums ). ENDMETHOD. ENDCLASS. ",6973,False,1478.1346843020401,median "*&---------------------------------------------------------------------* *& Include ZABAPGIT_GIT *&---------------------------------------------------------------------* CLASS ltcl_git_pack DEFINITION DEFERRED. *----------------------------------------------------------------------* * CLASS lcl_transport DEFINITION *----------------------------------------------------------------------* CLASS lcl_git_transport DEFINITION FINAL. PUBLIC SECTION. * remote to local CLASS-METHODS upload_pack IMPORTING io_repo TYPE REF TO lcl_repo_online iv_deepen TYPE abap_bool DEFAULT abap_true it_branches TYPE lcl_git_branch_list=>ty_git_branch_list_tt OPTIONAL EXPORTING et_objects TYPE ty_objects_tt ev_branch TYPE ty_sha1 RAISING lcx_exception. * local to remote CLASS-METHODS receive_pack IMPORTING iv_url TYPE string iv_old TYPE ty_sha1 iv_new TYPE ty_sha1 iv_branch_name TYPE string iv_pack TYPE xstring RAISING lcx_exception. CLASS-METHODS branches IMPORTING iv_url TYPE string RETURNING VALUE(ro_branch_list) TYPE REF TO lcl_git_branch_list RAISING lcx_exception. PRIVATE SECTION. CONSTANTS: BEGIN OF c_service, receive TYPE string VALUE 'receive', ""#EC NOTEXT upload TYPE string VALUE 'upload', ""#EC NOTEXT END OF c_service. CLASS-METHODS branch_list IMPORTING iv_url TYPE string iv_service TYPE string EXPORTING eo_client TYPE REF TO lcl_http_client eo_branch_list TYPE REF TO lcl_git_branch_list RAISING lcx_exception. CLASS-METHODS find_branch IMPORTING iv_url TYPE string iv_service TYPE string iv_branch_name TYPE string EXPORTING eo_client TYPE REF TO lcl_http_client ev_branch TYPE ty_sha1 RAISING lcx_exception. CLASS-METHODS parse EXPORTING ev_pack TYPE xstring CHANGING cv_data TYPE xstring RAISING lcx_exception. ENDCLASS. ""lcl_transport DEFINITION *----------------------------------------------------------------------* * CLASS lcl_pack DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_git_pack DEFINITION FINAL FRIENDS ltcl_git_pack. PUBLIC SECTION. TYPES: BEGIN OF ty_node, chmod TYPE ty_chmod, name TYPE string, sha1 TYPE ty_sha1, END OF ty_node. TYPES: ty_nodes_tt TYPE STANDARD TABLE OF ty_node WITH DEFAULT KEY. TYPES: BEGIN OF ty_commit, tree TYPE ty_sha1, parent TYPE ty_sha1, parent2 TYPE ty_sha1, author TYPE string, committer TYPE string, body TYPE string, END OF ty_commit. CLASS-METHODS decode IMPORTING iv_data TYPE xstring RETURNING VALUE(rt_objects) TYPE ty_objects_tt RAISING lcx_exception. CLASS-METHODS decode_tree IMPORTING iv_data TYPE xstring RETURNING VALUE(rt_nodes) TYPE ty_nodes_tt RAISING lcx_exception. CLASS-METHODS decode_commit IMPORTING iv_data TYPE xstring RETURNING VALUE(rs_commit) TYPE ty_commit RAISING lcx_exception. CLASS-METHODS encode IMPORTING it_objects TYPE ty_objects_tt RETURNING VALUE(rv_data) TYPE xstring RAISING lcx_exception. CLASS-METHODS encode_tree IMPORTING it_nodes TYPE ty_nodes_tt RETURNING VALUE(rv_data) TYPE xstring. CLASS-METHODS encode_commit IMPORTING is_commit TYPE ty_commit RETURNING VALUE(rv_data) TYPE xstring. PRIVATE SECTION. CONSTANTS: c_pack_start TYPE x LENGTH 4 VALUE '5041434B', "" PACK c_zlib TYPE x LENGTH 2 VALUE '789C', c_zlib_hmm TYPE x LENGTH 2 VALUE '7801', c_version TYPE x LENGTH 4 VALUE '00000002'. CLASS-METHODS decode_deltas CHANGING ct_objects TYPE ty_objects_tt RAISING lcx_exception. CLASS-METHODS type_and_length IMPORTING is_object TYPE ty_object RETURNING VALUE(rv_xstring) TYPE xstring RAISING lcx_exception. CLASS-METHODS delta IMPORTING is_object TYPE ty_object CHANGING ct_objects TYPE ty_objects_tt RAISING lcx_exception. CLASS-METHODS delta_header EXPORTING ev_header TYPE i CHANGING cv_delta TYPE xstring. CLASS-METHODS sort_tree IMPORTING it_nodes TYPE ty_nodes_tt RETURNING VALUE(rt_nodes) TYPE ty_nodes_tt. CLASS-METHODS get_type IMPORTING iv_x TYPE x RETURNING VALUE(rv_type) TYPE ty_type RAISING lcx_exception. CLASS-METHODS get_length EXPORTING ev_length TYPE i CHANGING cv_data TYPE xstring. ENDCLASS. ""lcl_pack DEFINITION *----------------------------------------------------------------------* * CLASS lcl_transport IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_git_transport IMPLEMENTATION. METHOD find_branch. DATA: lo_branch_list TYPE REF TO lcl_git_branch_list. branch_list( EXPORTING iv_url = iv_url iv_service = iv_service IMPORTING eo_client = eo_client eo_branch_list = lo_branch_list ). IF ev_branch IS SUPPLIED. ev_branch = lo_branch_list->find_by_name( iv_branch_name )-sha1. ENDIF. ENDMETHOD. ""find_branch METHOD branches. DATA: lo_client TYPE REF TO lcl_http_client. lcl_git_transport=>branch_list( EXPORTING iv_url = iv_url iv_service = c_service-upload IMPORTING eo_client = lo_client eo_branch_list = ro_branch_list ). lo_client->close( ). ENDMETHOD. ""branches METHOD branch_list. DATA: lv_data TYPE string. eo_client = lcl_http=>create_by_url( iv_url = iv_url iv_service = iv_service ). lv_data = eo_client->get_cdata( ). CREATE OBJECT eo_branch_list EXPORTING iv_data = lv_data. ENDMETHOD. ""branch_list METHOD receive_pack. DATA: lo_client TYPE REF TO lcl_http_client, lv_cmd_pkt TYPE string, lv_line TYPE string, lv_tmp TYPE xstring, lv_xstring TYPE xstring, lv_string TYPE string, lv_cap_list TYPE string, lv_buffer TYPE string. find_branch( EXPORTING iv_url = iv_url iv_service = c_service-receive iv_branch_name = iv_branch_name IMPORTING eo_client = lo_client ). lo_client->set_headers( iv_url = iv_url iv_service = c_service-receive ). lv_cap_list = 'report-status agent=' && lcl_http=>get_agent( ) ##NO_TEXT. lv_line = iv_old && ` ` && iv_new && ` ` && iv_branch_name && lcl_git_utils=>get_null( ) && ` ` && lv_cap_list && gc_newline. ""#EC NOTEXT lv_cmd_pkt = lcl_git_utils=>pkt_string( lv_line ). lv_buffer = lv_cmd_pkt && '0000'. lv_tmp = lcl_convert=>string_to_xstring_utf8( lv_buffer ). CONCATENATE lv_tmp iv_pack INTO lv_xstring IN BYTE MODE. lv_xstring = lo_client->send_receive_close( lv_xstring ). lv_string = lcl_convert=>xstring_to_string_utf8( lv_xstring ). IF NOT lv_string CP '*unpack ok*'. lcx_exception=>raise( 'unpack not ok' ). ELSEIF lv_string CP '*pre-receive hook declined*'. lcx_exception=>raise( 'pre-receive hook declined' ). ELSEIF lv_string CP '*funny refname*'. lcx_exception=>raise( 'funny refname' ). ENDIF. ENDMETHOD. ""receive_pack METHOD parse. CONSTANTS: lc_band1 TYPE x VALUE '01'. DATA: lv_len TYPE i, lv_contents TYPE xstring, lv_pack TYPE xstring. WHILE xstrlen( cv_data ) >= 4. lv_len = lcl_git_utils=>length_utf8_hex( cv_data ). IF lv_len > xstrlen( cv_data ). lcx_exception=>raise( 'parse, string length too large' ). ENDIF. lv_contents = cv_data(lv_len). IF lv_len = 0. cv_data = cv_data+4. CONTINUE. ELSE. cv_data = cv_data+lv_len. ENDIF. lv_contents = lv_contents+4. IF xstrlen( lv_contents ) > 1 AND lv_contents(1) = lc_band1. CONCATENATE lv_pack lv_contents+1 INTO lv_pack IN BYTE MODE. ENDIF. ENDWHILE. ev_pack = lv_pack. ENDMETHOD. ""parse METHOD upload_pack. DATA: lo_client TYPE REF TO lcl_http_client, lv_buffer TYPE string, lv_xstring TYPE xstring, lv_line TYPE string, lv_pack TYPE xstring, lt_branches TYPE lcl_git_branch_list=>ty_git_branch_list_tt, lv_capa TYPE string. FIELD-SYMBOLS: LIKE LINE OF lt_branches. CLEAR et_objects. find_branch( EXPORTING iv_url = io_repo->get_url( ) iv_service = c_service-upload iv_branch_name = io_repo->get_branch_name( ) IMPORTING eo_client = lo_client ev_branch = ev_branch ). IF it_branches IS INITIAL. APPEND INITIAL LINE TO lt_branches ASSIGNING . -sha1 = ev_branch. ELSE. lt_branches = it_branches. ENDIF. lo_client->set_headers( iv_url = io_repo->get_url( ) iv_service = c_service-upload ). LOOP AT lt_branches FROM 1 ASSIGNING . IF sy-tabix = 1. lv_capa = 'side-band-64k no-progress multi_ack agent=' && lcl_http=>get_agent( ) ##NO_TEXT. lv_line = 'want' && ` ` && -sha1 && ` ` && lv_capa && gc_newline. ""#EC NOTEXT ELSE. lv_line = 'want' && ` ` && -sha1 && gc_newline. ""#EC NOTEXT ENDIF. lv_buffer = lv_buffer && lcl_git_utils=>pkt_string( lv_line ). ENDLOOP. IF iv_deepen = abap_true. lv_buffer = lv_buffer && lcl_git_utils=>pkt_string( 'deepen 1' && gc_newline ). ""#EC NOTEXT ENDIF. lv_buffer = lv_buffer && '0000' && '0009done' && gc_newline. lv_xstring = lo_client->send_receive_close( lcl_convert=>string_to_xstring_utf8( lv_buffer ) ). parse( IMPORTING ev_pack = lv_pack CHANGING cv_data = lv_xstring ). IF lv_pack IS INITIAL. lcx_exception=>raise( 'empty pack' ). ENDIF. et_objects = lcl_git_pack=>decode( lv_pack ). ENDMETHOD. ""upload_pack ENDCLASS. ""lcl_transport IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_git_pack IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_git_pack IMPLEMENTATION. METHOD sort_tree. TYPES: BEGIN OF ty_sort, sort TYPE string, node TYPE ty_node, END OF ty_sort. DATA: lt_sort TYPE STANDARD TABLE OF ty_sort WITH DEFAULT KEY. FIELD-SYMBOLS: LIKE LINE OF lt_sort, LIKE LINE OF it_nodes. LOOP AT it_nodes ASSIGNING . APPEND INITIAL LINE TO lt_sort ASSIGNING . IF -chmod = gc_chmod-dir. CONCATENATE -name '/' INTO -sort. ELSE. -sort = -name. ENDIF. -node = . ENDLOOP. * following has to be done, or unpack will fail on server side SORT lt_sort BY sort ASCENDING. LOOP AT lt_sort ASSIGNING . APPEND -node TO rt_nodes. ENDLOOP. ENDMETHOD. METHOD type_and_length. DATA: lv_bits TYPE string, lv_type TYPE string, lv_result TYPE string, lv_c TYPE c, lv_offset TYPE i, lv_x4 TYPE x LENGTH 4, lv_x TYPE x LENGTH 1. CASE is_object-type. WHEN gc_type-commit. lv_type = '001'. WHEN gc_type-tree. lv_type = '010'. WHEN gc_type-blob. lv_type = '011'. WHEN gc_type-ref_d. lv_type = '111'. WHEN OTHERS. lcx_exception=>raise( 'Unexpected object type while encoding pack' ). ENDCASE. lv_x4 = xstrlen( is_object-data ). DO 32 TIMES. GET BIT sy-index OF lv_x4 INTO lv_c. CONCATENATE lv_bits lv_c INTO lv_bits. ENDDO. IF lv_bits(28) = '0000000000000000000000000000'. CONCATENATE '0' lv_type lv_bits+28(4) INTO lv_result. ELSEIF lv_bits(21) = '000000000000000000000'. CONCATENATE '1' lv_type lv_bits+28(4) INTO lv_result. CONCATENATE lv_result '0' lv_bits+21(7) INTO lv_result. ELSEIF lv_bits(14) = '00000000000000'. CONCATENATE '1' lv_type lv_bits+28(4) INTO lv_result. CONCATENATE lv_result '1' lv_bits+21(7) INTO lv_result. CONCATENATE lv_result '0' lv_bits+14(7) INTO lv_result. ELSEIF lv_bits(7) = '0000000'. CONCATENATE '1' lv_type lv_bits+28(4) INTO lv_result. CONCATENATE lv_result '1' lv_bits+21(7) INTO lv_result. CONCATENATE lv_result '1' lv_bits+14(7) INTO lv_result. CONCATENATE lv_result '0' lv_bits+7(7) INTO lv_result. ELSE. * this IF can be refactored, use shifting? lcx_exception=>raise( 'Todo, encoding length' ). ENDIF. * convert bit string to xstring CLEAR lv_x. DO strlen( lv_result ) TIMES. lv_offset = sy-index - 1. IF lv_result+lv_offset(1) = '1'. SET BIT ( lv_offset MOD 8 ) + 1 OF lv_x. ENDIF. IF ( lv_offset + 1 ) MOD 8 = 0. CONCATENATE rv_xstring lv_x INTO rv_xstring IN BYTE MODE. CLEAR lv_x. ENDIF. ENDDO. ENDMETHOD. ""type_and_length METHOD get_length. DATA: lv_x TYPE x, lv_length_bits TYPE string, lv_bitbyte TYPE ty_bitbyte. lv_x = cv_data(1). lv_bitbyte = lcl_convert=>x_to_bitbyte( lv_x ). cv_data = cv_data+1. lv_length_bits = lv_bitbyte+4. WHILE lv_bitbyte(1) <> '0'. lv_x = cv_data(1). lv_bitbyte = lcl_convert=>x_to_bitbyte( lv_x ). cv_data = cv_data+1. CONCATENATE lv_bitbyte+1 lv_length_bits INTO lv_length_bits. ENDWHILE. ev_length = lcl_convert=>bitbyte_to_int( lv_length_bits ). ENDMETHOD. ""get_length METHOD encode_tree. CONSTANTS: lc_null TYPE x VALUE '00'. DATA: lv_string TYPE string, lt_nodes LIKE it_nodes, lv_hex20 TYPE x LENGTH 20, lv_xstring TYPE xstring. FIELD-SYMBOLS: LIKE LINE OF it_nodes. lt_nodes = sort_tree( it_nodes ). LOOP AT lt_nodes ASSIGNING . ASSERT NOT -chmod IS INITIAL. ASSERT NOT -name IS INITIAL. ASSERT NOT -sha1 IS INITIAL. CONCATENATE -chmod -name INTO lv_string SEPARATED BY space. lv_xstring = lcl_convert=>string_to_xstring_utf8( lv_string ). lv_hex20 = to_upper( -sha1 ). CONCATENATE rv_data lv_xstring lc_null lv_hex20 INTO rv_data IN BYTE MODE. ENDLOOP. ENDMETHOD. ""encode_tree METHOD encode_commit. DATA: lv_string TYPE string, lv_tmp TYPE string, lv_tree_lower TYPE string, lv_parent_lower TYPE string. lv_tree_lower = is_commit-tree. TRANSLATE lv_tree_lower TO LOWER CASE. lv_string = ''. CONCATENATE 'tree' lv_tree_lower INTO lv_tmp SEPARATED BY space. ""#EC NOTEXT CONCATENATE lv_string lv_tmp gc_newline INTO lv_string. IF NOT is_commit-parent IS INITIAL. lv_parent_lower = is_commit-parent. TRANSLATE lv_parent_lower TO LOWER CASE. CONCATENATE 'parent' lv_parent_lower INTO lv_tmp SEPARATED BY space. ""#EC NOTEXT CONCATENATE lv_string lv_tmp gc_newline INTO lv_string. ENDIF. IF NOT is_commit-parent2 IS INITIAL. lv_parent_lower = is_commit-parent2. TRANSLATE lv_parent_lower TO LOWER CASE. CONCATENATE 'parent' lv_parent_lower INTO lv_tmp SEPARATED BY space. ""#EC NOTEXT CONCATENATE lv_string lv_tmp gc_newline INTO lv_string. ENDIF. CONCATENATE 'author' is_commit-author INTO lv_tmp SEPARATED BY space. ""#EC NOTEXT CONCATENATE lv_string lv_tmp gc_newline INTO lv_string. CONCATENATE 'committer' is_commit-committer INTO lv_tmp SEPARATED BY space. ""#EC NOTEXT CONCATENATE lv_string lv_tmp gc_newline INTO lv_string. CONCATENATE lv_string gc_newline is_commit-body INTO lv_string. rv_data = lcl_convert=>string_to_xstring_utf8( lv_string ). ENDMETHOD. ""encode_commit METHOD get_type. DATA: lv_char3 TYPE c LENGTH 3, lv_bitbyte TYPE ty_bitbyte. lv_bitbyte = lcl_convert=>x_to_bitbyte( iv_x ). lv_char3 = lv_bitbyte+1. CASE lv_char3. WHEN '001'. rv_type = gc_type-commit. WHEN '010'. rv_type = gc_type-tree. WHEN '011'. rv_type = gc_type-blob. WHEN '111'. rv_type = gc_type-ref_d. WHEN OTHERS. lcx_exception=>raise( 'Todo, unknown type' ). ENDCASE. ENDMETHOD. ""get_type METHOD decode_commit. DATA: lv_string TYPE string, lv_word TYPE string, lv_trash TYPE string ##NEEDED, lt_string TYPE TABLE OF string. FIELD-SYMBOLS: LIKE LINE OF lt_string. lv_string = lcl_convert=>xstring_to_string_utf8( iv_data ). SPLIT lv_string AT gc_newline INTO TABLE lt_string. LOOP AT lt_string ASSIGNING . IF NOT rs_commit-committer IS INITIAL. CONCATENATE rs_commit-body INTO rs_commit-body SEPARATED BY gc_newline. ELSE. SPLIT AT space INTO lv_word lv_trash. CASE lv_word. WHEN 'tree'. rs_commit-tree = +5. WHEN 'parent'. IF rs_commit-parent IS INITIAL. rs_commit-parent = +7. ELSE. rs_commit-parent2 = +7. ENDIF. WHEN 'author'. rs_commit-author = +7. WHEN 'committer'. rs_commit-committer = +10. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. ENDIF. ENDLOOP. * strip first newline IF strlen( rs_commit-body ) >= 2. rs_commit-body = rs_commit-body+2. ENDIF. IF rs_commit-author IS INITIAL OR rs_commit-committer IS INITIAL OR rs_commit-tree IS INITIAL. lcx_exception=>raise( 'multiple parents? not supported' ). ENDIF. ENDMETHOD. ""decode_commit METHOD delta_header. DATA: lv_bitbyte TYPE ty_bitbyte, lv_bits TYPE string, lv_x TYPE x. lv_bits = ''. DO. lv_x = cv_delta(1). cv_delta = cv_delta+1. lv_bitbyte = lcl_convert=>x_to_bitbyte( lv_x ). CONCATENATE lv_bitbyte+1 lv_bits INTO lv_bits. IF lv_bitbyte(1) = '0'. EXIT. "" current loop ENDIF. ENDDO. ev_header = lcl_convert=>bitbyte_to_int( lv_bits ). ENDMETHOD. ""delta_header METHOD delta. DATA: lv_delta TYPE xstring, lv_base TYPE xstring, lv_result TYPE xstring, lv_bitbyte TYPE ty_bitbyte, lv_offset TYPE i, lv_message TYPE string, lv_sha1 TYPE ty_sha1, ls_object LIKE LINE OF ct_objects, lv_len TYPE i, lv_x TYPE x. FIELD-SYMBOLS: LIKE LINE OF ct_objects. lv_delta = is_object-data. * find base READ TABLE ct_objects ASSIGNING WITH KEY sha1 = is_object-sha1. IF sy-subrc <> 0. CONCATENATE 'Base not found,' is_object-sha1 INTO lv_message SEPARATED BY space. ""#EC NOTEXT lcx_exception=>raise( lv_message ). ELSE. lv_base = -data. ENDIF. * sanity check IF -type = gc_type-ref_d. lcx_exception=>raise( 'Delta, base eq delta' ). ENDIF. * skip the 2 headers delta_header( CHANGING cv_delta = lv_delta ). delta_header( CHANGING cv_delta = lv_delta ). WHILE xstrlen( lv_delta ) > 0. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_bitbyte = lcl_convert=>x_to_bitbyte( lv_x ). IF lv_bitbyte(1) = '1'. "" MSB lv_offset = 0. IF lv_bitbyte+7(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_offset = lv_x. ENDIF. IF lv_bitbyte+6(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_offset = lv_offset + lv_x * 256. ENDIF. IF lv_bitbyte+5(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_offset = lv_offset + lv_x * 65536. ENDIF. IF lv_bitbyte+4(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_offset = lv_offset + lv_x * 16777216. "" hmm, overflow? ENDIF. lv_len = 0. IF lv_bitbyte+3(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_len = lv_x. ENDIF. IF lv_bitbyte+2(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_len = lv_len + lv_x * 256. ENDIF. IF lv_bitbyte+1(1) = '1'. lv_x = lv_delta(1). lv_delta = lv_delta+1. lv_len = lv_len + lv_x * 65536. ENDIF. IF lv_len = 0. lv_len = 65536. ENDIF. CONCATENATE lv_result lv_base+lv_offset(lv_len) INTO lv_result IN BYTE MODE. ELSE. "" lv_bitbyte(1) = '0' * insert from delta lv_len = lv_x. CONCATENATE lv_result lv_delta(lv_len) INTO lv_result IN BYTE MODE. lv_delta = lv_delta+lv_len. ENDIF. ENDWHILE. lv_sha1 = lcl_hash=>sha1( iv_type = -type iv_data = lv_result ). CLEAR ls_object. ls_object-sha1 = lv_sha1. ls_object-type = -type. ls_object-data = lv_result. APPEND ls_object TO ct_objects. ENDMETHOD. ""delta METHOD decode_deltas. DATA: ls_object LIKE LINE OF ct_objects, lt_deltas LIKE ct_objects. LOOP AT ct_objects INTO ls_object WHERE type = gc_type-ref_d. DELETE ct_objects INDEX sy-tabix. APPEND ls_object TO lt_deltas. ENDLOOP. LOOP AT lt_deltas INTO ls_object. delta( EXPORTING is_object = ls_object CHANGING ct_objects = ct_objects ). ENDLOOP. ENDMETHOD. ""decode_deltas METHOD decode_tree. CONSTANTS: lc_sha_length TYPE i VALUE 20, lc_null TYPE x VALUE '00'. DATA: lv_xstring TYPE xstring, lv_chmod TYPE ty_chmod, lv_name TYPE string, lv_string TYPE string, lv_len TYPE i, lv_offset TYPE i, lv_cursor TYPE i, ls_node TYPE ty_node, lv_start TYPE i. DO. IF lv_cursor >= xstrlen( iv_data ). EXIT. "" current loop ENDIF. IF iv_data+lv_cursor(1) = lc_null. lv_len = lv_cursor - lv_start. lv_xstring = iv_data+lv_start(lv_len). lv_string = lcl_convert=>xstring_to_string_utf8( lv_xstring ). SPLIT lv_string AT space INTO lv_chmod lv_name. lv_offset = lv_cursor + 1. CLEAR ls_node. ls_node-chmod = lv_chmod. IF ls_node-chmod <> gc_chmod-dir AND ls_node-chmod <> gc_chmod-file AND ls_node-chmod <> gc_chmod-executable. lcx_exception=>raise( 'Unknown chmod' ). ENDIF. ls_node-name = lv_name. ls_node-sha1 = iv_data+lv_offset(lc_sha_length). TRANSLATE ls_node-sha1 TO LOWER CASE. APPEND ls_node TO rt_nodes. lv_start = lv_cursor + 1 + lc_sha_length. lv_cursor = lv_start. ELSE. lv_cursor = lv_cursor + 1. ENDIF. ENDDO. ENDMETHOD. ""decode_tree METHOD decode. DATA: lv_x TYPE x, lv_data TYPE xstring, lv_type TYPE c LENGTH 6, lv_zlib TYPE x LENGTH 2, lv_objects TYPE i, lv_len TYPE i, lv_sha1 TYPE ty_sha1, lv_ref_delta TYPE ty_sha1, lv_adler32 TYPE lcl_hash=>ty_adler32, lv_compressed TYPE xstring, lv_compressed_len TYPE i, lv_decompress_len TYPE i, lv_decompressed TYPE xstring, lv_xstring TYPE xstring, lv_expected TYPE i, ls_object LIKE LINE OF rt_objects, ls_data TYPE lcl_zlib=>ty_decompress. lv_data = iv_data. * header IF NOT xstrlen( lv_data ) > 4 OR lv_data(4) <> c_pack_start. lcx_exception=>raise( 'Unexpected pack header' ). ENDIF. lv_data = lv_data+4. * version IF lv_data(4) <> c_version. lcx_exception=>raise( 'Version not supported' ). ENDIF. lv_data = lv_data+4. * number of objects lv_xstring = lv_data(4). lv_objects = lcl_convert=>xstring_to_int( lv_xstring ). lv_data = lv_data+4. DO lv_objects TIMES. lv_x = lv_data(1). lv_type = get_type( lv_x ). get_length( IMPORTING ev_length = lv_expected CHANGING cv_data = lv_data ). IF lv_type = gc_type-ref_d. lv_ref_delta = lv_data(20). lv_data = lv_data+20. ENDIF. * strip header, '789C', CMF + FLG lv_zlib = lv_data(2). IF lv_zlib <> c_zlib AND lv_zlib <> c_zlib_hmm. lcx_exception=>raise( 'Unexpected zlib header' ). ENDIF. lv_data = lv_data+2. ******************************* IF lv_zlib = c_zlib. cl_abap_gzip=>decompress_binary( EXPORTING gzip_in = lv_data IMPORTING raw_out = lv_decompressed raw_out_len = lv_decompress_len ). IF lv_expected <> lv_decompress_len. lcx_exception=>raise( 'Decompression falied' ). ENDIF. cl_abap_gzip=>compress_binary( EXPORTING raw_in = lv_decompressed IMPORTING gzip_out = lv_compressed gzip_out_len = lv_compressed_len ). IF lv_compressed(lv_compressed_len) <> lv_data(lv_compressed_len). lcx_exception=>raise( 'Compressed data doesnt match' ). ENDIF. lv_data = lv_data+lv_compressed_len. ELSEIF lv_zlib = c_zlib_hmm. * cl_abap_gzip copmression works for header '789C', but does not work for * '7801', call custom implementation of DEFLATE algorithm. * The custom implementation could handle both, but most likely the kernel * implementation runs faster than the custom ABAP. ls_data = lcl_zlib=>decompress( lv_data ). lv_compressed_len = ls_data-compressed_len. lv_decompressed = ls_data-raw. IF lv_compressed_len IS INITIAL. lcx_exception=>raise( 'Decompression falied :o/' ). ENDIF. lv_data = lv_data+lv_compressed_len. lv_adler32 = lcl_hash=>adler32( lv_decompressed ). IF lv_data(4) <> lv_adler32. lv_data = lv_data+1. ENDIF. IF lv_data(4) <> lv_adler32. lv_data = lv_data+1. ENDIF. IF lv_data(4) <> lv_adler32. lcx_exception=>raise( 'Wrong Adler checksum' ). ENDIF. ENDIF. lv_data = lv_data+4. "" skip adler checksum ************************* CLEAR ls_object. IF lv_type = gc_type-ref_d. ls_object-sha1 = lv_ref_delta. TRANSLATE ls_object-sha1 TO LOWER CASE. ELSE. ls_object-sha1 = lcl_hash=>sha1( iv_type = lv_type iv_data = lv_decompressed ). ENDIF. ls_object-type = lv_type. ls_object-data = lv_decompressed. APPEND ls_object TO rt_objects. ENDDO. * check SHA1 at end of pack lv_len = xstrlen( iv_data ) - 20. lv_xstring = iv_data(lv_len). lv_sha1 = lcl_hash=>sha1_raw( lv_xstring ). IF to_upper( lv_sha1 ) <> lv_data. lcx_exception=>raise( 'SHA1 at end of pack doesnt match' ). ENDIF. decode_deltas( CHANGING ct_objects = rt_objects ). ENDMETHOD. ""decode METHOD encode. DATA: lv_sha1 TYPE x LENGTH 20, lv_adler32 TYPE lcl_hash=>ty_adler32, lv_len TYPE i, lv_compressed TYPE xstring, lv_xstring TYPE xstring. FIELD-SYMBOLS: LIKE LINE OF it_objects. rv_data = c_pack_start. CONCATENATE rv_data c_version INTO rv_data IN BYTE MODE. lv_len = lines( it_objects ). lv_xstring = lcl_convert=>int_to_xstring( iv_i = lv_len iv_length = 4 ). CONCATENATE rv_data lv_xstring INTO rv_data IN BYTE MODE. LOOP AT it_objects ASSIGNING . lv_xstring = type_and_length( ). CONCATENATE rv_data lv_xstring INTO rv_data IN BYTE MODE. cl_abap_gzip=>compress_binary( EXPORTING raw_in = -data IMPORTING gzip_out = lv_compressed ). CONCATENATE rv_data c_zlib lv_compressed INTO rv_data IN BYTE MODE. lv_adler32 = lcl_hash=>adler32( -data ). CONCATENATE rv_data lv_adler32 INTO rv_data IN BYTE MODE. ENDLOOP. lv_sha1 = to_upper( lcl_hash=>sha1_raw( rv_data ) ). CONCATENATE rv_data lv_sha1 INTO rv_data IN BYTE MODE. ENDMETHOD. ""encode ENDCLASS. ""lcl_pack IMPLEMENTATION CLASS ltcl_git_porcelain DEFINITION DEFERRED. *----------------------------------------------------------------------* * CLASS lcl_porcelain DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_git_porcelain DEFINITION FINAL FRIENDS ltcl_git_porcelain. PUBLIC SECTION. TYPES: BEGIN OF ty_expanded, path TYPE string, name TYPE string, sha1 TYPE ty_sha1, chmod TYPE ty_chmod, END OF ty_expanded. TYPES: ty_expanded_tt TYPE STANDARD TABLE OF ty_expanded WITH DEFAULT KEY. CLASS-METHODS pull IMPORTING io_repo TYPE REF TO lcl_repo_online EXPORTING et_files TYPE ty_files_tt et_objects TYPE ty_objects_tt ev_branch TYPE ty_sha1 RAISING lcx_exception. CLASS-METHODS push IMPORTING io_repo TYPE REF TO lcl_repo_online is_comment TYPE ty_comment io_stage TYPE REF TO lcl_stage EXPORTING ev_branch TYPE ty_sha1 et_updated_files TYPE ty_file_signatures_tt RAISING lcx_exception. CLASS-METHODS create_branch IMPORTING io_repo TYPE REF TO lcl_repo_online iv_name TYPE string iv_from TYPE ty_sha1 RAISING lcx_exception. CLASS-METHODS delete_branch IMPORTING io_repo TYPE REF TO lcl_repo_online is_branch TYPE lcl_git_branch_list=>ty_git_branch RAISING lcx_exception. CLASS-METHODS full_tree IMPORTING it_objects TYPE ty_objects_tt iv_branch TYPE ty_sha1 RETURNING VALUE(rt_expanded) TYPE ty_expanded_tt RAISING lcx_exception. PRIVATE SECTION. TYPES: BEGIN OF ty_tree, path TYPE string, data TYPE xstring, sha1 TYPE ty_sha1, END OF ty_tree. TYPES: ty_trees_tt TYPE STANDARD TABLE OF ty_tree WITH DEFAULT KEY. TYPES: BEGIN OF ty_folder, path TYPE string, count TYPE i, sha1 TYPE ty_sha1, END OF ty_folder. TYPES: ty_folders_tt TYPE STANDARD TABLE OF ty_folder WITH DEFAULT KEY. CONSTANTS: c_zero TYPE ty_sha1 VALUE '0000000000000000000000000000000000000000'. CLASS-METHODS build_trees IMPORTING it_expanded TYPE ty_expanded_tt RETURNING VALUE(rt_trees) TYPE ty_trees_tt RAISING lcx_exception. CLASS-METHODS find_folders IMPORTING it_expanded TYPE ty_expanded_tt RETURNING VALUE(rt_folders) TYPE ty_folders_tt. CLASS-METHODS walk IMPORTING it_objects TYPE ty_objects_tt iv_sha1 TYPE ty_sha1 iv_path TYPE string CHANGING ct_files TYPE ty_files_tt RAISING lcx_exception. CLASS-METHODS walk_tree IMPORTING it_objects TYPE ty_objects_tt iv_tree TYPE ty_sha1 iv_base TYPE string RETURNING VALUE(rt_expanded) TYPE ty_expanded_tt RAISING lcx_exception. CLASS-METHODS receive_pack IMPORTING is_comment TYPE ty_comment io_repo TYPE REF TO lcl_repo_online it_trees TYPE ty_trees_tt it_blobs TYPE ty_files_tt io_stage TYPE REF TO lcl_stage RETURNING VALUE(rv_branch) TYPE ty_sha1 RAISING lcx_exception. ENDCLASS. ""lcl_porcelain DEFINITION *----------------------------------------------------------------------* * CLASS lcl_porcelain IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_git_porcelain IMPLEMENTATION. METHOD receive_pack. DATA: lv_time TYPE lcl_time=>ty_unixtime, lv_commit TYPE xstring, lt_objects TYPE ty_objects_tt, lv_pack TYPE xstring, ls_object LIKE LINE OF lt_objects, ls_commit TYPE lcl_git_pack=>ty_commit. FIELD-SYMBOLS: LIKE LINE OF it_trees, LIKE LINE OF it_blobs. lv_time = lcl_time=>get( ). READ TABLE it_trees ASSIGNING WITH KEY path = '/'. ASSERT sy-subrc = 0. * new commit ls_commit-tree = -sha1. ls_commit-parent = io_stage->get_branch_sha1( ). ls_commit-parent2 = io_stage->get_merge_source( ). CONCATENATE is_comment-username space '<' is_comment-email '>' space lv_time INTO ls_commit-author RESPECTING BLANKS. ls_commit-committer = ls_commit-author. ls_commit-body = is_comment-comment. lv_commit = lcl_git_pack=>encode_commit( ls_commit ). CLEAR ls_object. ls_object-sha1 = lcl_hash=>sha1( iv_type = gc_type-commit iv_data = lv_commit ). ls_object-type = gc_type-commit. ls_object-data = lv_commit. APPEND ls_object TO lt_objects. LOOP AT it_trees ASSIGNING . CLEAR ls_object. ls_object-sha1 = -sha1. ls_object-type = gc_type-tree. ls_object-data = -data. APPEND ls_object TO lt_objects. ENDLOOP. LOOP AT it_blobs ASSIGNING . CLEAR ls_object. ls_object-sha1 = lcl_hash=>sha1( iv_type = gc_type-blob iv_data = -data ). READ TABLE lt_objects WITH KEY type = gc_type-blob sha1 = ls_object-sha1 TRANSPORTING NO FIELDS. IF sy-subrc = 0. * two identical files added at the same time, only add one blob to the pack CONTINUE. ENDIF. ls_object-type = gc_type-blob. ASSERT NOT -data IS INITIAL. ls_object-data = -data. APPEND ls_object TO lt_objects. ENDLOOP. lv_pack = lcl_git_pack=>encode( lt_objects ). rv_branch = lcl_hash=>sha1( iv_type = gc_type-commit iv_data = lv_commit ). lcl_git_transport=>receive_pack( iv_url = io_repo->get_url( ) iv_old = io_stage->get_branch_sha1( ) iv_new = rv_branch iv_branch_name = io_stage->get_branch_name( ) iv_pack = lv_pack ). ENDMETHOD. ""receive_pack METHOD delete_branch. DATA: lt_objects TYPE ty_objects_tt, lv_pack TYPE xstring. * ""client MUST send an empty packfile"" * https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt#L514 lv_pack = lcl_git_pack=>encode( lt_objects ). lcl_git_transport=>receive_pack( iv_url = io_repo->get_url( ) iv_old = is_branch-sha1 iv_new = c_zero iv_branch_name = is_branch-name iv_pack = lv_pack ). ENDMETHOD. METHOD create_branch. DATA: lt_objects TYPE ty_objects_tt, lv_pack TYPE xstring. * ""client MUST send an empty packfile"" * https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt#L514 lv_pack = lcl_git_pack=>encode( lt_objects ). lcl_git_transport=>receive_pack( iv_url = io_repo->get_url( ) iv_old = c_zero iv_new = iv_from iv_branch_name = iv_name iv_pack = lv_pack ). ENDMETHOD. METHOD push. DATA: lt_expanded TYPE ty_expanded_tt, lt_blobs TYPE ty_files_tt, lv_sha1 TYPE ty_sha1, lt_trees TYPE ty_trees_tt, lt_objects TYPE ty_objects_tt, lt_branches TYPE lcl_git_branch_list=>ty_git_branch_list_tt, lt_stage TYPE lcl_stage=>ty_stage_tt. FIELD-SYMBOLS: LIKE LINE OF lt_stage, LIKE LINE OF et_updated_files, LIKE LINE OF lt_branches, LIKE LINE OF lt_expanded. CLEAR et_updated_files. IF io_stage->get_branch_sha1( ) = io_repo->get_sha1_remote( ). * objects cached in io_repo can be used, if pushing to the branch configured in repo lt_objects = io_repo->get_objects( ). ELSE. APPEND INITIAL LINE TO lt_branches ASSIGNING . -name = io_stage->get_branch_name( ). -sha1 = io_stage->get_branch_sha1( ). lcl_git_transport=>upload_pack( EXPORTING io_repo = io_repo it_branches = lt_branches IMPORTING et_objects = lt_objects ). ENDIF. lt_expanded = full_tree( it_objects = lt_objects iv_branch = io_stage->get_branch_sha1( ) ). lt_stage = io_stage->get_all( ). LOOP AT lt_stage ASSIGNING . "" Save file ref to updated files table APPEND INITIAL LINE TO et_updated_files ASSIGNING . MOVE-CORRESPONDING -file TO . CASE -method. WHEN lcl_stage=>c_method-add. APPEND -file TO lt_blobs. READ TABLE lt_expanded ASSIGNING WITH KEY name = -file-filename path = -file-path. IF sy-subrc <> 0. "" new files APPEND INITIAL LINE TO lt_expanded ASSIGNING . -name = -file-filename. -path = -file-path. -chmod = gc_chmod-file. ENDIF. lv_sha1 = lcl_hash=>sha1( iv_type = gc_type-blob iv_data = -file-data ). IF -sha1 <> lv_sha1. -sha1 = lv_sha1. ENDIF. -sha1 = lv_sha1. ""New sha1 WHEN lcl_stage=>c_method-rm. DELETE lt_expanded WHERE name = -file-filename AND path = -file-path. ASSERT sy-subrc = 0. CLEAR -sha1. "" Mark as deleted WHEN OTHERS. lcx_exception=>raise( 'stage method not supported, todo' ). ENDCASE. ENDLOOP. lt_trees = build_trees( lt_expanded ). ev_branch = receive_pack( is_comment = is_comment io_repo = io_repo it_trees = lt_trees it_blobs = lt_blobs io_stage = io_stage ). ENDMETHOD. ""push METHOD walk_tree. DATA: ls_object LIKE LINE OF it_objects, lt_expanded LIKE rt_expanded, lt_nodes TYPE lcl_git_pack=>ty_nodes_tt. FIELD-SYMBOLS: LIKE LINE OF rt_expanded, LIKE LINE OF lt_nodes. READ TABLE it_objects INTO ls_object WITH KEY sha1 = iv_tree type = gc_type-tree. IF sy-subrc <> 0. lcx_exception=>raise( 'tree not found' ). ENDIF. lt_nodes = lcl_git_pack=>decode_tree( ls_object-data ). LOOP AT lt_nodes ASSIGNING . CASE -chmod. WHEN gc_chmod-file OR gc_chmod-executable. APPEND INITIAL LINE TO rt_expanded ASSIGNING . -path = iv_base. -name = -name. -sha1 = -sha1. -chmod = -chmod. WHEN gc_chmod-dir. lt_expanded = walk_tree( it_objects = it_objects iv_tree = -sha1 iv_base = iv_base && -name && '/' ). APPEND LINES OF lt_expanded TO rt_expanded. WHEN OTHERS. lcx_exception=>raise( 'walk_tree: unknown chmod' ). ENDCASE. ENDLOOP. ENDMETHOD. METHOD full_tree. DATA: ls_object LIKE LINE OF it_objects, ls_commit TYPE lcl_git_pack=>ty_commit. READ TABLE it_objects INTO ls_object WITH KEY sha1 = iv_branch type = gc_type-commit. IF sy-subrc <> 0. lcx_exception=>raise( 'commit not found' ). ENDIF. ls_commit = lcl_git_pack=>decode_commit( ls_object-data ). rt_expanded = walk_tree( it_objects = it_objects iv_tree = ls_commit-tree iv_base = '/' ). ENDMETHOD. ""root_tree METHOD pull. DATA: ls_object LIKE LINE OF et_objects, ls_commit TYPE lcl_git_pack=>ty_commit. CLEAR et_files. CLEAR et_objects. CLEAR ev_branch. lcl_git_transport=>upload_pack( EXPORTING io_repo = io_repo IMPORTING et_objects = et_objects ev_branch = ev_branch ). READ TABLE et_objects INTO ls_object WITH KEY sha1 = ev_branch type = gc_type-commit. IF sy-subrc <> 0. lcx_exception=>raise( 'Commit/branch not found' ). ENDIF. ls_commit = lcl_git_pack=>decode_commit( ls_object-data ). walk( EXPORTING it_objects = et_objects iv_sha1 = ls_commit-tree iv_path = '/' CHANGING ct_files = et_files ). ENDMETHOD. ""pull METHOD find_folders. DATA: lt_paths TYPE TABLE OF string, lv_split TYPE string, lv_path TYPE string. FIELD-SYMBOLS: LIKE LINE OF rt_folders, LIKE LINE OF rt_folders, LIKE LINE OF it_expanded. LOOP AT it_expanded ASSIGNING . READ TABLE rt_folders WITH KEY path = -path TRANSPORTING NO FIELDS. IF sy-subrc <> 0. APPEND INITIAL LINE TO rt_folders ASSIGNING . -path = -path. ENDIF. ENDLOOP. * add empty folders LOOP AT rt_folders ASSIGNING . SPLIT -path AT '/' INTO TABLE lt_paths. CLEAR lv_path. LOOP AT lt_paths INTO lv_split. CONCATENATE lv_path lv_split '/' INTO lv_path. READ TABLE rt_folders WITH KEY path = lv_path TRANSPORTING NO FIELDS. IF sy-subrc <> 0. APPEND INITIAL LINE TO rt_folders ASSIGNING . -path = lv_path. ENDIF. ENDLOOP. ENDLOOP. LOOP AT rt_folders ASSIGNING . FIND ALL OCCURRENCES OF '/' IN -path MATCH COUNT -count. ENDLOOP. ENDMETHOD. METHOD build_trees. DATA: lt_nodes TYPE lcl_git_pack=>ty_nodes_tt, ls_tree LIKE LINE OF rt_trees, lv_sub TYPE string, lv_len TYPE i, lt_folders TYPE ty_folders_tt. FIELD-SYMBOLS: LIKE LINE OF lt_folders, LIKE LINE OF lt_nodes, LIKE LINE OF lt_folders, LIKE LINE OF it_expanded. lt_folders = find_folders( it_expanded ). * start with the deepest folders SORT lt_folders BY count DESCENDING. LOOP AT lt_folders ASSIGNING . CLEAR lt_nodes. * files LOOP AT it_expanded ASSIGNING WHERE path = -path. APPEND INITIAL LINE TO lt_nodes ASSIGNING . -chmod = -chmod. -name = -name. -sha1 = -sha1. ENDLOOP. * folders lv_sub = -path && '+*'. LOOP AT lt_folders ASSIGNING WHERE count = -count + 1 AND path CP lv_sub. APPEND INITIAL LINE TO lt_nodes ASSIGNING . -chmod = gc_chmod-dir. * extract folder name, this can probably be done easier using regular expressions lv_len = strlen( -path ). -name = -path+lv_len. lv_len = strlen( -name ) - 1. -name = -name(lv_len). -sha1 = -sha1. ENDLOOP. CLEAR ls_tree. ls_tree-path = -path. ls_tree-data = lcl_git_pack=>encode_tree( lt_nodes ). ls_tree-sha1 = lcl_hash=>sha1( iv_type = gc_type-tree iv_data = ls_tree-data ). APPEND ls_tree TO rt_trees. -sha1 = ls_tree-sha1. ENDLOOP. ENDMETHOD. METHOD walk. DATA: lv_path TYPE string, ls_file LIKE LINE OF ct_files, lt_nodes TYPE lcl_git_pack=>ty_nodes_tt. FIELD-SYMBOLS: LIKE LINE OF it_objects, LIKE LINE OF it_objects, LIKE LINE OF lt_nodes. READ TABLE it_objects ASSIGNING WITH KEY sha1 = iv_sha1 type = gc_type-tree. IF sy-subrc <> 0. lcx_exception=>raise( 'Walk, tree not found' ). ENDIF. lt_nodes = lcl_git_pack=>decode_tree( -data ). LOOP AT lt_nodes ASSIGNING . IF -chmod = gc_chmod-file. READ TABLE it_objects ASSIGNING WITH KEY sha1 = -sha1 type = gc_type-blob. IF sy-subrc <> 0. lcx_exception=>raise( 'Walk, blob not found' ). ENDIF. CLEAR ls_file. ls_file-path = iv_path. ls_file-filename = -name. ls_file-data = -data. ls_file-sha1 = -sha1. APPEND ls_file TO ct_files. ENDIF. ENDLOOP. LOOP AT lt_nodes ASSIGNING WHERE chmod = gc_chmod-dir. CONCATENATE iv_path -name '/' INTO lv_path. walk( EXPORTING it_objects = it_objects iv_sha1 = -sha1 iv_path = lv_path CHANGING ct_files = ct_files ). ENDLOOP. ENDMETHOD. ""walk ENDCLASS. ""lcl_porcelain IMPLEMENTATION ",12226,False,2498.3500324120228,median "********************************************************************** * MACRO ********************************************************************** define test_parse. clear ls_dummy. read table lt_components into ls_component with key name = '&1'. o->parse_field( exporting is_component = ls_component i_value = &2 importing e_field = ls_dummy-&1 ). end-of-definition. define test_parse_positive. clear lx. try. test_parse &1 &2. catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = ls_dummy-&1 exp = &3 msg = 'Parse field positive:' && &2 ). end-of-definition. define test_parse_negative. clear lx. try. test_parse &1 &2. catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( exp = &3 act = lx->code ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx msg = 'Parse field negative:' && &2 ). end-of-definition. define append_dummy. e_dummy_struc-tdate = &1. e_dummy_struc-tchar = &2. e_dummy_struc-tstring = &3. e_dummy_struc-tdecimal = &4. e_dummy_struc-tnumber = &5. if i_strict = abap_true. e_dummy_struc-traw = &6. e_dummy_struc-tinteger = &7. e_dummy_struc-talpha = &8. e_dummy_struc-tfloat = &9. endif. append e_dummy_struc to e_dummy_tab. end-of-definition. define append_dummy_s. l_dummy_s-tdate = &1. l_dummy_s-tchar = &2. l_dummy_s-tstring = &3. l_dummy_s-tdecimal = &4. l_dummy_s-tnumber = &5. if i_strict = abap_true. l_dummy_s-traw = &6. l_dummy_s-tinteger = &7. l_dummy_s-talpha = &8. l_dummy_s-tfloat = &9. endif. append l_dummy_s to e_dummy_tab_s. end-of-definition. ********************************************************************** * Test Class definition ********************************************************************** class ltcl_text2tab_parser_test definition for testing final risk level harmless duration short. * ================ public section. types: begin of ty_dummy, mandt type mandt, tdate type datum, tchar type c length 8, traw type x length 1, tstring type string, talpha type veri_alpha, tdecimal type p length 13 decimals 2, "" dmbtr tnumber type n length 4, tinteger type i, tfloat type float, end of ty_dummy, begin of ty_dummy_with_time, tchar(8), ttime type t, end of ty_dummy_with_time, tt_dummy type standard table of ty_dummy with default key, begin of ty_dummy_str, mandt type string, tdate type string, tchar type string, traw type string, tstring type string, talpha type string, tdecimal type string, tnumber type string, tinteger type string, tfloat type string, end of ty_dummy_str, tt_dummy_str type standard table of ty_dummy_str with default key. types: begin of ty_dummy_with_nonflat, mandt type mandt, tdate type datum, nonflat type ty_dummy, tchar type c length 8, end of ty_dummy_with_nonflat. types: begin of ty_deep_sub, id type i, sub type string, end of ty_deep_sub, tt_deep_sub type standard table of ty_deep_sub with key id, begin of ty_deep, field1 type i, field2 type i, deep_struc type ty_deep_sub, deep_tab type tt_deep_sub, end of ty_deep, tt_deep type standard table of ty_deep with key field1. * ================ private section. constants c_tab like cl_abap_char_utilities=>horizontal_tab value cl_abap_char_utilities=>horizontal_tab. constants c_crlf like cl_abap_char_utilities=>cr_lf value cl_abap_char_utilities=>cr_lf. constants c_lf like cl_abap_char_utilities=>newline value cl_abap_char_utilities=>newline. constants c_dummy type ty_dummy value is initial. data o type ref to zcl_text2tab_parser. ""class under test * ==== TESTING === methods create for testing. methods apply_conv_exit for testing. methods parse_field for testing. methods parse_field_unsupp for testing. methods map_head_structure for testing. methods map_head_structure_w_ignores for testing raising zcx_text2tab_error. methods parse_line_negative for testing. methods parse_data_empty_line for testing. methods parse_negative for testing. methods parse for testing. methods parse_time for testing raising zcx_text2tab_error. methods parse_typeless for testing. methods with_renames for testing. methods deep_structures for testing. * ==== HELPERS === methods setup raising zcx_text2tab_error. methods get_dummy_data importing i_strict type abap_bool default abap_true exporting e_dummy_struc type ty_dummy e_dummy_tab type tt_dummy e_dummy_tab_s type tt_dummy_str e_dummy_header type string e_dummy_string type string e_map type int4_table. methods get_dummy_data_with_time exporting e_exp_result type ty_dummy_with_time e_with_valid_time type string e_with_invalid_time type string. endclass. class zcl_text2tab_parser definition local friends ltcl_text2tab_parser_test. class lcl_deep_helper definition final for testing. public section. interfaces zif_text2tab_deep_provider. methods constructor importing tab type ltcl_text2tab_parser_test=>tt_deep_sub. data mt_tab type ltcl_text2tab_parser_test=>tt_deep_sub. endclass. class lcl_deep_helper implementation. method constructor. mt_tab = tab. endmethod. method zif_text2tab_deep_provider~select. data lv_id type i. data lt_tab like mt_tab. field-symbols type any. if i_address cs '222'. "" Very straihgt but why not ? :) lv_id = 222. else. assign component 'FIELD2' of structure i_cursor to . lv_id = . endif. if cl_abap_typedescr=>describe_by_data( e_container )->kind = 'T'. loop at mt_tab assigning where id = lv_id. append to lt_tab. endloop. e_container = lt_tab. else. "" structure read table mt_tab into e_container with key id = lv_id. endif. endmethod. endclass. ********************************************************************** * Implementation ********************************************************************** class ltcl_text2tab_parser_test implementation. method setup. o = zcl_text2tab_parser=>create( c_dummy ). endmethod. ""setup method create. data: lo type ref to zcl_text2tab_parser, lx type ref to zcx_text2tab_error, lv_date_format type char4, ls_dummy type ty_dummy, lt_dummy type tt_dummy, lv_dummy type i. try. lo = zcl_text2tab_parser=>create( i_pattern = ls_dummy ). cl_abap_unit_assert=>assert_not_initial( act = lo ). cl_abap_unit_assert=>assert_equals( act = lo->mv_amount_format exp = ' ,' ). lo = zcl_text2tab_parser=>create( i_pattern = lt_dummy i_amount_format = ' .' ). cl_abap_unit_assert=>assert_not_initial( act = lo ). cl_abap_unit_assert=>assert_equals( act = lo->mv_amount_format exp = ' .' ). lo = zcl_text2tab_parser=>create( i_pattern = ls_dummy i_amount_format = 'x' ). cl_abap_unit_assert=>assert_not_initial( act = lo ). cl_abap_unit_assert=>assert_equals( act = lo->mv_amount_format exp = ' ,' ). lo = zcl_text2tab_parser=>create( i_pattern = ls_dummy ). cl_abap_unit_assert=>assert_not_initial( act = lo ). cl_abap_unit_assert=>assert_equals( act = lo->mv_date_format exp = 'DMY.' ). lo = zcl_text2tab_parser=>create( i_pattern = ls_dummy i_date_format = 'YMD' ). cl_abap_unit_assert=>assert_not_initial( act = lo ). cl_abap_unit_assert=>assert_equals( act = lo->mv_date_format exp = 'YMD' ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. clear lx. try. lo = zcl_text2tab_parser=>create( i_pattern = lv_dummy ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'PE' ). "" Pattern error endtry. cl_abap_unit_assert=>assert_not_initial( act = lx ). do 3 times. case sy-index. when 1. lv_date_format = 'XXX'. when 2. lv_date_format = 'DM'. when 3. lv_date_format = 'DMY='. endcase. clear lx. try. lo = zcl_text2tab_parser=>create( i_pattern = ls_dummy i_date_format = lv_date_format ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'UD' ). "" Unsupported date format endtry. cl_abap_unit_assert=>assert_not_initial( act = lx ). enddo. endmethod. ""create method parse. data: dummy_act type ty_dummy, dummy_tab_act type tt_dummy, dummy_htab type hashed table of ty_dummy with unique key tdate, dummy_stab type sorted table of ty_dummy with unique key tdate, dummy_exp type ty_dummy, dummy_tab_exp type tt_dummy, dummy_head type string, l_string type string, lt_strings type table of string, lt_header_act type standard table of string, lt_header_exp type standard table of string, lx type ref to zcx_text2tab_error. "" Strict parsing ********************************* get_dummy_data( importing e_dummy_struc = dummy_exp e_dummy_tab = dummy_tab_exp e_dummy_header = dummy_head e_dummy_string = l_string ). split dummy_head at c_tab into table lt_header_exp. try. o->parse( exporting i_data = l_string importing e_container = dummy_act ). cl_abap_unit_assert=>assert_equals( act = dummy_act exp = dummy_exp ). o->parse( exporting i_data = l_string importing e_container = dummy_tab_act e_head_fields = lt_header_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). cl_abap_unit_assert=>assert_equals( act = lt_header_act exp = lt_header_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. "" Parse to sorted and hashed tables *************** try. o->parse( exporting i_data = l_string importing e_container = dummy_stab ). cl_abap_unit_assert=>assert_equals( act = dummy_stab exp = dummy_tab_exp ). o->parse( exporting i_data = l_string importing e_container = dummy_htab ). cl_abap_unit_assert=>assert_equals( act = dummy_htab exp = dummy_tab_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. "" Parse without head split l_string at c_crlf into table lt_strings. delete lt_strings index 1. concatenate lines of lt_strings into l_string separated by c_crlf. try. o->parse( exporting i_data = l_string i_has_head = abap_false importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. "" NOT STRICT parsing ****************************** get_dummy_data( exporting i_strict = abap_false importing e_dummy_tab = dummy_tab_exp e_dummy_header = dummy_head e_dummy_string = l_string ). split dummy_head at c_tab into table lt_header_exp. try. o->parse( exporting i_data = l_string i_strict = abap_false importing e_container = dummy_tab_act e_head_fields = lt_header_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). cl_abap_unit_assert=>assert_equals( act = lt_header_act exp = lt_header_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. endmethod. ""parse method parse_time. data: l_exp_result type ty_dummy_with_time, l_act_result type ty_dummy_with_time, l_with_valid_time type string, l_with_invalid_time type string, cut type ref to zcl_text2tab_parser, l_exc_expected type ref to zcx_text2tab_error. get_dummy_data_with_time( importing e_exp_result = l_exp_result e_with_valid_time = l_with_valid_time e_with_invalid_time = l_with_invalid_time ). cut = zcl_text2tab_parser=>create( l_exp_result ). "" not successfull parsing try. cut->parse( exporting i_data = l_with_invalid_time importing e_container = l_act_result ). cl_abap_unit_assert=>fail( msg = |no exception when given invalid time| ). catch zcx_text2tab_error into l_exc_expected. cl_abap_unit_assert=>assert_equals( exp = 'IT' act = l_exc_expected->code msg = |should throw exception-code IT on invalid time| ). endtry. "" successfull parsing cut->parse( exporting i_data = l_with_valid_time importing e_container = l_act_result ). cl_abap_unit_assert=>assert_equals( exp = l_exp_result act = l_act_result msg = |parsing should be sucessfull with correct time| ). endmethod. ""parse_time method parse_negative. data: begin of wrong_struc ##NEEDED, mandt type mandt, tdate type datum, tchar type char08, end of wrong_struc. data: l_exp_code type char2, dummy_val type char40 ##NEEDED, dummy_tab_act type tt_dummy ##NEEDED, l_string type string, l_string_bak type string, lx type ref to zcx_text2tab_error. get_dummy_data( importing e_dummy_string = l_string_bak ). do 5 times. clear lx. l_string = l_string_bak. try. case sy-index. when 1. "" Parse to field (not table or structure) l_exp_code = 'PE'. o->parse( exporting i_data = l_string importing e_container = dummy_val ). when 2. "" Parse empty file clear l_string. l_exp_code = 'DE'. o->parse( exporting i_data = l_string importing e_container = dummy_tab_act ). when 3. "" Add empty line at the beginning l_string = c_crlf && l_string. l_exp_code = 'HE'. o->parse( exporting i_data = l_string importing e_container = dummy_tab_act ). when 4. "" Wrong params l_exp_code = 'WP'. o->parse( exporting i_data = l_string i_strict = abap_false i_has_head = abap_false importing e_container = dummy_tab_act ). when 5. "" Wrong container type l_exp_code = 'TE'. o->parse( exporting i_data = l_string importing e_container = wrong_struc ). endcase. catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( exp = l_exp_code act = lx->code msg = |parse, case { sy-index }| ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx msg = |parse, case { sy-index }| ). enddo. endmethod. ""parse_negative method apply_conv_exit. data: l_dummy type ty_dummy, lx type ref to zcx_text2tab_error. try . o->apply_conv_exit( exporting i_convexit = 'ALPHA' i_value = '123' importing e_field = l_dummy-talpha ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = l_dummy-talpha exp = '0000000123' ). "" Check wrong exit clear lx. try . o->apply_conv_exit( exporting i_convexit = 'NONAME' i_value = '123' importing e_field = l_dummy-talpha ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'EM' ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx ). endmethod. ""apply_conv_exit method parse_field. data: ls_dummy type ty_dummy, lo_struc_descr type ref to cl_abap_structdescr, lt_components type zcl_text2tab_utils=>tt_comp_descr, ls_component like line of lt_components, lx type ref to zcx_text2tab_error. lo_struc_descr ?= cl_abap_structdescr=>describe_by_data( ls_dummy ). try. lt_components = zcl_text2tab_utils=>describe_struct( i_struc = lo_struc_descr i_ignore_nonflat = abap_false ). catch zcx_text2tab_error. cl_abap_unit_assert=>fail( ). endtry. "" Positive tests ****************************** test_parse_positive TDATE '01.02.2015' '20150201'. test_parse_positive TDATE '1.2.2015' '20150201'. test_parse_positive TCHAR 'ABC' 'ABC'. test_parse_positive TSTRING 'The string test' 'The string test'. test_parse_positive TALPHA '100000' '0000100000'. test_parse_positive TNUMBER '2015' '2015'. test_parse_positive TINTEGER '123' 123. test_parse_positive TRAW '8E' '8E'. test_parse_positive TFLOAT '1,123456789' '1.123456789'. test_parse_positive TFLOAT '""1,123456789""' '1.123456789'. "" Quoted data, issue#6 test_parse_positive TNUMBER '""2015""' '2015'. "" Quoted "" Negative tests ****************************** test_parse_negative TNUMBER '20ha' 'PF'. "" Decimal converion tests ********************* test_parse_positive TDECIMAL '1234,12' '1234.12'. test_parse_positive TDECIMAL '-1234,12' '-1234.12'. "" Different amount formats test_parse_positive TDECIMAL '-1234,12' '-1234.12'. test_parse_positive TDECIMAL '1234,12' '1234.12'. test_parse_positive TDECIMAL '1234' '1234'. test_parse_positive TDECIMAL '1 234' '1234'. test_parse_positive TDECIMAL '1 234,12' '1234.12'. test_parse_positive TDECIMAL '14,12' '14.12'. test_parse_positive TDECIMAL '1 234 567,12' '1234567.12'. o->mv_amount_format = '.,'. test_parse_positive TDECIMAL '1234,12' '1234.12'. test_parse_positive TDECIMAL '1 234,12' '1234.12'. test_parse_positive TDECIMAL '1.234,12' '1234.12'. test_parse_positive TDECIMAL '1.234' '1234'. test_parse_positive TDECIMAL '14,12' '14.12'. test_parse_positive TDECIMAL '1.234.567,12' '1234567.12'. o->mv_amount_format = ',.'. test_parse_positive TDECIMAL '1234.12' '1234.12'. test_parse_positive TDECIMAL '1 234.12' '1234.12'. test_parse_positive TDECIMAL '1,234.12' '1234.12'. test_parse_positive TDECIMAL '14.12' '14.12'. test_parse_positive TDECIMAL '1,234,567.12' '1234567.12'. "" Negative decimal tests o->mv_amount_format = ' ,'. "" Set defaults test_parse_negative TDECIMAL '1 234.12' 'PF'. test_parse_negative TDECIMAL '1 234_12' 'PF'. test_parse_negative TDECIMAL '1234,123' 'PF'. "" 3 decimal digits into amount which has just 2 test_parse_negative TDECIMAL '1234,12_' 'PF'. test_parse_negative TDECIMAL 'Not-a-number' 'PF'. o->mv_amount_format = '.,'. test_parse_negative TDECIMAL '1 234.12' 'PF'. test_parse_negative TDECIMAL '1,234.12' 'PF'. o->mv_amount_format = ',.'. test_parse_negative TDECIMAL '1 234,12' 'PF'. test_parse_negative TDECIMAL '1.234,12' 'PF'. "" Date tests ********************************** o->mv_date_format = 'MDY'. test_parse_positive TDATE '02012015' '20150201'. o->mv_date_format = 'YMD'. test_parse_positive TDATE '20150201' '20150201'. test_parse_negative TDATE '2015020' 'DL'. "" Too short o->mv_date_format = 'YMD-'. test_parse_positive TDATE '2015-02-01' '20150201'. test_parse_positive TDATE '2015-2-1' '20150201'. test_parse_positive TDATE ` ` '00000000'. test_parse_positive TDATE '' '00000000'. o->mv_date_format = 'DMY.'. "" Back to default "" Negative tests test_parse_negative TDATE 'AB022015' 'DY'. "" Wrong symbols test_parse_negative TDATE '01.02-2015' 'DY'. "" Wrong separators test_parse_negative TDATE '01.02.20156' 'DL'. "" Too long test_parse_negative TDATE '1.2.201567' 'DP'. "" Wrong part length test_parse_negative TDATE '123.2.2015' 'DP'. "" Wrong part length test_parse_negative TDATE '01022015' 'DS'. "" No separators test_parse_negative TDATE '01.012015' 'DS'. "" No second separator test_parse_negative TDATE '40.01.2015' 'DU'. "" Incorrect day test_parse_negative TDATE '01.13.2015' 'DU'. "" Incorrect month "" Overflow ************************************ test_parse_negative TCHAR 'ABCDEFGH123' 'FS'. test_parse_negative TNUMBER '201567' 'FS'. test_parse_negative TRAW '8E8F' 'FS'. test_parse_negative TRAW '8E8' 'FS'. "" CONV EXITS data lv_meins type meins. data ls_comp like line of lt_components. try. clear lx. ls_comp-type_kind = cl_abap_typedescr=>typekind_char. ls_comp-edit_mask = 'CUNIT'. ls_comp-output_length = 3. o->parse_field( exporting is_component = ls_comp i_value = 'KG' importing e_field = lv_meins ). cl_abap_unit_assert=>assert_equals( act = lv_meins exp = 'KG' ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. try. clear lx. ls_comp-type_kind = cl_abap_typedescr=>typekind_char. ls_comp-edit_mask = 'CUNIT'. ls_comp-output_length = 3. o->parse_field( exporting is_component = ls_comp i_value = '??' importing e_field = lv_meins ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'EF' ). endtry. cl_abap_unit_assert=>assert_not_initial( lx ). endmethod. ""parse_field method parse_field_unsupp. endmethod. ""parse_field_unsupp method map_head_structure. data: l_header type string, l_header_bak type string, l_exp_code type char2, l_act_map type int4_table, l_exp_map type int4_table, l_ren_map type zcl_text2tab_utils=>th_field_name_map, l_rename like line of l_ren_map, lx type ref to zcx_text2tab_error. get_dummy_data( exporting i_strict = abap_false "" Reduced importing e_dummy_header = l_header e_map = l_exp_map ). "" Positive test try. o->map_head_structure( exporting i_rename_map = l_ren_map i_header = l_header i_strict = abap_false importing et_map = l_act_map ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = l_act_map exp = l_exp_map ). "" Renames l_header = replace( val = l_header sub = 'TSTRING' with = 'SOME_FIELD' ). l_rename-from = 'SOME_FIELD'. l_rename-to = 'TSTRING'. insert l_rename into table l_ren_map. try. o->map_head_structure( exporting i_rename_map = l_ren_map i_header = l_header i_strict = abap_false importing et_map = l_act_map ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = l_act_map exp = l_exp_map ). clear l_ren_map. get_dummy_data( "" Complete importing e_dummy_header = l_header_bak e_map = l_exp_map ). delete l_exp_map index 1. "" remove MANDT mapping "" Skip MANDT l_header = l_header_bak. replace first occurrence of 'MANDT' && c_tab in l_header with ''. try. o->map_head_structure( exporting i_rename_map = l_ren_map i_header = l_header i_strict = abap_true importing et_map = l_act_map ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = l_act_map exp = l_exp_map ). "" Negative tests do 6 times. clear lx. l_header = l_header_bak. case sy-index. when 1. "" Duplicate field names replace first occurrence of 'TCHAR' in l_header with 'TDATE'. l_exp_code = 'DN'. when 2. "" Empty field names replace first occurrence of 'TCHAR' in l_header with ''. l_exp_code = 'EN'. when 3. "" Unknown field in text replace first occurrence of 'TCHAR' in l_header with 'UNKNOWN'. l_exp_code = 'MC'. when 4. "" More fields than in target structure l_header = l_header && c_tab && 'EXCESS_FIELD'. l_exp_code = 'CN'. when 5. "" Empty field at the end l_header = l_header && c_tab. l_exp_code = 'EE'. when 6. l_rename-from = 'TCHAR'. l_rename-to = 'TSTRING'. insert l_rename into table l_ren_map. l_exp_code = 'DR'. endcase. try. o->map_head_structure( i_rename_map = l_ren_map i_header = l_header i_strict = abap_true ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( exp = l_exp_code act = lx->code msg = |map_head_structure, case { sy-index }| ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx msg = |map_head_structure, case { sy-index }| ). enddo. "" Negative tests, typeless o->mv_is_typeless = abap_true. do 5 times. clear lx. case sy-index. when 1. "" Too long field l_header = 'A123456789_123456789_123456789_EXTRA'. l_exp_code = 'WE'. when 2. "" Special characters l_header = 'A123456789_123456789_123456789_EXTRA'. l_exp_code = 'WE'. endcase. try. o->map_head_structure( i_rename_map = l_ren_map i_header = l_header i_strict = abap_false ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( exp = l_exp_code act = lx->code msg = |map_head_structure typeless, case { sy-index }| ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx msg = |map_head_structure typeless, case { sy-index }| ). enddo. endmethod. ""map_head_structure method parse_line_negative. data: l_dataline type string, l_header_bak type string, l_exp_code type char2, lt_map type int4_table, lx type ref to zcx_text2tab_error. get_dummy_data( importing e_dummy_header = l_header_bak e_map = lt_map ). "" Negative tests do 2 times. clear lx. l_dataline = l_header_bak. case sy-index. when 1. "" More fields than in header l_dataline = l_dataline && c_tab && 'EXCESSFLD'. l_exp_code = '>H'. when 2. "" Less fields than in header replace first occurrence of c_tab && 'TINTEGER' in l_dataline with ''. l_exp_code = 'parse_line( i_dataline = l_dataline it_map = lt_map ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( exp = l_exp_code act = lx->code msg = |parse_line_negative, case { sy-index }| ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx msg = |parse_line_negative, case { sy-index }| ). enddo. endmethod. ""parse_line_negative method parse_data_empty_line. data: dummy_tab_exp type tt_dummy, dummy_tab_act type tt_dummy, l_string type string, lt_data type table of string, lt_map type int4_table, lx type ref to zcx_text2tab_error. get_dummy_data( importing e_dummy_tab = dummy_tab_exp e_dummy_string = l_string e_map = lt_map ). split l_string at c_crlf into table lt_data. delete lt_data index 1. "" Add empty line at the end ***************************** try. append '' to lt_data. o->parse_data( exporting it_data = lt_data it_map = lt_map importing e_container = dummy_tab_act ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). "" Add empty line in the middle *************************** try. insert '' into lt_data index 2. o->parse_data( exporting it_data = lt_data it_map = lt_map importing e_container = dummy_tab_act ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'LE' ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx ). endmethod. ""parse_data_empty_line method get_dummy_data. data: l_dummy_s type ty_dummy_str, l_offs type i, l_fields type i, l_string type string. clear e_map. if i_strict = abap_true. l_string = 'MANDT\\tTDATE\\tTCHAR\\tTRAW\\tTSTRING\\tTALPHA\\tTDECIMAL\\tTNUMBER\\tTINTEGER\\tTFLOAT\\n' && '\\t01.01.2015\\tTrololo1\\t8A\\tString1\\t100000\\t1234567,81\\t2015\\t1111\\t1,12345\\n' && '\\t02.01.2016\\tTrololo2\\t8B\\tString2\\t200000\\t1234567,82\\t2016\\t2222\\t1,00\\n' && '\\t03.01.2016\\tTrololo3\\t8C\\tString3\\t300000\\t1234567,83\\t2015\\t3333\\t1\\n' . do 10 times. append sy-index to e_map. enddo. else. l_string = 'TDATE\\tTSTRING\\tTCHAR\\tTDECIMAL\\tTNUMBER\\n' && '01.01.2015\\tString1\\tTrololo1\\t1234567,81\\t2015\\n' && '02.01.2016\\tString2\\tTrololo2\\t1234567,82\\t2016\\n' && '03.01.2016\\tString3\\tTrololo3\\t1234567,83\\t2015\\n' . append '2' to e_map. append '5' to e_map. append '3' to e_map. append '7' to e_map. append '8' to e_map. endif. replace all occurrences of '\\t' in l_string with c_tab. replace all occurrences of '\\n' in l_string with c_crlf. clear e_dummy_tab. "" TDATE TCHAR TSTRING TDECIMAL TNUM TRAW TINT TALPHA TFLOAT append_dummy '20150101' 'Trololo1' 'String1' '1234567.81' 2015 '8A' 1111 '0000100000' '1.12345'. append_dummy '20160102' 'Trololo2' 'String2' '1234567.82' 2016 '8B' 2222 '0000200000' '1.00'. append_dummy '20160103' 'Trololo3' 'String3' '1234567.83' 2015 '8C' 3333 '0000300000' '1.00'. "" TDATE TCHAR TSTRING TDECIMAL TNUM TRAW TINT TALPHA TFLOAT append_dummy_s '01.01.2015' 'Trololo1' 'String1' '1234567,81' '2015' '8A' '1111' '100000' '1,12345'. append_dummy_s '02.01.2016' 'Trololo2' 'String2' '1234567,82' '2016' '8B' '2222' '200000' '1,00'. append_dummy_s '03.01.2016' 'Trololo3' 'String3' '1234567,83' '2015' '8C' '3333' '300000' '1'. read table e_dummy_tab into e_dummy_struc index 1. e_dummy_string = l_string. find first occurrence of c_crlf in l_string match offset l_offs. e_dummy_header = l_string+0(l_offs). endmethod. "" get_dummy_data method get_dummy_data_with_time. e_with_valid_time = 'TCHAR\\tTTIME\\n' && 'Trolo2\\t08:30:00'. replace all occurrences of '\\t' in e_with_valid_time with c_tab. replace all occurrences of '\\n' in e_with_valid_time with c_crlf. e_with_invalid_time = 'TCHAR\\tTTIME\\n' && 'Trolo2\\t88:30:00'. replace all occurrences of '\\t' in e_with_invalid_time with c_tab. replace all occurrences of '\\n' in e_with_invalid_time with c_crlf. e_exp_result-tchar = 'Trolo2'. e_exp_result-ttime = '083000'. endmethod. "" get_dummy_data_with_time method parse_typeless. data: l_string type string, lt_exp type tt_dummy_str, lr_data type ref to data, lx type ref to zcx_text2tab_error. field-symbols: type string, type standard table. get_dummy_data( importing e_dummy_tab_s = lt_exp e_dummy_string = l_string ). try. o = zcl_text2tab_parser=>create_typeless( ). o->parse( exporting i_data = l_string importing e_container = lr_data ). assign lr_data->* to . catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = lines( ) exp = 3 ). cl_abap_unit_assert=>assert_equals( act = exp = lt_exp ). "" Check components are the same "" cl_abap_unit_assert accepts similar tables with different fielnames (wtf?) data lo_tt_act type ref to cl_abap_tabledescr. data lo_tt_exp type ref to cl_abap_tabledescr. data lo_st_act type ref to cl_abap_structdescr. data lo_st_exp type ref to cl_abap_structdescr. lo_tt_act ?= cl_abap_typedescr=>describe_by_data( ). lo_tt_exp ?= cl_abap_typedescr=>describe_by_data( lt_exp ). lo_st_act ?= lo_tt_act->get_table_line_type( ). lo_st_exp ?= lo_tt_exp->get_table_line_type( ). cl_abap_unit_assert=>assert_equals( act = lo_st_act->get_components( ) exp = lo_st_exp->get_components( ) ). "" Negatives try. o->parse( exporting i_data = l_string importing e_container = lt_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'DR' ). endtry. cl_abap_unit_assert=>assert_not_initial( act = lx ). endmethod. method with_renames. data: l_string type string, lt_typed_act type tt_dummy, lt_typed_exp type tt_dummy, lt_exp type tt_dummy_str, lr_data type ref to data, lv_dummy_head type string, lt_header_act type standard table of string, lt_header_exp type standard table of string, lx type ref to zcx_text2tab_error. field-symbols: type string, type standard table. get_dummy_data( importing e_dummy_tab = lt_typed_exp e_dummy_header = lv_dummy_head e_dummy_tab_s = lt_exp e_dummy_string = l_string ). split lv_dummy_head at c_tab into table lt_header_exp. l_string = replace( val = l_string sub = 'TSTRING' with = 'SOME_FIELD' ). data lt_map type zcl_text2tab_utils=>tt_field_name_map. field-symbols like line of lt_map. append initial line to lt_map assigning . -from = 'some_field'. -to = 'tstring'. "" Typefull try. o->parse( exporting i_data = l_string i_rename_fields = lt_map importing e_container = lt_typed_act e_head_fields = lt_header_act ). cl_abap_unit_assert=>assert_equals( act = lt_typed_act exp = lt_typed_exp ). cl_abap_unit_assert=>assert_equals( act = lt_header_act exp = lt_header_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. try. "" string based o->parse( exporting i_data = l_string i_rename_fields = 'some_field:tstring' importing e_container = lt_typed_act e_head_fields = lt_header_act ). cl_abap_unit_assert=>assert_equals( act = lt_typed_act exp = lt_typed_exp ). cl_abap_unit_assert=>assert_equals( act = lt_header_act exp = lt_header_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. "" Typeless try. o = zcl_text2tab_parser=>create_typeless( ). o->parse( exporting i_data = l_string i_rename_fields = lt_map importing e_container = lr_data ). assign lr_data->* to . catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = lines( ) exp = 3 ). cl_abap_unit_assert=>assert_equals( act = exp = lt_exp ). "" Check components are the same "" cl_abap_unit_assert accepts similar tables with different fielnames (wtf?) data lo_tt_act type ref to cl_abap_tabledescr. data lo_tt_exp type ref to cl_abap_tabledescr. data lo_st_act type ref to cl_abap_structdescr. data lo_st_exp type ref to cl_abap_structdescr. lo_tt_act ?= cl_abap_typedescr=>describe_by_data( ). lo_tt_exp ?= cl_abap_typedescr=>describe_by_data( lt_exp ). lo_st_act ?= lo_tt_act->get_table_line_type( ). lo_st_exp ?= lo_tt_exp->get_table_line_type( ). cl_abap_unit_assert=>assert_equals( act = lo_st_act->get_components( ) exp = lo_st_exp->get_components( ) ). endmethod. method map_head_structure_w_ignores. data ls_dummy type ty_dummy_with_nonflat. data ls_exp type ty_dummy_with_nonflat. o = zcl_text2tab_parser=>create( i_pattern = ls_dummy i_ignore_nonflat = abap_true ). data: lt_ren_map type zcl_text2tab_utils=>th_field_name_map, lt_act_map type zcl_text2tab_parser=>tt_field_map, lt_exp_map type zcl_text2tab_parser=>tt_field_map, lx type ref to zcx_text2tab_error. "" Happy path o->map_head_structure( exporting i_rename_map = lt_ren_map i_header = |TDATE{ c_tab }TCHAR| i_strict = abap_false importing et_map = lt_act_map ). append 2 to lt_exp_map. append 4 to lt_exp_map. cl_abap_unit_assert=>assert_equals( act = lt_act_map exp = lt_exp_map ). "" Fail with ignored field try . o->map_head_structure( exporting i_rename_map = lt_ren_map i_header = |TDATE{ c_tab }TCHAR{ c_tab }NONFLAT| i_strict = abap_false importing et_map = lt_act_map ). cl_abap_unit_assert=>fail( ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'IG' ). endtry. "" Integrated o->parse( exporting i_data = |TDATE{ c_tab }TCHAR{ c_lf }01.01.2019{ c_tab }AAA| i_strict = abap_false importing e_container = ls_dummy ). ls_exp-tdate = '20190101'. ls_exp-tchar = 'AAA'. cl_abap_unit_assert=>assert_equals( act = ls_dummy exp = ls_exp ). endmethod. method deep_structures. data lx type ref to zcx_text2tab_error. data lt_exp type tt_deep. data lt_sub type tt_deep_sub. data l_input type string. data lt_header_exp type standard table of string. field-symbols like line of lt_exp. field-symbols like line of -deep_tab. "" Fill expected data append initial line to lt_exp assigning . -field1 = 1. -field2 = 111. -deep_struc-id = 111. -deep_struc-sub = 'Ones'. append initial line to -deep_tab assigning . -id = 111. -sub = 'Ones'. append initial line to -deep_tab assigning . -id = 111. -sub = 'One one one'. append initial line to lt_exp assigning . -field1 = 2. -field2 = 222. -deep_struc-id = 222. -deep_struc-sub = 'Twos'. append initial line to -deep_tab assigning . -id = 222. -sub = 'Twos'. append initial line to lt_exp assigning . -field1 = 3. -field2 = 333. append initial line to lt_exp assigning . -field1 = 4. -field2 = 444. "" Sub append initial line to lt_sub assigning . -id = 111. -sub = 'Ones'. append initial line to lt_sub assigning . -id = 111. -sub = 'One one one'. append initial line to lt_sub assigning . -id = 222. -sub = 'Twos'. "" Header append 'FIELD1' to lt_header_exp. append 'FIELD2' to lt_header_exp. append 'DEEP_STRUC' to lt_header_exp. append 'DEEP_TAB' to lt_header_exp. "" Input l_input = 'FIELD1\\tFIELD2\\tDEEP_STRUC\\tDEEP_TAB\\n' && '1\\t111\\t@ext[id=@field2]\\t@ext[id=@field2]\\n' "" Test ref to field in current tab && '2\\t222\\t@ext[id=222]\\t@ext[id=222]\\n' "" Test fixed value && '3\\t333\\t@ext[id=@field2]\\t@ext[id=@field2]\\n' "" Test empty ext source && '4\\t444\\t\\t\\n'. "" Test empty ref replace all occurrences of '\\t' in l_input with c_tab. replace all occurrences of '\\n' in l_input with c_lf. "" Run data lt_act type tt_deep. data lt_header_act type standard table of string. data lo_deep_provider type ref to lcl_deep_helper. create object lo_deep_provider exporting tab = lt_sub. try. o = zcl_text2tab_parser=>create( i_pattern = lt_exp i_deep_provider = lo_deep_provider ). o->parse( exporting i_data = l_input importing e_container = lt_act e_head_fields = lt_header_act ). cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). cl_abap_unit_assert=>assert_equals( act = lt_header_act exp = lt_header_exp ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>fail( lx->get_text( ) ). endtry. endmethod. endclass. ",12243,True,2654.7234412185207,median "CLASS zcl_abapgit_gui_page_diff DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page CREATE PUBLIC. PUBLIC SECTION. TYPES: BEGIN OF ty_file_diff, path TYPE string, filename TYPE string, obj_type TYPE string, obj_name TYPE string, lstate TYPE char1, rstate TYPE char1, fstate TYPE char1, "" FILE state - Abstraction for shorter ifs o_diff TYPE REF TO zcl_abapgit_diff, changed_by TYPE xubname, type TYPE string, END OF ty_file_diff. TYPES: ty_file_diffs TYPE STANDARD TABLE OF ty_file_diff WITH NON-UNIQUE DEFAULT KEY WITH NON-UNIQUE SORTED KEY secondary COMPONENTS path filename. CONSTANTS: BEGIN OF c_fstate, local TYPE char1 VALUE 'L', remote TYPE char1 VALUE 'R', both TYPE char1 VALUE 'B', END OF c_fstate. METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception. METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION. PROTECTED SECTION. DATA mv_unified TYPE abap_bool VALUE abap_true ##NO_TEXT. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mt_diff_files TYPE ty_file_diffs . METHODS get_normalized_fname_with_path IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(rv_filename) TYPE string . METHODS normalize_path IMPORTING !iv_path TYPE string RETURNING VALUE(rv_normalized) TYPE string . METHODS normalize_filename IMPORTING !iv_filename TYPE string RETURNING VALUE(rv_normalized) TYPE string . METHODS add_menu_end IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS calculate_diff IMPORTING !is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL !is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL !it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL RAISING zcx_abapgit_exception . METHODS add_menu_begin IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_table_head_non_unified IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS render_beacon_begin_of_row IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS render_diff_head_after_state IMPORTING !ii_html TYPE REF TO zif_abapgit_html !is_diff TYPE ty_file_diff . METHODS insert_nav RETURNING VALUE(rv_insert_nav) TYPE abap_bool . METHODS render_line_split_row IMPORTING !ii_html TYPE REF TO zif_abapgit_html !iv_filename TYPE string !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_index TYPE sy-tabix !iv_fstate TYPE char1 !iv_new TYPE string !iv_old TYPE string RAISING zcx_abapgit_exception . METHODS build_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_content REDEFINITION . PRIVATE SECTION. CONSTANTS: BEGIN OF c_actions, toggle_unified TYPE string VALUE 'toggle_unified', END OF c_actions . DATA mt_delayed_lines TYPE zif_abapgit_definitions=>ty_diffs_tt . DATA mv_repo_key TYPE zif_abapgit_persistence=>ty_repo-key . DATA mv_seed TYPE string . "" Unique page id to bind JS sessionStorage METHODS render_diff IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_diff_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_table_head IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_beacon IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_line_split IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff !iv_filename TYPE string !iv_fstate TYPE char1 !iv_index TYPE sy-tabix RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_line_unified IMPORTING !is_diff_line TYPE zif_abapgit_definitions=>ty_diff OPTIONAL RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS append_diff IMPORTING !it_remote TYPE zif_abapgit_definitions=>ty_files_tt !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !is_status TYPE zif_abapgit_definitions=>ty_result RAISING zcx_abapgit_exception . METHODS is_binary IMPORTING !iv_d1 TYPE xstring !iv_d2 TYPE xstring RETURNING VALUE(rv_yes) TYPE abap_bool . METHODS add_jump_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS add_filter_sub_menu IMPORTING !io_menu TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_lines IMPORTING !is_diff TYPE ty_file_diff RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_table_head_unified IMPORTING !ii_html TYPE REF TO zif_abapgit_html . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS filter_diff_by_files IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_stage_tt CHANGING !ct_diff_files TYPE ty_file_diffs . ENDCLASS. CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION. METHOD add_filter_sub_menu. DATA: lo_sub_filter TYPE REF TO zcl_abapgit_html_toolbar, lt_types TYPE string_table, lt_users TYPE string_table. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files, TYPE string. "" Get unique LOOP AT mt_diff_files ASSIGNING . APPEND -type TO lt_types. APPEND -changed_by TO lt_users. ENDLOOP. SORT lt_types. DELETE ADJACENT DUPLICATES FROM lt_types. SORT lt_users. DELETE ADJACENT DUPLICATES FROM lt_users. IF lines( lt_types ) > 1 OR lines( lt_users ) > 1. CREATE OBJECT lo_sub_filter EXPORTING iv_id = 'diff-filter'. "" File types IF lines( lt_types ) > 1. lo_sub_filter->add( iv_txt = 'TYPE' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_types ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'type' iv_chk = abap_true ). ENDLOOP. ENDIF. "" Changed by IF lines( lt_users ) > 1. lo_sub_filter->add( iv_txt = 'CHANGED BY' iv_typ = zif_abapgit_html=>c_action_type-separator ). LOOP AT lt_users ASSIGNING . lo_sub_filter->add( iv_txt = iv_typ = zif_abapgit_html=>c_action_type-onclick iv_aux = 'changed-by' iv_chk = abap_true ). ENDLOOP. ENDIF. io_menu->add( iv_txt = 'Filter' io_sub = lo_sub_filter ). ENDIF. ENDMETHOD. METHOD add_jump_sub_menu. DATA: lo_sub_jump TYPE REF TO zcl_abapgit_html_toolbar, lv_jump_target TYPE string. FIELD-SYMBOLS: LIKE LINE OF mt_diff_files. CREATE OBJECT lo_sub_jump EXPORTING iv_id = 'jump'. LOOP AT mt_diff_files ASSIGNING . lv_jump_target = -path && -filename. lo_sub_jump->add( iv_id = |li_jump_{ sy-tabix }| iv_txt = lv_jump_target iv_typ = zif_abapgit_html=>c_action_type-onclick ). ENDLOOP. io_menu->add( iv_txt = 'Jump' io_sub = lo_sub_jump ). ENDMETHOD. METHOD add_menu_begin. ENDMETHOD. METHOD add_menu_end. io_menu->add( iv_txt = 'Split/Unified view' iv_act = c_actions-toggle_unified ). ENDMETHOD. METHOD append_diff. DATA: lv_offs TYPE i, ls_r_dummy LIKE LINE OF it_remote ##NEEDED, ls_l_dummy LIKE LINE OF it_local ##NEEDED. FIELD-SYMBOLS: LIKE LINE OF it_remote, LIKE LINE OF it_local, LIKE LINE OF mt_diff_files. READ TABLE it_remote ASSIGNING WITH KEY filename = is_status-filename path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_r_dummy TO . ENDIF. READ TABLE it_local ASSIGNING WITH KEY file-filename = is_status-filename file-path = is_status-path. IF sy-subrc <> 0. ASSIGN ls_l_dummy TO . ENDIF. IF IS INITIAL AND IS INITIAL. zcx_abapgit_exception=>raise( |DIFF: file not found { is_status-filename }| ). ENDIF. APPEND INITIAL LINE TO mt_diff_files ASSIGNING . -path = is_status-path. -filename = is_status-filename. -obj_type = is_status-obj_type. -obj_name = is_status-obj_name. -lstate = is_status-lstate. -rstate = is_status-rstate. IF -lstate IS NOT INITIAL AND -rstate IS NOT INITIAL. -fstate = c_fstate-both. ELSEIF -lstate IS NOT INITIAL. -fstate = c_fstate-local. ELSE. ""rstate IS NOT INITIAL, lstate = empty. -fstate = c_fstate-remote. ENDIF. "" Changed by IF -item-obj_type IS NOT INITIAL. -changed_by = to_lower( zcl_abapgit_objects=>changed_by( -item ) ). ENDIF. IF -changed_by IS INITIAL. -changed_by = to_lower( zcl_abapgit_objects_super=>c_user_unknown ). ENDIF. "" Extension IF -file-filename IS NOT INITIAL. -type = reverse( -file-filename ). ELSE. -type = reverse( -filename ). ENDIF. FIND FIRST OCCURRENCE OF '.' IN -type MATCH OFFSET lv_offs. -type = reverse( substring( val = -type len = lv_offs ) ). IF -type <> 'xml' AND -type <> 'abap'. -type = 'other'. ENDIF. IF -type = 'other' AND is_binary( iv_d1 = -data iv_d2 = -file-data ) = abap_true. -type = 'binary'. ENDIF. "" Diff data IF -type <> 'binary'. IF -fstate = c_fstate-remote. "" Remote file leading changes CREATE OBJECT -o_diff EXPORTING iv_new = -data iv_old = -file-data. ELSE. "" Local leading changes or both were modified CREATE OBJECT -o_diff EXPORTING iv_new = -file-data iv_old = -data. ENDIF. ENDIF. ENDMETHOD. METHOD build_menu. CREATE OBJECT ro_menu. add_menu_begin( ro_menu ). add_jump_sub_menu( ro_menu ). add_filter_sub_menu( ro_menu ). add_menu_end( ro_menu ). ENDMETHOD. METHOD calculate_diff. DATA: lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_status TYPE zif_abapgit_definitions=>ty_results_tt. FIELD-SYMBOLS: LIKE LINE OF lt_status. CLEAR: mt_diff_files. lt_remote = mo_repo->get_files_remote( ). lt_local = mo_repo->get_files_local( ). mo_repo->reset_status( ). lt_status = mo_repo->status( ). IF is_file IS NOT INITIAL. "" Diff for one file READ TABLE lt_status ASSIGNING WITH KEY path = is_file-path filename = is_file-filename. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ELSEIF is_object IS NOT INITIAL. "" Diff for whole object LOOP AT lt_status ASSIGNING WHERE obj_type = is_object-obj_type AND obj_name = is_object-obj_name AND match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ELSE. "" Diff for the whole repo SORT lt_status BY path ASCENDING filename ASCENDING. LOOP AT lt_status ASSIGNING WHERE match IS INITIAL. append_diff( it_remote = lt_remote it_local = lt_local is_status = ). ENDLOOP. ENDIF. filter_diff_by_files( EXPORTING it_files = it_files CHANGING ct_diff_files = mt_diff_files ). ENDMETHOD. METHOD constructor. DATA: lv_ts TYPE timestamp. super->constructor( ). ms_control-page_title = 'Diff'. mv_unified = zcl_abapgit_persistence_user=>get_instance( )->get_diff_unified( ). mv_repo_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). GET TIME STAMP FIELD lv_ts. mv_seed = |diff{ lv_ts }|. "" Generate based on time ASSERT is_file IS INITIAL OR is_object IS INITIAL. "" just one passed calculate_diff( is_file = is_file is_object = is_object it_files = it_files ). IF lines( mt_diff_files ) = 0. zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ). ENDIF. ms_control-page_menu = build_menu( ). ENDMETHOD. METHOD filter_diff_by_files. FIELD-SYMBOLS: TYPE ty_file_diff. IF lines( it_files ) = 0. RETURN. ENDIF. "" Diff only for specified files LOOP AT ct_diff_files ASSIGNING . READ TABLE it_files TRANSPORTING NO FIELDS WITH KEY file-filename = -filename. IF sy-subrc <> 0. DELETE TABLE ct_diff_files FROM . ENDIF. ENDLOOP. ENDMETHOD. METHOD get_normalized_fname_with_path. rv_filename = normalize_path( is_diff-path ) && `_` && normalize_filename( is_diff-filename ). ENDMETHOD. METHOD insert_nav. ENDMETHOD. METHOD is_binary. FIELD-SYMBOLS LIKE iv_d1. IF iv_d1 IS NOT INITIAL. "" One of them might be new and so empty ASSIGN iv_d1 TO . ELSE. ASSIGN iv_d2 TO . ENDIF. rv_yes = zcl_abapgit_utils=>is_binary( ). ENDMETHOD. METHOD normalize_filename. rv_normalized = replace( val = iv_filename sub = '.' occ = 0 with = '_' ). ENDMETHOD. METHOD normalize_path. rv_normalized = replace( val = iv_path sub = '/' occ = 0 with = '_' ). ENDMETHOD. METHOD render_beacon. DATA: lv_beacon TYPE string, lt_beacons TYPE zif_abapgit_definitions=>ty_string_tt. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_diff_line-beacon > 0. lt_beacons = is_diff-o_diff->get_beacons( ). READ TABLE lt_beacons INTO lv_beacon INDEX is_diff_line-beacon. ELSE. lv_beacon = '---'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). render_beacon_begin_of_row( ii_html = ri_html is_diff = is_diff ). IF mv_unified = abap_true. ri_html->add( '' ). ri_html->add( '' ). ri_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ELSE. ri_html->add( |@@ { is_diff_line-new_num } @@ { lv_beacon }| ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_beacon_begin_of_row. ii_html->add( '' ). ENDMETHOD. METHOD render_content. DATA: ls_diff_file LIKE LINE OF mt_diff_files, li_progress TYPE REF TO zif_abapgit_progress. CREATE OBJECT ri_html TYPE zcl_abapgit_html. li_progress = zcl_abapgit_progress=>get_instance( lines( mt_diff_files ) ). ri_html->add( `
` ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( mo_repo ) ). ri_html->add( `
` ). ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_js_error_banner( ) ). LOOP AT mt_diff_files INTO ls_diff_file. li_progress->show( iv_current = sy-tabix iv_text = |Render Diff - { ls_diff_file-filename }| ). ri_html->add( render_diff( ls_diff_file ) ). ENDLOOP. IF sy-subrc <> 0. ri_html->add( |No more diffs| ). ENDIF. ri_html->add( '
' ). register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_diff. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( render_diff_head( is_diff ) ). "" Content IF is_diff-type <> 'binary'. ri_html->add( '
' ). ri_html->add( || ). ri_html->add( render_table_head( is_diff ) ). ri_html->add( render_lines( is_diff ) ). ri_html->add( '
' ). ELSE. ri_html->add( '
' ). ri_html->add( 'The content seems to be binary.' ). ri_html->add( 'Cannot display as diff.' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_diff_head. DATA: ls_stats TYPE zif_abapgit_definitions=>ty_count, lv_adt_link TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '
' ). ri_html->add_icon( iv_name = 'chevron-down' iv_hint = 'Collapse/Expand' iv_class = 'cursor-pointer' iv_onclick = 'onDiffCollapse(event)' ). IF is_diff-type <> 'binary'. ls_stats = is_diff-o_diff->stats( ). IF is_diff-fstate = c_fstate-both. "" Merge stats into 'update' if both were changed ls_stats-update = ls_stats-update + ls_stats-insert + ls_stats-delete. CLEAR: ls_stats-insert, ls_stats-delete. ENDIF. ri_html->add( |+ { ls_stats-insert }| ). ri_html->add( |- { ls_stats-delete }| ). ri_html->add( |~ { ls_stats-update }| ). ENDIF. "" no links for nonexistent or deleted objects IF is_diff-lstate IS NOT INITIAL AND is_diff-lstate <> 'D'. lv_adt_link = ri_html->a( iv_txt = |{ is_diff-path }{ is_diff-filename }| iv_typ = zif_abapgit_html=>c_action_type-sapevent iv_act = |jump?TYPE={ is_diff-obj_type }&NAME={ is_diff-obj_name }| ). ENDIF. IF lv_adt_link IS NOT INITIAL. ri_html->add( |{ lv_adt_link }| ). ELSE. ri_html->add( |{ is_diff-path }{ is_diff-filename }| ). ENDIF. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_diff-lstate iv_rstate = is_diff-rstate ) ). render_diff_head_after_state( ii_html = ri_html is_diff = is_diff ). ri_html->add( |Last Changed by: { is_diff-changed_by }| ). ri_html->add( '
' ). ENDMETHOD. METHOD render_diff_head_after_state. IF is_diff-fstate = c_fstate-both AND mv_unified = abap_true. ii_html->add( 'Attention: Unified mode' && ' highlighting for MM assumes local file is newer ! ' ). ENDIF. ENDMETHOD. METHOD render_lines. DATA: lo_highlighter TYPE REF TO zcl_abapgit_syntax_highlighter, lt_diffs TYPE zif_abapgit_definitions=>ty_diffs_tt, lv_insert_nav TYPE abap_bool, lv_tabix TYPE syst-tabix. FIELD-SYMBOLS LIKE LINE OF lt_diffs. lo_highlighter = zcl_abapgit_syntax_highlighter=>create( is_diff-filename ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. lt_diffs = is_diff-o_diff->get( ). lv_insert_nav = insert_nav( ). LOOP AT lt_diffs ASSIGNING . lv_tabix = sy-tabix. IF -short = abap_false. lv_insert_nav = abap_true. CONTINUE. ENDIF. IF lv_insert_nav = abap_true. "" Insert separator line with navigation ri_html->add( render_beacon( is_diff_line = is_diff = is_diff ) ). lv_insert_nav = abap_false. ENDIF. IF lo_highlighter IS BOUND. -new = lo_highlighter->process_line( -new ). -old = lo_highlighter->process_line( -old ). ELSE. -new = escape( val = -new format = cl_abap_format=>e_html_attr ). -old = escape( val = -old format = cl_abap_format=>e_html_attr ). ENDIF. CONDENSE -new_num. ""get rid of leading spaces CONDENSE -old_num. IF mv_unified = abap_true. ri_html->add( render_line_unified( is_diff_line = ) ). ELSE. ri_html->add( render_line_split( is_diff_line = iv_filename = get_normalized_fname_with_path( is_diff ) iv_fstate = is_diff-fstate iv_index = lv_tabix ) ). ENDIF. ENDLOOP. IF mv_unified = abap_true. ri_html->add( render_line_unified( ) ). "" Release delayed lines ENDIF. ENDMETHOD. METHOD render_line_split. DATA: lv_new TYPE string, lv_old TYPE string, lv_mark TYPE string, lv_bg TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" New line lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-insert. lv_bg = ' diff_ins'. lv_mark = `+`. ENDIF. ENDIF. lv_new = || && |{ lv_mark }| && |{ is_diff_line-new }|. "" Old line CLEAR lv_bg. lv_mark = ` `. IF is_diff_line-result IS NOT INITIAL. IF iv_fstate = c_fstate-both OR is_diff_line-result = zif_abapgit_definitions=>c_diff-update. lv_bg = ' diff_upd'. lv_mark = `~`. ELSEIF is_diff_line-result = zif_abapgit_definitions=>c_diff-delete. lv_bg = ' diff_del'. lv_mark = `-`. ENDIF. ENDIF. lv_old = || && |{ lv_mark }| && |{ is_diff_line-old }|. "" render line, inverse sides if remote is newer ri_html->add( '' ). render_line_split_row( ii_html = ri_html iv_filename = iv_filename is_diff_line = is_diff_line iv_index = iv_index iv_fstate = iv_fstate iv_old = lv_old iv_new = lv_new ). ri_html->add( '' ). ENDMETHOD. METHOD render_line_split_row. IF iv_fstate = c_fstate-remote. "" Remote file leading changes ii_html->add( iv_old ). "" local ii_html->add( iv_new ). "" remote ELSE. "" Local leading changes or both were modified ii_html->add( iv_new ). "" local ii_html->add( iv_old ). "" remote ENDIF. ENDMETHOD. METHOD render_line_unified. FIELD-SYMBOLS LIKE LINE OF mt_delayed_lines. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" Release delayed subsequent update lines IF is_diff_line-result <> zif_abapgit_definitions=>c_diff-update. LOOP AT mt_delayed_lines ASSIGNING . ri_html->add( '' ). ri_html->add( |-old_num }"">| && || && |-| && |{ -old }| ). ri_html->add( '' ). ENDLOOP. LOOP AT mt_delayed_lines ASSIGNING . ri_html->add( '' ). ri_html->add( || && |-new_num }"">| && |+| && |{ -new }| ). ri_html->add( '' ). ENDLOOP. CLEAR mt_delayed_lines. ENDIF. ri_html->add( '' ). CASE is_diff_line-result. WHEN zif_abapgit_definitions=>c_diff-update. APPEND is_diff_line TO mt_delayed_lines. "" Delay output of subsequent updates WHEN zif_abapgit_definitions=>c_diff-insert. ri_html->add( || && || && |+| && |{ is_diff_line-new }| ). WHEN zif_abapgit_definitions=>c_diff-delete. ri_html->add( || && || && |-| && |{ is_diff_line-old }| ). WHEN OTHERS. ""none ri_html->add( || && || && | | && |{ is_diff_line-old }| ). ENDCASE. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( 'restoreScrollPosition();' ). ri_html->add( 'var gHelper = new DiffHelper({' ). ri_html->add( | seed: ""{ mv_seed }"",| ). ri_html->add( ' ids: {' ). ri_html->add( ' jump: ""jump"",' ). ri_html->add( ' diffList: ""diff-list"",' ). ri_html->add( ' filterMenu: ""diff-filter"",' ). ri_html->add( ' }' ). ri_html->add( '});' ). ri_html->add( 'addMarginBottom();' ). ri_html->add( 'var gGoJumpPalette = new CommandPalette(enumerateJumpAllFiles, {' ). ri_html->add( ' toggleKey: ""F2"",' ). ri_html->add( ' hotkeyDescription: ""Jump to file ...""' ). ri_html->add( '});' ). "" Feature for selecting ABAP code by column and copy to clipboard ri_html->add( 'var columnSelection = new DiffColumnSelection();' ). ENDMETHOD. METHOD render_table_head. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( '' ). IF mv_unified = abap_true. render_table_head_unified( ri_html ). ELSE. render_table_head_non_unified( ii_html = ri_html is_diff = is_diff ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_table_head_non_unified. ii_html->add( '' ). ii_html->add( '' ). ii_html->add( 'LOCAL' ). ii_html->add( '' ). ii_html->add( '' ). ii_html->add( 'REMOTE' ). ENDMETHOD. METHOD render_table_head_unified. ii_html->add( 'old' ). ii_html->add( 'new' ). ii_html->add( '' ). ii_html->add( 'code' ). ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. CASE ii_event->mv_action. WHEN c_actions-toggle_unified. "" Toggle file diplay mv_unified = zcl_abapgit_persistence_user=>get_instance( )->toggle_diff_unified( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). ENDCASE. ENDMETHOD. ENDCLASS. ",8067,False,1496.5756812447667,median "CLASS zcl_excel_sheet_setup DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. *""* public components of class ZCL_EXCEL_SHEET_SETUP *""* do not include other source files here!!! TYPE-POOLS abap . DATA black_and_white TYPE flag . DATA cell_comments TYPE stringval . DATA copies TYPE int2 . CONSTANTS c_break_column TYPE zexcel_break VALUE 2. ""#EC NOTEXT CONSTANTS c_break_none TYPE zexcel_break VALUE 0. ""#EC NOTEXT CONSTANTS c_break_row TYPE zexcel_break VALUE 1. ""#EC NOTEXT CONSTANTS c_cc_as_displayed TYPE string VALUE 'asDisplayed'. ""#EC NOTEXT CONSTANTS c_cc_at_end TYPE string VALUE 'atEnd'. ""#EC NOTEXT CONSTANTS c_cc_none TYPE string VALUE 'none'. ""#EC NOTEXT CONSTANTS c_ord_downthenover TYPE string VALUE 'downThenOver'. ""#EC NOTEXT CONSTANTS c_ord_overthendown TYPE string VALUE 'overThenDown'. ""#EC NOTEXT CONSTANTS c_orientation_default TYPE zexcel_sheet_orienatation VALUE 'default'. ""#EC NOTEXT CONSTANTS c_orientation_landscape TYPE zexcel_sheet_orienatation VALUE 'landscape'. ""#EC NOTEXT CONSTANTS c_orientation_portrait TYPE zexcel_sheet_orienatation VALUE 'portrait'. ""#EC NOTEXT CONSTANTS c_papersize_6_3_4_envelope TYPE zexcel_sheet_paper_size VALUE 38. ""#EC NOTEXT CONSTANTS c_papersize_a2_paper TYPE zexcel_sheet_paper_size VALUE 64. ""#EC NOTEXT CONSTANTS c_papersize_a3 TYPE zexcel_sheet_paper_size VALUE 8. ""#EC NOTEXT CONSTANTS c_papersize_a3_extra_paper TYPE zexcel_sheet_paper_size VALUE 61. ""#EC NOTEXT CONSTANTS c_papersize_a3_extra_tv_paper TYPE zexcel_sheet_paper_size VALUE 66. ""#EC NOTEXT CONSTANTS c_papersize_a3_tv_paper TYPE zexcel_sheet_paper_size VALUE 65. ""#EC NOTEXT CONSTANTS c_papersize_a4 TYPE zexcel_sheet_paper_size VALUE 9. ""#EC NOTEXT CONSTANTS c_papersize_a4_extra_paper TYPE zexcel_sheet_paper_size VALUE 51. ""#EC NOTEXT CONSTANTS c_papersize_a4_plus_paper TYPE zexcel_sheet_paper_size VALUE 58. ""#EC NOTEXT CONSTANTS c_papersize_a4_small TYPE zexcel_sheet_paper_size VALUE 10. ""#EC NOTEXT CONSTANTS c_papersize_a4_tv_paper TYPE zexcel_sheet_paper_size VALUE 53. ""#EC NOTEXT CONSTANTS c_papersize_a5 TYPE zexcel_sheet_paper_size VALUE 11. ""#EC NOTEXT CONSTANTS c_papersize_a5_extra_paper TYPE zexcel_sheet_paper_size VALUE 62. ""#EC NOTEXT CONSTANTS c_papersize_a5_tv_paper TYPE zexcel_sheet_paper_size VALUE 59. ""#EC NOTEXT CONSTANTS c_papersize_b4 TYPE zexcel_sheet_paper_size VALUE 12. ""#EC NOTEXT CONSTANTS c_papersize_b4_envelope TYPE zexcel_sheet_paper_size VALUE 33. ""#EC NOTEXT CONSTANTS c_papersize_b5 TYPE zexcel_sheet_paper_size VALUE 13. ""#EC NOTEXT CONSTANTS c_papersize_b5_envelope TYPE zexcel_sheet_paper_size VALUE 34. ""#EC NOTEXT CONSTANTS c_papersize_b6_envelope TYPE zexcel_sheet_paper_size VALUE 35. ""#EC NOTEXT CONSTANTS c_papersize_c TYPE zexcel_sheet_paper_size VALUE 24. ""#EC NOTEXT CONSTANTS c_papersize_c3_envelope TYPE zexcel_sheet_paper_size VALUE 29. ""#EC NOTEXT CONSTANTS c_papersize_c4_envelope TYPE zexcel_sheet_paper_size VALUE 30. ""#EC NOTEXT CONSTANTS c_papersize_c5_envelope TYPE zexcel_sheet_paper_size VALUE 28. ""#EC NOTEXT CONSTANTS c_papersize_c65_envelope TYPE zexcel_sheet_paper_size VALUE 32. ""#EC NOTEXT CONSTANTS c_papersize_c6_envelope TYPE zexcel_sheet_paper_size VALUE 31. ""#EC NOTEXT CONSTANTS c_papersize_d TYPE zexcel_sheet_paper_size VALUE 25. ""#EC NOTEXT CONSTANTS c_papersize_de_leg_fanfold TYPE zexcel_sheet_paper_size VALUE 41. ""#EC NOTEXT CONSTANTS c_papersize_de_std_fanfold TYPE zexcel_sheet_paper_size VALUE 40. ""#EC NOTEXT CONSTANTS c_papersize_dl_envelope TYPE zexcel_sheet_paper_size VALUE 27. ""#EC NOTEXT CONSTANTS c_papersize_e TYPE zexcel_sheet_paper_size VALUE 26. ""#EC NOTEXT CONSTANTS c_papersize_executive TYPE zexcel_sheet_paper_size VALUE 7. ""#EC NOTEXT CONSTANTS c_papersize_folio TYPE zexcel_sheet_paper_size VALUE 14. ""#EC NOTEXT CONSTANTS c_papersize_invite_envelope TYPE zexcel_sheet_paper_size VALUE 47. ""#EC NOTEXT CONSTANTS c_papersize_iso_b4 TYPE zexcel_sheet_paper_size VALUE 42. ""#EC NOTEXT CONSTANTS c_papersize_iso_b5_extra_paper TYPE zexcel_sheet_paper_size VALUE 63. ""#EC NOTEXT CONSTANTS c_papersize_italy_envelope TYPE zexcel_sheet_paper_size VALUE 36. ""#EC NOTEXT CONSTANTS c_papersize_jis_b5_tv_paper TYPE zexcel_sheet_paper_size VALUE 60. ""#EC NOTEXT CONSTANTS c_papersize_jpn_dbl_postcard TYPE zexcel_sheet_paper_size VALUE 43. ""#EC NOTEXT CONSTANTS c_papersize_ledger TYPE zexcel_sheet_paper_size VALUE 4. ""#EC NOTEXT CONSTANTS c_papersize_legal TYPE zexcel_sheet_paper_size VALUE 5. ""#EC NOTEXT CONSTANTS c_papersize_legal_extra_paper TYPE zexcel_sheet_paper_size VALUE 49. ""#EC NOTEXT CONSTANTS c_papersize_letter TYPE zexcel_sheet_paper_size VALUE 1. ""#EC NOTEXT CONSTANTS c_papersize_letter_extra_paper TYPE zexcel_sheet_paper_size VALUE 48. ""#EC NOTEXT CONSTANTS c_papersize_letter_extv_paper TYPE zexcel_sheet_paper_size VALUE 54. ""#EC NOTEXT CONSTANTS c_papersize_letter_plus_paper TYPE zexcel_sheet_paper_size VALUE 57. ""#EC NOTEXT CONSTANTS c_papersize_letter_small TYPE zexcel_sheet_paper_size VALUE 2. ""#EC NOTEXT CONSTANTS c_papersize_letter_tv_paper TYPE zexcel_sheet_paper_size VALUE 52. ""#EC NOTEXT CONSTANTS c_papersize_monarch_envelope TYPE zexcel_sheet_paper_size VALUE 37. ""#EC NOTEXT CONSTANTS c_papersize_no10_envelope TYPE zexcel_sheet_paper_size VALUE 20. ""#EC NOTEXT CONSTANTS c_papersize_no11_envelope TYPE zexcel_sheet_paper_size VALUE 21. ""#EC NOTEXT CONSTANTS c_papersize_no12_envelope TYPE zexcel_sheet_paper_size VALUE 22. ""#EC NOTEXT CONSTANTS c_papersize_no14_envelope TYPE zexcel_sheet_paper_size VALUE 23. ""#EC NOTEXT CONSTANTS c_papersize_no9_envelope TYPE zexcel_sheet_paper_size VALUE 19. ""#EC NOTEXT CONSTANTS c_papersize_note TYPE zexcel_sheet_paper_size VALUE 18. ""#EC NOTEXT CONSTANTS c_papersize_quarto TYPE zexcel_sheet_paper_size VALUE 15. ""#EC NOTEXT CONSTANTS c_papersize_standard_1 TYPE zexcel_sheet_paper_size VALUE 16. ""#EC NOTEXT CONSTANTS c_papersize_standard_2 TYPE zexcel_sheet_paper_size VALUE 17. ""#EC NOTEXT CONSTANTS c_papersize_standard_paper_1 TYPE zexcel_sheet_paper_size VALUE 44. ""#EC NOTEXT CONSTANTS c_papersize_standard_paper_2 TYPE zexcel_sheet_paper_size VALUE 45. ""#EC NOTEXT CONSTANTS c_papersize_standard_paper_3 TYPE zexcel_sheet_paper_size VALUE 46. ""#EC NOTEXT CONSTANTS c_papersize_statement TYPE zexcel_sheet_paper_size VALUE 6. ""#EC NOTEXT CONSTANTS c_papersize_supera_a4_paper TYPE zexcel_sheet_paper_size VALUE 55. ""#EC NOTEXT CONSTANTS c_papersize_superb_a3_paper TYPE zexcel_sheet_paper_size VALUE 56. ""#EC NOTEXT CONSTANTS c_papersize_tabloid TYPE zexcel_sheet_paper_size VALUE 3. ""#EC NOTEXT CONSTANTS c_papersize_tabl_extra_paper TYPE zexcel_sheet_paper_size VALUE 50. ""#EC NOTEXT CONSTANTS c_papersize_us_std_fanfold TYPE zexcel_sheet_paper_size VALUE 39. ""#EC NOTEXT CONSTANTS c_pe_blank TYPE string VALUE 'blank'. ""#EC NOTEXT CONSTANTS c_pe_dash TYPE string VALUE 'dash'. ""#EC NOTEXT CONSTANTS c_pe_displayed TYPE string VALUE 'displayed'. ""#EC NOTEXT CONSTANTS c_pe_na TYPE string VALUE 'NA'. ""#EC NOTEXT DATA diff_oddeven_headerfooter TYPE flag . DATA draft TYPE flag . DATA errors TYPE stringval . DATA even_footer TYPE zexcel_s_worksheet_head_foot . DATA even_header TYPE zexcel_s_worksheet_head_foot . DATA first_page_number TYPE int2 . DATA fit_to_height TYPE int2 . DATA fit_to_page TYPE flag . DATA fit_to_width TYPE int2 . DATA horizontal_centered TYPE flag . DATA horizontal_dpi TYPE int2 . DATA margin_bottom TYPE zexcel_dec_8_2 . DATA margin_footer TYPE zexcel_dec_8_2 . DATA margin_header TYPE zexcel_dec_8_2 . DATA margin_left TYPE zexcel_dec_8_2 . DATA margin_right TYPE zexcel_dec_8_2 . DATA margin_top TYPE zexcel_dec_8_2 . DATA odd_footer TYPE zexcel_s_worksheet_head_foot . DATA odd_header TYPE zexcel_s_worksheet_head_foot . DATA orientation TYPE zexcel_sheet_orienatation . DATA page_order TYPE string . DATA paper_height TYPE string . DATA paper_size TYPE int2 . DATA paper_width TYPE string . DATA scale TYPE int2 . DATA use_first_page_num TYPE flag . DATA use_printer_defaults TYPE flag . DATA vertical_centered TYPE flag . DATA vertical_dpi TYPE int2 . METHODS constructor . METHODS set_page_margins IMPORTING !ip_bottom TYPE float OPTIONAL !ip_footer TYPE float OPTIONAL !ip_header TYPE float OPTIONAL !ip_left TYPE float OPTIONAL !ip_right TYPE float OPTIONAL !ip_top TYPE float OPTIONAL !ip_unit TYPE csequence DEFAULT 'in' . METHODS set_header_footer IMPORTING !ip_odd_header TYPE zexcel_s_worksheet_head_foot OPTIONAL !ip_odd_footer TYPE zexcel_s_worksheet_head_foot OPTIONAL !ip_even_header TYPE zexcel_s_worksheet_head_foot OPTIONAL !ip_even_footer TYPE zexcel_s_worksheet_head_foot OPTIONAL . METHODS get_header_footer_string EXPORTING !ep_odd_header TYPE string !ep_odd_footer TYPE string !ep_even_header TYPE string !ep_even_footer TYPE string . METHODS get_header_footer EXPORTING !ep_odd_header TYPE zexcel_s_worksheet_head_foot !ep_odd_footer TYPE zexcel_s_worksheet_head_foot !ep_even_header TYPE zexcel_s_worksheet_head_foot !ep_even_footer TYPE zexcel_s_worksheet_head_foot . PROTECTED SECTION. *""* protected components of class ZCL_EXCEL_SHEET_SETUP *""* do not include other source files here!!! METHODS process_header_footer IMPORTING !ip_header TYPE zexcel_s_worksheet_head_foot !ip_side TYPE string RETURNING VALUE(rv_processed_string) TYPE string . PRIVATE SECTION. *""* private components of class ZCL_EXCEL_SHEET_SETUP *""* do not include other source files here!!! ENDCLASS. CLASS zcl_excel_sheet_setup IMPLEMENTATION. METHOD constructor. orientation = me->c_orientation_default. * default margins margin_bottom = '0.75'. margin_footer = '0.3'. margin_header = '0.3'. margin_left = '0.7'. margin_right = '0.7'. margin_top = '0.75'. * clear page settings CLEAR: black_and_white, cell_comments, copies, draft, errors, first_page_number, fit_to_page, fit_to_height, fit_to_width, horizontal_dpi, orientation, page_order, paper_height, paper_size, paper_width, scale, use_first_page_num, use_printer_defaults, vertical_dpi. ENDMETHOD. METHOD get_header_footer. * Only Basic font/text formatting possible: * Bold (yes / no), Font Type, Font Size * * usefull placeholders, which can be used in header/footer value strings * '&P' - page number * '&N' - total number of pages * '&D' - Date * '&T' - Time * '&F' - File Name * '&Z' - Path * '&A' - Sheet name * new line via class constant CL_ABAP_CHAR_UTILITIES=>newline * * Example Value String 'page &P of &N' * * DO NOT USE &L , &C or &R which automatically created as position markers ep_odd_header = me->odd_header. ep_odd_footer = me->odd_footer. ep_even_header = me->even_header. ep_even_footer = me->even_footer. ENDMETHOD. METHOD get_header_footer_string. * ---------------------------------------------------------------------- DATA: lc_marker_left(2) TYPE c VALUE '&L' , lc_marker_right(2) TYPE c VALUE '&R' , lc_marker_center(2) TYPE c VALUE '&C' , lv_value TYPE string . * ---------------------------------------------------------------------- IF ep_odd_header IS SUPPLIED. IF me->odd_header-left_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->odd_header ip_side = 'LEFT' ). CONCATENATE lc_marker_left lv_value INTO ep_odd_header. ENDIF. IF me->odd_header-center_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->odd_header ip_side = 'CENTER' ). CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_odd_header. ENDIF. IF me->odd_header-right_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->odd_header ip_side = 'RIGHT' ). CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_odd_header. ENDIF. IF me->odd_header-left_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_odd_header. ENDIF. IF me->odd_header-center_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_odd_header. ENDIF. IF me->odd_header-right_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_odd_header. ENDIF. ENDIF. * ---------------------------------------------------------------------- IF ep_odd_footer IS SUPPLIED. IF me->odd_footer-left_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->odd_footer ip_side = 'LEFT' ). CONCATENATE lc_marker_left lv_value INTO ep_odd_footer. ENDIF. IF me->odd_footer-center_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->odd_footer ip_side = 'CENTER' ). CONCATENATE ep_odd_footer lc_marker_center lv_value INTO ep_odd_footer. ENDIF. IF me->odd_footer-right_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->odd_footer ip_side = 'RIGHT' ). CONCATENATE ep_odd_footer lc_marker_right lv_value INTO ep_odd_footer. ENDIF. IF me->odd_footer-left_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_odd_footer. ENDIF. IF me->odd_footer-center_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_odd_footer. ENDIF. IF me->odd_footer-right_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_odd_footer. ENDIF. ENDIF. * ---------------------------------------------------------------------- IF ep_even_header IS SUPPLIED. IF me->even_header-left_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->even_header ip_side = 'LEFT' ). CONCATENATE lc_marker_left lv_value INTO ep_even_header. ENDIF. IF me->even_header-center_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->even_header ip_side = 'CENTER' ). CONCATENATE ep_even_header lc_marker_center lv_value INTO ep_even_header. ENDIF. IF me->even_header-right_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->even_header ip_side = 'RIGHT' ). CONCATENATE ep_even_header lc_marker_right lv_value INTO ep_even_header. ENDIF. IF me->even_header-left_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_even_header. ENDIF. IF me->even_header-center_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_even_header. ENDIF. IF me->even_header-right_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_even_header. ENDIF. ENDIF. * ---------------------------------------------------------------------- IF ep_even_footer IS SUPPLIED. IF me->even_footer-left_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->even_footer ip_side = 'LEFT' ). CONCATENATE lc_marker_left lv_value INTO ep_even_footer. ENDIF. IF me->even_footer-center_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->even_footer ip_side = 'CENTER' ). CONCATENATE ep_even_footer lc_marker_center lv_value INTO ep_even_footer. ENDIF. IF me->even_footer-right_value IS NOT INITIAL. lv_value = me->process_header_footer( ip_header = me->even_footer ip_side = 'RIGHT' ). CONCATENATE ep_even_footer lc_marker_right lv_value INTO ep_even_footer. ENDIF. IF me->even_footer-left_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_even_footer. ENDIF. IF me->even_footer-center_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_even_footer. ENDIF. IF me->even_footer-right_image IS NOT INITIAL. lv_value = '&G'. CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_even_footer. ENDIF. ENDIF. * ---------------------------------------------------------------------- ENDMETHOD. METHOD process_header_footer. * ---------------------------------------------------------------------- * Only Basic font/text formatting possible: * Bold (yes / no), Font Type, Font Size DATA: lv_fname(12) TYPE c , lv_string TYPE string . FIELD-SYMBOLS: TYPE string , TYPE zexcel_s_style_font . * ---------------------------------------------------------------------- CONCATENATE ip_side '_VALUE' INTO lv_fname. ASSIGN COMPONENT lv_fname OF STRUCTURE ip_header TO . CONCATENATE ip_side '_FONT' INTO lv_fname. ASSIGN COMPONENT lv_fname OF STRUCTURE ip_header TO . IF IS ASSIGNED AND IS ASSIGNED. IF = '&G'. ""image header rv_processed_string = . ELSE. IF -name IS NOT INITIAL. CONCATENATE '&""' -name ',' INTO rv_processed_string. ELSE. rv_processed_string = '&""-,'. ENDIF. IF -bold = abap_true. CONCATENATE rv_processed_string 'Bold""' INTO rv_processed_string. ELSE. CONCATENATE rv_processed_string 'Standard""' INTO rv_processed_string. ENDIF. IF -size IS NOT INITIAL. lv_string = -size. CONCATENATE rv_processed_string '&' lv_string INTO rv_processed_string. CONDENSE rv_processed_string NO-GAPS. ENDIF. CONCATENATE rv_processed_string INTO rv_processed_string. ENDIF. ENDIF. * ---------------------------------------------------------------------- ENDMETHOD. METHOD set_header_footer. * Only Basic font/text formatting possible: * Bold (yes / no), Font Type, Font Size * * usefull placeholders, which can be used in header/footer value strings * '&P' - page number * '&N' - total number of pages * '&D' - Date * '&T' - Time * '&F' - File Name * '&Z' - Path * '&A' - Sheet name * new line via class constant CL_ABAP_CHAR_UTILITIES=>newline * * Example Value String 'page &P of &N' * * DO NOT USE &L , &C or &R which automatically created as position markers me->odd_header = ip_odd_header. me->odd_footer = ip_odd_footer. me->even_header = ip_even_header. me->even_footer = ip_even_footer. IF me->even_header IS NOT INITIAL OR me->even_footer IS NOT INITIAL. me->diff_oddeven_headerfooter = abap_true. ENDIF. ENDMETHOD. METHOD set_page_margins. DATA: lv_coef TYPE f, lv_unit TYPE string. lv_unit = ip_unit. TRANSLATE lv_unit TO UPPER CASE. CASE lv_unit. WHEN 'IN'. lv_coef = 1. WHEN 'CM'. lv_coef = '0.393700787'. WHEN 'MM'. lv_coef = '0.0393700787'. ENDCASE. IF ip_bottom IS SUPPLIED. margin_bottom = lv_coef * ip_bottom. ENDIF. IF ip_footer IS SUPPLIED. margin_footer = lv_coef * ip_footer. ENDIF. IF ip_header IS SUPPLIED. margin_header = lv_coef * ip_header. ENDIF. IF ip_left IS SUPPLIED. margin_left = lv_coef * ip_left. ENDIF. IF ip_right IS SUPPLIED. margin_right = lv_coef * ip_right. ENDIF. IF ip_top IS SUPPLIED. margin_top = lv_coef * ip_top. ENDIF. ENDMETHOD. ENDCLASS. ",5170,False,876.1064262656034,median "/** * VERSION: 12.1.1 * DATE: 2013-12-07 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com **/ package com.greensock.core { import temple.core.destruction.IDestructible; import flash.display.Shape; import flash.events.Event; import flash.utils.getTimer; /** * Base class for all TweenLite, TweenMax, TimelineLite, and TimelineMax classes, providing * core methods/properties/functionality, but there is no reason to create an instance of this * class directly. It can be very useful, however, as a data type in AS3/AS2 for methods/properties that * can contain tweens or timelines. For example, maybe you build an animateIn() and * animateOut() method for many of your own custom classes, and they each return an * Animation instance which could be a tween or a timeline: * * function animateIn():Animation { return TweenLite.to(this, 1, {scaleX:1, scaleY:1, autoAlpha:1}); } function animateOut():Animation { var tl:TimelineLite = new TimelineLite(); tl.to(this, 1, {scaleX:0.5, scaleY:0.5}); tl.to(this, 0.5, {autoAlpha:0}, ""-=0.25""); return tl; } var anim:Animation = animateIn(); //now we can control the animation with the common methods: anim.pause(); anim.play(); anim.reverse(); //or somewhere else, we could build a sequence like this: var tl:TimelineLite = new TimelineLite(); tl.add( animateIn() ); tl.add( animateOut(), 3); * *

Copyright 2008-2014, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.

* * @author Jack Doyle, jack@greensock.com */ public class Animation implements IDestructible{ /** @private **/ public static const version:String = ""12.1.1""; /** * The object that dispatches a ""tick"" event each time the engine updates, making it easy for * you to add your own listener(s) to run custom logic after each update (great for game developers). * Add as many listeners as you want. The basic syntax is the same for all versions (AS2, AS3, and JavaScript): * *

Basic example (AS2, AS3, and JavaScript):

//add listener Animation.ticker.addEventListener(""tick"", myFunction); function myFunction(event) { //executes on every tick after the core engine updates } //to remove the listener later... Animation.ticker.removeEventListener(""tick"", myFunction); * *

Due to differences in the core languages (and to maximize efficiency), the advanced syntax is slightly different * for the AS3 version compared to AS2 and JavaScript. The parameters beyond the first 2 in the addEventListener() * method are outlined below:

* *

JavaScript and AS2

*

addEventListener(type, callback, scope, useParam, priority)

*

Parameters: *

    *
  1. type : String - type of listener, should always be ""tick""
  2. *
  3. callback : Function - the function to call when the event occurs
  4. *
  5. scope : Object - binds the scope to a particular object (scope is basically what ""this"" refers to in your function). This can be very useful in JavaScript and AS2 because scope isn't generally maintained.
  6. *
  7. useParam : Boolean - if true, an event object will be generated and fed to the callback each time the event occurs. The event is a generic object and has two properties: type (always ""tick"") and target which refers to the ticker instance. The default for useParam is false because it improves performance.
  8. *
  9. priority : Integer - influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.
  10. *
*

* *

In JavaScript, the Animation object/class is located at com.greensock.core.Animation - it is not added to the global namespace in order to avoid polluting it (developers rarely directly access the Animation class)

* *

Advanced example (JavaScript and AS2):

//add listener that requests an event object parameter, binds scope to the current scope (this), and sets priority to 1 so that it is called before any other listeners that had a priority lower than 1... Animation.ticker.addEventListener(""tick"", myFunction, this, true, 1); function myFunction(event) { //executes on every tick after the core engine updates } //to remove the listener later... Animation.ticker.removeEventListener(""tick"", myFunction); * *

AS3

*

The AS3 version uses the standard EventDispatcher.addEventListener() syntax which * basically allows you to define a priority and whether or not to use weak references (see Adobe's * docs for details).

* *

Advanced example [AS3 only]:

import flash.events.Event; //add listener with weak reference (standard syntax - notice the 5th parameter is true) Animation.ticker.addEventListener(""tick"", myFunction, false, 0, true); function myFunction(event:Event):void { //executes on every tick after the core engine updates } //to remove the listener later... Animation.ticker.removeEventListener(""tick"", myFunction); **/ public static var ticker:Shape = new Shape(); /** @private root timeline on which all time-based tweens/timelines are initially placed (_rootFramesTimeline is for frames-based tweens/timelines where useFrames:true is defined in the constructor's vars parameter). **/ public static var _rootTimeline:SimpleTimeline; /** @private root timeline on which all frames-based tweens/timelines are initially placed (_rootTimeline is for time-based tweens/timelines). A frames-based animation is one that has useFrames:true defined in the constructor's vars parameter or it is placed into a parent timeline that is frames-based (the parent timeline always defines the timing mode). **/ public static var _rootFramesTimeline:SimpleTimeline; /** @private Each time the root timelines are updated, _rootFrame is incremented in order to keep track of how many frames have been rendered. **/ protected static var _rootFrame:Number = -1; /** @private We reuse this event instance for better memory management rather than recreating a new instance on every frame. **/ protected static var _tickEvent:Event = new Event(""tick""); /** @private **/ protected static var _tinyNum:Number = 0.0000000001; /** @private The onUpdate callback (if one is defined). Checking an instance property is faster than looking it up in the vars object on every render. This is purely a speed optimization **/ protected var _onUpdate:Function; /** @private Delay in seconds (or frames for frames-based tweens/timelines) **/ public var _delay:Number; /** @private Primarily used for zero-duration tweens to determine the direction/momentum of time in its parent timeline which controls whether the starting or ending values should be rendered. See the render() method for usage (which is slightly different in tweens versus timelines) **/ public var _rawPrevTime:Number; /** @private Indicates whether or not the tween is currently active (typically when the parent timeline's playhead is between the start and end time of this animation). Makes conditional logic faster in the rendering queue of the parent timeline because if a tween is active, it'll always get rendered and we can flip _acitve to false when it completes. **/ public var _active:Boolean; /** @private Flagged for garbage collection (indicates the tween has been disabled, but keep in mind that a tween can be re-enabled later too!) **/ public var _gc:Boolean; /** @private Indicates whether or not the animation has been initialized (for tweens, this is when all the tweening properties get analyzed and their start/end values recorded, etc.) **/ public var _initted:Boolean; /** @private The time at which the animation begins, according to its parent timeline's time. For example, if the tween starts at exactly 3 seconds into the timeline on which it is placed, startTime would be 3. **/ public var _startTime:Number; /** @private The local position of the playhead (essentially the current time). If the animation has a non-zero repeat (only available on TweenMax and TimelineMax instances), its time goes back to zero upon repeating even though the totalTime continues forward linearly (or if it yoyo is true, the time alternates between moving forward and backward). time never exceeds the duration whereas the totalTime reflects the overall time including any repeats and repeatDelays. For example, if a TweenMax instance has a duration of 2 and a repeat of 3, totalTime will go from 0 to 8 during the course of the tween (plays once then repeats 3 times, making 4 total cycles) whereas time will go from 0 to 2 a total of 4 times. **/ public var _time:Number; /** @private The overall position of the playhead including any repeats and repeatDelays (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has a duration of 2 and a repeat of 3, totalTime will go from 0 to 8 during the course of the tween (plays once then repeats 3 times, making 4 total cycles) whereas time will go from 0 to 2 a total of 4 times. **/ public var _totalTime:Number; /** @private Duration of the animation, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has a duration of 2 and a repeat of 3, its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles). **/ public var _duration:Number; /** @private Total duration of the animation including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has a duration of 2 and a repeat of 3, its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles). **/ public var _totalDuration:Number; /** @private Records the parent timeline's rawTime when the animation is paused (so that we can place it at the appropriate time when it is unpaused). NaN when the animation isn't paused. **/ public var _pauseTime:Number; /** @private Factor that's used to scale the time in the animation where 1 = normal speed, 0.5 = half speed, 2 = double speed, etc. For example, if a tween's duration is 2 but its timeScale is 0.5, it will take 4 seconds to finish. If you nest that tween in a TimelineLite that has a timeScale of 0.5 as well, it will take 8 seconds to finish. You can even tween another tween's (or timeline's) timeScale to gradually slow it down or speed it up. **/ public var _timeScale:Number; /** @private Indicates whether or not the animation is reversed. **/ public var _reversed:Boolean; /** @private The most recent parent timeline (only null for the _rootTimeline and _rootFramesTimeline). The timeline property (no ""_"" prefix) is null whenever the animation is removed from its parent timeline. We use this internally in slightly different ways. We need to always maintain a reference to the last parent timeline so that if the animation is re-enabled, we know where to put it. ""_gc"" is different in that a Animation could be eligible for gc yet not removed from its timeline, like when a TimelineLite completes for example. It makes things much faster to enable again if/when necessary, like if the TimelineLite gets restarted. **/ public var _timeline:SimpleTimeline; /** @private If true, the _duration or _totalDuration may need refreshing. For example, if a TimelineLite's child had a change in duration or startTime, it could affect the parent timeline's duration but we don't want to always make the update immediately because there may be many more changes made before the timeline actually need to be rendered again, so this helps improve performance. If the _dirty is false, we can skip the method call and quickly read from the _duration and/or _totalDuration. **/ public var _dirty:Boolean; /** @private Provides a quick way to check whether or not a animation is currently paused (skipping the paused() method call). **/ public var _paused:Boolean; /** @private Next Animation in the linked list. **/ public var _next:Animation; /** @private Previous Animation in the linked list. **/ public var _prev:Animation; /** The vars object passed into the constructor which stores configuration variables like onComplete, onUpdate, etc. as well as tweening properties like opacity, x, y or whatever. **/ public var vars:Object; /** [Read-only] Parent timeline. Every animation is placed onto a timeline (the root timeline by default) and can only have one parent. An instance cannot exist in multiple timelines at once. **/ public var timeline:SimpleTimeline; /** A place to store any data you want (initially populated with vars.data if it exists). **/ public var data:*; /** * Constructor * * @param duration duration in seconds (or frames for frames-based tweens) * @param vars configuration variables (for example, {x:100, y:0, opacity:0.5, onComplete:myFunction}) */ public function Animation(duration:Number=0, vars:Object=null) { this.vars = vars || {}; if (this.vars._isGSVars) { this.vars = this.vars.vars; } _duration = _totalDuration = duration || 0; _delay = Number(this.vars.delay) || 0; _timeScale = 1; _totalTime = _time = 0; data = this.vars.data; _rawPrevTime = -1; if (_rootTimeline == null) { if (_rootFrame == -1) { _rootFrame = 0; _rootFramesTimeline = new SimpleTimeline(); _rootTimeline = new SimpleTimeline(); _rootTimeline._startTime = getTimer() / 1000; _rootFramesTimeline._startTime = 0; _rootTimeline._active = _rootFramesTimeline._active = true; ticker.addEventListener(""enterFrame"", _updateRoot, false, 0, true); } else { return; } } var tl:SimpleTimeline = (this.vars.useFrames) ? _rootFramesTimeline : _rootTimeline; tl.add(this, tl._time); _reversed = (this.vars.reversed == true); if (this.vars.paused) { paused(true); } } /** * Begins playing forward, optionally from a specific time (by default playback begins from * wherever the playhead currently is). This also ensures that the instance is neither paused * nor reversed. * *

If you define a ""from"" time (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //begins playing from wherever the playhead currently is: myAnimation.play(); //begins playing from exactly 2-seconds into the animation: myAnimation.play(2); //begins playing from exactly 2-seconds into the animation but doesn't suppress events during the initial move: myAnimation.play(2, false); * * @param from The time (or label for TimelineLite/TimelineMax instances) from which the animation should begin playing (if none is defined, it will begin playing from wherever the playhead currently is). * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter. * @return self (makes chaining easier) */ public function play(from:*=null, suppressEvents:Boolean=true):* { if (from != null) { seek(from, suppressEvents); } reversed(false); return paused(false); } /** * Pauses the instance, optionally jumping to a specific time. * *

If you define a time to jump to (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //pauses wherever the playhead currently is: myAnimation.pause(); //jumps to exactly 2-seconds into the animation and then pauses: myAnimation.pause(2); //jumps to exactly 2-seconds into the animation and pauses but doesn't suppress events during the initial move: myAnimation.pause(2, false); * * @param atTime The time (or label for TimelineLite/TimelineMax instances) that the instance should jump to before pausing (if none is defined, it will pause wherever the playhead is currently located). * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the atTime parameter. * @return self (makes chaining easier) */ public function pause(atTime:*=null, suppressEvents:Boolean=true):* { if (atTime != null) { seek(atTime, suppressEvents); } return paused(true); } /** * Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. * *

If you define a time to jump to (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //resumes from wherever the playhead currently is: myAnimation.resume(); //jumps to exactly 2-seconds into the animation and then resumes playback: myAnimation.resume(2); //jumps to exactly 2-seconds into the animation and resumes playbck but doesn't suppress events during the initial move: myAnimation.resume(2, false); * * @param from The time (or label for TimelineLite/TimelineMax instances) that the instance should jump to before resuming playback (if none is defined, it will resume wherever the playhead is currently located). * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter. * @return self (makes chaining easier) */ public function resume(from:*=null, suppressEvents:Boolean=true):* { if (from != null) { seek(from, suppressEvents); } return paused(false); } /** * Jumps to a specific time without affecting whether or not the instance is paused or reversed. * *

If there are any events/callbacks inbetween where the playhead was and the new time, * they will not be triggered because by default suppressEvents (the 2nd parameter) * is true. Think of it like picking the needle up on a record player and moving it * to a new position before placing it back on the record. If, however, you do not want the * events/callbacks suppressed during that initial move, simply set the suppressEvents * parameter to false.

* * //jumps to exactly 2 seconds myAnimation.seek(2); //jumps to exactly 2 seconds but doesn't suppress events during the initial move: myAnimation.seek(2, false); * * @param time The time (or label for TimelineLite/TimelineMax instances) to go to. * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. * @return self (makes chaining easier) */ public function seek(time:*, suppressEvents:Boolean=true):* { return totalTime(Number(time), suppressEvents); } /** * Restarts and begins playing forward from the beginning. * * //restarts, not including any delay that was defined myAnimation.restart(); //restarts, including any delay, and doesn't suppress events during the initial move back to time:0 myAnimation.restart(true, false); * * @param includeDelay Determines whether or not the delay (if any) is honored when restarting. For example, if a tween has a delay of 1 second, like new TweenLite(mc, 2, {x:100, delay:1}); and then later restart() is called, it will begin immediately, but restart(true) will cause the delay to be honored so that it won't begin for another 1 second. * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. * @return self (makes chaining easier) */ public function restart(includeDelay:Boolean=false, suppressEvents:Boolean=true):* { reversed(false); paused(false); return totalTime((includeDelay ? -_delay : 0), suppressEvents, true); } /** * Reverses playback so that all aspects of the animation are oriented backwards including, for example, * a tween's ease. This will cause the instance's time and totalTime to move * back towards zero as well. You can optionally define a specific time to jump to before reversing * (by default it begins playing in reverse from wherever the playhead currently is). * Calling reverse() also ensures that the instance is neither paused nor reversed. * *

To jump to the very end of the animation and play in reverse from there, use 0 as the * ""from"" parameter, like reverse(0).

* *

To check whether or not the instance is reversed, use the reversed() method, like * if (myAnimation.reversed()) {...}

* *

If you define a ""from"" time (the first parameter, which could also be a label for TimelineLite * or TimelineMax instances), the playhead moves there immediately and if there are any * events/callbacks inbetween where the playhead was and the new time, they will not be triggered * because by default suppressEvents (the 2nd parameter) is true. * Think of it like picking the needle up on a record player and moving it to a new position * before placing it back on the record. If, however, you do not want the events/callbacks suppressed * during that initial move, simply set the suppressEvents parameter to false.

* * //reverses playback from wherever the playhead currently is: myAnimation.reverse(); //reverses playback from exactly 2 seconds into the animation: myAnimation.reverse(2); //reverses playback from exactly 2 seconds into the animation but doesn't suppress events during the initial move: myAnimation.reverse(2, false); //reverses playback from the very END of the animation: myAnimation.reverse(0); //reverses playback starting from exactly 1 second before the end of the animation: myAnimation.reverse(-1); //flips the orientation (if it's forward, it will go backward, if it is backward, it will go forward): if (myAnimation.reversed()) { myAnimation.play(); } else { myAnimation.reverse(); } //flips the orientation using the reversed() method instead (shorter version of the code above): myAnimation.reversed( !myAnimation.reversed() ); * * @param from The time (or label for TimelineLite/TimelineMax instances) from which the animation should begin playing in reverse (if none is defined, it will begin playing from wherever the playhead currently is). To begin at the very end of the animation, use 0. Negative numbers are relative to the end of the animation, so -1 would be 1 second from the end. * @param suppressEvents If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter. * @return self (makes chaining easier) */ public function reverse(from:*=null, suppressEvents:Boolean=true):* { if (from != null) { seek((from || totalDuration()), suppressEvents); } reversed(true); return paused(false); } /** * @private * Renders the animation at a particular time (or frame number for frames-based tweens). * The time is based simply on the overall duration. For example, if an animations's duration * is 3, render(1.5) would render it as halfway finished. * * @param time time (or frame number for frames-based animations) to render. If a negative value is used, it will act like 0. If the value exceeds the totalDuration, it will act like the totalDuration. * @param suppressEvents If true, no events or callbacks will be triggered for this render (like onComplete, onUpdate, onReverseComplete, etc.) * @param force Normally the animation will skip rendering if the time matches the _totalTime (to improve performance), but if force is true, it forces a render. This is primarily used internally for tweens with durations of zero in TimelineLite/Max instances. */ public function render(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void { } /** * Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, * you want to restart a tween without reverting to any previously recorded starting values. When you invalidate() * an animation, it will be re-initialized the next time it renders and its vars object will be re-parsed. * The timing of the animation (duration, startTime, delay) will not be affected. * *

Another example would be if you have a TweenMax(mc, 1, {x:100, y:100}) that ran when mc.x and mc.y * were initially at 0, but now mc.x and mc.y are 200 and you want them tween to 100 again, you could simply * invalidate() the tween and restart() it. Without invalidating first, restarting it * would cause the values jump back to 0 immediately (where they started when the tween originally began). * When you invalidate a TimelineLite/TimelineMax, it automatically invalidates all of its children.

* @return self (makes chaining easier) **/ public function invalidate():* { return this; } /** * Indicates whether or not the animation is currently active (meaning the virtual playhead is actively moving across * this instance's time span and it is not paused, nor are any of its ancestor timelines). * So for example, if a tween is in the middle of tweening, it's active, but after it is finished (or before * it begins), it is not active. If it is paused or if it is placed inside of a timeline that's paused * (or if any of its ancestor timelines are paused), isActive() will return false. If the * playhead is directly on top of the animation's start time (even if it hasn't rendered quite yet), that counts * as ""active"". * *

You may also check the progress() or totalProgress(), but those don't take into consideration * the paused state or the position of the parent timeline's playhead.

* * @see #progress() * @see #totalProgress() **/ public function isActive():Boolean { var tl:SimpleTimeline = _timeline, //the 2 root timelines won't have a _timeline; they're always active. rawTime:Number; return ((tl == null) || (!_gc && !_paused && tl.isActive() && (rawTime = tl.rawTime()) >= _startTime && rawTime < _startTime + totalDuration() / _timeScale)); } /** * @private * If an animation is enabled, it is eligible to be rendered (unless it is paused). Disabling it * essentially removes it from its parent timeline and stops protecting it from garbage collection. * * @param enabled Enabled state of the animation * @param ignoreTimeline By default, the tween/timeline will remove itself from its parent timeline when it is disabled and add itself when it is enabled, but this parameter allows you to skip that behavior. * @return Boolean value indicating whether or not important properties may have changed when the animation was enabled/disabled. For example, when a MotionBlurPlugin is disabled, it swaps out a BitmapData for the target and may alter the opacity. We need to know this in order to determine whether or not a new tween that is overwriting this one should be re-initialized with the changed properties. **/ public function _enabled(enabled:Boolean, ignoreTimeline:Boolean=false):Boolean { _gc = !enabled; //note: it is possible for _gc to be true and timeline not to be null in situations where a parent TimelineLite/Max has completed and is removed - the developer might hold a reference to that timeline and later restart() it or something. _active = Boolean(enabled && !_paused && _totalTime > 0 && _totalTime < _totalDuration); if (!ignoreTimeline) { if (enabled && timeline == null) { _timeline.add(this, _startTime - _delay); } else if (!enabled && timeline != null) { _timeline._remove(this, true); } } return false; } /** @private Same as kill() except that it returns a Boolean that indicates whether or not important properties may have changed when the animation was killed. For example, when a MotionBlurPlugin is disabled, it swaps out a BitmapData for the target and may alter the opacity. We need to know this in order to determine whether or not a new tween that is overwriting this one should be re-initialized with the changed properties. **/ public function _kill(vars:Object=null, target:Object=null):Boolean { return _enabled(false, false); } /** * Kills the animation entirely or in part depending on the parameters. Simply calling kill() * (omitting the parameters) will immediately stop the animation and release it for garbage collection. * To kill only particular tweening properties of the animation, use the first parameter which should * be a generic object with enumerable properties corresponding to those that should be killed, * like {x:true, y:true}. The second parameter allows you to define a target * (or array of targets) to affect. * *

Note: the values assigned to each property of the vars parameter object don't * matter - the sole purpose of the object is for iteration over the named properties. In other * words, {x:true, y:true} would produce the same results as {x:false, y:false}.

* * //kill the entire animation: myAnimation.kill(); //kill only the ""x"" and ""y"" properties of the animation (all targets): myAnimation.kill({x:true, y:true}); //kill all parts of the animation related to the target ""myObject"" (if the tween has multiple targets, the others will not be affected): myAnimation.kill(null, myObject); //kill only the ""x"" and ""y"" properties of animations of the target ""myObject"": myAnimation.kill({x:true, y:true}, myObject); //kill only the ""opacity"" properties of animations of the targets ""myObject1"" and ""myObject2"": myAnimation.kill({opacity:true}, [myObject1, myObject2]); * * @param vars To kill only specific properties, use a generic object containing enumerable properties corresponding to the ones that should be killed, like {x:true, y:true}. The values assigned to each property of the object don't matter - the sole purpose of the object is for iteration over the named properties (in this case, x and y). If no object (or null) is defined, ALL properties will be killed. * @param target To kill only aspects of the animation related to a particular target (or targets), reference it here. For example, to kill only parts having to do with myObject, do kill(null, myObject) or to kill only parts having to do with myObject1 and myObject2, do kill(null, [myObject1, myObject2]). If no target is defined, ALL targets will be affected. * @return self (makes chaining easier) **/ public function kill(vars:Object=null, target:Object=null):* { _kill(vars, target); return this; } /** * @private * Sets the _dirty property of all anscestor timelines (and optionally this instance too). Setting * the _dirty property to true forces any necessary recalculation of its _duration and * _totalDuration properties and sorts the affected timelines' children animations so that they're in the proper order * next time the duration or totalDuration is requested. We don't just recalculate them * immediately because it can be much faster to do it this way. * * @param includeSelf indicates whether or not this tween's _dirty property should be affected. * @return self (makes chaining easier) */ protected function _uncache(includeSelf:Boolean):* { var tween:Animation = includeSelf ? this : timeline; while (tween) { tween._dirty = true; tween = tween.timeline; } return this; } /** @private This method gets called on every frame and is responsible for rendering/updating the root timelines. If you want to unhook the engine from its ticker, you could do Animation.ticker.removeEventListener(""enterFrame"", _updateRoot) and then call it yourself whenever you want to update. **/ public static function _updateRoot(event:Event=null):void { _rootFrame++; _rootTimeline.render((getTimer() / 1000 - _rootTimeline._startTime) * _rootTimeline._timeScale, false, false); _rootFramesTimeline.render((_rootFrame - _rootFramesTimeline._startTime) * _rootFramesTimeline._timeScale, false, false); ticker.dispatchEvent(_tickEvent); } /** @private **/ protected function _swapSelfInParams(params:Array):Array { var i:int = params.length, copy:Array = params.concat(); while (--i > -1) { if (params[i] === ""{self}"") { copy[i] = this; } } return copy; } //---- GETTERS / SETTERS ------------------------------------------------------------ /** * Gets or sets an event callback like ""onComplete"", ""onUpdate"", ""onStart"", ""onReverseComplete"" * or ""onRepeat"" (onRepeat only applies to TweenMax or TimelineMax instances) * along with any parameters that should be passed to that callback. This is the same as defining * the values directly in the constructor's vars parameter initially, so the following * two lines are functionally equivalent: * * //the following two lines produce IDENTICAL results: var myAnimation = new TweenLite(mc, 1, {x:100, onComplete:myFunction, onCompleteParams:[""param1"",""param2""]}); myAnimation.eventCallback(""onComplete"", myFunction, [""param1"",""param2""]); *

The benefit of using eventCallback() is that it allows you to set callbacks * even after the animation instance has been created and it also allows you to inspect the * callback references or even delete them on-the-fly (use null to delete the * event callback).

* * //deletes the onUpdate myAnimation.eventCallback(""onUpdate"", null); * *

IMPORTANT:Animation instances can only have one callback associated with each * event type (one onComplete, one onUpdate, one onStart, etc.). * So setting a new value will overwrite the old one. All of the values populate the vars * object too which was originally passed into the constructor (think of that like a storage place for * configuration data).

* *

This method serves as both a getter and setter. Omitting all but the first parameter returns * the current value (getter), whereas defining more than the first parameter sets the value (setter) * and returns the instance itself for easier chaining, like * myAnimation.eventCallback(""onComplete"", completeHandler).eventCallback(""onUpdate"", updateHandler, [""param1"",""{self}""]).play(1);

* * var currentOnComplete = myAnimation.eventCallback(""onComplete""); //gets current onComplete myAnimation.eventCallback(""onComplete"", myFunction); //sets the onComplete * *

JavaScript and AS2 note: - Due to the way JavaScript and AS2 don't * maintain scope (what ""this"" refers to, or the context) in function calls, * it can be useful to define the scope specifically. Therefore, in the JavaScript and AS2 * versions accept an extra (4th) parameter for scope.

* * @param type The type of event callback, like ""onComplete"", ""onUpdate"", ""onStart"" or ""onRepeat"". This is case-sensitive. * @param callback The function that should be called when the event occurs. * @param params An array of parameters to pass the callback. Use ""{self}"" to refer to the animation instance itself. Example: [""param1"",""{self}""] * @return Omitting the all but the first parameter returns the current value (getter), whereas defining more than the first parameter sets the callback (setter) and returns the instance itself for easier chaining. */ public function eventCallback(type:String, callback:Function=null, params:Array=null):* { if (type == null) { return null; } else if (type.substr(0,2) == ""on"") { if (arguments.length == 1) { return vars[type]; } if (callback == null) { delete vars[type]; } else { vars[type] = callback; vars[type + ""Params""] = ((params is Array) && params.join("""").indexOf(""{self}"") !== -1) ? _swapSelfInParams(params) : params; } if (type == ""onUpdate"") { _onUpdate = callback; } } return this; } /** * Gets or sets the animation's initial delay which is the length of time in seconds * (or frames for frames-based tweens) before the animation should begin. * A tween's starting values are not recorded until after the delay has expired (except in * from() tweens which render immediately by default unless immediateRender:false * is set in the vars parameter). An animation's delay is unaffected * by its timeScale, so if you were to change timeScale from 1 to 10, * for example, it wouldn't cause the delay to grow tenfold. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.delay(2).timeScale(0.5).play(1);

* * var currentDelay = myAnimation.delay(); //gets current delay myAnimation.delay(2); //sets delay * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. **/ public function delay(value:Number=NaN):* { if (!arguments.length) { return _delay; } if (_timeline.smoothChildTiming) { startTime( _startTime + value - _delay ); } _delay = value; return this; } /** * Gets or sets the animation's duration, not including any repeats or repeatDelays * (which are only available in TweenMax and TimelineMax). For example, if a TweenMax instance has * a duration of 2 and a repeat of 3, its totalDuration * would be 8 (one standard play plus 3 repeats equals 4 total cycles). * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.duration(2).delay(0.5).play(1);

* * var currentDuration = myAnimation.duration(); //gets current duration myAnimation.duration(2); //sets duration * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #totalDuration() * @see #timeScale() **/ public function duration(value:Number=NaN):* { if (!arguments.length) { _dirty = false; return _duration; } _duration = _totalDuration = value; _uncache(true); //true in case it's a TweenMax or TimelineMax that has a repeat - we'll need to refresh the totalDuration. if (_timeline.smoothChildTiming) if (_time > 0) if (_time < _duration) if (value != 0) { totalTime(_totalTime * (value / _duration), true); } return this; } /** * Gets or sets the animation's total duration including * any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). * For example, if a TweenMax instance has a duration of 2 and a repeat of 3, * its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles). * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.totalDuration(2).delay(0.5).play(1);

* * var ctd = myAnimation.totalDuration(); //gets current total duration myAnimation.totalDuration(2); //sets total duration * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #duration() * @see #timeScale() **/ public function totalDuration(value:Number=NaN):* { _dirty = false; return (!arguments.length) ? _totalDuration : duration(value); } /** * Gets or sets the local position of the playhead (essentially the current time), * described in seconds (or frames for frames-based animations) which * will never be less than 0 or greater than the animation's duration. * For example, if the duration is 10 and you were to watch the * time during the course of the animation, you'd see it go from 0 * at the beginning to 10 at the end. Setting time to 5 would cause the * animation to jump to its midway point (because it's half of the duration). * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* * var currentTime = myAnimation.time(); //gets current time myAnimation.time(2); //sets time, jumping to new value just like seek(). * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. Negative values will be interpreted from the END of the animation. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position defined in the value parameter. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #seek() * @see #play() * @see #reverse() * @see #pause() * @see #totalTime() **/ public function time(value:Number=NaN, suppressEvents:Boolean=false):* { if (!arguments.length) { return _time; } if (_dirty) { totalDuration(); } if (value > _duration) { value = _duration; } return totalTime(value, suppressEvents); } /** * Gets or sets the position of the playhead according to the totalDuration * which includes any repeats and repeatDelays (only available * in TweenMax and TimelineMax). For example, if a TweenMax instance has a * duration of 2 and a repeat of 3, totalTime * will go from 0 to 8 during the course of the tween (plays once then repeats 3 times, * making 4 total cycles) whereas time will go from 0 to 2 a total of 4 times. * If you added a repeatDelay of 1, that would make the totalTime * go from 0 to 11 over the course of the tween. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* *

totalTime will never exceed the totalDuration, nor will it be * less than 0 (values will be clipped appropriately). Negative values will be interpreted from * the END of the animation. For example, -2 would be 2 seconds before the end. If the * animation's totalDuration is 6 and you do myAnimation.totalTime(-2), * it will jump to a totalTime of 4.

* * var tt = myAnimation.totalTime(); //gets total time myAnimation.totalTime(2); //sets total time, jumping to new value just like seek(). * * @param time Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. Negative values will be interpreted from the END of the animation. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. * @param uncapped By default, the time will be capped at totalDuration and if a negative number is used, it will be measured from the END of the animation, but if uncapped is true, the time won't be adjusted at all (negatives will be allowed, as will values that exceed totalDuration). * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #time() * @see #seek() * @see #play() * @see #reverse() * @see #pause() **/ public function totalTime(time:Number=NaN, suppressEvents:Boolean=false, uncapped:Boolean=false):* { if (!arguments.length) { return _totalTime; } if (_timeline) { if (time < 0 && !uncapped) { time += totalDuration(); } if (_timeline.smoothChildTiming) { if (_dirty) { totalDuration(); } if (time > _totalDuration && !uncapped) { time = _totalDuration; } var tl:SimpleTimeline = _timeline; _startTime = (_paused ? _pauseTime : tl._time) - ((!_reversed ? time : _totalDuration - time) / _timeScale); if (!_timeline._dirty) { //for performance improvement. If the parent's cache is already dirty, it already took care of marking the anscestors as dirty too, so skip the function call here. _uncache(false); } //in case any of the ancestor timelines had completed but should now be enabled, we should reset their totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The startTime of that child would get pushed out, but one of the ancestors may have completed. if (tl._timeline != null) { while (tl._timeline) { if (tl._timeline._time !== (tl._startTime + tl._totalTime) / tl._timeScale) { tl.totalTime(tl._totalTime, true); } tl = tl._timeline; } } } if (_gc) { _enabled(true, false); } if (_totalTime != time || _duration === 0) { render(time, suppressEvents, false); } } return this; } /** * Gets or sets the animations's progress which is a value between 0 and 1 indicating the position * of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, * and 1 is at the end (complete). If the animation has a non-zero repeat defined (only available in TweenMax and TimelineMax), * progress() and totalProgress() will be different because progress() doesn't include the * repeat or repeatDelay whereas totalProgress() does. For example, if a TimelineMax instance * is set to repeat once, at the end of the first cycle totalProgress() would only be 0.5 * whereas progress() would be 1. If you watched both properties over the course of the entire * animation, you'd see progress() go from 0 to 1 twice (once for each cycle) in the * same time it takes the totalProgress() to go from 0 to 1 once. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.progress(0.5).play();

* * var progress = myAnimation.progress(); //gets current progress myAnimation.progress(0.25); //sets progress to one quarter finished * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #seek() * @see #time() * @see #totalTime() * @see #totalProgress() **/ public function progress(value:Number=NaN, suppressEvents:Boolean=false):* { return (!arguments.length) ? _time / duration() : totalTime(duration() * value, suppressEvents); } /** * Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position * of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is * at the halfway point, and 1 is at the end (complete). If the animation has a non-zero repeat defined (only available in TweenMax and TimelineMax), * progress() and totalProgress() will be different because progress() * doesn't include the repeat or repeatDelay whereas totalProgress() does. For example, * if a TimelineMax instance is set to repeat once, at the end of the first cycle totalProgress() * would only be 0.5 whereas progress would be 1. If you watched both properties over the * course of the entire animation, you'd see progress go from 0 to 1 twice (once for * each cycle) in the same time it takes the totalProgress() to go from 0 to 1 once. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.totalProgress(0.5).play();

* * var progress = myAnimation.totalProgress(); //gets total progress myAnimation.totalProgress(0.25); //sets total progress to one quarter finished * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @param suppressEvents If true, no events or callbacks will be triggered when the playhead moves to the new position. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #progress() * @see #seek() * @see #time() * @see #totalTime() **/ public function totalProgress(value:Number=NaN, suppressEvents:Boolean=false):* { return (!arguments.length) ? _time / duration() : totalTime(duration() * value, suppressEvents); } /** * Gets or sets the time at which the animation begins on its parent timeline (after any delay * that was defined). For example, if a tween starts at exactly 3 seconds into the timeline * on which it is placed, the tween's startTime would be 3. * *

The startTime may be automatically adjusted to make the timing appear * seamless if the parent timeline's smoothChildTiming property is true * and a timing-dependent change is made on-the-fly, like reverse() is called or * timeScale() is changed, etc. See the documentation for the smoothChildTiming * property of timelines for more details.

* *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* * var start = myAnimation.startTime(); //gets current start time myAnimation.startTime(2); //sets the start time * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. **/ public function startTime(value:Number=NaN):* { if (!arguments.length) { return _startTime; } if (value != _startTime) { _startTime = value; if (timeline) if (timeline._sortChildren) { timeline.add(this, value - _delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct. } } return this; } /** * Factor that's used to scale time in the animation where 1 = normal speed (the default), * 0.5 = half speed, 2 = double speed, etc. For example, if an animation's duration * is 2 but its timeScale is 0.5, it will take 4 seconds to finish. If you nest that * animation in a timeline whose timeScale is 0.5 as well, it would take 8 seconds * to finish. You can even tween the timeScale to gradually slow it down or speed it up. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.timeScale(2).play(1);

* * var currentTimeScale = myAnimation.timeScale(); //gets current timeScale myAnimation.timeScale( 0.5 ); //sets timeScale to half-speed * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #duration() **/ public function timeScale(value:Number=NaN):* { if (!arguments.length) { return _timeScale; } value = value || 0.000001; //can't allow zero because it'll throw the math off if (_timeline && _timeline.smoothChildTiming) { var t:Number = (_pauseTime || _pauseTime == 0) ? _pauseTime : _timeline._totalTime; _startTime = t - ((t - _startTime) * _timeScale / value); } _timeScale = value; return _uncache(false); } /** * Gets or sets the animation's reversed state which indicates whether or not the animation * should be played backwards. This value is not affected by yoyo repeats * (TweenMax and TimelineMax only) and it does not take into account the reversed state of * anscestor timelines. So for example, a tween that is not reversed might appear reversed * if its parent timeline (or any ancenstor timeline) is reversed. * *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining.

* * var rev = myAnimation.reversed(); //gets current orientation myAnimation.reversed( true ); //sets the orientation to reversed myAnimation.reversed( !myAnimation.reversed() ); //toggles the orientation * * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #reverse() * @see #play() **/ public function reversed(value:Boolean=false):* { if (!arguments.length) { return _reversed; } if (value != _reversed) { _reversed = value; totalTime(((_timeline && !_timeline.smoothChildTiming) ? totalDuration() - _totalTime : _totalTime), true); } return this; } /** * Gets or sets the animation's paused state which indicates whether or not the animation * is currently paused. This does not take into account anscestor timelines. So for example, * a tween that is not paused might appear paused if its parent timeline (or any ancenstor * timeline) is paused. Pausing an animation doesn't remove it from its parent timeline, * but it does cause it not to be factored into the parent timeline's * duration/totalDuration. When an animation completes, it does * NOT alter its paused state. * *

In most cases, it is easiest to use the pause() method to pause * the animation, and resume() to resume it. But to check the current * state, you must use the paused() method. It can also be useful for * toggling like myAnimation.paused( !myAnimation.paused() );

* *

You can set the paused state initially by passing paused:true * in the vars parameter.

* *

This method serves as both a getter and setter. Omitting the parameter returns the current * value (getter), whereas defining the parameter sets the value (setter) and returns the instance * itself for easier chaining, like myAnimation.paused(true).delay(2).timeScale(0.5);

* * var paused = myAnimation.paused(); //gets current paused state myAnimation.paused( true ); //sets paused state to true (just like pause()) myAnimation.paused( !myAnimation.paused() ); //toggles the paused state * @param value Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * @return Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining. * * @see #pause() * @see #resume() * @see #play() **/ public function paused(value:Boolean=false):* { if (!arguments.length) { return _paused; } if (value != _paused) if (_timeline) { var raw:Number = _timeline.rawTime(), elapsed:Number = raw - _pauseTime; if (!value && _timeline.smoothChildTiming) { _startTime += elapsed; _uncache(false); } _pauseTime = value ? raw : NaN; _paused = value; _active = (!value && _totalTime > 0 && _totalTime < _totalDuration); if (!value && elapsed != 0 && _initted && duration() !== 0) { render((_timeline.smoothChildTiming ? _totalTime : (raw - _startTime) / _timeScale), true, true); //in case the target's properties changed via some other tween or manual update by the user, we should force a render. } } if (_gc && !value) { _enabled(true, false); } return this; } public function destruct():void { kill(); } public function get isDestructed():Boolean { return _gc; } } }",16257,True,3305.9263606950303,median "CLASS zcl_abapgit_objects_program DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super. PUBLIC SECTION. TYPES: BEGIN OF ty_progdir, name TYPE progdir-name, state TYPE progdir-state, sqlx TYPE progdir-sqlx, edtx TYPE progdir-edtx, varcl TYPE progdir-varcl, dbapl TYPE progdir-dbapl, dbna TYPE progdir-dbna, clas TYPE progdir-clas, type TYPE progdir-type, occurs TYPE progdir-occurs, subc TYPE progdir-subc, appl TYPE progdir-appl, secu TYPE progdir-secu, cnam TYPE progdir-cnam, cdat TYPE progdir-cdat, unam TYPE progdir-unam, udat TYPE progdir-udat, vern TYPE progdir-vern, levl TYPE progdir-levl, rstat TYPE progdir-rstat, rmand TYPE progdir-rmand, rload TYPE progdir-rload, fixpt TYPE progdir-fixpt, sset TYPE progdir-sset, sdate TYPE progdir-sdate, stime TYPE progdir-stime, idate TYPE progdir-idate, itime TYPE progdir-itime, ldbname TYPE progdir-ldbname, uccheck TYPE progdir-uccheck, END OF ty_progdir. METHODS serialize_program IMPORTING io_xml TYPE REF TO zcl_abapgit_xml_output OPTIONAL is_item TYPE zif_abapgit_definitions=>ty_item io_files TYPE REF TO zcl_abapgit_objects_files iv_program TYPE programm OPTIONAL iv_extra TYPE clike OPTIONAL RAISING zcx_abapgit_exception. METHODS read_progdir IMPORTING iv_program TYPE programm RETURNING VALUE(rs_progdir) TYPE ty_progdir. METHODS deserialize_program IMPORTING is_progdir TYPE ty_progdir it_source TYPE abaptxt255_tab it_tpool TYPE textpool_table iv_package TYPE devclass RAISING zcx_abapgit_exception. PROTECTED SECTION. TYPES: ty_spaces_tt TYPE STANDARD TABLE OF i WITH DEFAULT KEY . TYPES: BEGIN OF ty_dynpro, header TYPE rpy_dyhead, containers TYPE dycatt_tab, fields TYPE dyfatc_tab, flow_logic TYPE swydyflow, spaces TYPE ty_spaces_tt, END OF ty_dynpro . TYPES: ty_dynpro_tt TYPE STANDARD TABLE OF ty_dynpro WITH DEFAULT KEY . TYPES: BEGIN OF ty_cua, adm TYPE rsmpe_adm, sta TYPE STANDARD TABLE OF rsmpe_stat WITH DEFAULT KEY, fun TYPE STANDARD TABLE OF rsmpe_funt WITH DEFAULT KEY, men TYPE STANDARD TABLE OF rsmpe_men WITH DEFAULT KEY, mtx TYPE STANDARD TABLE OF rsmpe_mnlt WITH DEFAULT KEY, act TYPE STANDARD TABLE OF rsmpe_act WITH DEFAULT KEY, but TYPE STANDARD TABLE OF rsmpe_but WITH DEFAULT KEY, pfk TYPE STANDARD TABLE OF rsmpe_pfk WITH DEFAULT KEY, set TYPE STANDARD TABLE OF rsmpe_staf WITH DEFAULT KEY, doc TYPE STANDARD TABLE OF rsmpe_atrt WITH DEFAULT KEY, tit TYPE STANDARD TABLE OF rsmpe_titt WITH DEFAULT KEY, biv TYPE STANDARD TABLE OF rsmpe_buts WITH DEFAULT KEY, END OF ty_cua . METHODS serialize_dynpros IMPORTING !iv_program_name TYPE programm RETURNING VALUE(rt_dynpro) TYPE ty_dynpro_tt RAISING zcx_abapgit_exception . METHODS serialize_cua IMPORTING !iv_program_name TYPE programm RETURNING VALUE(rs_cua) TYPE ty_cua RAISING zcx_abapgit_exception . METHODS deserialize_dynpros IMPORTING !it_dynpros TYPE ty_dynpro_tt RAISING zcx_abapgit_exception . METHODS deserialize_textpool IMPORTING !iv_program TYPE programm !it_tpool TYPE textpool_table !iv_language TYPE langu OPTIONAL !iv_is_include TYPE abap_bool DEFAULT abap_false RAISING zcx_abapgit_exception . METHODS deserialize_cua IMPORTING !iv_program_name TYPE programm !is_cua TYPE ty_cua RAISING zcx_abapgit_exception . METHODS is_any_dynpro_locked IMPORTING !iv_program TYPE programm RETURNING VALUE(rv_is_any_dynpro_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS is_cua_locked IMPORTING !iv_program TYPE programm RETURNING VALUE(rv_is_cua_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS is_text_locked IMPORTING !iv_program TYPE programm RETURNING VALUE(rv_is_text_locked) TYPE abap_bool RAISING zcx_abapgit_exception . CLASS-METHODS add_tpool IMPORTING !it_tpool TYPE textpool_table RETURNING VALUE(rt_tpool) TYPE zif_abapgit_definitions=>ty_tpool_tt . CLASS-METHODS read_tpool IMPORTING !it_tpool TYPE zif_abapgit_definitions=>ty_tpool_tt RETURNING VALUE(rt_tpool) TYPE zif_abapgit_definitions=>ty_tpool_tt . PRIVATE SECTION. METHODS: uncondense_flow IMPORTING it_flow TYPE swydyflow it_spaces TYPE ty_spaces_tt RETURNING VALUE(rt_flow) TYPE swydyflow. CLASS-METHODS auto_correct_cua_adm IMPORTING is_cua TYPE ty_cua CHANGING cs_adm TYPE rsmpe_adm. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECTS_PROGRAM IMPLEMENTATION. METHOD add_tpool. FIELD-SYMBOLS: LIKE LINE OF it_tpool, LIKE LINE OF rt_tpool. LOOP AT it_tpool ASSIGNING . APPEND INITIAL LINE TO rt_tpool ASSIGNING . MOVE-CORRESPONDING TO . IF -id = 'S'. -split = -entry. -entry = -entry+8. ENDIF. ENDLOOP. ENDMETHOD. METHOD auto_correct_cua_adm. "" issue #1807 automatic correction of CUA interfaces saved incorrectly in the past (ADM was not saved in the XML) CONSTANTS: lc_num_n_space TYPE string VALUE ' 0123456789', lc_num_only TYPE string VALUE '0123456789'. FIELD-SYMBOLS: TYPE rsmpe_pfk, TYPE rsmpe_act, TYPE rsmpe_men. IF cs_adm IS NOT INITIAL AND ( cs_adm-actcode CO lc_num_n_space AND cs_adm-mencode CO lc_num_n_space AND cs_adm-pfkcode CO lc_num_n_space ). ""Check performed in form check_adm of include LSMPIF03 RETURN. ENDIF. LOOP AT is_cua-act ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO lc_num_only. cs_adm-actcode = -code. ENDIF. ENDLOOP. LOOP AT is_cua-men ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO lc_num_only. cs_adm-mencode = -code. ENDIF. ENDLOOP. LOOP AT is_cua-pfk ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO lc_num_only. cs_adm-pfkcode = -code. ENDIF. ENDLOOP. ENDMETHOD. METHOD deserialize_cua. DATA: ls_tr_key TYPE trkey, ls_adm TYPE rsmpe_adm. IF lines( is_cua-sta ) = 0 AND lines( is_cua-fun ) = 0 AND lines( is_cua-men ) = 0 AND lines( is_cua-mtx ) = 0 AND lines( is_cua-act ) = 0 AND lines( is_cua-but ) = 0 AND lines( is_cua-pfk ) = 0 AND lines( is_cua-set ) = 0 AND lines( is_cua-doc ) = 0 AND lines( is_cua-tit ) = 0 AND lines( is_cua-biv ) = 0. RETURN. ENDIF. SELECT SINGLE devclass INTO ls_tr_key-devclass FROM tadir WHERE pgmid = 'R3TR' AND object = ms_item-obj_type AND obj_name = ms_item-obj_name. ""#EC CI_GENBUFF IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'not found in tadir' ). ENDIF. ls_tr_key-obj_type = ms_item-obj_type. ls_tr_key-obj_name = ms_item-obj_name. ls_tr_key-sub_type = 'CUAD'. ls_tr_key-sub_name = iv_program_name. ls_adm = is_cua-adm. auto_correct_cua_adm( EXPORTING is_cua = is_cua CHANGING cs_adm = ls_adm ). sy-tcode = 'SE41' ##write_ok. "" evil hack, workaround to handle fixes in note 2159455 CALL FUNCTION 'RS_CUA_INTERNAL_WRITE' EXPORTING program = iv_program_name language = mv_language tr_key = ls_tr_key adm = ls_adm state = 'I' TABLES sta = is_cua-sta fun = is_cua-fun men = is_cua-men mtx = is_cua-mtx act = is_cua-act but = is_cua-but pfk = is_cua-pfk set = is_cua-set doc = is_cua-doc tit = is_cua-tit biv = is_cua-biv EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc <> 0. * if moving code from SAPlink, see https://github.com/larshp/abapGit/issues/562 zcx_abapgit_exception=>raise( |Error from RS_CUA_INTERNAL_WRITE. Subrc = { sy-subrc }| ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'CUAD' iv_name = iv_program_name ). ENDMETHOD. METHOD deserialize_dynpros. CONSTANTS lc_rpyty_force_off TYPE char01 VALUE '/' ##NO_TEXT. DATA: lv_name TYPE dwinactiv-obj_name, ls_dynpro LIKE LINE OF it_dynpros. FIELD-SYMBOLS: TYPE rpy_dyfatc. * ls_dynpro is changed by the function module, a field-symbol will cause * the program to dump since it_dynpros cannot be changed LOOP AT it_dynpros INTO ls_dynpro. "" todo: kept for compatibility, remove after grace period #3680 ls_dynpro-flow_logic = uncondense_flow( it_flow = ls_dynpro-flow_logic it_spaces = ls_dynpro-spaces ). LOOP AT ls_dynpro-fields ASSIGNING . * if the DDIC element has a PARAMETER_ID and the flag ""from_dict"" is active * the import will enable the SET-/GET_PARAM flag. In this case: ""force off"" IF -param_id IS NOT INITIAL AND -from_dict = abap_true. IF -set_param IS INITIAL. -set_param = lc_rpyty_force_off. ENDIF. IF -get_param IS INITIAL. -get_param = lc_rpyty_force_off. ENDIF. ENDIF. * If the previous conditions are met the value 'F' will be taken over * during de-serialization potentially overlapping other fields in the screen, * we set the tag to the correct value 'X' IF -type = 'CHECK' AND -from_dict = abap_true AND -text IS INITIAL AND -modific IS INITIAL. -modific = 'X'. ENDIF. ""fix for issue #2747: IF -foreignkey IS INITIAL. -foreignkey = lc_rpyty_force_off. ENDIF. ENDLOOP. CALL FUNCTION 'RPY_DYNPRO_INSERT' EXPORTING header = ls_dynpro-header suppress_exist_checks = abap_true TABLES containers = ls_dynpro-containers fields_to_containers = ls_dynpro-fields flow_logic = ls_dynpro-flow_logic EXCEPTIONS cancelled = 1 already_exists = 2 program_not_exists = 3 not_executed = 4 missing_required_field = 5 illegal_field_value = 6 field_not_allowed = 7 not_generated = 8 illegal_field_position = 9 OTHERS = 10. IF sy-subrc <> 2 AND sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. * todo, RPY_DYNPRO_UPDATE? CONCATENATE ls_dynpro-header-program ls_dynpro-header-screen INTO lv_name RESPECTING BLANKS. ASSERT NOT lv_name IS INITIAL. zcl_abapgit_objects_activation=>add( iv_type = 'DYNP' iv_name = lv_name ). ENDLOOP. ENDMETHOD. METHOD deserialize_program. DATA: lv_exists TYPE abap_bool, lv_progname TYPE reposrc-progname, ls_tpool LIKE LINE OF it_tpool, lv_title TYPE rglif-title, ls_progdir_new TYPE progdir. FIELD-SYMBOLS: TYPE any. CALL FUNCTION 'RS_CORR_INSERT' EXPORTING object = is_progdir-name object_class = 'ABAP' devclass = iv_package master_language = mv_language mode = 'I' suppress_dialog = abap_true EXCEPTIONS cancelled = 1 permission_failure = 2 unknown_objectclass = 3 OTHERS = 4. IF sy-subrc = 1. zcx_abapgit_exception=>raise( |Error from RS_CORR_INSERT, Cancelled, { sy-msgid }, { sy-msgno }| ). ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Error from RS_CORR_INSERT, { sy-msgid }, { sy-msgno }| ). ENDIF. READ TABLE it_tpool INTO ls_tpool WITH KEY id = 'R'. IF sy-subrc = 0. * there is a bug in RPY_PROGRAM_UPDATE, the header line of TTAB is not * cleared, so the title length might be inherited from a different program. ASSIGN ('(SAPLSIFP)TTAB') TO . IF sy-subrc = 0. CLEAR . ENDIF. lv_title = ls_tpool-entry. ENDIF. SELECT SINGLE progname FROM reposrc INTO lv_progname WHERE progname = is_progdir-name AND r3state = 'A'. IF sy-subrc = 0. lv_exists = abap_true. ELSE. lv_exists = abap_false. ENDIF. IF lv_exists = abap_true. zcl_abapgit_language=>set_current_language( mv_language ). CALL FUNCTION 'RPY_PROGRAM_UPDATE' EXPORTING program_name = is_progdir-name title_string = lv_title save_inactive = 'I' TABLES source_extended = it_source EXCEPTIONS cancelled = 1 permission_error = 2 not_found = 3 OTHERS = 4. IF sy-subrc <> 0. zcl_abapgit_language=>restore_login_language( ). IF sy-msgid = 'EU' AND sy-msgno = '510'. zcx_abapgit_exception=>raise( 'User is currently editing program' ). ELSEIF sy-msgid = 'EU' AND sy-msgno = '522'. * for generated table maintenance function groups, the author is set to SAP* instead of the user which * generates the function group. This hits some standard checks, pulling new code again sets the author * to the current user which avoids the check zcx_abapgit_exception=>raise( |Delete function group and pull again, { is_progdir-name } (EU522)| ). ELSE. zcx_abapgit_exception=>raise( |PROG { is_progdir-name }, updating error: { sy-msgid } { sy-msgno }| ). ENDIF. ENDIF. zcl_abapgit_language=>restore_login_language( ). ELSEIF strlen( is_progdir-name ) > 30. * function module RPY_PROGRAM_INSERT cannot handle function group includes "" special treatment for extensions "" if the program name exceeds 30 characters it is not a usual "" ABAP program but might be some extension, which requires the internal "" addition EXTENSION TYPE, see "" http://help.sap.com/abapdocu_751/en/abapinsert_report_internal.htm#!ABAP_ADDITION_1@1@ "" This e.g. occurs in case of transportable Code Inspector variants (ending with ===VC) INSERT REPORT is_progdir-name FROM it_source STATE 'I' EXTENSION TYPE is_progdir-name+30. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT REPORT .. EXTENSION TYPE' ). ENDIF. ELSE. INSERT REPORT is_progdir-name FROM it_source STATE 'I' PROGRAM TYPE is_progdir-subc. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT REPORT' ). ENDIF. ENDIF. IF NOT it_tpool[] IS INITIAL. INSERT TEXTPOOL is_progdir-name FROM it_tpool LANGUAGE mv_language STATE 'I'. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ). ENDIF. ENDIF. CALL FUNCTION 'READ_PROGDIR' EXPORTING i_progname = is_progdir-name i_state = 'I' IMPORTING e_progdir = ls_progdir_new EXCEPTIONS not_exists = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |not found in PROGDIR. Subrc = { sy-subrc }| ). ENDIF. * todo, package? ls_progdir_new-ldbname = is_progdir-ldbname. ls_progdir_new-dbna = is_progdir-dbna. ls_progdir_new-dbapl = is_progdir-dbapl. ls_progdir_new-rload = is_progdir-rload. ls_progdir_new-fixpt = is_progdir-fixpt. ls_progdir_new-varcl = is_progdir-varcl. ls_progdir_new-appl = is_progdir-appl. ls_progdir_new-rstat = is_progdir-rstat. ls_progdir_new-sqlx = is_progdir-sqlx. ls_progdir_new-uccheck = is_progdir-uccheck. CALL FUNCTION 'UPDATE_PROGDIR' EXPORTING i_progdir = ls_progdir_new i_progname = ls_progdir_new-name i_state = ls_progdir_new-state EXCEPTIONS not_executed = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |PROG, error inserting. Subrc = { sy-subrc }| ). ENDIF. SELECT SINGLE * FROM progdir INTO ls_progdir_new WHERE name = ls_progdir_new-name AND state = ls_progdir_new-state. IF sy-subrc = 0 AND is_progdir-varcl = space AND ls_progdir_new-varcl = abap_true. * function module UPDATE_PROGDIR does not update VARCL UPDATE progdir SET varcl = is_progdir-varcl WHERE name = ls_progdir_new-name AND state = ls_progdir_new-state. ""#EC CI_SUBRC ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'REPS' iv_name = is_progdir-name ). ENDMETHOD. METHOD deserialize_textpool. DATA lv_language TYPE langu. DATA lv_state TYPE c. DATA lv_delete TYPE abap_bool. IF iv_language IS INITIAL. lv_language = mv_language. ELSE. lv_language = iv_language. ENDIF. IF lv_language = mv_language. lv_state = 'I'. ""Textpool in master language needs to be activated ELSE. lv_state = 'A'. ""Translations are always active ENDIF. IF it_tpool IS INITIAL. IF iv_is_include = abap_false OR lv_state = 'A'. DELETE TEXTPOOL iv_program ""Remove initial description from textpool if LANGUAGE lv_language ""original program does not have a textpool STATE lv_state. lv_delete = abap_true. ELSE. INSERT TEXTPOOL iv_program ""In case of includes: Deletion of textpool in FROM it_tpool ""master language cannot be activated because LANGUAGE lv_language ""this woul activate the deletion of the textpool STATE lv_state. ""of the mail program -> insert empty textpool ENDIF. ELSE. IF lines( it_tpool ) = 1 AND lv_language = mv_language. READ TABLE it_tpool WITH KEY id = 'R' TRANSPORTING NO FIELDS. IF sy-subrc = 0. RETURN. ""No action because description in master language is already there ENDIF. ENDIF. INSERT TEXTPOOL iv_program FROM it_tpool LANGUAGE lv_language STATE lv_state. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ). ENDIF. ENDIF. IF lv_state = 'I'. ""Textpool in master language needs to be activated zcl_abapgit_objects_activation=>add( iv_type = 'REPT' iv_name = iv_program iv_delete = lv_delete ). ENDIF. ENDMETHOD. METHOD is_any_dynpro_locked. DATA: lt_dynpros TYPE ty_dynpro_tt, lv_object TYPE seqg3-garg. FIELD-SYMBOLS: TYPE ty_dynpro. lt_dynpros = serialize_dynpros( iv_program ). LOOP AT lt_dynpros ASSIGNING . lv_object = |{ -header-screen }{ -header-program }|. IF exists_a_lock_entry_for( iv_lock_object = 'ESCRP' iv_argument = lv_object ) = abap_true. rv_is_any_dynpro_locked = abap_true. EXIT. ENDIF. ENDLOOP. ENDMETHOD. METHOD is_cua_locked. DATA: lv_object TYPE eqegraarg. lv_object = |CU{ iv_program }|. OVERLAY lv_object WITH ' '. lv_object = lv_object && '*'. rv_is_cua_locked = exists_a_lock_entry_for( iv_lock_object = 'ESCUAPAINT' iv_argument = lv_object ). ENDMETHOD. METHOD is_text_locked. DATA: lv_object TYPE eqegraarg. lv_object = |*{ iv_program }|. rv_is_text_locked = exists_a_lock_entry_for( iv_lock_object = 'EABAPTEXTE' iv_argument = lv_object ). ENDMETHOD. METHOD read_progdir. DATA: ls_sapdir TYPE progdir. CALL FUNCTION 'READ_PROGDIR' EXPORTING i_progname = iv_program i_state = 'A' IMPORTING e_progdir = ls_sapdir. MOVE-CORRESPONDING ls_sapdir TO rs_progdir. CLEAR: rs_progdir-edtx, rs_progdir-cnam, rs_progdir-cdat, rs_progdir-unam, rs_progdir-udat, rs_progdir-levl, rs_progdir-vern, rs_progdir-rmand, rs_progdir-sdate, rs_progdir-stime, rs_progdir-idate, rs_progdir-itime, rs_progdir-varcl, rs_progdir-state. ENDMETHOD. METHOD read_tpool. FIELD-SYMBOLS: LIKE LINE OF it_tpool, LIKE LINE OF rt_tpool. LOOP AT it_tpool ASSIGNING . APPEND INITIAL LINE TO rt_tpool ASSIGNING . MOVE-CORRESPONDING TO . IF -id = 'S'. CONCATENATE -split -entry INTO -entry RESPECTING BLANKS. ENDIF. ENDLOOP. ENDMETHOD. METHOD serialize_cua. CALL FUNCTION 'RS_CUA_INTERNAL_FETCH' EXPORTING program = iv_program_name language = mv_language state = 'A' IMPORTING adm = rs_cua-adm TABLES sta = rs_cua-sta fun = rs_cua-fun men = rs_cua-men mtx = rs_cua-mtx act = rs_cua-act but = rs_cua-but pfk = rs_cua-pfk set = rs_cua-set doc = rs_cua-doc tit = rs_cua-tit biv = rs_cua-biv EXCEPTIONS not_found = 1 unknown_version = 2 OTHERS = 3. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from RS_CUA_INTERNAL_FETCH, { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD serialize_dynpros. DATA: ls_header TYPE rpy_dyhead, lt_containers TYPE dycatt_tab, lt_fields_to_containers TYPE dyfatc_tab, lt_flow_logic TYPE swydyflow, lt_d020s TYPE TABLE OF d020s, lt_fieldlist_int TYPE TABLE OF d021s. ""internal format FIELD-SYMBOLS: LIKE LINE OF lt_d020s, TYPE scrpostyle, LIKE LINE OF lt_containers, LIKE LINE OF lt_fields_to_containers, LIKE LINE OF rt_dynpro, LIKE LINE OF lt_fieldlist_int. ""#2746: relevant flag values (taken from include MSEUSBIT) CONSTANTS: lc_flg1ddf TYPE x VALUE '20', lc_flg3fku TYPE x VALUE '08', lc_flg3for TYPE x VALUE '04', lc_flg3fdu TYPE x VALUE '02'. CALL FUNCTION 'RS_SCREEN_LIST' EXPORTING dynnr = '' progname = iv_program_name TABLES dynpros = lt_d020s EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc = 2. zcx_abapgit_exception=>raise( |Error from RS_SCREEN_LIST. Subrc = { sy-subrc }| ). ENDIF. SORT lt_d020s BY dnum ASCENDING. * loop dynpros and skip generated selection screens LOOP AT lt_d020s ASSIGNING WHERE type <> 'S' AND type <> 'W' AND type <> 'J' AND NOT dnum IS INITIAL. CALL FUNCTION 'RPY_DYNPRO_READ' EXPORTING progname = iv_program_name dynnr = -dnum IMPORTING header = ls_header TABLES containers = lt_containers fields_to_containers = lt_fields_to_containers flow_logic = lt_flow_logic EXCEPTIONS cancelled = 1 not_found = 2 permission_error = 3 OTHERS = 4. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Error while reading dynpro: { sy-subrc }| ). ENDIF. ""#2746: we need the dynpro fields in internal format: FREE lt_fieldlist_int. CALL FUNCTION 'RPY_DYNPRO_READ_NATIVE' EXPORTING progname = iv_program_name dynnr = -dnum TABLES fieldlist = lt_fieldlist_int. LOOP AT lt_fields_to_containers ASSIGNING . * output style is a NUMC field, the XML conversion will fail if it contains invalid value * field does not exist in all versions ASSIGN COMPONENT 'OUTPUTSTYLE' OF STRUCTURE TO . IF sy-subrc = 0 AND = ' '. CLEAR . ENDIF. ""2746: we apply the same logic as in SAPLWBSCREEN ""for setting or unsetting the foreignkey field: UNASSIGN . READ TABLE lt_fieldlist_int ASSIGNING WITH KEY fnam = -name. IF IS ASSIGNED. IF -flg1 O lc_flg1ddf AND -flg3 O lc_flg3for AND -flg3 Z lc_flg3fdu AND -flg3 Z lc_flg3fku. -foreignkey = 'X'. ELSE. CLEAR -foreignkey. ENDIF. ENDIF. ENDLOOP. LOOP AT lt_containers ASSIGNING . IF -c_resize_v = abap_false. CLEAR -c_line_min. ENDIF. IF -c_resize_h = abap_false. CLEAR -c_coln_min. ENDIF. ENDLOOP. APPEND INITIAL LINE TO rt_dynpro ASSIGNING . -header = ls_header. -containers = lt_containers. -fields = lt_fields_to_containers. -flow_logic = lt_flow_logic. ENDLOOP. ENDMETHOD. METHOD serialize_program. DATA: ls_progdir TYPE ty_progdir, lv_program_name TYPE programm, lt_dynpros TYPE ty_dynpro_tt, ls_cua TYPE ty_cua, lt_source TYPE TABLE OF abaptxt255, lt_tpool TYPE textpool_table, ls_tpool LIKE LINE OF lt_tpool, lo_xml TYPE REF TO zcl_abapgit_xml_output. IF iv_program IS INITIAL. lv_program_name = is_item-obj_name. ELSE. lv_program_name = iv_program. ENDIF. zcl_abapgit_language=>set_current_language( mv_language ). CALL FUNCTION 'RPY_PROGRAM_READ' EXPORTING program_name = lv_program_name with_includelist = abap_false with_lowercase = abap_true TABLES source_extended = lt_source textelements = lt_tpool EXCEPTIONS cancelled = 1 not_found = 2 permission_error = 3 OTHERS = 4. IF sy-subrc = 2. zcl_abapgit_language=>restore_login_language( ). RETURN. ELSEIF sy-subrc <> 0. zcl_abapgit_language=>restore_login_language( ). zcx_abapgit_exception=>raise( |Error reading program with RPY_PROGRAM_READ. Subrc = { sy-subrc }| ). ENDIF. zcl_abapgit_language=>restore_login_language( ). ls_progdir = read_progdir( lv_program_name ). IF io_xml IS BOUND. lo_xml = io_xml. ELSE. CREATE OBJECT lo_xml. ENDIF. lo_xml->add( iv_name = 'PROGDIR' ig_data = ls_progdir ). IF ls_progdir-subc = '1' OR ls_progdir-subc = 'M'. lt_dynpros = serialize_dynpros( lv_program_name ). lo_xml->add( iv_name = 'DYNPROS' ig_data = lt_dynpros ). ls_cua = serialize_cua( lv_program_name ). IF NOT ls_cua IS INITIAL. lo_xml->add( iv_name = 'CUA' ig_data = ls_cua ). ENDIF. ENDIF. READ TABLE lt_tpool WITH KEY id = 'R' INTO ls_tpool. IF sy-subrc = 0 AND ls_tpool-key = '' AND ls_tpool-length = 0. DELETE lt_tpool INDEX sy-tabix. ENDIF. lo_xml->add( iv_name = 'TPOOL' ig_data = add_tpool( lt_tpool ) ). IF NOT io_xml IS BOUND. io_files->add_xml( iv_extra = iv_extra io_xml = lo_xml ). ENDIF. io_files->add_abap( iv_extra = iv_extra it_abap = lt_source ). ENDMETHOD. METHOD uncondense_flow. DATA: lv_spaces LIKE LINE OF it_spaces. FIELD-SYMBOLS: LIKE LINE OF it_flow, LIKE LINE OF rt_flow. LOOP AT it_flow ASSIGNING . APPEND INITIAL LINE TO rt_flow ASSIGNING . -line = -line. READ TABLE it_spaces INDEX sy-tabix INTO lv_spaces. IF sy-subrc = 0. SHIFT -line RIGHT BY lv_spaces PLACES IN CHARACTER MODE. ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. ",8141,False,1653.2424361931369,median "CLASS zcl_abapgit_objects_program DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super. PUBLIC SECTION. TYPES: BEGIN OF ty_progdir, name TYPE progdir-name, state TYPE progdir-state, sqlx TYPE progdir-sqlx, edtx TYPE progdir-edtx, varcl TYPE progdir-varcl, dbapl TYPE progdir-dbapl, dbna TYPE progdir-dbna, clas TYPE progdir-clas, type TYPE progdir-type, occurs TYPE progdir-occurs, subc TYPE progdir-subc, appl TYPE progdir-appl, secu TYPE progdir-secu, cnam TYPE progdir-cnam, cdat TYPE progdir-cdat, unam TYPE progdir-unam, udat TYPE progdir-udat, vern TYPE progdir-vern, levl TYPE progdir-levl, rstat TYPE progdir-rstat, rmand TYPE progdir-rmand, rload TYPE progdir-rload, fixpt TYPE progdir-fixpt, sset TYPE progdir-sset, sdate TYPE progdir-sdate, stime TYPE progdir-stime, idate TYPE progdir-idate, itime TYPE progdir-itime, ldbname TYPE progdir-ldbname, uccheck TYPE progdir-uccheck, END OF ty_progdir. METHODS serialize_program IMPORTING io_xml TYPE REF TO zcl_abapgit_xml_output OPTIONAL is_item TYPE zif_abapgit_definitions=>ty_item io_files TYPE REF TO zcl_abapgit_objects_files iv_program TYPE programm OPTIONAL iv_extra TYPE clike OPTIONAL RAISING zcx_abapgit_exception. METHODS read_progdir IMPORTING iv_program TYPE programm RETURNING VALUE(rs_progdir) TYPE ty_progdir. METHODS deserialize_program IMPORTING is_progdir TYPE ty_progdir it_source TYPE abaptxt255_tab it_tpool TYPE textpool_table iv_package TYPE devclass RAISING zcx_abapgit_exception. PROTECTED SECTION. TYPES: ty_spaces_tt TYPE STANDARD TABLE OF i WITH DEFAULT KEY . TYPES: BEGIN OF ty_dynpro, header TYPE rpy_dyhead, containers TYPE dycatt_tab, fields TYPE dyfatc_tab, flow_logic TYPE swydyflow, spaces TYPE ty_spaces_tt, END OF ty_dynpro . TYPES: ty_dynpro_tt TYPE STANDARD TABLE OF ty_dynpro WITH DEFAULT KEY . TYPES: BEGIN OF ty_cua, adm TYPE rsmpe_adm, sta TYPE STANDARD TABLE OF rsmpe_stat WITH DEFAULT KEY, fun TYPE STANDARD TABLE OF rsmpe_funt WITH DEFAULT KEY, men TYPE STANDARD TABLE OF rsmpe_men WITH DEFAULT KEY, mtx TYPE STANDARD TABLE OF rsmpe_mnlt WITH DEFAULT KEY, act TYPE STANDARD TABLE OF rsmpe_act WITH DEFAULT KEY, but TYPE STANDARD TABLE OF rsmpe_but WITH DEFAULT KEY, pfk TYPE STANDARD TABLE OF rsmpe_pfk WITH DEFAULT KEY, set TYPE STANDARD TABLE OF rsmpe_staf WITH DEFAULT KEY, doc TYPE STANDARD TABLE OF rsmpe_atrt WITH DEFAULT KEY, tit TYPE STANDARD TABLE OF rsmpe_titt WITH DEFAULT KEY, biv TYPE STANDARD TABLE OF rsmpe_buts WITH DEFAULT KEY, END OF ty_cua . METHODS serialize_dynpros IMPORTING !iv_program_name TYPE programm RETURNING VALUE(rt_dynpro) TYPE ty_dynpro_tt RAISING zcx_abapgit_exception . METHODS serialize_cua IMPORTING !iv_program_name TYPE programm RETURNING VALUE(rs_cua) TYPE ty_cua RAISING zcx_abapgit_exception . METHODS deserialize_dynpros IMPORTING !it_dynpros TYPE ty_dynpro_tt RAISING zcx_abapgit_exception . METHODS deserialize_textpool IMPORTING !iv_program TYPE programm !it_tpool TYPE textpool_table !iv_language TYPE langu OPTIONAL !iv_is_include TYPE abap_bool DEFAULT abap_false RAISING zcx_abapgit_exception . METHODS deserialize_cua IMPORTING !iv_program_name TYPE programm !is_cua TYPE ty_cua RAISING zcx_abapgit_exception . METHODS is_any_dynpro_locked IMPORTING !iv_program TYPE programm RETURNING VALUE(rv_is_any_dynpro_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS is_cua_locked IMPORTING !iv_program TYPE programm RETURNING VALUE(rv_is_cua_locked) TYPE abap_bool RAISING zcx_abapgit_exception . METHODS is_text_locked IMPORTING !iv_program TYPE programm RETURNING VALUE(rv_is_text_locked) TYPE abap_bool RAISING zcx_abapgit_exception . CLASS-METHODS add_tpool IMPORTING !it_tpool TYPE textpool_table RETURNING VALUE(rt_tpool) TYPE zif_abapgit_definitions=>ty_tpool_tt . CLASS-METHODS read_tpool IMPORTING !it_tpool TYPE zif_abapgit_definitions=>ty_tpool_tt RETURNING VALUE(rt_tpool) TYPE zif_abapgit_definitions=>ty_tpool_tt . PRIVATE SECTION. METHODS: uncondense_flow IMPORTING it_flow TYPE swydyflow it_spaces TYPE ty_spaces_tt RETURNING VALUE(rt_flow) TYPE swydyflow. CLASS-METHODS auto_correct_cua_adm IMPORTING is_cua TYPE ty_cua CHANGING cs_adm TYPE rsmpe_adm. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECTS_PROGRAM IMPLEMENTATION. METHOD add_tpool. FIELD-SYMBOLS: LIKE LINE OF it_tpool, LIKE LINE OF rt_tpool. LOOP AT it_tpool ASSIGNING . APPEND INITIAL LINE TO rt_tpool ASSIGNING . MOVE-CORRESPONDING TO . IF -id = 'S'. -split = -entry. -entry = -entry+8. ENDIF. ENDLOOP. ENDMETHOD. METHOD auto_correct_cua_adm. "" issue #1807 automatic correction of CUA interfaces saved incorrectly in the past (ADM was not saved in the XML) CONSTANTS: lc_num_n_space TYPE string VALUE ' 0123456789', lc_num_only TYPE string VALUE '0123456789'. FIELD-SYMBOLS: TYPE rsmpe_pfk, TYPE rsmpe_act, TYPE rsmpe_men. IF cs_adm IS NOT INITIAL AND ( cs_adm-actcode CO lc_num_n_space AND cs_adm-mencode CO lc_num_n_space AND cs_adm-pfkcode CO lc_num_n_space ). ""Check performed in form check_adm of include LSMPIF03 RETURN. ENDIF. LOOP AT is_cua-act ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO lc_num_only. cs_adm-actcode = -code. ENDIF. ENDLOOP. LOOP AT is_cua-men ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO lc_num_only. cs_adm-mencode = -code. ENDIF. ENDLOOP. LOOP AT is_cua-pfk ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO lc_num_only. cs_adm-pfkcode = -code. ENDIF. ENDLOOP. ENDMETHOD. METHOD deserialize_cua. DATA: ls_tr_key TYPE trkey, ls_adm TYPE rsmpe_adm. IF lines( is_cua-sta ) = 0 AND lines( is_cua-fun ) = 0 AND lines( is_cua-men ) = 0 AND lines( is_cua-mtx ) = 0 AND lines( is_cua-act ) = 0 AND lines( is_cua-but ) = 0 AND lines( is_cua-pfk ) = 0 AND lines( is_cua-set ) = 0 AND lines( is_cua-doc ) = 0 AND lines( is_cua-tit ) = 0 AND lines( is_cua-biv ) = 0. RETURN. ENDIF. SELECT SINGLE devclass INTO ls_tr_key-devclass FROM tadir WHERE pgmid = 'R3TR' AND object = ms_item-obj_type AND obj_name = ms_item-obj_name. ""#EC CI_GENBUFF IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'not found in tadir' ). ENDIF. ls_tr_key-obj_type = ms_item-obj_type. ls_tr_key-obj_name = ms_item-obj_name. ls_tr_key-sub_type = 'CUAD'. ls_tr_key-sub_name = iv_program_name. ls_adm = is_cua-adm. auto_correct_cua_adm( EXPORTING is_cua = is_cua CHANGING cs_adm = ls_adm ). sy-tcode = 'SE41' ##write_ok. "" evil hack, workaround to handle fixes in note 2159455 CALL FUNCTION 'RS_CUA_INTERNAL_WRITE' EXPORTING program = iv_program_name language = mv_language tr_key = ls_tr_key adm = ls_adm state = 'I' TABLES sta = is_cua-sta fun = is_cua-fun men = is_cua-men mtx = is_cua-mtx act = is_cua-act but = is_cua-but pfk = is_cua-pfk set = is_cua-set doc = is_cua-doc tit = is_cua-tit biv = is_cua-biv EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc <> 0. * if moving code from SAPlink, see https://github.com/larshp/abapGit/issues/562 zcx_abapgit_exception=>raise( |Error from RS_CUA_INTERNAL_WRITE. Subrc = { sy-subrc }| ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'CUAD' iv_name = iv_program_name ). ENDMETHOD. METHOD deserialize_dynpros. CONSTANTS lc_rpyty_force_off TYPE char01 VALUE '/'. DATA: lv_name TYPE dwinactiv-obj_name, ls_dynpro LIKE LINE OF it_dynpros. FIELD-SYMBOLS: TYPE rpy_dyfatc. * ls_dynpro is changed by the function module, a field-symbol will cause * the program to dump since it_dynpros cannot be changed LOOP AT it_dynpros INTO ls_dynpro. "" todo: kept for compatibility, remove after grace period #3680 ls_dynpro-flow_logic = uncondense_flow( it_flow = ls_dynpro-flow_logic it_spaces = ls_dynpro-spaces ). LOOP AT ls_dynpro-fields ASSIGNING . * if the DDIC element has a PARAMETER_ID and the flag ""from_dict"" is active * the import will enable the SET-/GET_PARAM flag. In this case: ""force off"" IF -param_id IS NOT INITIAL AND -from_dict = abap_true. IF -set_param IS INITIAL. -set_param = lc_rpyty_force_off. ENDIF. IF -get_param IS INITIAL. -get_param = lc_rpyty_force_off. ENDIF. ENDIF. * If the previous conditions are met the value 'F' will be taken over * during de-serialization potentially overlapping other fields in the screen, * we set the tag to the correct value 'X' IF -type = 'CHECK' AND -from_dict = abap_true AND -text IS INITIAL AND -modific IS INITIAL. -modific = 'X'. ENDIF. ""fix for issue #2747: IF -foreignkey IS INITIAL. -foreignkey = lc_rpyty_force_off. ENDIF. ENDLOOP. CALL FUNCTION 'RPY_DYNPRO_INSERT' EXPORTING header = ls_dynpro-header suppress_exist_checks = abap_true TABLES containers = ls_dynpro-containers fields_to_containers = ls_dynpro-fields flow_logic = ls_dynpro-flow_logic EXCEPTIONS cancelled = 1 already_exists = 2 program_not_exists = 3 not_executed = 4 missing_required_field = 5 illegal_field_value = 6 field_not_allowed = 7 not_generated = 8 illegal_field_position = 9 OTHERS = 10. IF sy-subrc <> 2 AND sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. * todo, RPY_DYNPRO_UPDATE? CONCATENATE ls_dynpro-header-program ls_dynpro-header-screen INTO lv_name RESPECTING BLANKS. ASSERT NOT lv_name IS INITIAL. zcl_abapgit_objects_activation=>add( iv_type = 'DYNP' iv_name = lv_name ). ENDLOOP. ENDMETHOD. METHOD deserialize_program. DATA: lv_exists TYPE abap_bool, lv_progname TYPE reposrc-progname, ls_tpool LIKE LINE OF it_tpool, lv_title TYPE rglif-title, ls_progdir_new TYPE progdir. FIELD-SYMBOLS: TYPE any. CALL FUNCTION 'RS_CORR_INSERT' EXPORTING object = is_progdir-name object_class = 'ABAP' devclass = iv_package master_language = mv_language mode = 'I' suppress_dialog = abap_true EXCEPTIONS cancelled = 1 permission_failure = 2 unknown_objectclass = 3 OTHERS = 4. IF sy-subrc = 1. zcx_abapgit_exception=>raise( |Error from RS_CORR_INSERT, Cancelled, { sy-msgid }, { sy-msgno }| ). ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Error from RS_CORR_INSERT, { sy-msgid }, { sy-msgno }| ). ENDIF. READ TABLE it_tpool INTO ls_tpool WITH KEY id = 'R'. IF sy-subrc = 0. * there is a bug in RPY_PROGRAM_UPDATE, the header line of TTAB is not * cleared, so the title length might be inherited from a different program. ASSIGN ('(SAPLSIFP)TTAB') TO . IF sy-subrc = 0. CLEAR . ENDIF. lv_title = ls_tpool-entry. ENDIF. SELECT SINGLE progname FROM reposrc INTO lv_progname WHERE progname = is_progdir-name AND r3state = 'A'. IF sy-subrc = 0. lv_exists = abap_true. ELSE. lv_exists = abap_false. ENDIF. IF lv_exists = abap_true. zcl_abapgit_language=>set_current_language( mv_language ). CALL FUNCTION 'RPY_PROGRAM_UPDATE' EXPORTING program_name = is_progdir-name title_string = lv_title save_inactive = 'I' TABLES source_extended = it_source EXCEPTIONS cancelled = 1 permission_error = 2 not_found = 3 OTHERS = 4. IF sy-subrc <> 0. zcl_abapgit_language=>restore_login_language( ). IF sy-msgid = 'EU' AND sy-msgno = '510'. zcx_abapgit_exception=>raise( 'User is currently editing program' ). ELSEIF sy-msgid = 'EU' AND sy-msgno = '522'. * for generated table maintenance function groups, the author is set to SAP* instead of the user which * generates the function group. This hits some standard checks, pulling new code again sets the author * to the current user which avoids the check zcx_abapgit_exception=>raise( |Delete function group and pull again, { is_progdir-name } (EU522)| ). ELSE. zcx_abapgit_exception=>raise( |PROG { is_progdir-name }, updating error: { sy-msgid } { sy-msgno }| ). ENDIF. ENDIF. zcl_abapgit_language=>restore_login_language( ). ELSEIF strlen( is_progdir-name ) > 30. * function module RPY_PROGRAM_INSERT cannot handle function group includes "" special treatment for extensions "" if the program name exceeds 30 characters it is not a usual "" ABAP program but might be some extension, which requires the internal "" addition EXTENSION TYPE, see "" http://help.sap.com/abapdocu_751/en/abapinsert_report_internal.htm#!ABAP_ADDITION_1@1@ "" This e.g. occurs in case of transportable Code Inspector variants (ending with ===VC) INSERT REPORT is_progdir-name FROM it_source STATE 'I' EXTENSION TYPE is_progdir-name+30. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT REPORT .. EXTENSION TYPE' ). ENDIF. ELSE. INSERT REPORT is_progdir-name FROM it_source STATE 'I' PROGRAM TYPE is_progdir-subc. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT REPORT' ). ENDIF. ENDIF. IF NOT it_tpool[] IS INITIAL. INSERT TEXTPOOL is_progdir-name FROM it_tpool LANGUAGE mv_language STATE 'I'. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ). ENDIF. ENDIF. CALL FUNCTION 'READ_PROGDIR' EXPORTING i_progname = is_progdir-name i_state = 'I' IMPORTING e_progdir = ls_progdir_new EXCEPTIONS not_exists = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |not found in PROGDIR. Subrc = { sy-subrc }| ). ENDIF. * todo, package? ls_progdir_new-ldbname = is_progdir-ldbname. ls_progdir_new-dbna = is_progdir-dbna. ls_progdir_new-dbapl = is_progdir-dbapl. ls_progdir_new-rload = is_progdir-rload. ls_progdir_new-fixpt = is_progdir-fixpt. ls_progdir_new-varcl = is_progdir-varcl. ls_progdir_new-appl = is_progdir-appl. ls_progdir_new-rstat = is_progdir-rstat. ls_progdir_new-sqlx = is_progdir-sqlx. ls_progdir_new-uccheck = is_progdir-uccheck. CALL FUNCTION 'UPDATE_PROGDIR' EXPORTING i_progdir = ls_progdir_new i_progname = ls_progdir_new-name i_state = ls_progdir_new-state EXCEPTIONS not_executed = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |PROG, error inserting. Subrc = { sy-subrc }| ). ENDIF. SELECT SINGLE * FROM progdir INTO ls_progdir_new WHERE name = ls_progdir_new-name AND state = ls_progdir_new-state. IF sy-subrc = 0 AND is_progdir-varcl = space AND ls_progdir_new-varcl = abap_true. * function module UPDATE_PROGDIR does not update VARCL UPDATE progdir SET varcl = is_progdir-varcl WHERE name = ls_progdir_new-name AND state = ls_progdir_new-state. ""#EC CI_SUBRC ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'REPS' iv_name = is_progdir-name ). ENDMETHOD. METHOD deserialize_textpool. DATA lv_language TYPE langu. DATA lv_state TYPE c. DATA lv_delete TYPE abap_bool. IF iv_language IS INITIAL. lv_language = mv_language. ELSE. lv_language = iv_language. ENDIF. IF lv_language = mv_language. lv_state = 'I'. ""Textpool in master language needs to be activated ELSE. lv_state = 'A'. ""Translations are always active ENDIF. IF it_tpool IS INITIAL. IF iv_is_include = abap_false OR lv_state = 'A'. DELETE TEXTPOOL iv_program ""Remove initial description from textpool if LANGUAGE lv_language ""original program does not have a textpool STATE lv_state. lv_delete = abap_true. ELSE. INSERT TEXTPOOL iv_program ""In case of includes: Deletion of textpool in FROM it_tpool ""master language cannot be activated because LANGUAGE lv_language ""this woul activate the deletion of the textpool STATE lv_state. ""of the mail program -> insert empty textpool ENDIF. ELSE. IF lines( it_tpool ) = 1 AND lv_language = mv_language. READ TABLE it_tpool WITH KEY id = 'R' TRANSPORTING NO FIELDS. IF sy-subrc = 0. RETURN. ""No action because description in master language is already there ENDIF. ENDIF. INSERT TEXTPOOL iv_program FROM it_tpool LANGUAGE lv_language STATE lv_state. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ). ENDIF. ENDIF. IF lv_state = 'I'. ""Textpool in master language needs to be activated zcl_abapgit_objects_activation=>add( iv_type = 'REPT' iv_name = iv_program iv_delete = lv_delete ). ENDIF. ENDMETHOD. METHOD is_any_dynpro_locked. DATA: lt_dynpros TYPE ty_dynpro_tt, lv_object TYPE seqg3-garg. FIELD-SYMBOLS: TYPE ty_dynpro. lt_dynpros = serialize_dynpros( iv_program ). LOOP AT lt_dynpros ASSIGNING . lv_object = |{ -header-screen }{ -header-program }|. IF exists_a_lock_entry_for( iv_lock_object = 'ESCRP' iv_argument = lv_object ) = abap_true. rv_is_any_dynpro_locked = abap_true. EXIT. ENDIF. ENDLOOP. ENDMETHOD. METHOD is_cua_locked. DATA: lv_object TYPE eqegraarg. lv_object = |CU{ iv_program }|. OVERLAY lv_object WITH ' '. lv_object = lv_object && '*'. rv_is_cua_locked = exists_a_lock_entry_for( iv_lock_object = 'ESCUAPAINT' iv_argument = lv_object ). ENDMETHOD. METHOD is_text_locked. DATA: lv_object TYPE eqegraarg. lv_object = |*{ iv_program }|. rv_is_text_locked = exists_a_lock_entry_for( iv_lock_object = 'EABAPTEXTE' iv_argument = lv_object ). ENDMETHOD. METHOD read_progdir. DATA: ls_sapdir TYPE progdir. CALL FUNCTION 'READ_PROGDIR' EXPORTING i_progname = iv_program i_state = 'A' IMPORTING e_progdir = ls_sapdir. MOVE-CORRESPONDING ls_sapdir TO rs_progdir. CLEAR: rs_progdir-edtx, rs_progdir-cnam, rs_progdir-cdat, rs_progdir-unam, rs_progdir-udat, rs_progdir-levl, rs_progdir-vern, rs_progdir-rmand, rs_progdir-sdate, rs_progdir-stime, rs_progdir-idate, rs_progdir-itime, rs_progdir-varcl, rs_progdir-state. ENDMETHOD. METHOD read_tpool. FIELD-SYMBOLS: LIKE LINE OF it_tpool, LIKE LINE OF rt_tpool. LOOP AT it_tpool ASSIGNING . APPEND INITIAL LINE TO rt_tpool ASSIGNING . MOVE-CORRESPONDING TO . IF -id = 'S'. CONCATENATE -split -entry INTO -entry RESPECTING BLANKS. ENDIF. ENDLOOP. ENDMETHOD. METHOD serialize_cua. CALL FUNCTION 'RS_CUA_INTERNAL_FETCH' EXPORTING program = iv_program_name language = mv_language state = 'A' IMPORTING adm = rs_cua-adm TABLES sta = rs_cua-sta fun = rs_cua-fun men = rs_cua-men mtx = rs_cua-mtx act = rs_cua-act but = rs_cua-but pfk = rs_cua-pfk set = rs_cua-set doc = rs_cua-doc tit = rs_cua-tit biv = rs_cua-biv EXCEPTIONS not_found = 1 unknown_version = 2 OTHERS = 3. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from RS_CUA_INTERNAL_FETCH, { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD serialize_dynpros. DATA: ls_header TYPE rpy_dyhead, lt_containers TYPE dycatt_tab, lt_fields_to_containers TYPE dyfatc_tab, lt_flow_logic TYPE swydyflow, lt_d020s TYPE TABLE OF d020s, lt_fieldlist_int TYPE TABLE OF d021s. ""internal format FIELD-SYMBOLS: LIKE LINE OF lt_d020s, TYPE scrpostyle, LIKE LINE OF lt_containers, LIKE LINE OF lt_fields_to_containers, LIKE LINE OF rt_dynpro, LIKE LINE OF lt_fieldlist_int. ""#2746: relevant flag values (taken from include MSEUSBIT) CONSTANTS: lc_flg1ddf TYPE x VALUE '20', lc_flg3fku TYPE x VALUE '08', lc_flg3for TYPE x VALUE '04', lc_flg3fdu TYPE x VALUE '02'. CALL FUNCTION 'RS_SCREEN_LIST' EXPORTING dynnr = '' progname = iv_program_name TABLES dynpros = lt_d020s EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc = 2. zcx_abapgit_exception=>raise( |Error from RS_SCREEN_LIST. Subrc = { sy-subrc }| ). ENDIF. SORT lt_d020s BY dnum ASCENDING. * loop dynpros and skip generated selection screens LOOP AT lt_d020s ASSIGNING WHERE type <> 'S' AND type <> 'W' AND type <> 'J' AND NOT dnum IS INITIAL. CALL FUNCTION 'RPY_DYNPRO_READ' EXPORTING progname = iv_program_name dynnr = -dnum IMPORTING header = ls_header TABLES containers = lt_containers fields_to_containers = lt_fields_to_containers flow_logic = lt_flow_logic EXCEPTIONS cancelled = 1 not_found = 2 permission_error = 3 OTHERS = 4. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Error while reading dynpro: { sy-subrc }| ). ENDIF. ""#2746: we need the dynpro fields in internal format: FREE lt_fieldlist_int. CALL FUNCTION 'RPY_DYNPRO_READ_NATIVE' EXPORTING progname = iv_program_name dynnr = -dnum TABLES fieldlist = lt_fieldlist_int. LOOP AT lt_fields_to_containers ASSIGNING . * output style is a NUMC field, the XML conversion will fail if it contains invalid value * field does not exist in all versions ASSIGN COMPONENT 'OUTPUTSTYLE' OF STRUCTURE TO . IF sy-subrc = 0 AND = ' '. CLEAR . ENDIF. ""2746: we apply the same logic as in SAPLWBSCREEN ""for setting or unsetting the foreignkey field: UNASSIGN . READ TABLE lt_fieldlist_int ASSIGNING WITH KEY fnam = -name. IF IS ASSIGNED. IF -flg1 O lc_flg1ddf AND -flg3 O lc_flg3for AND -flg3 Z lc_flg3fdu AND -flg3 Z lc_flg3fku. -foreignkey = 'X'. ELSE. CLEAR -foreignkey. ENDIF. ENDIF. ENDLOOP. LOOP AT lt_containers ASSIGNING . IF -c_resize_v = abap_false. CLEAR -c_line_min. ENDIF. IF -c_resize_h = abap_false. CLEAR -c_coln_min. ENDIF. ENDLOOP. APPEND INITIAL LINE TO rt_dynpro ASSIGNING . -header = ls_header. -containers = lt_containers. -fields = lt_fields_to_containers. -flow_logic = lt_flow_logic. ENDLOOP. ENDMETHOD. METHOD serialize_program. DATA: ls_progdir TYPE ty_progdir, lv_program_name TYPE programm, lt_dynpros TYPE ty_dynpro_tt, ls_cua TYPE ty_cua, lt_source TYPE TABLE OF abaptxt255, lt_tpool TYPE textpool_table, ls_tpool LIKE LINE OF lt_tpool, lo_xml TYPE REF TO zcl_abapgit_xml_output. IF iv_program IS INITIAL. lv_program_name = is_item-obj_name. ELSE. lv_program_name = iv_program. ENDIF. zcl_abapgit_language=>set_current_language( mv_language ). CALL FUNCTION 'RPY_PROGRAM_READ' EXPORTING program_name = lv_program_name with_includelist = abap_false with_lowercase = abap_true TABLES source_extended = lt_source textelements = lt_tpool EXCEPTIONS cancelled = 1 not_found = 2 permission_error = 3 OTHERS = 4. IF sy-subrc = 2. zcl_abapgit_language=>restore_login_language( ). RETURN. ELSEIF sy-subrc <> 0. zcl_abapgit_language=>restore_login_language( ). zcx_abapgit_exception=>raise( |Error reading program with RPY_PROGRAM_READ. Subrc = { sy-subrc }| ). ENDIF. zcl_abapgit_language=>restore_login_language( ). ls_progdir = read_progdir( lv_program_name ). IF io_xml IS BOUND. lo_xml = io_xml. ELSE. CREATE OBJECT lo_xml. ENDIF. lo_xml->add( iv_name = 'PROGDIR' ig_data = ls_progdir ). IF ls_progdir-subc = '1' OR ls_progdir-subc = 'M'. lt_dynpros = serialize_dynpros( lv_program_name ). lo_xml->add( iv_name = 'DYNPROS' ig_data = lt_dynpros ). ls_cua = serialize_cua( lv_program_name ). IF NOT ls_cua IS INITIAL. lo_xml->add( iv_name = 'CUA' ig_data = ls_cua ). ENDIF. ENDIF. READ TABLE lt_tpool WITH KEY id = 'R' INTO ls_tpool. IF sy-subrc = 0 AND ls_tpool-key = '' AND ls_tpool-length = 0. DELETE lt_tpool INDEX sy-tabix. ENDIF. lo_xml->add( iv_name = 'TPOOL' ig_data = add_tpool( lt_tpool ) ). IF NOT io_xml IS BOUND. io_files->add_xml( iv_extra = iv_extra io_xml = lo_xml ). ENDIF. io_files->add_abap( iv_extra = iv_extra it_abap = lt_source ). ENDMETHOD. METHOD uncondense_flow. DATA: lv_spaces LIKE LINE OF it_spaces. FIELD-SYMBOLS: LIKE LINE OF it_flow, LIKE LINE OF rt_flow. LOOP AT it_flow ASSIGNING . APPEND INITIAL LINE TO rt_flow ASSIGNING . -line = -line. READ TABLE it_spaces INDEX sy-tabix INTO lv_spaces. IF sy-subrc = 0. SHIFT -line RIGHT BY lv_spaces PLACES IN CHARACTER MODE. ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. ",8138,False,1653.9945354103531,median "package input.phonetic.data { internal final class T { public static const T:Array = [""ta 他"",""ta 她"",""ta 它"",""ta 踏"",""ta 塔"",""ta 塌"",""ta 拓"",""ta 獭"",""ta 挞"",""ta 蹋"",""ta 溻"",""ta 趿"",""ta 鳎"",""ta 沓"",""ta 榻"",""ta 漯"",""ta 遢"",""ta 铊"",""ta 闼"",""ta 嗒"",""ta 侤"",""ta 傝"",""ta 呾"",""ta 咜"",""ta 嚃"",""ta 嚺"",""ta 墖"",""ta 太"",""ta 崉"",""ta 搨"",""ta 搭"",""ta 撘"",""ta 撻"",""ta 榙"",""ta 毾"",""ta 涾"",""ta 湿"",""ta 溚"",""ta 澾"",""ta 濌"",""ta 濕"",""ta 牠"",""ta 狧"",""ta 獺"",""ta 祂"",""ta 禢"",""ta 荅"",""ta 褟"",""ta 誻"",""ta 譶"",""ta 蹹"",""ta 躢"",""ta 达"",""ta 迏"",""ta 迖"",""ta 逹"",""ta 達"",""ta 遝"",""ta 鉈"",""ta 錔"",""ta 鎉"",""ta 鎑"",""ta 闒"",""ta 闟"",""ta 闥"",""ta 阘"",""ta 鞈"",""ta 鞑"",""ta 鞜"",""ta 鞳"",""ta 韃"",""ta 鮙"",""ta 鰨"",""taban 踏板"",""tabu 踏步"",""tae 垈"",""tae 襨"",""tafang 塌方"",""taguo 他国"",""tai 太"",""tai 抬"",""tai 台"",""tai 态"",""tai 胎"",""tai 苔"",""tai 泰"",""tai 酞"",""tai 汰"",""tai 炱"",""tai 肽"",""tai 跆"",""tai 呔"",""tai 鲐"",""tai 钛"",""tai 薹"",""tai 邰"",""tai 骀"",""tai 儓"",""tai 冭"",""tai 咍"",""tai 囼"",""tai 坮"",""tai 大"",""tai 夳"",""tai 奤"",""tai 嬯"",""tai 孡"",""tai 忕"",""tai 忲"",""tai 態"",""tai 擡"",""tai 斄"",""tai 旲"",""tai 枱"",""tai 檯"",""tai 溙"",""tai 漦"",""tai 炲"",""tai 燤"",""tai 珆"",""tai 箈"",""tai 籉"",""tai 粏"",""tai 能"",""tai 臺"",""tai 舦"",""tai 菭"",""tai 詒"",""tai 诒"",""tai 軚"",""tai 釐"",""tai 鈦"",""tai 鈶"",""tai 颱"",""tai 駘"",""tai 鮐"",""taian 泰安"",""taibao 台胞"",""taibei 台北"",""taibuqitoula 抬不起头来"",""taibuziliang 太不自量"",""taidou 泰斗"",""taidu 态度"",""taidu 台独"",""taiduduanzhe 态度端正"",""taiduelie 态度恶劣"",""taidushengyi 态度生硬"",""taier 胎儿"",""taifeng 台风"",""taigao 抬高"",""taijie 台阶"",""taikong 太空"",""taimeng 台盟"",""taiping 太平"",""taipingsheng 太平盛世"",""taipingyang 太平洋"",""tairan 泰然"",""tairanchuzhi 泰然处之"",""tairanziruo 泰然自若"",""taishan 泰山"",""taishang 台上"",""taishanyadin 泰山压顶"",""taishi 态势"",""taishu 台属"",""taitai 太太"",""taitou 抬头"",""taiwan 台湾"",""taiwandangju 台湾当局"",""taiwanminzhu 台湾民主自治同盟"",""taiwansheng 台湾省"",""taiwantongba 台湾同胞"",""taixia 台下"",""taiyang 太阳"",""taiyangguang 太阳光"",""taiyangneng 太阳能"",""taiyuanshi 太原市"",""taizhong 台中"",""taizhou 台州"",""taizhuzi 台柱子"",""tajike 塔吉克"",""tamen 他们"",""tamen 它们"",""tamen 她们"",""tan 谈"",""tan 叹"",""tan 探"",""tan 滩"",""tan 弹"",""tan 碳"",""tan 摊"",""tan 潭"",""tan 贪"",""tan 坛"",""tan 痰"",""tan 毯"",""tan 坦"",""tan 炭"",""tan 瘫"",""tan 谭"",""tan 坍"",""tan 檀"",""tan 袒"",""tan 钽"",""tan 郯"",""tan 镡"",""tan 锬"",""tan 覃"",""tan 澹"",""tan 昙"",""tan 忐"",""tan 但"",""tan 倓"",""tan 傝"",""tan 僋"",""tan 儃"",""tan 啴"",""tan 嗿"",""tan 嘆"",""tan 嘽"",""tan 嘾"",""tan 埮"",""tan 墰"",""tan 墵"",""tan 壇"",""tan 壜"",""tan 婒"",""tan 弾"",""tan 彈"",""tan 怹"",""tan 惔"",""tan 憛"",""tan 憳"",""tan 憻"",""tan 掸"",""tan 撢"",""tan 撣"",""tan 擹"",""tan 攤"",""tan 暺"",""tan 曇"",""tan 榃"",""tan 橝"",""tan 歎"",""tan 沈"",""tan 淡"",""tan 湛"",""tan 湠"",""tan 漢"",""tan 潬"",""tan 灘"",""tan 炎"",""tan 璮"",""tan 痑"",""tan 癉"",""tan 癱"",""tan 禪"",""tan 緂"",""tan 繵"",""tan 罈"",""tan 罎"",""tan 胆"",""tan 舑"",""tan 舔"",""tan 舕"",""tan 荨"",""tan 菼"",""tan 蕁"",""tan 蕈"",""tan 藫"",""tan 裧"",""tan 襢"",""tan 談"",""tan 譚"",""tan 譠"",""tan 貚"",""tan 貪"",""tan 賧"",""tan 赕"",""tan 醈"",""tan 醓"",""tan 醰"",""tan 鉭"",""tan 錟"",""tan 顃"",""tan 餤"",""tan 鷤"",""tan 黮"",""tanbai 坦白"",""tanbaicongku 坦白从宽"",""tanbing 探病"",""tanbushang 谈不上"",""tancai 贪财"",""tance 探测"",""tancha 探查"",""tancheng 坦诚"",""tanchengxian 坦诚相待"",""tandang 坦荡"",""tandaqiuquan 贪大求全"",""tandeshang 谈得上"",""tandewuyan 贪得无厌"",""tandian 摊点"",""tanduo 贪多"",""tanfan 摊贩"",""tanfang 探访"",""tanfu 叹服"",""tang 躺"",""tang 趟"",""tang 堂"",""tang 糖"",""tang 汤"",""tang 塘"",""tang 烫"",""tang 倘"",""tang 淌"",""tang 唐"",""tang 搪"",""tang 棠"",""tang 膛"",""tang 螳"",""tang 樘"",""tang 羰"",""tang 醣"",""tang 瑭"",""tang 镗"",""tang 傥"",""tang 饧"",""tang 溏"",""tang 耥"",""tang 帑"",""tang 铴"",""tang 螗"",""tang 伖"",""tang 偒"",""tang 傏"",""tang 儻"",""tang 劏"",""tang 啺"",""tang 嘡"",""tang 坣"",""tang 嵣"",""tang 弹"",""tang 愓"",""tang 戃"",""tang 扩"",""tang 摥"",""tang 擴"",""tang 攩"",""tang 曭"",""tang 榶"",""tang 橖"",""tang 欓"",""tang 湯"",""tang 漟"",""tang 漡"",""tang 煻"",""tang 燙"",""tang 爣"",""tang 矘"",""tang 磄"",""tang 禟"",""tang 篖"",""tang 簜"",""tang 糃"",""tang 糛"",""tang 膅"",""tang 荡"",""tang 蓎"",""tang 蕩"",""tang 薚"",""tang 蘯"",""tang 蝪"",""tang 赯"",""tang 踼"",""tang 蹚"",""tang 逿"",""tang 鄌"",""tang 鎕"",""tang 鎲"",""tang 鏜"",""tang 鐋"",""tang 鐺"",""tang 钂"",""tang 铛"",""tang 镋"",""tang 閶"",""tang 闛"",""tang 闣"",""tang 阊"",""tang 隚"",""tang 鞺"",""tang 餳"",""tang 餹"",""tang 饄"",""tang 鶶"",""tang 黨"",""tang 鼞"",""tangchang 糖厂"",""tangci 搪瓷"",""tangdao 躺倒"",""tangguo 糖果"",""tangruo 倘若"",""tangse 搪塞"",""tangshan 唐山"",""tangtangzhen 堂堂正正"",""tangtu 唐突"",""tangxia 躺下"",""tangyipaodan 糖衣炮弹"",""tanhu 袒护"",""tanhua 谈话"",""tanhuan 瘫痪"",""tanhuayixian 昙花一现"",""tanhusebian 谈虎色变"",""tanjiu 探究"",""tanke 坦克"",""tankuang 探矿"",""tanlan 贪婪"",""tanlian 贪恋"",""tanlu 袒露"",""tanlu 探路"",""tanlun 谈论"",""tanming 探明"",""tannangquwu 探囊取物"",""tanpai 摊牌"",""tanpai 摊派"",""tanpan 谈判"",""tanpanzhuo 谈判桌"",""tanpianyi 贪便宜"",""tanqi 叹气"",""tanqi 谈起"",""tanqin 探亲"",""tanqinfangyo 探亲访友"",""tanqing 谈清"",""tanqiu 探求"",""tanran 坦然"",""tanranziruo 坦然自若"",""tanruan 瘫软"",""tanshengpasi 贪生怕死"",""tanshuai 坦率"",""tansuo 探索"",""tanta 坍塌"",""tantao 探讨"",""tantaowenti 探讨问题"",""tantebuan 忐忑不安"",""tantian 谈天"",""tantianshuod 谈天说地"",""tantianzhigo 贪天之功为己有"",""tanting 探听"",""tantingxushi 探听虚实"",""tantou 滩头"",""tantu 贪图"",""tantu 谈吐"",""tantu 坦途"",""tantu 滩涂"",""tantuanyi 贪图安逸"",""tantuo 谈妥"",""tantuxiangsh 贪图享受"",""tanwang 探望"",""tanwei 摊位"",""tanweiguanzh 叹为观止"",""tanwen 探问"",""tanwu 贪污"",""tanwudaoqie 贪污盗窃"",""tanwufan 贪污犯"",""tanwufuhua 贪污腐化"",""tanwushouhui 贪污受贿"",""tanwuzui 贪污罪"",""tanxi 叹息"",""tanxian 探险"",""tanxiao 谈笑"",""tanxiaofengs 谈笑风生"",""tanxiaopiany 贪小便宜"",""tanxiaoshida 贪小失大"",""tanxiaoziruo 谈笑自若"",""tanxin 谈心"",""tanxin 贪心"",""tanxinbuzu 贪心不足"",""tanxing 弹性"",""tanxionglub 袒胸露背"",""tanxiongluf 袒胸露腹"",""tanxun 探询"",""tanxun 探寻"",""tanzang 贪赃"",""tanzangwangf 贪赃枉法"",""tanzi 摊子"",""tao 套"",""tao 掏"",""tao 逃"",""tao 桃"",""tao 讨"",""tao 淘"",""tao 涛"",""tao 滔"",""tao 陶"",""tao 绦"",""tao 萄"",""tao 鼗"",""tao 洮"",""tao 焘"",""tao 啕"",""tao 饕"",""tao 韬"",""tao 叨"",""tao 仐"",""tao 匋"",""tao 咷"",""tao 夲"",""tao 夵"",""tao 姚"",""tao 嫍"",""tao 幍"",""tao 弢"",""tao 慆"",""tao 抭"",""tao 挑"",""tao 搯"",""tao 梼"",""tao 槄"",""tao 檮"",""tao 涭"",""tao 濤"",""tao 燾"",""tao 瑫"",""tao 祹"",""tao 筹"",""tao 籌"",""tao 絛"",""tao 綢"",""tao 綯"",""tao 縚"",""tao 縧"",""tao 绸"",""tao 绹"",""tao 蜪"",""tao 裪"",""tao 討"",""tao 詜"",""tao 謟"",""tao 跳"",""tao 轁"",""tao 迯"",""tao 醄"",""tao 鋾"",""tao 錭"",""tao 鞀"",""tao 鞉"",""tao 鞱"",""tao 韜"",""tao 頫"",""tao 飸"",""tao 饀"",""tao 駣"",""tao 騊"",""taoben 逃奔"",""taobi 逃避"",""taobing 逃兵"",""taobixianshi 逃避现实"",""taobuguo 逃不过"",""taochu 掏出"",""taoci 陶瓷"",""taocuan 逃窜"",""taodao 逃到"",""taodun 逃遁"",""taogou 套购"",""taohao 讨好"",""taohuan 讨还"",""taohui 套汇"",""taojia 讨价"",""taojiahuanji 讨价还价"",""taojian 套间"",""taojin 淘金"",""taoli 桃李"",""taoli 逃离"",""taolun 讨论"",""taolunjuedin 讨论决定"",""taoluntonggu 讨论通过"",""taonan 逃难"",""taopao 逃跑"",""taosan 逃散"",""taosheng 逃生"",""taoshui 逃税"",""taotai 淘汰"",""taotaisai 淘汰赛"",""taotaobujue 滔滔不绝"",""taotian 滔天"",""taotuo 逃脱"",""taowang 逃亡"",""taowang 逃往"",""taoyan 讨厌"",""taoyaobao 掏腰包"",""taoye 陶冶"",""taoyeqingcao 陶冶情操"",""taoyong 套用"",""taozhai 讨债"",""taozhong 套种"",""taozhuang 套装"",""taozou 逃走"",""taozui 陶醉"",""tap 畓"",""taping 踏平"",""tarushehui 踏入社会"",""tashanzhishi 他山之石"",""tashi 踏实"",""tataer 塔塔尔"",""tatashishi 踏踏实实"",""te 特"",""te 慝"",""te 铽"",""te 忑"",""te 忒"",""te 匿"",""te 式"",""te 犆"",""te 職"",""te 脦"",""te 蚮"",""te 螣"",""te 蟘"",""te 貣"",""te 貸"",""te 贷"",""te 鋱"",""tebie 特别"",""tebiefating 特别法庭"",""tebiehuiyi 特别会议"",""tebieqiangdi 特别强调"",""tebieshi 特别是"",""tebieyanzhon 特别严重"",""techan 特产"",""techang 特长"",""teci 特此"",""tecitongzhi 特此通知"",""teda 特大"",""tedeng 特等"",""tedengjiang 特等奖"",""tedi 特地"",""tedian 特点"",""teding 特定"",""tei 忒"",""teji 特级"",""teji 特技"",""teji 特辑"",""teji 特急"",""tekan 特刊"",""tekuai 特快"",""tekunhu 特困户"",""teli 特例"",""teng 疼"",""teng 腾"",""teng 藤"",""teng 誊"",""teng 滕"",""teng 僜"",""teng 儯"",""teng 幐"",""teng 漛"",""teng 痋"",""teng 籐"",""teng 籘"",""teng 縢"",""teng 膯"",""teng 虅"",""teng 螣"",""teng 謄"",""teng 邆"",""teng 霯"",""teng 駦"",""teng 騰"",""teng 驣"",""teng 鰧"",""teng 鼟"",""tengai 疼爱"",""tengfei 腾飞"",""tengkong 腾空"",""tengkongerqi 腾空而起"",""tengtong 疼痛"",""tengyue 腾越"",""tengyunjiawu 腾云驾雾"",""teo 唞"",""tepai 特派"",""tequ 特区"",""tequan 特权"",""tequjianshe 特区建设"",""tese 特色"",""teshi 特使"",""teshu 特殊"",""teshuhua 特殊化"",""teshurenwu 特殊任务"",""teshuxing 特殊性"",""teshuxuyao 特殊需要"",""teshuyaoqiu 特殊要求"",""teshuzhengce 特殊政策"",""teshuzuoyong 特殊作用"",""teul 朰"",""teun 朩"",""texiang 特向"",""texiao 特效"",""texiaoyao 特效药"",""texie 特写"",""texing 特性"",""texu 特许"",""teyao 特邀"",""teyaodaibiao 特邀代表"",""teyi 特意"",""teyi 特异"",""teyigongneng 特异功能"",""teyou 特有"",""tezheng 特征"",""ti 提"",""ti 替"",""ti 体"",""ti 题"",""ti 踢"",""ti 蹄"",""ti 剃"",""ti 剔"",""ti 梯"",""ti 锑"",""ti 啼"",""ti 涕"",""ti 嚏"",""ti 惕"",""ti 屉"",""ti 醍"",""ti 鹈"",""ti 绨"",""ti 缇"",""ti 倜"",""ti 裼"",""ti 逖"",""ti 荑"",""ti 悌"",""ti 俶"",""ti 偍"",""ti 厗"",""ti 啑"",""ti 嗁"",""ti 嚔"",""ti 奃"",""ti 姼"",""ti 媂"",""ti 媞"",""ti 屜"",""ti 崹"",""ti 嵜"",""ti 弚"",""ti 弟"",""ti 徥"",""ti 徲"",""ti 悐"",""ti 惖"",""ti 惿"",""ti 戻"",""ti 折"",""ti 挮"",""ti 掦"",""ti 揥"",""ti 擿"",""ti 是"",""ti 桋"",""ti 棣"",""ti 楴"",""ti 歒"",""ti 殢"",""ti 洟"",""ti 渧"",""ti 漽"",""ti 狄"",""ti 珶"",""ti 瑅"",""ti 瓋"",""ti 睇"",""ti 碮"",""ti 磃"",""ti 禵"",""ti 稊"",""ti 穉"",""ti 籊"",""ti 綈"",""ti 緹"",""ti 罤"",""ti 肆"",""ti 苐"",""ti 蕛"",""ti 薙"",""ti 虒"",""ti 蝭"",""ti 蟬"",""ti 衹"",""ti 褅"",""ti 褆"",""ti 詆"",""ti 諦"",""ti 謕"",""ti 诋"",""ti 谛"",""ti 趧"",""ti 趯"",""ti 跃"",""ti 踶"",""ti 蹏"",""ti 躍"",""ti 躰"",""ti 軆"",""ti 达"",""ti 迏"",""ti 迖"",""ti 逷"",""ti 遆"",""ti 適"",""ti 銻"",""ti 錫"",""ti 鍗"",""ti 鐟"",""ti 锡"",""ti 題"",""ti 騠"",""ti 骵"",""ti 體"",""ti 髢"",""ti 髰"",""ti 鬀"",""ti 鬄"",""ti 鮧"",""ti 鮷"",""ti 鯷"",""ti 鳀"",""ti 鴺"",""ti 鵜"",""ti 鶗"",""ti 鶙"",""ti 鷈"",""ti 鷉"",""ti 鷤"",""ti 扌"",""tian 天"",""tian 田"",""tian 添"",""tian 填"",""tian 甜"",""tian 舔"",""tian 恬"",""tian 腆"",""tian 佃"",""tian 掭"",""tian 钿"",""tian 阗"",""tian 忝"",""tian 殄"",""tian 畋"",""tian 倎"",""tian 兲"",""tian 典"",""tian 吞"",""tian 呑"",""tian 唺"",""tian 嗔"",""tian 塡"",""tian 娗"",""tian 婖"",""tian 寘"",""tian 屇"",""tian 悿"",""tian 捵"",""tian 搷"",""tian 晪"",""tian 栝"",""tian 沺"",""tian 沾"",""tian 淟"",""tian 湉"",""tian 滇"",""tian 琠"",""tian 瑱"",""tian 璳"",""tian 甛"",""tian 甸"",""tian 町"",""tian 畇"",""tian 畑"",""tian 畠"",""tian 痶"",""tian 盷"",""tian 睓"",""tian 睼"",""tian 瞋"",""tian 碵"",""tian 磌"",""tian 窴"",""tian 紾"",""tian 緂"",""tian 胋"",""tian 舑"",""tian 舚"",""tian 苫"",""tian 菾"",""tian 蚕"",""tian 蚺"",""tian 覥"",""tian 觍"",""tian 賟"",""tian 酟"",""tian 鈿"",""tian 銛"",""tian 錪"",""tian 鍩"",""tian 鎭"",""tian 鎮"",""tian 铦"",""tian 锘"",""tian 镇"",""tian 闐"",""tian 靔"",""tian 靝"",""tian 靦"",""tian 顚"",""tian 顛"",""tian 颠"",""tian 餂"",""tian 鴫"",""tian 鷆"",""tian 鷏"",""tian 黇"",""tian 提案"",""tiananmen 天安门"",""tiananmenche 天安门城楼"",""tiananmengua 天安门广场"",""tianbao 填报"",""tianbiandito 田边地头"",""tianbiao 填表"",""tianbu 填补"",""tianbu 添补"",""tianbuguonei 填补国内空白"",""tianbukongba 填补空白"",""tianbuzhichi 恬不知耻"",""tiancai 天才"",""tianchangdij 天长地久"",""tianchangrij 天长日久"",""tianchong 填充"",""tiancongreny 天从人愿"",""tiandi 田地"",""tiandi 天地"",""tiandi 天敌"",""tianfandifu 天翻地覆"",""tianfu 天赋"",""tianfuzhiguo 天府之国"",""tiangou 添购"",""tianguo 天国"",""tianhualuanz 天花乱坠"",""tianji 天际"",""tianjia 添加"",""tianjiaji 添加剂"",""tianjian 田间"",""tianjianguan 田间管理"",""tianjin 天津"",""tianjing 恬静"",""tianjing 田径"",""tianjingdiyi 天经地义"",""tianjingsai 田径赛"",""tianjingyund 田径运动"",""tianjinshi 天津市"",""tiankong 天空"",""tiankongbuqu 填空补缺"",""tianli 天理"",""tianli 田里"",""tianlian 田联"",""tianliang 天亮"",""tianluan 添乱"",""tianlunzhile 天伦之乐"",""tianluodiwan 天罗地网"",""tianmei 甜美"",""tianmi 甜蜜"",""tianming 天明"",""tiannandibei 天南地北"",""tiannurenyua 天怒人怨"",""tianping 天平"",""tianping 填平"",""tianpingbuqi 填平补齐"",""tianqi 天气"",""tianqian 天堑"",""tianqiao 天桥"",""tianqixianxi 天气现象"",""tianqiyubao 天气预报"",""tianran 天然"",""tianrangzhib 天壤之别"",""tianranqi 天然气"",""tianse 天色"",""tianshan 天山"",""tianshang 天上"",""tianshe 添设"",""tiansheng 天生"",""tianshi 天时"",""tianshi 天使"",""tianshidili 天时地利"",""tiantan 天坛"",""tiantang 天堂"",""tianti 天体"",""tiantian 天天"",""tiantianxian 天天向上"",""tiantou 甜头"",""tiantou 田头"",""tianwei 甜味"",""tianwen 天文"",""tianwentai 天文台"",""tianwujueren 天无绝人之路"",""tianxia 天下"",""tianxiadashi 天下大事"",""tianxiadiyi 天下第一"",""tianxian 天线"",""tianxiaweigo 天下为公"",""tianxiawunan 天下无难事"",""tianxie 填写"",""tianyahaijia 天涯海角"",""tianyanmiyu 甜言蜜语"",""tianye 田野"",""tianyiwufeng 天衣无缝"",""tianyoubucef 天有不测风云"",""tianyoujiacu 添油加醋"",""tianyuan 田园"",""tianyuanfeng 田园风光"",""tianzai 天灾"",""tianzairenhu 天灾人祸"",""tianzhen 天真"",""tianzhenhuop 天真活泼"",""tianzhenlanm 天真烂漫"",""tianzhenwuxi 天真无邪"",""tianzhi 添置"",""tianzhi 天职"",""tianzhijiaoz 天之骄子"",""tianzhijiaye 添枝加叶"",""tianzhuanjia 添砖加瓦"",""tianzi 天资"",""tiao 条"",""tiao 跳"",""tiao 挑"",""tiao 调"",""tiao 迢"",""tiao 眺"",""tiao 龆"",""tiao 笤"",""tiao 祧"",""tiao 蜩"",""tiao 髫"",""tiao 佻"",""tiao 窕"",""tiao 鲦"",""tiao 苕"",""tiao 粜"",""tiao 儵"",""tiao 咷"",""tiao 啁"",""tiao 姚"",""tiao 嬥"",""tiao 宨"",""tiao 岧"",""tiao 岹"",""tiao 庣"",""tiao 恌"",""tiao 斢"",""tiao 旫"",""tiao 晀"",""tiao 朓"",""tiao 朷"",""tiao 桃"",""tiao 條"",""tiao 樤"",""tiao 祒"",""tiao 稠"",""tiao 窱"",""tiao 糶"",""tiao 絩"",""tiao 聎"",""tiao 脁"",""tiao 脩"",""tiao 艞"",""tiao 芀"",""tiao 萔"",""tiao 蓚"",""tiao 蓧"",""tiao 蓨"",""tiao 螩"",""tiao 覜"",""tiao 誂"",""tiao 調"",""tiao 超"",""tiao 趒"",""tiao 趠"",""tiao 踔"",""tiao 銚"",""tiao 鋚"",""tiao 鎥"",""tiao 铫"",""tiao 鞗"",""tiao 頫"",""tiao 鯈"",""tiao 鰷"",""tiao 齠"",""tiaoban 跳板"",""tiaobo 挑拨"",""tiaobolijian 挑拨离间"",""tiaoci 挑刺"",""tiaodaliang 挑大梁"",""tiaodong 跳动"",""tiaodong 挑动"",""tiaofeijians 挑肥拣瘦"",""tiaohe 调和"",""tiaoji 调剂"",""tiaojia 调价"",""tiaojian 条件"",""tiaojian 挑拣"",""tiaojie 调节"",""tiaojie 调解"",""tiaojieshui 调节税"",""tiaojieweiyu 调解委员会"",""tiaojiezuoyo 调节作用"",""tiaojin 跳进"",""tiaokong 调控"",""tiaokuai 条块"",""tiaokuaijieh 条块结合"",""tiaokuan 条款"",""tiaoli 条理"",""tiaoli 条例"",""tiaoliangxia 跳梁小丑"",""tiaolifenmin 条理分明"",""tiaoling 条令"",""tiaomaobing 挑毛病"",""tiaomu 条目"",""tiaopei 调配"",""tiaoqi 挑起"",""tiaoru 跳入"",""tiaoshi 调试"",""tiaosuo 挑唆"",""tiaoti 挑剔"",""tiaotiaokuan 条条框框"",""tiaowang 眺望"",""tiaowen 条纹"",""tiaowen 条文"",""tiaowu 跳舞"",""tiaoxin 挑衅"",""tiaoxingma 条形码"",""tiaoxinxing 挑衅性"",""tiaoxuan 挑选"",""tiaoyue 条约"",""tiaoyue 跳跃"",""tiaozhan 挑战"",""tiaozhanshu 挑战书"",""tiaozheng 调整"",""tiaozhongdan 挑重担"",""tiaozi 条子"",""tiba 提拔"",""tiban 替班"",""ticai 题材"",""ticai 体裁"",""ticao 体操"",""ticha 体察"",""tichang 提倡"",""ticheng 提成"",""tichu 提出"",""tichu 剔除"",""tichu 剔出"",""tichun 提纯"",""tichupiping 提出批评"",""tichushenqin 提出申请"",""tici 题词"",""tidai 替代"",""tidan 提单"",""tidao 提到"",""tidui 梯队"",""tie 铁"",""tie 贴"",""tie 帖"",""tie 萜"",""tie 餮"",""tie 僣"",""tie 占"",""tie 呫"",""tie 怗"",""tie 惵"",""tie 聑"",""tie 蛈"",""tie 蝶"",""tie 貼"",""tie 跕"",""tie 鉄"",""tie 鉆"",""tie 銕"",""tie 鋨"",""tie 鐡"",""tie 鐵"",""tie 锇"",""tie 飻"",""tie 驖"",""tie 鴩"",""tieanrushan 铁案如山"",""tieban 铁板"",""tiebanyikuai 铁板一块"",""tiebu 贴补"",""tiedao 铁道"",""tiedaobu 铁道部"",""tiefanwan 铁饭碗"",""tiegui 铁轨"",""tiehejin 铁合金"",""tiejin 贴近"",""tiekuang 铁矿"",""tielu 铁路"",""tielufenju 铁路分局"",""tieluganxian 铁路干线"",""tieluju 铁路局"",""tieluxian 铁路线"",""tieluyunshu 铁路运输"",""tiemen 铁门"",""tiemianwusi 铁面无私"",""tieqie 贴切"",""tiequan 铁拳"",""tieren 铁人"",""tieshixincha 铁石心肠"",""tiexi 贴息"",""tiexian 贴现"",""tiexidaikuan 贴息贷款"",""tiexin 贴心"",""tiexinren 贴心人"",""tiezheng 铁证"",""tiezhengrush 铁证如山"",""tifa 体罚"",""tigaiwei 体改委"",""tigan 提干"",""tigang 提纲"",""tigangqielin 提纲挈领"",""tigao 提高"",""tigaochanlia 提高产量"",""tigaochanpin 提高产品质量"",""tigaodanweim 提高单位面积产量"",""tigaodaoyige 提高到一个新的阶段"",""tigaogongzuo 提高工作效率"",""tigaojingjix 提高经济效益"",""tigaojingti 提高警惕"",""tigaojishu 提高技术"",""tigaojuewu 提高觉悟"",""tigaolaodong 提高劳动生产率"",""tigaolaodong 提高劳动效率"",""tigaorenshi 提高认识"",""tigaoshengch 提高生产率"",""tigaoshenghu 提高生活水平"",""tigaoshuipin 提高水平"",""tigaoxiaolv 提高效率"",""tigaoxiaoyi 提高效益"",""tigaozhilian 提高质量"",""tige 体格"",""tigong 提供"",""tigongyouzhi 提供优质服务"",""tihuan 替换"",""tihui 体会"",""tihuo 提货"",""tiji 体积"",""tiji 梯级"",""tiji 提级"",""tiji 提及"",""tijia 提价"",""tijian 体检"",""tijiao 提交"",""tijikaifa 梯级开发"",""tikuan 提款"",""tili 体力"",""tili 体例"",""tilian 提炼"",""tiliang 体谅"",""tililaodong 体力劳动"",""timian 体面"",""timing 提名"",""timing 题名"",""timu 题目"",""tinei 体内"",""ting 听"",""ting 停"",""ting 挺"",""ting 厅"",""ting 亭"",""ting 艇"",""ting 庭"",""ting 廷"",""ting 烃"",""ting 汀"",""ting 町"",""ting 莛"",""ting 铤"",""ting 葶"",""ting 婷"",""ting 蜓"",""ting 梃"",""ting 霆"",""ting 侱"",""ting 侹"",""ting 厛"",""ting 圢"",""ting 奠"",""ting 奵"",""ting 娗"",""ting 嵉"",""ting 庁"",""ting 庍"",""ting 廰"",""ting 廳"",""ting 忊"",""ting 桯"",""ting 楟"",""ting 榳"",""ting 涏"",""ting 渟"",""ting 濎"",""ting 烴"",""ting 烶"",""ting 珵"",""ting 珽"",""ting 筳"",""ting 綎"",""ting 耓"",""ting 聤"",""ting 聴"",""ting 聼"",""ting 聽"",""ting 脡"",""ting 艼"",""ting 蝏"",""ting 誔"",""ting 諪"",""ting 邒"",""ting 鋌"",""ting 閮"",""ting 鞓"",""ting 頲"",""ting 颋"",""ting 鼮"",""tingba 挺拔"",""tingban 停办"",""tingbo 停泊"",""tingbujin 听不进"",""tingchan 停产"",""tingche 停车"",""tingchechang 停车场"",""tingcong 听从"",""tingdang 停当"",""tingdao 听到"",""tingdun 停顿"",""tingerbuwen 听而不闻"",""tingfa 停发"",""tingfang 停放"",""tingfu 停付"",""tinggong 停工"",""tinggongdail 停工待料"",""tinghou 听候"",""tinghouchuli 听候处理"",""tinghua 听话"",""tinghuo 停火"",""tinghuoxieyi 停火协议"",""tingjian 听见"",""tingjian 停建"",""tingjin 挺进"",""tingjue 听觉"",""tingjuji 厅局级"",""tingjuzhang 厅局长"",""tingli 挺立"",""tingli 听力"",""tingliu 停留"",""tingliushiji 停留时间"",""tingming 听命"",""tingping 听凭"",""tingqing 听清"",""tingqiziran 听其自然"",""tingqu 听取"",""tingquhuibao 听取汇报"",""tingqupiping 听取批评"",""tingquyijian 听取意见"",""tingshenerch 挺身而出"",""tingshuo 听说"",""tingtianyoum 听天由命"",""tingxi 停息"",""tingxie 停歇"",""tingxinliuzh 停薪留职"",""tingye 停业"",""tingyezhengd 停业整顿"",""tingyong 停用"",""tingyuan 庭院"",""tingyuan 庭园"",""tingzhan 停战"",""tingzhang 厅长"",""tingzhi 停止"",""tingzhi 停滞"",""tingzhibuqia 停滞不前"",""tingzhigongz 停止工作"",""tingzhijianc 停职检查"",""tingzhirenzh 听之任之"",""tingzhong 听众"",""tipiqiu 踢皮球"",""tipo 体魄"",""tiqi 提起"",""tiqian 提前"",""tiqianwanche 提前完成"",""tiqing 提请"",""tiqu 提取"",""tiruoduobing 体弱多病"",""tishen 提审"",""tishen 替身"",""tisheng 提升"",""tishi 提示"",""titai 体态"",""titan 体坛"",""titian 梯田"",""titie 体贴"",""titieruwei 体贴入微"",""titong 体统"",""tiu 焞"",""tiwai 体外"",""tiwei 体味"",""tiwei 题为"",""tiwei 体委"",""tiwen 提问"",""tiwuwanfu 体无完肤"",""tixi 体系"",""tixian 体现"",""tixiao 体校"",""tixiaojiefei 啼笑皆非"",""tixie 题写"",""tixie 体协"",""tixing 提醒"",""tixing 梯形"",""tiyan 体验"",""tiyanshenghu 体验生活"",""tiyao 提要"",""tiyi 提议"",""tiyijian 提意见"",""tiyu 体育"",""tiyuaihaozhe 体育爱好者"",""tiyuan 体院"",""tiyuchang 体育场"",""tiyuguan 体育馆"",""tiyuhuodong 体育活动"",""tiyujie 体育界"",""tiyujingsai 体育竞赛"",""tiyushiye 体育事业"",""tiyuxinwen 体育新闻"",""tiyuyongpin 体育用品"",""tiyuyundong 体育运动"",""tizao 提早"",""tizhi 体制"",""tizhi 体质"",""tizhigaige 体制改革"",""tizhong 体重"",""tizi 题字"",""tizuiyang 替罪羊"",""tol 乭"",""ton 獤"",""tong 同"",""tong 通"",""tong 痛"",""tong 铜"",""tong 桶"",""tong 筒"",""tong 捅"",""tong 统"",""tong 童"",""tong 彤"",""tong 桐"",""tong 瞳"",""tong 恫"",""tong 侗"",""tong 酮"",""tong 潼"",""tong 茼"",""tong 仝"",""tong 砼"",""tong 峒"",""tong 恸"",""tong 佟"",""tong 嗵"",""tong 垌"",""tong 偅"",""tong 僮"",""tong 劏"",""tong 勭"",""tong 哃"",""tong 囲"",""tong 峂"",""tong 峝"",""tong 庝"",""tong 恿"",""tong 慟"",""tong 憅"",""tong 晍"",""tong 曈"",""tong 朣"",""tong 樋"",""tong 橦"",""tong 氃"",""tong 洞"",""tong 浵"",""tong 湩"",""tong 炵"",""tong 烔"",""tong 熥"",""tong 燑"",""tong 爞"",""tong 犝"",""tong 狪"",""tong 獞"",""tong 痌"",""tong 眮"",""tong 硐"",""tong 硧"",""tong 秱"",""tong 穜"",""tong 筩"",""tong 粡"",""tong 絧"",""tong 統"",""tong 綂"",""tong 膧"",""tong 艟"",""tong 蓪"",""tong 蚒"",""tong 蜼"",""tong 蟲"",""tong 衕"",""tong 詷"",""tong 赨"",""tong 重"",""tong 鉖"",""tong 鉵"",""tong 銅"",""tong 餇"",""tong 鮦"",""tong 鲖"",""tong 冂"",""tongban 同伴"",""tongbao 同胞"",""tongbao 通报"",""tongbaopipin 通报批评"",""tongbing 通病"",""tongbingxian 同病相怜"",""tongbu 同步"",""tongbuzengzh 同步增长"",""tongchang 通常"",""tongchang 通畅"",""tongche 通车"",""tongcheng 统称"",""tongcheng 通称"",""tongchi 痛斥"",""tongchou 统筹"",""tongchouanpa 统筹安排"",""tongchoudika 同仇敌忾"",""tongchoujian 统筹兼顾"",""tongchu 痛处"",""tongchuan 铜川"",""tongchuyizhe 同出一辙"",""tongda 通达"",""tongda 痛打"",""tongdeng 同等"",""tongdengduid 同等对待"",""tongdengtiao 同等条件"",""tongdengxuel 同等学历"",""tongdian 通电"",""tongdie 通牒"",""tongfeng 通风"",""tongfengbaox 通风报信"",""tongfenjiehe 统分结合"",""tonggaiqianf 痛改前非"",""tonggan 痛感"",""tonggan 同感"",""tonggangongk 同甘共苦"",""tonggao 通告"",""tonggong 统共"",""tonggong 童工"",""tonggongbuto 同工不同酬"",""tonggongtong 同工同酬"",""tonggou 统购"",""tongguan 统管"",""tongguo 通过"",""tongguojiand 通过鉴定"",""tongguojueyi 通过决议"",""tongguotaolu 通过讨论"",""tongguoxuexi 通过学习"",""tonghang 通航"",""tonghang 同行"",""tonghangye 同行业"",""tonghen 痛恨"",""tonghua 童话"",""tonghua 通话"",""tonghuo 通货"",""tonghuo 同伙"",""tonghuopengz 通货膨胀"",""tongji 统计"",""tongji 痛击"",""tongji 通缉"",""tongji 同级"",""tongjibiao 统计表"",""tongjidiaoch 统计调查"",""tongjifenxi 统计分析"",""tongjigongzu 统计工作"",""tongjiju 统计局"",""tongjishuzi 统计数字"",""tongjiziliao 统计资料"",""tongkao 统考"",""tongku 痛苦"",""tongkuai 痛快"",""tongkuang 铜矿"",""tonglanbiaot 通栏标题"",""tonglei 同类"",""tongleichanp 同类产品"",""tonglihezuo 通力合作"",""tongling 通令"",""tongling 同龄"",""tongling 铜陵"",""tonglingjiaj 通令嘉奖"",""tongliuhewu 同流合污"",""tonglouzi 捅娄子"",""tonglu 通路"",""tongluren 同路人"",""tongmafengwo 捅马蜂窝"",""tongmeng 同盟"",""tongmengguo 同盟国"",""tongmenghui 同盟会"",""tongmengjun 同盟军"",""tongmengzhe 同盟者"",""tongming 通明"",""tongming 同名"",""tongmou 同谋"",""tongnian 童年"",""tongnian 同年"",""tongpai 铜牌"",""tongpankaolv 通盘考虑"",""tongpei 统配"",""tongpian 通篇"",""tongpiao 通票"",""tongqi 同期"",""tongqiangtie 铜墙铁壁"",""tongqing 同情"",""tongqingdali 通情达理"",""tongqingxin 同情心"",""tongri 同日"",""tongrong 通融"",""tongshang 通商"",""tongshang 同上"",""tongshi 同时"",""tongshi 同事"",""tongshi 痛失"",""tongshibingj 同时并举"",""tongshiliang 痛失良机"",""tongshiqi 同时期"",""tongshuai 统帅"",""tongshuai 统率"",""tongshun 通顺"",""tongsu 通俗"",""tongsuduwu 通俗读物"",""tongsuyidong 通俗易懂"",""tongtongkuai 痛痛快快"",""tongtu 通途"",""tongwang 通往"",""tongwang 同往"",""tongwangchan 同往常一样"",""tongxi 痛惜"",""tongxia 统辖"",""tongxiang 同乡"",""tongxiang 通向"",""tongxiang 铜像"",""tongxiao 通宵"",""tongxiao 通晓"",""tongxiao 统销"",""tongxiaodada 通宵达旦"",""tongxin 通信"",""tongxin 童心"",""tongxin 痛心"",""tongxindizhi 通信地址"",""tongxing 通行"",""tongxing 同行"",""tongxingongc 通信工程"",""tongxingwuzu 通行无阻"",""tongxinjisho 痛心疾首"",""tongxinlianl 通信联络"",""tongxintongd 同心同德"",""tongxinweixi 通信卫星"",""tongxinxianl 通信线路"",""tongxinxieli 同心协力"",""tongxinyuan 通信员"",""tongxue 同学"",""tongxun 通讯"",""tongxunlu 通讯录"",""tongxunshe 通讯社"",""tongxunweixi 通讯卫星"",""tongxunyuan 通讯员"",""tongyang 同样"",""tongyang 痛痒"",""tongye 同业"",""tongye 通夜"",""tongyi 同意"",""tongyi 统一"",""tongyi 同一"",""tongyibiaozh 统一标准"",""tongyidaye 统一大业"",""tongyifenpei 统一分配"",""tongyiguanli 统一管理"",""tongyiguihua 统一规划"",""tongyijingyi 统一经营"",""tongyikoujin 统一口径"",""tongyilingda 统一领导"",""tongyirenshi 统一认识"",""tongyisixian 统一思想"",""tongyiti 统一体"",""tongyixing 统一性"",""tongyizhanxi 统一战线"",""tongyizuguo 统一祖国"",""tongyizuzhi 统一组织"",""tongyong 通用"",""tongyou 通邮"",""tongze 通则"",""tongzhan 统战"",""tongzhanbu 统战部"",""tongzhi 同志"",""tongzhi 统治"",""tongzhi 通知"",""tongzhimen 同志们"",""tongzhishu 通知书"",""tongzhougong 同舟共济"",""tongzhuang 童装"",""tongzu 同组"",""tou 头"",""tou 偷"",""tou 透"",""tou 投"",""tou 钭"",""tou 骰"",""tou 亠"",""tou 偸"",""tou 埱"",""tou 妵"",""tou 婾"",""tou 媮"",""tou 愉"",""tou 敨"",""tou 斢"",""tou 殕"",""tou 紏"",""tou 綉"",""tou 緰"",""tou 绣"",""tou 蘣"",""tou 褕"",""tou 諭"",""tou 諳"",""tou 谕"",""tou 谙"",""tou 逗"",""tou 鋀"",""tou 鍮"",""tou 頭"",""tou 飳"",""tou 黈"",""touan 投案"",""touanzishou 投案自首"",""toubantoutia 头版头条"",""toubao 投保"",""touben 投奔"",""toubiao 投标"",""toubu 头部"",""touchan 投产"",""touche 透彻"",""toudao 偷盗"",""toudengdashi 头等大事"",""toudi 投递"",""touding 头顶"",""touding 透顶"",""toufa 头发"",""toufang 投放"",""toufangshich 投放市场"",""toufeng 透风"",""tougongjianl 偷工减料"",""touguo 透过"",""touhao 头号"",""touji 投机"",""touji 投寄"",""toujidaoba 投机倒把"",""toujiquqiao 投机取巧"",""toukao 投靠"",""touliang 透亮"",""toulianghuan 偷梁换柱"",""toulou 偷漏"",""touloushui 偷漏税"",""toulu 透露"",""toumianrenwu 头面人物"",""touming 透明"",""toumingdu 透明度"",""toumu 头目"",""tounao 头脑"",""tounaofare 头脑发热"",""tounaoqingxi 头脑清醒"",""toupiao 投票"",""touqi 透气"",""touqie 偷窃"",""touqisuohao 投其所好"",""touru 投入"",""touruchanchu 投入产出"",""tourushengch 投入生产"",""tourushiyong 投入使用"",""toushang 头上"",""toushen 投身"",""toushenyu 投身于"",""toushi 透视"",""toushui 偷税"",""toushuiloush 偷税漏税"",""tousong 投送"",""tousu 投诉"",""touteng 头疼"",""toutiao 头条"",""toutong 头痛"",""toutoumomo 偷偷摸摸"",""toutoushidao 头头是道"",""touxi 偷袭"",""touxian 头衔"",""touxiang 投降"",""touxiang 投向"",""touxu 头绪"",""touyici 头一次"",""touyihui 头一回"",""touyinian 头一年"",""touyue 偷越"",""touyun 偷运"",""touzhi 透支"",""touzhongjiao 头重脚轻"",""touzi 投资"",""touzie 投资额"",""touzigongsi 投资公司"",""touziguimo 投资规模"",""touzihuanjin 投资环境"",""touziyinhang 投资银行"",""touzizhe 投资者"",""touzizonge 投资总额"",""tu 土"",""tu 图"",""tu 兔"",""tu 涂"",""tu 吐"",""tu 秃"",""tu 突"",""tu 徒"",""tu 凸"",""tu 途"",""tu 屠"",""tu 酴"",""tu 荼"",""tu 钍"",""tu 菟"",""tu 堍"",""tu 余"",""tu 兎"",""tu 凃"",""tu 唋"",""tu 啚"",""tu 図"",""tu 圖"",""tu 圗"",""tu 圡"",""tu 堗"",""tu 塗"",""tu 墿"",""tu 宊"",""tu 峹"",""tu 嵞"",""tu 嶀"",""tu 庩"",""tu 廜"",""tu 怢"",""tu 悇"",""tu 捈"",""tu 捸"",""tu 揬"",""tu 摕"",""tu 斁"",""tu 杜"",""tu 梌"",""tu 檡"",""tu 汢"",""tu 涋"",""tu 湥"",""tu 潳"",""tu 瑹"",""tu 痜"",""tu 瘏"",""tu 禿"",""tu 稌"",""tu 筡"",""tu 腞"",""tu 腯"",""tu 莵"",""tu 葖"",""tu 蒤"",""tu 趃"",""tu 跌"",""tu 跿"",""tu 迌"",""tu 釷"",""tu 鈯"",""tu 鋀"",""tu 鋵"",""tu 鍎"",""tu 馟"",""tu 駼"",""tu 鵌"",""tu 鵚"",""tu 鵵"",""tu 鶟"",""tu 鷋"",""tu 鷵"",""tu 鼵"",""tuan 团"",""tuan 湍"",""tuan 疃"",""tuan 抟"",""tuan 彖"",""tuan 剬"",""tuan 剸"",""tuan 団"",""tuan 圕"",""tuan 團"",""tuan 塼"",""tuan 墥"",""tuan 嫥"",""tuan 專"",""tuan 慱"",""tuan 摶"",""tuan 敦"",""tuan 槫"",""tuan 檲"",""tuan 湪"",""tuan 漙"",""tuan 煓"",""tuan 猯"",""tuan 畽"",""tuan 磚"",""tuan 稅"",""tuan 税"",""tuan 篿"",""tuan 糰"",""tuan 蓴"",""tuan 褍"",""tuan 褖"",""tuan 貒"",""tuan 鏄"",""tuan 鱄"",""tuan 鶉"",""tuan 鷒"",""tuan 鷻"",""tuan 鹑"",""tuan 图案"",""tuanbu 团部"",""tuandaihui 团代会"",""tuandegongzu 团的工作"",""tuanhuo 团伙"",""tuanjie 团结"",""tuanjiehezuo 团结合作"",""tuanjiehuzhu 团结互助"",""tuanjieyizhi 团结一致"",""tuanju 团聚"",""tuanqi 团旗"",""tuanti 团体"",""tuantiguanju 团体冠军"",""tuantisai 团体赛"",""tuantuan 团团"",""tuantuanzhua 团团转"",""tuanwei 团委"",""tuanyuan 团员"",""tuanyuan 团圆"",""tuanzhang 团长"",""tuanzhibu 团支部"",""tuanzhongyan 团中央"",""tuanzuzhi 团组织"",""tubanfa 土办法"",""tubengwajie 土崩瓦解"",""tubian 突变"",""tubiao 图表"",""tubu 徒步"",""tuchan 土产"",""tuchu 突出"",""tuchubiaoxia 突出表现"",""tuchugongxia 突出贡献"",""tudi 土地"",""tudi 徒弟"",""tudifa 土地法"",""tufa 土法"",""tufa 突发"",""tufashangma 土法上马"",""tufaxing 突发性"",""tufeimengjin 突飞猛进"",""tugunaxin 吐故纳新"",""tuhua 图画"",""tui 腿"",""tui 推"",""tui 退"",""tui 褪"",""tui 颓"",""tui 蜕"",""tui 煺"",""tui 忒"",""tui 侻"",""tui 俀"",""tui 僓"",""tui 啍"",""tui 墤"",""tui 娧"",""tui 尵"",""tui 弚"",""tui 弟"",""tui 怢"",""tui 橔"",""tui 稅"",""tui 税"",""tui 穨"",""tui 聉"",""tui 脫"",""tui 脮"",""tui 脱"",""tui 蓷"",""tui 藬"",""tui 蘈"",""tui 蛻"",""tui 謉"",""tui 讉"",""tui 蹆"",""tui 蹪"",""tui 追"",""tui 隤"",""tui 頹"",""tui 頺"",""tui 頽"",""tui 饋"",""tui 馈"",""tui 駾"",""tui 騩"",""tui 骽"",""tui 魋"",""tuibai 颓败"",""tuibi 退避"",""tuibisanshe 退避三舍"",""tuibozhulan 推波助澜"",""tuibu 退步"",""tuice 推测"",""tuichang 退场"",""tuichenchuxi 推陈出新"",""tuichi 推迟"",""tuichong 推崇"",""tuichu 推出"",""tuichu 退出"",""tuici 推辞"",""tuidang 退党"",""tuidao 推倒"",""tuidaochongl 推倒重来"",""tuidiao 退掉"",""tuidong 推动"",""tuidongli 推动力"",""tuiduan 推断"",""tuierguangzh 推而广之"",""tuifan 推翻"",""tuifei 颓废"",""tuiguang 推广"",""tuiguangying 推广应用"",""tuihou 退后"",""tuihua 退化"",""tuihua 蜕化"",""tuihuabianzh 蜕化变质"",""tuihuan 退还"",""tuihuan 退换"",""tuihui 退回"",""tuihuo 退货"",""tuijian 推荐"",""tuijin 推进"",""tuijingaige 推进改革"",""tuiju 推举"",""tuijuerxian 退居二线"",""tuikai 推开"",""tuili 推理"",""tuilu 退路"",""tuilun 推论"",""tuipei 退赔"",""tuiqiao 推敲"",""tuique 退却"",""tuirang 退让"",""tuise 褪色"",""tuishui 退税"",""tuisuan 推算"",""tuisuo 退缩"",""tuiwu 退伍"",""tuiwujunren 退伍军人"",""tuixiang 推想"",""tuixiao 推销"",""tuixiezeren 推卸责任"",""tuixinzhifu 推心置腹"",""tuixiu 退休"",""tuixiufei 退休费"",""tuixiuganbu 退休干部"",""tuixiujin 退休金"",""tuixuan 推选"",""tuiyi 推移"",""tuiyi 退役"",""tuiyibushuo 退一步说"",""tuizhi 退职"",""tuji 突击"",""tujia 土家"",""tujian 土建"",""tujie 图解"",""tujing 途径"",""tujing 图景"",""tujing 途经"",""tujishou 突击手"",""tulao 徒劳"",""tulaowuyi 徒劳无益"",""tuli 图例"",""tuliao 涂料"",""tulituqi 土里土气"",""tulu 吐露"",""tumo 涂抹"",""tumou 图谋"",""tumu 土木"",""tumugongchen 土木工程"",""tun 吞"",""tun 屯"",""tun 褪"",""tun 臀"",""tun 囤"",""tun 氽"",""tun 饨"",""tun 豚"",""tun 暾"",""tun 吨"",""tun 吴"",""tun 呑"",""tun 啍"",""tun 噋"",""tun 坉"",""tun 庉"",""tun 忳"",""tun 憞"",""tun 旽"",""tun 朜"",""tun 汭"",""tun 沌"",""tun 涒"",""tun 炖"",""tun 焞"",""tun 燉"",""tun 畽"",""tun 窀"",""tun 純"",""tun 纯"",""tun 肫"",""tun 膯"",""tun 臋"",""tun 芚"",""tun 蜳"",""tun 豘"",""tun 軘"",""tun 逐"",""tun 錪"",""tun 霕"",""tun 飩"",""tun 魨"",""tun 鲀"",""tun 黗"",""tunbing 吞并"",""tunji 囤积"",""tunjijuqi 囤积居奇"",""tunmie 吞灭"",""tunmo 吞没"",""tunshi 吞噬"",""tuntu 吞吐"",""tuntuliang 吞吐量"",""tuntunengli 吞吐能力"",""tuntuntutu 吞吞吐吐"",""tuo 拖"",""tuo 脱"",""tuo 托"",""tuo 妥"",""tuo 驮"",""tuo 拓"",""tuo 驼"",""tuo 椭"",""tuo 唾"",""tuo 鸵"",""tuo 陀"",""tuo 魄"",""tuo 橐"",""tuo 柝"",""tuo 跎"",""tuo 乇"",""tuo 坨"",""tuo 佗"",""tuo 庹"",""tuo 酡"",""tuo 柁"",""tuo 鼍"",""tuo 沱"",""tuo 箨"",""tuo 砣"",""tuo 他"",""tuo 仛"",""tuo 侂"",""tuo 侻"",""tuo 咃"",""tuo 啴"",""tuo 嘽"",""tuo 堶"",""tuo 媠"",""tuo 嫷"",""tuo 它"",""tuo 岮"",""tuo 彵"",""tuo 惰"",""tuo 扡"",""tuo 拕"",""tuo 挩"",""tuo 捝"",""tuo 撱"",""tuo 杔"",""tuo 杝"",""tuo 棁"",""tuo 楕"",""tuo 槖"",""tuo 橢"",""tuo 毤"",""tuo 毻"",""tuo 汑"",""tuo 池"",""tuo 沰"",""tuo 涶"",""tuo 牠"",""tuo 狏"",""tuo 砤"",""tuo 碢"",""tuo 磚"",""tuo 稅"",""tuo 税"",""tuo 籜"",""tuo 紽"",""tuo 脫"",""tuo 舃"",""tuo 舄"",""tuo 莌"",""tuo 萚"",""tuo 蘀"",""tuo 蛇"",""tuo 蟺"",""tuo 袉"",""tuo 袘"",""tuo 袥"",""tuo 訑"",""tuo 託"",""tuo 詑"",""tuo 說"",""tuo 説"",""tuo 讬"",""tuo 说"",""tuo 跅"",""tuo 踻"",""tuo 軃"",""tuo 迆"",""tuo 迤"",""tuo 迱"",""tuo 鉈"",""tuo 鋖"",""tuo 铊"",""tuo 阤"",""tuo 陁"",""tuo 隋"",""tuo 飥"",""tuo 饦"",""tuo 馱"",""tuo 馲"",""tuo 駄"",""tuo 駝"",""tuo 駞"",""tuo 騨"",""tuo 驒"",""tuo 驝"",""tuo 魠"",""tuo 鮀"",""tuo 鰖"",""tuo 鱓"",""tuo 鴕"",""tuo 鵎"",""tuo 鼉"",""tuo 鼧"",""tuo 舵"",""tuoban 托办"",""tuochan 脱产"",""tuochanganbu 脱产干部"",""tuochanxuexi 脱产学习"",""tuoersuo 托儿所"",""tuofu 托付"",""tuogou 脱钩"",""tuogu 托故"",""tuoguan 托管"",""tuohoutui 拖后腿"",""tuohuang 拓荒"",""tuohuangzhe 拓荒者"",""tuojiangzhim 脱缰之马"",""tuojie 脱节"",""tuokouerchu 脱口而出"",""tuokua 拖垮"",""tuokuan 拓宽"",""tuola 拖拉"",""tuolaji 拖拉机"",""tuolajichang 拖拉机厂"",""tuolei 拖累"",""tuoli 脱离"",""tuoliqunzhon 脱离群众"",""tuolishiji 脱离实际"",""tuoliweixian 脱离危险"",""tuoluo 脱落"",""tuoma 唾骂"",""tuomang 脱盲"",""tuonidaishui 拖泥带水"",""tuopin 脱贫"",""tuopinzhifu 脱贫致富"",""tuoqi 唾弃"",""tuoqian 拖欠"",""tuoren 托人"",""tuoru 拖入"",""tuoshan 妥善"",""tuoshananzhi 妥善安置"",""tuoshanchuli 妥善处理"",""tuoshanjieju 妥善解决"",""tuoshen 脱身"",""tuoshou 脱手"",""tuoshoukede 唾手可得"",""tuotaihuangu 脱胎换骨"",""tuotuolala 拖拖拉拉"",""tuoxian 脱险"",""tuoxiao 脱销"",""tuoxie 妥协"",""tuoyan 拖延"",""tuoyingerchu 脱颖而出"",""tuozhan 拓展"",""tupian 图片"",""tupo 突破"",""tupodian 突破点"",""tuponanguan 突破难关"",""tupoxing 突破性"",""tuqi 突起"",""turan 突然"",""turang 土壤"",""turanjian 突然间"",""turanxiji 突然袭击"",""turuqilai 突如其来"",""tusha 屠杀"",""tushengtuzha 土生土长"",""tushifang 土石方"",""tushou 徒手"",""tushoukongqu 徒手空拳"",""tushu 图书"",""tushuguan 图书馆"",""tushushi 图书室"",""tushuziliao 图书资料"",""tusihubei 兔死狐悲"",""tutechan 土特产"",""tutechanpin 土特产品"",""tuwenbingmao 图文并茂"",""tuxiang 图象"",""tuxiang 图像"",""tuxing 图形"",""tuxing 徒刑"",""tuyang 图样"",""tuyangjiehe 土洋结合"",""tuyouxuming 徒有虚名"",""tuzhi 图纸"",""tuzhi 土质"",""tuzhimofen 涂脂抹粉"",""tuzhong 途中"",""tuzhuanjia 土专家""]; } }",16184,True,3899.4553344285546,median "CLASS zcl_mdg_mm_helper_staging DEFINITION PUBLIC INHERITING FROM zcl_mdg_mm_helper FINAL CREATE PRIVATE . PUBLIC SECTION. CLASS-METHODS destruct_instance . CLASS-METHODS get_instance RETURNING VALUE(ro_mm_data) TYPE REF TO zcl_mdg_mm_helper EXCEPTIONS instance_creation_failed entity_data_all_read_error app_context_get_failed appcontext_attribute_get_error unexpected_error model_get_failed . PROTECTED SECTION. PRIVATE SECTION. * TYPES: * BEGIN OF gty_s_instance, * crequest TYPE usmd_crequest, * material TYPE matnr, * instance TYPE REF TO zcl_mdg_mm_helper_staging, * END OF gty_s_instance . * TYPES: * gty_t_instance TYPE SORTED TABLE OF gty_s_instance WITH UNIQUE KEY crequest material . CLASS-DATA go_instance TYPE REF TO zcl_mdg_mm_helper_staging . DATA gv_crid TYPE usmd_crequest . DATA gv_wiid TYPE sww_wiid . CLASS-DATA gv_final_status_set TYPE abap_bool . METHODS constructor EXCEPTIONS entity_data_all_read_error app_context_get_failed appcontext_attribute_get_error model_get_failed discard_instance unexpected_error . METHODS read_entity_data_cr EXCEPTIONS model_get_failed app_context_get_failed appcontext_attribute_get_error entity_data_all_read_error discard_instance data_not_found dyn_assignment_failed . METHODS transfer_txtmi_instantiation . METHODS read_active_data_of_cr IMPORTING !iv_crequest TYPE usmd_crequest !io_model TYPE REF TO if_usmd_model_ext EXPORTING !et_entity_data_act TYPE usmd_ts_data_entity . METHODS read_matchgmng_data IMPORTING !it_materials TYPE table_matnr !iv_crequest TYPE usmd_crequest OPTIONAL !it_data_entity TYPE usmd_ts_data_entity OPTIONAL EXPORTING !et_matchgmng TYPE usmd_ts_data_entity . ENDCLASS. CLASS ZCL_MDG_MM_HELPER_STAGING IMPLEMENTATION. METHOD constructor. CALL METHOD super->constructor. CALL METHOD read_entity_data_cr EXCEPTIONS entity_data_all_read_error = 1 app_context_get_failed = 2 appcontext_attribute_get_error = 3 model_get_failed = 4 discard_instance = 5 OTHERS = 6. IF sy-subrc <> 0 . CASE sy-subrc. WHEN 1. RAISE entity_data_all_read_error. WHEN 2. RAISE app_context_get_failed. WHEN 3. RAISE appcontext_attribute_get_error. WHEN 4. RAISE model_get_failed. WHEN 5. RAISE discard_instance. WHEN OTHERS. RAISE unexpected_error. ENDCASE. ENDIF. ENDMETHOD. METHOD destruct_instance. FREE go_instance. ENDMETHOD. METHOD get_instance. DATA: lo_app_context TYPE REF TO if_usmd_app_context, lv_force_reload TYPE abap_bool, lo_crequest_util TYPE REF TO cl_usmd_crequest_util, lo_model TYPE REF TO if_usmd_model, ls_crequest TYPE usmd_s_crequest, lt_messages TYPE usmd_t_message, lv_error TYPE abap_bool, lv_material TYPE matnr. FIELD-SYMBOLS: TYPE usmd_s_message. lv_force_reload = abap_false. CALL METHOD cl_usmd_app_context=>get_context RECEIVING eo_context = lo_app_context. IF lo_app_context IS BOUND. IF lo_app_context->mv_crequest_id IS INITIAL. lv_material = cl_mdg_bs_mat_assist_ui=>gv_current_material. CALL METHOD zcl_mdg_mm_helper_active=>get_instance EXPORTING iv_material = lv_material RECEIVING ro_mm_data = ro_mm_data EXCEPTIONS instance_creation_failed = 1 entity_data_all_read_error = 2 app_context_get_failed = 3 appcontext_attribute_get_error = 4 unexpected_error = 5 model_get_failed = 6 OTHERS = 7. IF sy-subrc <> 0. CASE sy-subrc. WHEN 1. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_bp TYPE 'X' NUMBER 001 RAISING entity_data_all_read_error ##MG_MISSING. WHEN 2. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_br_bp TYPE 'X' NUMBER 004 RAISING app_context_get_failed ##MG_MISSING. WHEN 3. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_br_bp TYPE 'X' NUMBER 004 RAISING app_context_get_failed ##MG_MISSING. WHEN 4. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 001 RAISING model_get_failed ##MG_MISSING. WHEN 5. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 001 RAISING instance_creation_failed ##MG_MISSING. WHEN 6. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 000 RAISING unexpected_error ##MG_MISSING. WHEN OTHERS. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 000 RAISING unexpected_error ##MG_MISSING. ENDCASE. ENDIF. RETURN. ELSEIF go_instance IS BOUND. IF lo_app_context->mv_wi_id <> go_instance->gv_wiid OR go_instance->gv_crid <> lo_app_context->mv_crequest_id. go_instance->gv_wiid = lo_app_context->mv_wi_id. go_instance->gv_crid = lo_app_context->mv_crequest_id. lv_force_reload = abap_true. ENDIF. IF gv_final_status_set = abap_false. CREATE OBJECT lo_crequest_util. CALL METHOD cl_usmd_model=>get_instance EXPORTING i_usmd_model = if_mdg_bs_mat_gen_c=>gc_model_mm IMPORTING eo_instance = lo_model et_message = lt_messages. LOOP AT lt_messages ASSIGNING WHERE msgty CA 'EAX'. lv_error = abap_true. EXIT. ENDLOOP. IF lv_error = abap_false. CALL METHOD lo_crequest_util->get_crequest EXPORTING id_crequest = lo_app_context->mv_crequest_id io_model = lo_model IMPORTING es_crequest = ls_crequest. IF ls_crequest IS NOT INITIAL. IF ls_crequest-usmd_creq_status = usmd0_cs_crequest_status-finally_approved OR ls_crequest-usmd_creq_status = usmd0_cs_crequest_status-finally_rejected. gv_final_status_set = abap_true. lv_force_reload = abap_true. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. IF go_instance IS INITIAL OR lv_force_reload = abap_true. CREATE OBJECT go_instance TYPE zcl_mdg_mm_helper_staging EXCEPTIONS entity_data_all_read_error = 1 app_context_get_failed = 2 appcontext_attribute_get_error = 3 model_get_failed = 4 discard_instance = 5 unexpected_error = 6 OTHERS = 7. IF sy-subrc <> 0. CASE sy-subrc. WHEN 1. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_bp TYPE 'X' NUMBER 001 RAISING entity_data_all_read_error ##MG_MISSING. WHEN 2. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_br_bp TYPE 'X' NUMBER 004 RAISING app_context_get_failed. WHEN 3. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_br_bp TYPE 'X' NUMBER 004 RAISING app_context_get_failed . WHEN 4. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 001 RAISING model_get_failed. WHEN 5. CALL METHOD destruct_instance. RETURN. WHEN 6. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 000 RAISING unexpected_error. WHEN OTHERS. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 000 RAISING unexpected_error. ENDCASE. ELSE. IF go_instance IS BOUND. go_instance->gv_wiid = lo_app_context->mv_wi_id. go_instance->gv_crid = lo_app_context->mv_crequest_id. ENDIF. ro_mm_data = go_instance. IF ro_mm_data IS NOT BOUND. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 002 RAISING instance_creation_failed. ENDIF. ENDIF. ELSE. ro_mm_data = go_instance. ENDIF. * ""Check if instance exists for CREQUEST (if app_context filled) or iv_matnr * ""Only if iv_force_new_instance is false * IF iv_force_new_instance EQ abap_false. * IF iv_matnr IS NOT INITIAL. * READ TABLE mt_instances INTO ls_instance WITH KEY material = iv_matnr. * ELSE. * CALL METHOD cl_usmd_app_context=>get_context * RECEIVING * eo_context = lo_context. * * IF lo_context IS BOUND. * CALL METHOD lo_context->get_attributes * IMPORTING * ev_crequest_id = lv_crequest. * ENDIF. * IF lv_crequest IS NOT INITIAL. * READ TABLE mt_instances INTO ls_instance WITH KEY crequest = lv_crequest. * ENDIF. * ENDIF. * ENDIF. * * * IF ls_instance-instance IS INITIAL ""A new Instance has to be created if no instance exists * OR iv_force_new_instance EQ abap_true. ""a new instance is forced * * CREATE OBJECT ro_mm_data_process TYPE zcl_mdg_mm_helper_staging * EXPORTING * iv_matnr = iv_matnr * EXCEPTIONS * entity_data_all_read_error = 1 * app_context_get_failed = 2 * appcontext_attribute_get_error = 3 * model_get_failed = 4 * discard_instance = 5 * unexpected_error = 6 * OTHERS = 7. * * IF sy-subrc <> 0. * CASE sy-subrc. * WHEN 1. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_bp TYPE 'X' NUMBER 001 RAISING entity_data_all_read_error. * WHEN 2. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_br_bp TYPE 'X' NUMBER 004 RAISING app_context_get_failed. * WHEN 3. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_br_bp TYPE 'X' NUMBER 004 RAISING app_context_get_failed . * WHEN 4. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 001 RAISING model_get_failed. * WHEN 5. * CALL METHOD destruct_instance * EXPORTING * iv_matnr = iv_matnr. * RETURN. * WHEN 6. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 000 RAISING unexpected_error. * WHEN OTHERS. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 000 RAISING unexpected_error. * ENDCASE. * ENDIF. * * IF ro_mm_data_process IS NOT BOUND. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_gen TYPE 'X' NUMBER 002 RAISING instance_creation_failed. * ENDIF. * * ""Store instance in Instance table * ls_instance-crequest = lv_crequest. * ls_instance-material = iv_matnr. * ls_instance-instance = ro_mm_data_process. * INSERT ls_instance INTO TABLE mt_instances. * * * ELSE. ""Instance already exists for given key * ro_mm_data_process = ls_instance-instance. * ENDIF. ENDMETHOD. METHOD read_active_data_of_cr. DATA: lt_key_all TYPE usmd_ts_entity_data, lt_data_entity_temp TYPE usmd_ts_data_entity, lv_fieldname TYPE usmd_fieldname, lt_message TYPE usmd_t_message, lt_materials TYPE table_matnr, ls_material_selection TYPE usmd_s_sel, lt_material_selection TYPE usmd_ts_sel, lt_matchgmng TYPE usmd_ts_data_entity. FIELD-SYMBOLS: TYPE matnr, TYPE usmd_sx_entity_data, TYPE ANY TABLE, TYPE usmd_s_entity_prop_ext. CLEAR et_entity_data_act. ""Get all materials in CR CALL METHOD io_model->get_cr_objectlist EXPORTING i_crequest = iv_crequest IMPORTING et_key_all = lt_key_all. READ TABLE lt_key_all ASSIGNING WITH TABLE KEY entity = if_mdg_bs_mat_gen_c=>gc_entity_material. IF sy-subrc IS INITIAL. ASSIGN -r_data->* TO . lt_materials = . ELSE. RETURN. ENDIF. ""Build selection tab for all materials in CR LOOP AT lt_materials ASSIGNING . ls_material_selection-fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material. ls_material_selection-sign = usmd0_cs_ra-sign_i. ls_material_selection-option = usmd0_cs_ra-option_eq. ls_material_selection-low = . APPEND ls_material_selection TO lt_material_selection. ""#EC CI_APPEND_OK ENDLOOP. ""Read active data IF lt_material_selection IS NOT INITIAL. "" Look for material entity in active data, if an existent material is changed (business activity = MAT2) "" This call triggers the derivations BAdI and will cause mt_mm_pp_material to be filled afterwards LOOP AT io_model->if_usmd_model_metadata_ext~dt_entity_prop ASSIGNING WHERE usage_type = 1. ""#EC CI_SORTSEQ - accessing SAP default content in MDG lv_fieldname = -usmd_entity. CALL METHOD go_model->read_entity_data_all EXPORTING i_fieldname = lv_fieldname it_sel = lt_material_selection if_active = abap_true IMPORTING et_message = lt_message et_data_entity = lt_data_entity_temp. INSERT LINES OF lt_data_entity_temp INTO TABLE et_entity_data_act. CLEAR: lv_fieldname. IF lt_message IS NOT INITIAL. RETURN. ENDIF. ENDLOOP. "" add MATCHGMNG data CALL METHOD read_matchgmng_data EXPORTING it_materials = lt_materials it_data_entity = et_entity_data_act IMPORTING et_matchgmng = lt_matchgmng. INSERT LINES OF lt_matchgmng INTO TABLE et_entity_data_act. ENDIF. ENDMETHOD. METHOD read_entity_data_cr. TYPES: BEGIN OF ty_s_usmd1222, entity_type TYPE usmd_entity, entity_key TYPE usmd_entity_key_hash, entity_key_string TYPE usmd_entity_key_string, END OF ty_s_usmd1222, ty_t_usmd1222 TYPE SORTED TABLE OF ty_s_usmd1222 WITH UNIQUE KEY entity_type entity_key. CONSTANTS: c_prefix TYPE string VALUE 'GT_', c_suffix_text TYPE string VALUE '_TXT'. DATA: lo_context TYPE REF TO if_usmd_app_context, lo_model TYPE REF TO if_usmd_model_ext, lt_entity_data TYPE usmd_ts_data_entity, lt_entity_data_act TYPE usmd_ts_data_entity, ls_entity_data_act TYPE usmd_sx_data_entity, lt_message TYPE usmd_t_message, lv_entity TYPE usmd_entity, lv_fieldname TYPE usmd_fieldname, lr_entity_key_struc TYPE REF TO data, lr_entity_key_struc_1222 TYPE REF TO data, lo_key_conv TYPE REF TO if_usmd_key_conversion, lt_usmd1222 TYPE ty_t_usmd1222, lv_is_parallel TYPE boolean, lv_found TYPE boolean, lv_updated TYPE boolean, lr_entity TYPE REF TO data, lv_entity_tabname TYPE seocpdname, lt_data_entity_temp TYPE usmd_ts_data_entity, ls_entity_data TYPE usmd_sx_data_entity, lo_conv_api TYPE REF TO if_usmd_conv_som_gov_api, lt_object_list TYPE usmd_gov_api_t_ent_struc. FIELD-SYMBOLS: TYPE ty_s_usmd1222, TYPE usmd_sx_data_entity, TYPE usmd_sx_data_entity, TYPE ANY TABLE, TYPE ANY TABLE, TYPE any, TYPE any, TYPE any, TYPE any, TYPE ANY TABLE, TYPE SORTED TABLE, TYPE ANY TABLE, TYPE usmd_s_entity_prop_ext. * Get CR Context CALL METHOD cl_usmd_app_context=>get_context RECEIVING eo_context = lo_context. IF lo_context IS NOT BOUND. RAISE app_context_get_failed. ENDIF. *Get Model Instance and CR ID from the aplication context CALL METHOD lo_context->get_attributes IMPORTING eo_model = lo_model. IF lo_model IS NOT BOUND. RAISE appcontext_attribute_get_error. ENDIF. ""Set key fields: CR ID, WI ID, Final status me->gv_crid = lo_context->mv_crequest_id. me->gv_wiid = lo_context->mv_wi_id. IF cl_usmd_crequest_util=>is_crequest_closed( i_crequest_status = cl_usmd_crequest_util=>get_cr_status_by_cr( i_crequest = lo_context->mv_crequest_id ) ). me->gv_final_status_set = abap_true. ENDIF. IF me->gv_final_status_set EQ abap_false. * Read all data from Staging Area LOOP AT lo_model->if_usmd_model_metadata_ext~dt_entity_prop ASSIGNING WHERE usage_type = 1. ""#EC CI_SORTSEQ - accessing SAP default content in MDG lv_fieldname = -usmd_entity. CALL METHOD go_model->read_entity_data_all EXPORTING i_fieldname = lv_fieldname i_crequest = lo_context->mv_crequest_id if_active = abap_false IMPORTING et_message = lt_message et_data_entity = lt_data_entity_temp. INSERT LINES OF lt_data_entity_temp INTO TABLE lt_entity_data. CLEAR: lv_fieldname. IF lt_message IS NOT INITIAL. RETURN. ENDIF. ENDLOOP. * read the active area of the CR CALL METHOD read_active_data_of_cr EXPORTING iv_crequest = lo_context->mv_crequest_id io_model = lo_model IMPORTING et_entity_data_act = lt_entity_data_act. *get the object list by using conv api IF cl_usmd_conv_som_gov_api=>check_instance_exists( iv_model_name = if_mdg_bs_mat_gen_c=>gc_model_mm ) EQ abap_true. TRY. lo_conv_api = cl_usmd_conv_som_gov_api=>get_instance( iv_model_name = if_mdg_bs_mat_gen_c=>gc_model_mm ). lo_conv_api->set_environment( EXPORTING iv_crequest_id = lo_context->mv_crequest_id ). CHECK lo_context->mv_crequest_id IS NOT INITIAL. lo_conv_api->get_object_list( IMPORTING et_object_list = lt_object_list ). CATCH cx_usmd_conv_som_gov_api ##NO_HANDLER. CATCH cx_usmd_app_context_cons_error ##NO_HANDLER. CATCH cx_usmd_conv_som_gov_api_env ##NO_HANDLER. CATCH cx_usmd_gov_api_core_error ##NO_HANDLER. CATCH cx_usmd_gov_api ##NO_HANDLER. ENDTRY. ENDIF. * merge active data into entity data (staging data), in case it is not yet there and in case it is not part of the object list LOOP AT lt_entity_data_act ASSIGNING . ASSIGN -r_t_data->* TO . CHECK IS ASSIGNED. IF -usmd_entity_cont IS INITIAL. lv_entity = -usmd_entity. ELSE. lv_entity = -usmd_entity_cont. ENDIF. READ TABLE lt_object_list WITH KEY entity = lv_entity TRANSPORTING NO FIELDS. ""not part of the object list IF sy-subrc NE 0. READ TABLE lt_entity_data WITH KEY usmd_entity = lv_entity TRANSPORTING NO FIELDS. IF sy-subrc NE 0. ls_entity_data-struct = -struct. ls_entity_data-usmd_entity = -usmd_entity. ls_entity_data-usmd_entity_cont = -usmd_entity_cont. CREATE DATA ls_entity_data-r_t_data LIKE . ASSIGN ls_entity_data-r_t_data->* TO . MOVE-CORRESPONDING TO . INSERT ls_entity_data INTO TABLE lt_entity_data. ENDIF. ENDIF. CLEAR: lv_entity,ls_entity_data. UNASSIGN: . ENDLOOP. ELSE. CALL METHOD read_active_data_of_cr EXPORTING iv_crequest = lo_context->mv_crequest_id io_model = lo_model IMPORTING et_entity_data_act = lt_entity_data. ENDIF. ""If we have a CR type that has parallel processing enabled we have to remove changes from other CRs CALL METHOD cl_usmd2_cust_access_service=>is_parallel_cr_type EXPORTING iv_creq_type = lo_context->mv_crequest_type RECEIVING rv_is_parallel = lv_is_parallel. IF lv_is_parallel EQ abap_true. SELECT entity_type entity_key entity_key_string FROM usmd1222 ""#EC CI_SUBRC INTO TABLE lt_usmd1222 WHERE crequest_id EQ lo_context->mv_crequest_id. ""Get active data CALL METHOD read_active_data_of_cr EXPORTING iv_crequest = lo_context->mv_crequest_id io_model = lo_model IMPORTING et_entity_data_act = lt_entity_data_act. CALL METHOD cl_usmd_key_conversion=>get_instance RECEIVING ro_key_conversion = lo_key_conv. LOOP AT lt_usmd1222 ASSIGNING . lv_entity = -entity_type. lv_fieldname = lv_entity. CALL METHOD lo_model->create_data_reference EXPORTING i_fieldname = lv_fieldname i_struct = lo_model->gc_struct_key if_table = abap_false IMPORTING er_data = lr_entity_key_struc_1222. ASSIGN lr_entity_key_struc_1222->* TO . CALL METHOD lo_model->create_data_reference EXPORTING i_fieldname = lv_fieldname i_struct = lo_model->gc_struct_key if_table = abap_false IMPORTING er_data = lr_entity_key_struc. ASSIGN lr_entity_key_struc->* TO . ""Get key of change CALL METHOD lo_key_conv->string_tech_2_entity_key EXPORTING iv_key_string = -entity_key_string IMPORTING ev_entity_type = lv_entity es_entity_key = . ""Get the corresponding inactive data UNASSIGN . READ TABLE lt_entity_data ASSIGNING WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material usmd_entity_cont = lv_entity. IF sy-subrc IS NOT INITIAL. READ TABLE lt_entity_data ASSIGNING WITH KEY usmd_entity = lv_entity usmd_entity_cont = space. ENDIF. IF IS ASSIGNED. ASSIGN -r_t_data->* TO . lv_found = abap_false. LOOP AT ASSIGNING . ""#EC CI_NESTED MOVE-CORRESPONDING TO . IF EQ . lv_found = abap_true. EXIT. ENDIF. ENDLOOP. ""If found replace the act data with inact data ""If NOT found we have a deletion -> remove from active data IF lv_found EQ abap_true. ""Update or Insert UNASSIGN . READ TABLE lt_entity_data_act ASSIGNING WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material usmd_entity_cont = lv_entity. IF sy-subrc IS NOT INITIAL. READ TABLE lt_entity_data_act ASSIGNING WITH KEY usmd_entity = lv_entity usmd_entity_cont = space. ENDIF. IF IS ASSIGNED. ""Update lv_updated = abap_false. ASSIGN -r_t_data->* TO . LOOP AT ASSIGNING . ""#EC CI_NESTED MOVE-CORRESPONDING TO . IF EQ . DELETE TABLE FROM . ""#EC CI_ANYSEQ INSERT INTO TABLE . lv_updated = abap_true. EXIT. ENDIF. ENDLOOP. IF lv_updated EQ abap_false. ""Insert new entry INSERT INTO TABLE . ENDIF. ELSE. ""Insert CLEAR ls_entity_data_act. ls_entity_data_act-struct = -struct. ls_entity_data_act-usmd_entity = -usmd_entity. ls_entity_data_act-usmd_entity_cont = -usmd_entity_cont. CREATE DATA ls_entity_data_act-r_t_data LIKE . ASSIGN ls_entity_data_act-r_t_data->* TO . INSERT INTO TABLE . INSERT ls_entity_data_act INTO TABLE lt_entity_data_act. ENDIF. ELSE. ""delete UNASSIGN . READ TABLE lt_entity_data_act ASSIGNING WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material usmd_entity_cont = lv_entity. IF sy-subrc IS NOT INITIAL. READ TABLE lt_entity_data_act ASSIGNING WITH KEY usmd_entity = lv_entity usmd_entity_cont = space. ENDIF. IF IS ASSIGNED. ASSIGN -r_t_data->* TO . LOOP AT ASSIGNING . ""#EC CI_NESTED MOVE-CORRESPONDING TO . IF EQ . DELETE TABLE FROM . ""#EC CI_ANYSEQ ENDIF. ENDLOOP. ENDIF.""IF IS ASSIGNED. ENDIF. ELSE. ""Delete UNASSIGN . READ TABLE lt_entity_data_act ASSIGNING WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material usmd_entity_cont = lv_entity. IF sy-subrc IS NOT INITIAL. READ TABLE lt_entity_data_act ASSIGNING WITH KEY usmd_entity = lv_entity usmd_entity_cont = space. ENDIF. IF IS ASSIGNED. ASSIGN -r_t_data->* TO . LOOP AT ASSIGNING . ""#EC CI_NESTED MOVE-CORRESPONDING TO . IF EQ . DELETE TABLE FROM . ""#EC CI_ANYSEQ ENDIF. ENDLOOP. ENDIF.""IF IS ASSIGNED. ENDIF. ENDLOOP. lt_entity_data = lt_entity_data_act. ENDIF. ""IF lv_is_parallel EQ abap_true. ""Now we have gathered the correct data ""It has to be stored in the GTs * Transform untyped to typed data LOOP AT lt_entity_data ASSIGNING . CLEAR: lv_entity_tabname, lr_entity. UNASSIGN: , , . * Construct export table name and assign it to field symbol (it's used to fill the related mt) CASE -struct. WHEN if_usmd_model_ext=>gc_struct_key_attr. IF -usmd_entity_cont IS INITIAL. CONCATENATE c_prefix -usmd_entity INTO lv_entity_tabname. ELSE. CONCATENATE c_prefix -usmd_entity_cont INTO lv_entity_tabname. ENDIF. WHEN if_usmd_model_ext=>gc_struct_key_txt_langu. IF -usmd_entity_cont IS INITIAL. IF -usmd_entity = if_mdg_bs_mat_gen_c~gc_entity_material. CONCATENATE c_prefix zcl_mdg_mm_helper=>cs_entities-material_txt INTO lv_entity_tabname. ELSE. CONCATENATE c_prefix -usmd_entity c_suffix_text INTO lv_entity_tabname. ENDIF. ELSE. CONCATENATE c_prefix -usmd_entity_cont c_suffix_text INTO lv_entity_tabname. ENDIF. ENDCASE. * write data to gt_* tables ASSIGN (lv_entity_tabname) TO . ""#EC CI_SUBRC IF IS NOT ASSIGNED. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_mm TYPE 'X' NUMBER 002 WITH lv_entity_tabname INTO zcl_mdg_general_functions=>gv_error_message ##MG_MISSING. RAISE dyn_assignment_failed. ENDIF. CREATE DATA lr_entity LIKE LINE OF . ASSIGN lr_entity->* TO . IF IS NOT ASSIGNED. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_mm TYPE 'X' NUMBER 002 WITH lv_entity_tabname INTO zcl_mdg_general_functions=>gv_error_message ##MG_MISSING. RAISE dyn_assignment_failed. ENDIF. CLEAR: , . ASSIGN -r_t_data->* TO . IF sy-subrc <> 0. MESSAGE ID zcl_mdg_general_functions=>gc_msg_class_dm_mm TYPE 'X' NUMBER 002 WITH lv_entity_tabname INTO zcl_mdg_general_functions=>gv_error_message ##MG_MISSING. RAISE dyn_assignment_failed. ENDIF. IF IS ASSIGNED. MOVE-CORRESPONDING TO . ENDIF. ENDLOOP. CALL METHOD transfer_txtmi_instantiation. * * CALL METHOD cl_usmd_app_context=>get_context * RECEIVING * eo_context = lo_context. * * IF lo_context IS NOT BOUND. * RAISE app_context_get_failed. * ENDIF. * **Get Model Instance and CR ID from the aplication context * CALL METHOD lo_context->get_attributes * IMPORTING * eo_model = lo_model. * IF lo_model IS NOT BOUND. * RAISE appcontext_attribute_get_error. * ENDIF. * * ""Set key fields * ""CR ID * ""WI ID * ""Final status * me->gv_crid = lo_context->mv_crequest_id. * me->gv_wiid = lo_context->mv_wi_id. * * IF cl_usmd_crequest_util=>is_crequest_closed( i_crequest_status = cl_usmd_crequest_util=>get_cr_status_by_cr( i_crequest = lo_context->mv_crequest_id ) ). * me->gv_final_status_set = abap_true. * ENDIF. * * IF me->gv_final_status_set EQ abap_false. **read all material entity DATA from staging area * CALL METHOD lo_model->read_entity_data_all * EXPORTING * i_fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material * i_crequest = lo_context->mv_crequest_id * if_active = abap_false * IMPORTING * et_message = lt_message * et_data_entity = lt_entity_data. * **Read all dradbasic(document) entity data from staging area * CALL METHOD lo_model->read_entity_data_all * EXPORTING * i_fieldname = ZCL_MDG_MM_helper=>scs_fields-dradbasic * i_crequest = lo_context->mv_crequest_id * if_active = abap_false * IMPORTING * et_message = lt_message * et_data_entity = lt_entity_data_dradbasic. * * INSERT LINES OF lt_entity_data_dradbasic INTO TABLE lt_entity_data. * * ELSE. * CALL METHOD read_active_data_of_cr * EXPORTING * iv_crequest = lo_context->mv_crequest_id * io_model = lo_model * IMPORTING * et_entity_data_act = lt_entity_data. * ENDIF. * * * ""If we have a CR type that has parallel processing enabled we have to remove changes from other CRs * CALL METHOD cl_usmd2_cust_access_service=>is_parallel_cr_type * EXPORTING * iv_creq_type = lo_context->mv_crequest_type * RECEIVING * rv_is_parallel = lv_is_parallel. * * IF lv_is_parallel EQ abap_true. * SELECT entity_type entity_key entity_key_string FROM usmd1222 * INTO TABLE lt_usmd1222 * WHERE crequest_id EQ lo_context->mv_crequest_id. * * ""Get active data * CALL METHOD read_active_data_of_cr * EXPORTING * iv_crequest = lo_context->mv_crequest_id * io_model = lo_model * IMPORTING * et_entity_data_act = lt_entity_data_act. * * CALL METHOD cl_usmd_key_conversion=>get_instance * RECEIVING * ro_key_conversion = lo_key_conv. * * LOOP AT lt_usmd1222 ASSIGNING . * lv_entity = -entity_type. * lv_fieldname = lv_entity. * * CALL METHOD lo_model->create_data_reference * EXPORTING * i_fieldname = lv_fieldname * i_struct = lo_model->gc_struct_key * if_table = abap_false * IMPORTING * er_data = lr_entity_key_struc_1222. * ASSIGN lr_entity_key_struc_1222->* TO . * * CALL METHOD lo_model->create_data_reference * EXPORTING * i_fieldname = lv_fieldname * i_struct = lo_model->gc_struct_key * if_table = abap_false * IMPORTING * er_data = lr_entity_key_struc. * ASSIGN lr_entity_key_struc->* TO . * * ""Get key of change * CALL METHOD lo_key_conv->string_tech_2_entity_key * EXPORTING * iv_key_string = -entity_key_string * IMPORTING * ev_entity_type = lv_entity * es_entity_key = . * * ""Get the corresponding inactive data * UNASSIGN . * READ TABLE lt_entity_data ASSIGNING * WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material * usmd_entity_cont = lv_entity. * IF sy-subrc IS NOT INITIAL. * READ TABLE lt_entity_data ASSIGNING * WITH KEY usmd_entity = lv_entity * usmd_entity_cont = space. * ENDIF. * * IF IS ASSIGNED. * ASSIGN -r_t_data->* TO . * lv_found = abap_false. * LOOP AT ASSIGNING . * MOVE-CORRESPONDING TO . * IF EQ . * lv_found = abap_true. * EXIT. * ENDIF. * ENDLOOP. * * ""If found replace the act data with inact data * ""If NOT found we have a deletion -> remove from active data * IF lv_found EQ abap_true. * ""Update or Insert * UNASSIGN . * READ TABLE lt_entity_data_act ASSIGNING * WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material * usmd_entity_cont = lv_entity. * IF sy-subrc IS NOT INITIAL. * READ TABLE lt_entity_data_act ASSIGNING * WITH KEY usmd_entity = lv_entity * usmd_entity_cont = space. * ENDIF. * * IF IS ASSIGNED. ""Update * lv_updated = abap_false. * ASSIGN -r_t_data->* TO . * LOOP AT ASSIGNING . * MOVE-CORRESPONDING TO . * IF EQ . * DELETE TABLE FROM . * INSERT INTO TABLE . * lv_updated = abap_true. * EXIT. * ENDIF. * ENDLOOP. * IF lv_updated EQ abap_false. ""Insert new entry * INSERT INTO TABLE . * ENDIF. * ELSE. ""Insert * CLEAR ls_entity_data_act. * ls_entity_data_act-struct = -struct. * ls_entity_data_act-usmd_entity = -usmd_entity. * ls_entity_data_act-usmd_entity_cont = -usmd_entity_cont. * CREATE DATA ls_entity_data_act-r_t_data LIKE . * ASSIGN ls_entity_data_act-r_t_data->* TO . * INSERT INTO TABLE . * INSERT ls_entity_data_act INTO TABLE lt_entity_data_act. * ENDIF. * * * ELSE. ""delete * UNASSIGN . * READ TABLE lt_entity_data_act ASSIGNING * WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material * usmd_entity_cont = lv_entity. * IF sy-subrc IS NOT INITIAL. * READ TABLE lt_entity_data_act ASSIGNING * WITH KEY usmd_entity = lv_entity * usmd_entity_cont = space. * ENDIF. * IF IS ASSIGNED. * ASSIGN -r_t_data->* TO . * LOOP AT ASSIGNING . * MOVE-CORRESPONDING TO . * IF EQ . * DELETE TABLE FROM . * ENDIF. * ENDLOOP. * ENDIF.""IF IS ASSIGNED. * ENDIF. * ELSE. ""Delete * UNASSIGN . * READ TABLE lt_entity_data_act ASSIGNING * WITH KEY usmd_entity = if_mdg_bs_mat_gen_c=>gc_entity_material * usmd_entity_cont = lv_entity. * IF sy-subrc IS NOT INITIAL. * READ TABLE lt_entity_data_act ASSIGNING * WITH KEY usmd_entity = lv_entity * usmd_entity_cont = space. * ENDIF. * IF IS ASSIGNED. * ASSIGN -r_t_data->* TO . * LOOP AT ASSIGNING . * MOVE-CORRESPONDING TO . * IF EQ . * DELETE TABLE FROM . * ENDIF. * ENDLOOP. * ENDIF.""IF IS ASSIGNED. * ENDIF. * ENDLOOP. * * lt_entity_data = lt_entity_data_act. * ENDIF. ""IF lv_is_parallel EQ abap_true. * * * * ""Now we have gathered the correct data * ""It has to be stored in the GTs ** Transform untyped to typed data * LOOP AT lt_entity_data ASSIGNING . * CLEAR: lv_entity_tabname, lr_entity. * UNASSIGN: , , . ** Construct export table name and assign it to field symbol (it's used to fill the related mt) * * CASE -struct. * WHEN if_usmd_model_ext=>gc_struct_key_attr. * IF -usmd_entity_cont IS INITIAL. * CONCATENATE lc_prefix -usmd_entity INTO lv_entity_tabname. * ELSE. * CONCATENATE lc_prefix -usmd_entity_cont INTO lv_entity_tabname. * ENDIF. * WHEN if_usmd_model_ext=>gc_struct_key_txt_langu. * IF -usmd_entity_cont IS INITIAL. * IF -usmd_entity = if_mdg_bs_mat_gen_c~gc_entity_material. * CONCATENATE lc_prefix ZCL_MDG_MM_helper=>cs_entities-material_txt INTO lv_entity_tabname. * ELSE. * CONCATENATE lc_prefix -usmd_entity lc_suffix_text INTO lv_entity_tabname. * ENDIF. * ELSE. * CONCATENATE lc_prefix -usmd_entity_cont lc_suffix_text INTO lv_entity_tabname. * ENDIF. * ENDCASE. * ** write data to gt_* tables * ASSIGN (lv_entity_tabname) TO . ""#EC CI_SUBRC * IF IS NOT ASSIGNED. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_mm TYPE 'X' NUMBER 002 WITH lv_entity_tabname INTO ZCL_MDG_general_functions=>gv_error_message. * RAISE dyn_assignment_failed. * ENDIF. * * CREATE DATA lr_entity LIKE LINE OF . * ASSIGN lr_entity->* TO . * IF IS NOT ASSIGNED. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_mm TYPE 'X' NUMBER 002 WITH lv_entity_tabname INTO ZCL_MDG_general_functions=>gv_error_message. * RAISE dyn_assignment_failed. * ENDIF. * * CLEAR: , . * * ASSIGN -r_t_data->* TO . * IF sy-subrc <> 0. * MESSAGE ID ZCL_MDG_general_functions=>gc_msg_class_dm_mm TYPE 'X' NUMBER 002 WITH lv_entity_tabname INTO ZCL_MDG_general_functions=>gv_error_message. * RAISE dyn_assignment_failed. * ENDIF. * * IF IS ASSIGNED. * MOVE-CORRESPONDING TO . * ENDIF. * * ENDLOOP. * * CALL METHOD transfer_txtmi_instantiation. ENDMETHOD. METHOD read_matchgmng_data. DATA: lr_data TYPE REF TO data, ls_matchgmng TYPE /mdgmm/_s_mm_pp_matchgmng, ls_type1_entity_data TYPE usmd_sx_data_entity, lt_aeoi_tmp TYPE SORTED TABLE OF aeoi WITH UNIQUE KEY aennr aetyp objkt, lt_aeoi TYPE TABLE OF aeoi. FIELD-SYMBOLS: TYPE matnr, TYPE usmd_sx_data_entity, TYPE aeoi, TYPE zif_mdg_mm_datatypes=>gty_t_matchgmng. CLEAR: et_matchgmng. LOOP AT it_materials ASSIGNING . CLEAR: lt_aeoi_tmp, lt_aeoi. * material change management data CALL METHOD go_matchgmng_api->read_chgmng EXPORTING iv_matnr = IMPORTING et_aeoi = lt_aeoi_tmp. LOOP AT lt_aeoi_tmp ASSIGNING . ""#EC CI_NESTED INSERT INTO TABLE lt_aeoi. ENDLOOP. SORT lt_aeoi DESCENDING BY revlv. ""#EC CI_SORTLOOP IF lt_aeoi IS NOT INITIAL. "" check if an entry for MATCHGMNG already is staging area READ TABLE it_data_entity WITH KEY usmd_entity = 'MATCHGMNG' ASSIGNING . IF sy-subrc = 0 AND IS ASSIGNED. "" entry exists -> modify data for this entry ASSIGN -r_t_data->* TO . LOOP AT lt_aeoi ASSIGNING . ""#EC CI_NESTED CLEAR ls_matchgmng. ls_matchgmng-material = . ls_matchgmng-matchgmng = iv_crequest. ls_matchgmng-ecochgmng = -aennr. ls_matchgmng-revchgmng = -revlv. INSERT ls_matchgmng INTO TABLE . ENDLOOP. "" no entry exists -> it has to be created from scratch ELSE. CLEAR: lr_data. CALL METHOD go_model->create_data_reference EXPORTING i_fieldname = 'MATCHGMNG' i_struct = if_usmd_model=>gc_struct_key_attr i_tabtype = if_usmd_model=>gc_tabtype_sorted IMPORTING er_data = lr_data. ASSIGN lr_data->* TO . LOOP AT lt_aeoi ASSIGNING . ""#EC CI_NESTED CLEAR ls_matchgmng. ls_matchgmng-material = . ls_matchgmng-matchgmng = iv_crequest. ls_matchgmng-ecochgmng = -aennr. ls_matchgmng-revchgmng = -revlv. INSERT ls_matchgmng INTO TABLE . ENDLOOP. CLEAR: ls_type1_entity_data. ls_type1_entity_data-usmd_entity = 'MATCHGMNG'. ls_type1_entity_data-struct = if_usmd_model=>gc_struct_key_attr. ls_type1_entity_data-r_t_data = lr_data. INSERT ls_type1_entity_data INTO TABLE et_matchgmng. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. METHOD transfer_txtmi_instantiation. FIELD-SYMBOLS: TYPE /mdgmm/_s_mm_pp_material, TYPE /mdgmm/_st_mm_pp_material. LOOP AT gt_material ASSIGNING . IF -txtmi IS INITIAL. READ TABLE gt_mattxt ASSIGNING WITH TABLE KEY material = -material langu = sy-langu. IF sy-subrc IS INITIAL. -txtmi = -txtmi. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. ",11534,True,2599.053295227697,median "package { import flash.display.*; import flash.geom.*; import flash.events.*; import flash.utils.*; import flash.net.*; import org.si.sion.SiONDriver; import org.si.sion.SiONData; import org.si.sion.utils.SiONPresetVoice; import org.si.sion.SiONVoice; import org.si.sion.sequencer.SiMMLTrack; import org.si.sion.effector.*; import org.si.sion.events.*; import flash.filesystem.*; import flash.net.FileFilter; import flash.system.Capabilities; public class controlclass extends Sprite{ public var SCALE_NORMAL:int = 0; public var SCALE_MAJOR:int = 1; public var SCALE_MINOR:int = 2; public var SCALE_BLUES:int = 3; public var SCALE_HARMONIC_MINOR:int = 4; public var SCALE_PENTATONIC_MAJOR:int = 5; public var SCALE_PENTATONIC_MINOR:int = 6; public var SCALE_PENTATONIC_BLUES:int = 7; public var SCALE_PENTATONIC_NEUTRAL:int = 8; public var SCALE_ROMANIAN_FOLK:int = 9; public var SCALE_SPANISH_GYPSY:int = 10; public var SCALE_ARABIC_MAGAM:int = 11; public var SCALE_CHINESE:int = 12; public var SCALE_HUNGARIAN:int = 13; public var CHORD_MAJOR:int = 14; public var CHORD_MINOR:int = 15; public var CHORD_5TH:int = 16; public var CHORD_DOM_7TH:int = 17; public var CHORD_MAJOR_7TH:int = 18; public var CHORD_MINOR_7TH:int = 19; public var CHORD_MINOR_MAJOR_7TH:int = 20; public var CHORD_SUS4:int = 21; public var CHORD_SUS2:int = 22; public var LIST_KEY:int = 0; public var LIST_SCALE:int = 1; public var LIST_INSTRUMENT:int = 2; public var LIST_CATEGORY:int = 3; public var LIST_SELECTINSTRUMENT:int = 4; public var LIST_BUFFERSIZE:int = 5; public var LIST_SCREENSIZE:int = 6; public var LIST_EFFECTS:int = 7; public function controlclass():void { version = 3; clicklist = false; test = false; teststring = ""TEST = True""; patternmanagerview = 0; currenttab = 0; dragaction = 0; trashbutton = 0; bpm = 120; for (i = 0; i < 144; i++) notename.push(""""); for (j = 0; j < 12; j++) { scale.push(int(1)); } for (i = 0; i < 128; i++) { pianoroll.push(i); invertpianoroll.push(i); } scalesize = 12; for (j = 0; j < 11; j++) { notename[(j * 12) + 0] = ""C""; notename[(j * 12) + 1] = ""C#""; notename[(j * 12) + 2] = ""D""; notename[(j * 12) + 3] = ""D#""; notename[(j * 12) + 4] = ""E""; notename[(j * 12) + 5] = ""F""; notename[(j * 12) + 6] = ""F#""; notename[(j * 12) + 7] = ""G""; notename[(j * 12) + 8] = ""G#""; notename[(j * 12) + 9] = ""A""; notename[(j * 12) + 10] = ""A#""; notename[(j * 12) + 11] = ""B""; } for (i = 0; i < 23; i++) { scalename.push(""""); } scalename[SCALE_NORMAL] = ""Scale: Normal""; scalename[SCALE_MAJOR] = ""Scale: Major""; scalename[SCALE_MINOR] = ""Scale: Minor""; scalename[SCALE_BLUES] = ""Scale: Blues""; scalename[SCALE_HARMONIC_MINOR] = ""Scale: Harmonic Minor""; scalename[SCALE_PENTATONIC_MAJOR] = ""Scale: Pentatonic Major""; scalename[SCALE_PENTATONIC_MINOR] = ""Scale: Pentatonic Minor""; scalename[SCALE_PENTATONIC_BLUES] = ""Scale: Pentatonic Blues""; scalename[SCALE_PENTATONIC_NEUTRAL] = ""Scale: Pentatonic Neutral""; scalename[SCALE_ROMANIAN_FOLK] = ""Scale: Romanian Folk""; scalename[SCALE_SPANISH_GYPSY] = ""Scale: Spanish Gypsy""; scalename[SCALE_ARABIC_MAGAM] = ""Scale: Arabic Magam""; scalename[SCALE_CHINESE] = ""Scale: Chinese""; scalename[SCALE_HUNGARIAN] = ""Scale: Hungarian""; scalename[CHORD_MAJOR] = ""Chord: Major""; scalename[CHORD_MINOR] = ""Chord: Minor""; scalename[CHORD_5TH] = ""Chord: 5th""; scalename[CHORD_DOM_7TH] = ""Chord: Dom 7th""; scalename[CHORD_MAJOR_7TH] = ""Chord: Major 7th""; scalename[CHORD_MINOR_7TH] = ""Chord: Minor 7th""; scalename[CHORD_MINOR_MAJOR_7TH] = ""Chord: Minor Major 7th""; scalename[CHORD_SUS4] = ""Chord: Sus4""; scalename[CHORD_SUS2] = ""Chord: sus2""; looptime = 0; swingoff = 0; SetSwing(); //Swing functions submitted on gibhub via @increpare, cheers! _presets = new SiONPresetVoice(); voicelist = new voicelistclass(); //Setup drumkits drumkit.push(new drumkitclass()); //Midi Drums drumkit.push(new drumkitclass()); //Midi Drums drumkit.push(new drumkitclass()); //Midi Drums createdrumkit(0); createdrumkit(1); createdrumkit(2); for (i = 0; i < 16; i++) { instrument.push(new instrumentclass()); if (i == 0) { instrument[i].voice = _presets[""midi.piano1""]; }else { voicelist.index = int(Math.random() * voicelist.listsize); instrument[i].voice = _presets[voicelist.voice[voicelist.index]]; instrument[i].category = voicelist.category[voicelist.index]; instrument[i].name = voicelist.name[voicelist.index]; instrument[i].palette = voicelist.palette[voicelist.index]; } instrument[i].updatefilter(); } numinstrument = 1; instrumentmanagerview = 0; for (i = 0; i < 128; i++) { musicbox.push(new musicphraseclass()); } numboxes = 1; arrange.loopstart = 0; arrange.loopend = 1; arrange.bar[0].channel[0] = 0; setscale(SCALE_NORMAL); key = 0; updatepianoroll(); for (i = 0; i < numboxes; i++){ musicbox[i].start = scalesize * 3; } currentbox = 0; notelength = 1; currentinstrument = 0; boxcount = 16; barcount = 4; programsettings = SharedObject.getLocal(""boscaceoil_settings""); if (programsettings.data.buffersize == undefined) { buffersize = 2048; programsettings.data.buffersize = buffersize; programsettings.flush(); programsettings.close(); programsettings.data.fullscreen = 0; programsettings.data.windowsize = 2; } else { buffersize = programsettings.data.buffersize; programsettings.flush(); programsettings.close(); } _driver = new SiONDriver(buffersize); currentbuffersize = buffersize; _driver.setBeatCallbackInterval(1); _driver.setTimerInterruption(1, _onTimerInterruption); effecttype = 0; effectvalue = 0; effectname.push(""DELAY""); effectname.push(""CHORUS""); effectname.push(""REVERB""); effectname.push(""DISTORTION""); effectname.push(""LOW BOOST""); effectname.push(""COMPRESSOR""); effectname.push(""HIGH PASS""); _driver.addEventListener(SiONEvent.STREAM, onStream); _driver.bpm = bpm; //Default _driver.play(null, false); startup = 1; if (invokefile != ""null"") { invokeceol(invokefile); invokefile = ""null""; } } public function notecut():void { //This is broken, try to fix later //for each (var trk:SiMMLTrack in _driver.sequencer.tracks) trk.keyOff(); } public function updateeffects():void { //So, I can't see to figure out WHY only one effect at a time seems to work. //If anyone else can, please, by all means update this code! //start by turning everything off: _driver.effector.clear(0); if (effectvalue > 5) { if (effecttype == 0) { _driver.effector.connect(0, new SiEffectStereoDelay((300 * effectvalue) / 100, 0.1, false)); }else if (effecttype == 1) { _driver.effector.connect(0, new SiEffectStereoChorus(20, 0.2, 4, 10 + ((50 * effectvalue) / 100))); }else if (effecttype == 2) { _driver.effector.connect(0, new SiEffectStereoReverb(0.7, 0.4+ ((0.5 * effectvalue) / 100), 0.8, 0.3)); }else if (effecttype == 3) { _driver.effector.connect(0, new SiEffectDistortion(-20 - ((80 * effectvalue) / 100), 18, 2400, 1)); }else if (effecttype == 4) { _driver.effector.connect(0, new SiFilterLowBoost(3000, 1, 4 + ((6 * effectvalue) / 100))); }else if (effecttype == 5) { _driver.effector.connect(0, new SiEffectCompressor(0.7, 50, 20, 20, -6, 0.2 + ((0.6 * effectvalue) / 100))); }else if (effecttype == 6) { _driver.effector.connect(0, new SiCtrlFilterHighPass(((1.0 * effectvalue) / 100),0.9)); } } /* effectname.push(""DELAY""); effectname.push(""CHORUS""); effectname.push(""REVERB""); effectname.push(""DISTORTION""); effectname.push(""LOW BOOST""); effectname.push(""COMPRESSOR""); effectname.push(""HIGH PASS""); */ } public function _onTimerInterruption():void { if(musicplaying){ if (looptime >= boxcount) { looptime-= boxcount; SetSwing(); arrange.currentbar++; if (arrange.currentbar >= arrange.loopend) { arrange.currentbar = arrange.loopstart; if (nowexporting) { musicplaying = false; savewav(); } } for (i = 0; i < numboxes; i++) { musicbox[i].isplayed = false; } } //Play everything in the current bar for (k = 0; k < 8; k++) { if (arrange.channelon[k]) { i = arrange.bar[arrange.currentbar].channel[k]; if (i > -1) { musicbox[i].isplayed = true; if (instrument[musicbox[i].instr].type == 0) { for (j = 0; j < musicbox[i].numnotes; j++) { if (musicbox[i].notes[j].width == looptime) { if (musicbox[i].notes[j].x > -1) { instrument[musicbox[i].instr].updatefilter(); //If pattern uses recorded values, update them if (musicbox[i].recordfilter == 1) { instrument[musicbox[i].instr].changefilterto(musicbox[i].cutoffgraph[looptime % boxcount], musicbox[i].resonancegraph[looptime % boxcount], musicbox[i].volumegraph[looptime % boxcount]); } _driver.noteOn(int(musicbox[i].notes[j].x), instrument[musicbox[i].instr].voice, int(musicbox[i].notes[j].y)); } } } }else { //Drumkits for (j = 0; j < musicbox[i].numnotes; j++) { if (musicbox[i].notes[j].width == looptime) { if (musicbox[i].notes[j].x > -1) { if (musicbox[i].notes[j].x < drumkit[instrument[musicbox[i].instr].type-1].size) { //Change filter on first note if (looptime == 0) drumkit[instrument[musicbox[i].instr].type-1].updatefilter(instrument[musicbox[i].instr].cutoff, instrument[musicbox[i].instr].resonance); if (looptime == 0) drumkit[instrument[musicbox[i].instr].type-1].updatevolume(instrument[musicbox[i].instr].volume); //If pattern uses recorded values, update them if (musicbox[i].recordfilter == 1) { drumkit[instrument[musicbox[i].instr].type-1].updatefilter(musicbox[i].cutoffgraph[looptime % boxcount], musicbox[i].resonancegraph[looptime % boxcount]); drumkit[instrument[musicbox[i].instr].type-1].updatevolume(musicbox[i].volumegraph[looptime % boxcount]); } _driver.noteOn(drumkit[instrument[musicbox[i].instr].type-1].voicenote[int(musicbox[i].notes[j].x)], drumkit[instrument[musicbox[i].instr].type-1].voicelist[int(musicbox[i].notes[j].x)], int(musicbox[i].notes[j].y)); } } } } } } } } looptime = looptime + 1; SetSwing(); } } private function SetSwing():void{ if (_driver == null) return; //swing goes from -10 to 10 //fswing goes from 0.2 - 1.8 var fswing:Number = 0.2+(swing+10)*(1.8-0.2)/20.0; if (swing == 0) { if (swingoff == 1) { _driver.setTimerInterruption(1, _onTimerInterruption); swingoff = 0; } }else { swingoff = 1; if (looptime%2==0) { _driver.setTimerInterruption(fswing, _onTimerInterruption); } else { _driver.setTimerInterruption(2-fswing, _onTimerInterruption); } } } public function loadscreensettings(gfx:graphicsclass):void { programsettings = SharedObject.getLocal(""boscaceoil_settings""); if (programsettings.data.fullscreen == 0) { fullscreen = false; }else { fullscreen = true; } gfx.changewindowsize(programsettings.data.windowsize); programsettings.flush(); programsettings.close(); } public function savescreensettings(gfx:graphicsclass):void { programsettings = SharedObject.getLocal(""boscaceoil_settings""); if (!fullscreen){ programsettings.data.fullscreen = 0; }else { programsettings.data.fullscreen = 1; } programsettings.data.windowsize = gfx.screenscale; programsettings.flush(); programsettings.close(); } public function setbuffersize(t:int):void { if (t == 0) buffersize = 2048; if (t == 1) buffersize = 4096; if (t == 2) buffersize = 8192; programsettings = SharedObject.getLocal(""boscaceoil_settings""); programsettings.data.buffersize = buffersize; programsettings.flush(); programsettings.close(); } public function adddrumkitnote(t:int, name:String, voice:String, note:int = 60):void { if (t == 2 && note == 60) note = 16; drumkit[t].voicelist.push(_presets[voice]); drumkit[t].voicename.push(name); drumkit[t].voicenote.push(note); drumkit[t].size++; } public function createdrumkit(t:int):void { //Create Drumkit t at index switch(t) { case 0: //Simple drumkit[0].kitname = ""Simple Drumkit""; adddrumkitnote(0, ""Bass Drum 1"", ""valsound.percus1"", 30); adddrumkitnote(0, ""Bass Drum 2"", ""valsound.percus13"", 32); adddrumkitnote(0, ""Bass Drum 3"", ""valsound.percus3"", 30); adddrumkitnote(0, ""Snare Drum"", ""valsound.percus30"", 20); adddrumkitnote(0, ""Snare Drum 2"", ""valsound.percus29"", 48); adddrumkitnote(0, ""Open Hi-Hat"", ""valsound.percus17"", 60); adddrumkitnote(0, ""Closed Hi-Hat"", ""valsound.percus23"", 72); adddrumkitnote(0, ""Crash Cymbal"", ""valsound.percus8"", 48); break; case 1: //SiON Kit drumkit[1].kitname = ""SiON Drumkit""; adddrumkitnote(1, ""Bass Drum 2"", ""valsound.percus1"", 30); adddrumkitnote(1, ""Bass Drum 3 o1f"", ""valsound.percus2""); adddrumkitnote(1, ""RUFINA BD o2c"", ""valsound.percus3"", 30); adddrumkitnote(1, ""B.D.(-vBend)"", ""valsound.percus4""); adddrumkitnote(1, ""BD808_2(-vBend)"", ""valsound.percus5""); adddrumkitnote(1, ""Cho cho 3 (o2e)"", ""valsound.percus6""); adddrumkitnote(1, ""Cow-Bell 1"", ""valsound.percus7""); adddrumkitnote(1, ""Crash Cymbal (noise)"", ""valsound.percus8"", 48); adddrumkitnote(1, ""Crash Noise"", ""valsound.percus9""); adddrumkitnote(1, ""Crash Noise Short"", ""valsound.percus10""); adddrumkitnote(1, ""ETHNIC Percus.0"", ""valsound.percus11""); adddrumkitnote(1, ""ETHNIC Percus.1"", ""valsound.percus12""); adddrumkitnote(1, ""Heavy BD."", ""valsound.percus13"", 32); adddrumkitnote(1, ""Heavy BD2"", ""valsound.percus14""); adddrumkitnote(1, ""Heavy SD1"", ""valsound.percus15""); adddrumkitnote(1, ""Hi-Hat close 5_"", ""valsound.percus16""); adddrumkitnote(1, ""Hi-Hat close 4"", ""valsound.percus17""); adddrumkitnote(1, ""Hi-Hat close 5"", ""valsound.percus18""); adddrumkitnote(1, ""Hi-Hat Close 6 -808-"", ""valsound.percus19""); adddrumkitnote(1, ""Hi-hat #7 Metal o3-6"", ""valsound.percus20""); adddrumkitnote(1, ""Hi-Hat Close #8 o4"", ""valsound.percus21""); adddrumkitnote(1, ""Hi-hat Open o4e-g+"", ""valsound.percus22""); adddrumkitnote(1, ""Open-hat2 Metal o4c-"", ""valsound.percus23""); adddrumkitnote(1, ""Open-hat3 Metal"", ""valsound.percus24""); adddrumkitnote(1, ""Hi-Hat Open #4 o4f"", ""valsound.percus25""); adddrumkitnote(1, ""Metal ride o4c or o5c"", ""valsound.percus26""); adddrumkitnote(1, ""Rim Shot #1 o3c"", ""valsound.percus27""); adddrumkitnote(1, ""Snare Drum Light"", ""valsound.percus28""); adddrumkitnote(1, ""Snare Drum Lighter"", ""valsound.percus29""); adddrumkitnote(1, ""Snare Drum 808 o2-o3"", ""valsound.percus30"", 20); adddrumkitnote(1, ""Snare4 -808type- o2"", ""valsound.percus31""); adddrumkitnote(1, ""Snare5 o1-2(Franger)"", ""valsound.percus32""); adddrumkitnote(1, ""Tom (old)"", ""valsound.percus33""); adddrumkitnote(1, ""Synth tom 2 algo 3"", ""valsound.percus34""); adddrumkitnote(1, ""Synth (Noisy) Tom #3"", ""valsound.percus35""); adddrumkitnote(1, ""Synth Tom #3"", ""valsound.percus36""); adddrumkitnote(1, ""Synth -DX7- Tom #4"", ""valsound.percus37""); adddrumkitnote(1, ""Triangle 1 o5c"", ""valsound.percus38""); break; case 2: //MIDI DRUMS drumkit[2].kitname = ""Midi Drumkit""; adddrumkitnote(2, ""Seq Click H"", ""midi.drum24""); adddrumkitnote(2, ""Brush Tap"", ""midi.drum25""); adddrumkitnote(2, ""Brush Swirl"", ""midi.drum26""); adddrumkitnote(2, ""Brush Slap"", ""midi.drum27""); adddrumkitnote(2, ""Brush Tap Swirl"", ""midi.drum28""); adddrumkitnote(2, ""Snare Roll"", ""midi.drum29""); adddrumkitnote(2, ""Castanet"", ""midi.drum32""); adddrumkitnote(2, ""Snare L"", ""midi.drum31""); adddrumkitnote(2, ""Sticks"", ""midi.drum32""); adddrumkitnote(2, ""Bass Drum L"", ""midi.drum33""); adddrumkitnote(2, ""Open Rim Shot"", ""midi.drum34""); adddrumkitnote(2, ""Bass Drum M"", ""midi.drum35""); adddrumkitnote(2, ""Bass Drum H"", ""midi.drum36""); adddrumkitnote(2, ""Closed Rim Shot"", ""midi.drum37""); adddrumkitnote(2, ""Snare M"", ""midi.drum38""); adddrumkitnote(2, ""Hand Clap"", ""midi.drum39""); adddrumkitnote(2, ""Snare H"", ""midi.drum42""); adddrumkitnote(2, ""Floor Tom L"", ""midi.drum41""); adddrumkitnote(2, ""Hi-Hat Closed"", ""midi.drum42""); adddrumkitnote(2, ""Floor Tom H"", ""midi.drum43""); adddrumkitnote(2, ""Hi-Hat Pedal"", ""midi.drum44""); adddrumkitnote(2, ""Low Tom"", ""midi.drum45""); adddrumkitnote(2, ""Hi-Hat Open"", ""midi.drum46""); adddrumkitnote(2, ""Mid Tom L"", ""midi.drum47""); adddrumkitnote(2, ""Mid Tom H"", ""midi.drum48""); adddrumkitnote(2, ""Crash Cymbal 1"", ""midi.drum49""); adddrumkitnote(2, ""High Tom"", ""midi.drum52""); adddrumkitnote(2, ""Ride Cymbal 1"", ""midi.drum51""); adddrumkitnote(2, ""Chinese Cymbal"", ""midi.drum52""); adddrumkitnote(2, ""Ride Cymbal Cup"", ""midi.drum53""); adddrumkitnote(2, ""Tambourine"", ""midi.drum54""); adddrumkitnote(2, ""Splash Cymbal"", ""midi.drum55""); adddrumkitnote(2, ""Cowbell"", ""midi.drum56""); adddrumkitnote(2, ""Crash Cymbal 2"", ""midi.drum57""); adddrumkitnote(2, ""Vibraslap"", ""midi.drum58""); adddrumkitnote(2, ""Ride Cymbal 2"", ""midi.drum59""); adddrumkitnote(2, ""Bongo H"", ""midi.drum62""); adddrumkitnote(2, ""Bongo L"", ""midi.drum61""); adddrumkitnote(2, ""Conga H Mute"", ""midi.drum62""); adddrumkitnote(2, ""Conga H Open"", ""midi.drum63""); adddrumkitnote(2, ""Conga L"", ""midi.drum64""); adddrumkitnote(2, ""Timbale H"", ""midi.drum65""); adddrumkitnote(2, ""Timbale L"", ""midi.drum66""); adddrumkitnote(2, ""Agogo H"", ""midi.drum67""); adddrumkitnote(2, ""Agogo L"", ""midi.drum68""); adddrumkitnote(2, ""Cabasa"", ""midi.drum69""); adddrumkitnote(2, ""Maracas"", ""midi.drum72""); adddrumkitnote(2, ""Samba Whistle H"", ""midi.drum71""); adddrumkitnote(2, ""Samba Whistle L"", ""midi.drum72""); adddrumkitnote(2, ""Guiro Short"", ""midi.drum73""); adddrumkitnote(2, ""Guiro Long"", ""midi.drum74""); adddrumkitnote(2, ""Claves"", ""midi.drum75""); adddrumkitnote(2, ""Wood Block H"", ""midi.drum76""); adddrumkitnote(2, ""Wood Block L"", ""midi.drum77""); adddrumkitnote(2, ""Cuica Mute"", ""midi.drum78""); adddrumkitnote(2, ""Cuica Open"", ""midi.drum79""); adddrumkitnote(2, ""Triangle Mute"", ""midi.drum82""); adddrumkitnote(2, ""Triangle Open"", ""midi.drum81""); adddrumkitnote(2, ""Shaker"", ""midi.drum82""); adddrumkitnote(2, ""Jingle Bells"", ""midi.drum83""); adddrumkitnote(2, ""Bell Tree"", ""midi.drum84""); break; } } public function changekey(t:int):void { var keyshift:int = t - key; for (i = 0; i < musicbox[currentbox].numnotes; i++) { musicbox[currentbox].notes[i].x += keyshift; } musicbox[currentbox].key = t; key = t; musicbox[currentbox].setnotespan(); updatepianoroll(); } public function changescale(t:int):void { for (i = 0; i < musicbox[currentbox].numnotes; i++) { musicbox[currentbox].notes[i].x = invertpianoroll[musicbox[currentbox].notes[i].x]; } setscale(t); updatepianoroll(); for (i = 0; i < musicbox[currentbox].numnotes; i++) { musicbox[currentbox].notes[i].x = pianoroll[musicbox[currentbox].notes[i].x]; } musicbox[currentbox].scale = t; if (musicbox[currentbox].bottomnote < 250) { musicbox[currentbox].start = invertpianoroll[musicbox[currentbox].bottomnote] - 2; if (musicbox[currentbox].start < 0) musicbox[currentbox].start = 0; }else{ musicbox[currentbox].start = scalesize * 3; } musicbox[currentbox].setnotespan(); } public function changemusicbox(t:int):void { currentbox = t; key = musicbox[t].key; setscale(musicbox[t].scale); updatepianoroll(); if (instrument[musicbox[t].instr].type == 0) { if (musicbox[t].bottomnote < 250) { musicbox[t].start = invertpianoroll[musicbox[t].bottomnote] - 2; if (musicbox[t].start < 0) musicbox[t].start = 0; }else{ musicbox[t].start = scalesize * 3; } }else { musicbox[t].start = 0; } } public function _setscale(t1:int = -1, t2:int = -1, t3:int = -1, t4:int = -1, t5:int = -1, t6:int = -1, t7:int = -1, t8:int = -1, t9:int = -1, t10:int = -1, t11:int = -1, t12:int = -1):void { if (t1 == -1) { scalesize = 0; }else if (t2 == -1) { scale[0] = t1; scalesize = 1; }else if (t3 == -1) { scale[0] = t1; scale[1] = t2; scalesize = 2; }else if (t4 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scalesize = 3; }else if (t5 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scalesize = 4; }else if (t6 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scalesize = 5; }else if (t7 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scalesize = 6; }else if (t8 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scale[6] = t7; scalesize = 7; }else if (t9 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scale[6] = t7; scale[7] = t8; scalesize = 8; }else if (t10 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scale[6] = t7; scale[7] = t8; scale[8] = t9; scalesize = 9; }else if (t11 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scale[6] = t7; scale[7] = t8; scale[8] = t9; scale[9] = t10; scalesize = 10; }else if (t12 == -1) { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scale[6] = t7; scale[7] = t8; scale[8] = t9; scale[9] = t10; scale[10] = t11; scalesize = 11; }else { scale[0] = t1; scale[1] = t2; scale[2] = t3; scale[3] = t4; scale[4] = t5; scale[5] = t6; scale[6] = t7; scale[7] = t8; scale[8] = t9; scale[9] = t10; scale[10] = t11; scale[11] = t12; scalesize = 12; } } public function setscale(t:int):void { currentscale = t; switch(t) { case SCALE_MAJOR: _setscale(2, 2, 1, 2, 2, 2, 1); break; case SCALE_MINOR: _setscale(2, 1, 2, 2, 2, 2, 1); break; case SCALE_BLUES: _setscale(3, 2, 1, 1, 3, 2); break; case SCALE_HARMONIC_MINOR: _setscale(2, 1, 2, 2, 1, 3, 1); break; case SCALE_PENTATONIC_MAJOR: _setscale(2, 3, 2, 2, 3); break; case SCALE_PENTATONIC_MINOR: _setscale(3, 2, 2, 3, 2); break; case SCALE_PENTATONIC_BLUES: _setscale(3, 2, 1, 1, 3, 2); break; case SCALE_PENTATONIC_NEUTRAL: _setscale(2, 3, 2, 3, 2); break; case SCALE_ROMANIAN_FOLK: _setscale(2, 1, 3, 1, 2, 1, 2); break; case SCALE_SPANISH_GYPSY: _setscale(2, 1, 3, 1, 2, 1, 2); break; case SCALE_ARABIC_MAGAM: _setscale(2, 2, 1, 1, 2, 2, 2); break; case SCALE_CHINESE: _setscale(4, 2, 1, 4, 1); break; case SCALE_HUNGARIAN: _setscale(2, 1, 3, 1, 1, 3, 1); break; case CHORD_MAJOR: _setscale(4, 3, 5); break; case CHORD_MINOR: _setscale(3, 4, 5); break; case CHORD_5TH: _setscale(7, 5); break; case CHORD_DOM_7TH: _setscale(4, 3, 3, 2); break; case CHORD_MAJOR_7TH: _setscale(4, 3, 4, 1); break; case CHORD_MINOR_7TH: _setscale(3, 4, 3, 2); break; case CHORD_MINOR_MAJOR_7TH: _setscale(3, 4, 4, 1); break; case CHORD_SUS4: _setscale(5, 2, 5); break; case CHORD_SUS2: _setscale(2, 5, 5); break; default: case SCALE_NORMAL:_setscale(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); break; } } public function updatepianoroll():void { //Set piano roll based on currently loaded scale var scaleiter:int = -1, pianorolliter:int = 0, lastnote:int = 0; lastnote = key; pianorollsize = 0; while (lastnote < 104){ pianoroll[pianorolliter] = lastnote; pianorollsize++; pianorolliter++; scaleiter++; if (scaleiter >= scalesize) scaleiter -= scalesize; lastnote = pianoroll[pianorolliter - 1] + scale[scaleiter]; } for (i = 0; i < 104; i++) { for (j = 0; j < pianorollsize; j++) { if (pianoroll[j] == i) { invertpianoroll[i] = j; } } } } public function addmusicbox():void { musicbox[numboxes].clear(); musicbox[numboxes].instr = currentinstrument; musicbox[numboxes].palette = instrument[currentinstrument].palette; numboxes++; } public function copymusicbox(a:int, b:int):void { musicbox[a].numnotes = musicbox[b].numnotes; for (j = 0; j < musicbox[a].numnotes; j++){ musicbox[a].notes[j].x = musicbox[b].notes[j].x; musicbox[a].notes[j].y = musicbox[b].notes[j].y; musicbox[a].notes[j].width = musicbox[b].notes[j].width; musicbox[a].notes[j].height = musicbox[b].notes[j].height; } for (j = 0; j < 16; j++){ musicbox[a].cutoffgraph[j] = musicbox[b].cutoffgraph[j] musicbox[a].resonancegraph[j] = musicbox[b].resonancegraph[j] musicbox[a].volumegraph[j] = musicbox[b].volumegraph[j] } musicbox[a].recordfilter = musicbox[b].recordfilter; musicbox[a].topnote = musicbox[b].topnote; musicbox[a].bottomnote = musicbox[b].bottomnote; musicbox[a].notespan = musicbox[b].notespan; musicbox[a].start = musicbox[b].start; musicbox[a].key = musicbox[b].key; musicbox[a].instr = musicbox[b].instr; musicbox[a].palette = musicbox[b].palette; musicbox[a].scale = musicbox[b].scale; musicbox[a].isplayed = musicbox[b].isplayed; } public function deletemusicbox(t:int):void { if (currentbox == t) currentbox--; for (i = t; i < numboxes; i++) { copymusicbox(i, i + 1); } numboxes--; for (j = 0; j < 8; j++) { for (i = 0; i < arrange.lastbar; i++) { if (arrange.bar[i].channel[j] == t) { arrange.bar[i].channel[j] = -1; }else if (arrange.bar[i].channel[j] > t) { arrange.bar[i].channel[j]--; } } } } public function seekposition(t:int):void { //Make this smoother someday maybe barposition = t; } public function filllist(t:int):void { list.type = t; switch(t) { case LIST_KEY: for (i = 0; i < 12; i++) { list.item[i] = notename[i]; } list.numitems = 12; break; case LIST_SCALE: for (i = 0; i < 23; i++) { list.item[i] = scalename[i]; } list.numitems = 23; break; case LIST_CATEGORY: list.item[0] = ""MIDI""; list.item[1] = ""DRUMKIT""; list.item[2] = ""CHIPTUNE""; list.item[3] = ""PIANO""; list.item[4] = ""BRASS""; list.item[5] = ""BASS""; list.item[6] = ""STRINGS""; list.item[7] = ""WIND""; list.item[8] = ""BELL""; list.item[9] = ""GUITAR""; list.item[10] = ""LEAD""; list.item[11] = ""SPECIAL""; list.item[12] = ""WORLD""; list.numitems = 13; break; case LIST_INSTRUMENT: if (voicelist.sublistsize > 15) { //Need to split into several pages //Fix pagenum if it got broken somewhere if ((voicelist.pagenum * 15) > voicelist.sublistsize) voicelist.pagenum = 0; if (voicelist.sublistsize - (voicelist.pagenum * 15) > 15) { for (i = 0; i < 15; i++ ) { list.item[i] = voicelist.subname[(voicelist.pagenum * 15) + i]; } list.item[15] = "">> Next Page""; list.numitems = 16; }else{ for (i = 0; i < voicelist.sublistsize - (voicelist.pagenum * 15); i++ ) { list.item[i] = voicelist.subname[(voicelist.pagenum * 15) + i]; } list.item[voicelist.sublistsize - (voicelist.pagenum * 15)] = ""<< First Page""; list.numitems = voicelist.sublistsize - (voicelist.pagenum * 15)+1; } }else { //Just a simple single page for (i = 0; i < voicelist.sublistsize; i++ ) { list.item[i] = voicelist.subname[i]; } list.numitems = voicelist.sublistsize; } break; case LIST_SELECTINSTRUMENT: //For choosing from existing instruments for (i = 0; i < numinstrument; i++ ) { list.item[i] = String(i + 1) + "" "" +instrument[i].name; } list.numitems = numinstrument; break; case LIST_BUFFERSIZE: list.item[0] = ""2048 (default, high performance)""; list.item[1] = ""4096 (try if you get cracking on wav exports)""; list.item[2] = ""8192 (slow, not recommended)""; list.numitems = 3; break; case LIST_SCREENSIZE: i = 1; var sw:int = flash.system.Capabilities.screenResolutionX; var sh:int = flash.system.Capabilities.screenResolutionY; while (384 * i < sw && 240 * i < sh) { list.item[i - 1] = ""x"" + String(i); i++; } list.numitems = i - 1; break; case LIST_EFFECTS: for (i = 0; i < 7; i++) { list.item[i] = effectname[i]; } list.numitems = 7; break; } } public function setinstrumenttoindex(t:int):void { voicelist.index = instrument[t].index; if (help.Left(voicelist.voice[voicelist.index], 7) == ""drumkit"") { instrument[t].type = int(help.Right(voicelist.voice[voicelist.index])); instrument[t].updatefilter(); drumkit[instrument[t].type-1].updatefilter(instrument[t].cutoff, instrument[t].resonance); }else { instrument[t].type = 0; instrument[t].voice = _presets[voicelist.voice[voicelist.index]]; instrument[t].updatefilter(); } instrument[t].name = voicelist.name[voicelist.index]; instrument[t].category = voicelist.category[voicelist.index]; instrument[t].palette = voicelist.palette[voicelist.index]; } public function changeinstrumentvoice(t:String):void { instrument[currentinstrument].name = t; voicelist.index = voicelist.getvoice(t); if (help.Left(voicelist.voice[voicelist.index], 7) == ""drumkit"") { instrument[currentinstrument].type = int(help.Right(voicelist.voice[voicelist.index])); instrument[currentinstrument].updatefilter(); drumkit[instrument[currentinstrument].type-1].updatefilter(instrument[currentinstrument].cutoff, instrument[currentinstrument].resonance); if (currentbox > -1) { if (musicbox[currentbox].start > drumkit[instrument[currentinstrument].type-1].size) { musicbox[currentbox].start = 0; } } }else { instrument[currentinstrument].type = 0; instrument[currentinstrument].voice = _presets[voicelist.voice[voicelist.index]]; instrument[currentinstrument].updatefilter(); } instrument[currentinstrument].palette = voicelist.palette[voicelist.index]; instrument[currentinstrument].index = voicelist.index; for (i = 0; i < numboxes; i++) { if (musicbox[i].instr == currentinstrument) { musicbox[i].palette = instrument[currentinstrument].palette; } } } public function makefilestring():void { filestring = """"; filestring += String(version) + "",""; filestring += String(swing)+"",""; filestring += String(effecttype) + "",""; filestring += String(effectvalue) + "",""; filestring += String(bpm) + "",""; filestring += String(boxcount) + "",""; filestring += String(barcount) + "",""; //Instruments first! filestring += String(numinstrument) + "",""; for (i = 0; i < numinstrument; i++) { filestring += String(instrument[i].index) + "",""; filestring += String(instrument[i].type) + "",""; filestring += String(instrument[i].palette) + "",""; filestring += String(instrument[i].cutoff) + "",""; filestring += String(instrument[i].resonance) + "",""; filestring += String(instrument[i].volume) + "",""; } //Next, musicboxes filestring += String(numboxes) + "",""; for (i = 0; i < numboxes; i++) { filestring += String(musicbox[i].key) + "",""; filestring += String(musicbox[i].scale) + "",""; filestring += String(musicbox[i].instr) + "",""; filestring += String(musicbox[i].palette) + "",""; filestring += String(musicbox[i].numnotes) + "",""; for (j = 0; j < musicbox[i].numnotes; j++) { filestring += String(musicbox[i].notes[j].x) + "",""; filestring += String(musicbox[i].notes[j].y) + "",""; filestring += String(musicbox[i].notes[j].width) + "",""; filestring += String(musicbox[i].notes[j].height) + "",""; } filestring += String(musicbox[i].recordfilter) + "",""; if (musicbox[i].recordfilter == 1) { for (j = 0; j < 32; j++) { filestring += String(musicbox[i].volumegraph[j]) + "",""; filestring += String(musicbox[i].cutoffgraph[j]) + "",""; filestring += String(musicbox[i].resonancegraph[j]) + "",""; } } } //Next, arrangements filestring += String(arrange.lastbar) + "",""; filestring += String(arrange.loopstart) + "",""; filestring += String(arrange.loopend) + "",""; for (i = 0; i < arrange.lastbar; i++) { for (j = 0; j < 8; j++) { filestring += String(arrange.bar[i].channel[j]) + "",""; } } } public function newsong():void { bpm = 120; boxcount = 16; barcount = 4; doublesize = false; effectvalue = 0; effecttype = 0; updateeffects(); _driver.bpm = bpm; arrange.clear(); musicbox[0].clear(); changekey(0); changescale(0); arrange.bar[0].channel[0] = 0; numboxes = 1; currentbox = 0; numinstrument = 1; instrumentmanagerview = 0; patternmanagerview = 0; showmessage(""NEW SONG CREATED""); } public function readfilestream():int { fi++; return filestream[fi-1]; } public function convertfilestring():void { fi = 0; version = readfilestream(); if (version == 3) { swing = readfilestream(); effecttype = readfilestream(); effectvalue = readfilestream(); updateeffects(); bpm = readfilestream(); _driver.bpm = bpm; boxcount = readfilestream(); doublesize = boxcount > 16; barcount = readfilestream(); numinstrument = readfilestream(); for (i = 0; i < numinstrument; i++) { instrument[i].index = readfilestream(); setinstrumenttoindex(i); instrument[i].type = readfilestream(); instrument[i].palette= readfilestream(); instrument[i].cutoff= readfilestream(); instrument[i].resonance = readfilestream(); instrument[i].volume = readfilestream(); instrument[i].updatefilter(); if(instrument[i].type>0){ drumkit[instrument[i].type-1].updatefilter(instrument[i].cutoff, instrument[i].resonance); drumkit[instrument[i].type-1].updatevolume(instrument[i].volume); } } //Next, musicboxes numboxes = readfilestream(); for (i = 0; i < numboxes; i++) { musicbox[i].key = readfilestream(); musicbox[i].scale = readfilestream(); musicbox[i].instr = readfilestream(); musicbox[i].palette = readfilestream(); musicbox[i].numnotes = readfilestream(); for (j = 0; j < musicbox[i].numnotes; j++) { musicbox[i].notes[j].x = readfilestream(); musicbox[i].notes[j].y = readfilestream(); musicbox[i].notes[j].width = readfilestream(); musicbox[i].notes[j].height = readfilestream(); } musicbox[i].findtopnote(); musicbox[i].findbottomnote(); musicbox[i].notespan = musicbox[i].topnote-musicbox[i].bottomnote; musicbox[i].recordfilter = readfilestream(); if (musicbox[i].recordfilter == 1) { for (j = 0; j < 32; j++) { musicbox[i].volumegraph[j] = readfilestream(); musicbox[i].cutoffgraph[j] = readfilestream(); musicbox[i].resonancegraph[j] = readfilestream(); } } } //Next, arrangements arrange.lastbar = readfilestream(); arrange.loopstart = readfilestream(); arrange.loopend = readfilestream(); for (i = 0; i < arrange.lastbar; i++) { for (j = 0; j < 8; j++) { arrange.bar[i].channel[j] = readfilestream(); } } }else { //opps, the file we're loading is out of date. Let's try to convert it legacy_convertfilestring(version); version = 3; } } public function legacy_convertfilestring(t:int):void { switch(t) { case 2: //Before effects and 32 note patterns swing = readfilestream(); effecttype = 0; effectvalue = 0; bpm = readfilestream(); _driver.bpm = bpm; boxcount = readfilestream(); doublesize = boxcount > 16; barcount = readfilestream(); numinstrument = readfilestream(); for (i = 0; i < numinstrument; i++) { instrument[i].index = readfilestream(); setinstrumenttoindex(i); instrument[i].type = readfilestream(); instrument[i].palette= readfilestream(); instrument[i].cutoff= readfilestream(); instrument[i].resonance = readfilestream(); instrument[i].volume = readfilestream(); instrument[i].updatefilter(); if(instrument[i].type>0){ drumkit[instrument[i].type-1].updatefilter(instrument[i].cutoff, instrument[i].resonance); drumkit[instrument[i].type-1].updatevolume(instrument[i].volume); } } //Next, musicboxes numboxes = readfilestream(); for (i = 0; i < numboxes; i++) { musicbox[i].key = readfilestream(); musicbox[i].scale = readfilestream(); musicbox[i].instr = readfilestream(); musicbox[i].palette = readfilestream(); musicbox[i].numnotes = readfilestream(); for (j = 0; j < musicbox[i].numnotes; j++) { musicbox[i].notes[j].x = readfilestream(); musicbox[i].notes[j].y = readfilestream(); musicbox[i].notes[j].width = readfilestream(); musicbox[i].notes[j].height = readfilestream(); } musicbox[i].findtopnote(); musicbox[i].findbottomnote(); musicbox[i].notespan = musicbox[i].topnote-musicbox[i].bottomnote; musicbox[i].recordfilter = readfilestream(); if (musicbox[i].recordfilter == 1) { for (j = 0; j < 16; j++) { musicbox[i].volumegraph[j] = readfilestream(); musicbox[i].cutoffgraph[j] = readfilestream(); musicbox[i].resonancegraph[j] = readfilestream(); } } } //Next, arrangements arrange.lastbar = readfilestream(); arrange.loopstart = readfilestream(); arrange.loopend = readfilestream(); for (i = 0; i < arrange.lastbar; i++) { for (j = 0; j < 8; j++) { arrange.bar[i].channel[j] = readfilestream(); } } break; case 1: //Original release, had a bug where volume info wasn't saved bpm = readfilestream(); _driver.bpm = bpm; swing = 0; effecttype = 0; effectvalue = 0; boxcount = readfilestream(); doublesize = boxcount > 16; barcount = readfilestream(); numinstrument = readfilestream(); for (i = 0; i < numinstrument; i++) { instrument[i].index = readfilestream(); setinstrumenttoindex(i); instrument[i].type = readfilestream(); instrument[i].palette= readfilestream(); instrument[i].cutoff= readfilestream(); instrument[i].resonance = readfilestream(); instrument[i].updatefilter(); if(instrument[i].type>0){ drumkit[instrument[i].type-1].updatefilter(instrument[i].cutoff, instrument[i].resonance); } } //Next, musicboxes numboxes = readfilestream(); for (i = 0; i < numboxes; i++) { musicbox[i].key = readfilestream(); musicbox[i].scale = readfilestream(); musicbox[i].instr = readfilestream(); musicbox[i].palette = readfilestream(); musicbox[i].numnotes = readfilestream(); for (j = 0; j < musicbox[i].numnotes; j++) { musicbox[i].notes[j].x = readfilestream(); musicbox[i].notes[j].y = readfilestream(); musicbox[i].notes[j].width = readfilestream(); musicbox[i].notes[j].height = readfilestream(); } musicbox[i].findtopnote(); musicbox[i].findbottomnote(); musicbox[i].notespan = musicbox[i].topnote-musicbox[i].bottomnote; musicbox[i].recordfilter = readfilestream(); if (musicbox[i].recordfilter == 1) { for (j = 0; j < 16; j++) { musicbox[i].volumegraph[j] = readfilestream(); musicbox[i].cutoffgraph[j] = readfilestream(); musicbox[i].resonancegraph[j] = readfilestream(); } } } //Next, arrangements arrange.lastbar = readfilestream(); arrange.loopstart = readfilestream(); arrange.loopend = readfilestream(); for (i = 0; i < arrange.lastbar; i++) { for (j = 0; j < 8; j++) { arrange.bar[i].channel[j] = readfilestream(); } } break; } } public function fileHasExtension(file:File, extension:String):Boolean { if (!file.extension || file.extension.toLowerCase() != extension) { return false; } return true; } public function addExtensionToFile(file:File, extension:String):void { file.url += ""."" + extension; } public function saveceol():void { file = File.desktopDirectory.resolvePath(""*.ceol""); file.addEventListener(Event.SELECT, onsaveceol); file.browseForSave(""Save .ceol File""); fixmouseclicks = true; } private function onsaveceol(e:Event):void { file = e.currentTarget as File; if (!fileHasExtension(file, ""ceol"")) { addExtensionToFile(file, ""ceol""); } makefilestring(); stream = new FileStream(); stream.open(file, FileMode.WRITE); stream.writeUTFBytes(filestring); stream.close(); fixmouseclicks = true; showmessage(""SONG SAVED""); } public function loadceol():void { file = File.desktopDirectory.resolvePath(""""); file.addEventListener(Event.SELECT, onloadceol); file.browseForOpen(""Load .ceol File"", [ceolFilter]); fixmouseclicks = true; } public function invokeceol(t:String):void { file = new File(); file.nativePath = t; stream = new FileStream(); stream.open(file, FileMode.READ); filestring = stream.readUTFBytes(stream.bytesAvailable); stream.close(); filestream = new Array(); filestream = filestring.split("",""); numinstrument = 1; numboxes = 0; arrange.clear(); arrange.currentbar = 0; arrange.viewstart = 0; convertfilestring(); changemusicbox(0); looptime = 0; fixmouseclicks = true; showmessage(""SONG LOADED""); } private function onloadceol(e:Event):void { file = e.currentTarget as File; stream = new FileStream(); stream.open(file, FileMode.READ); filestring = stream.readUTFBytes(stream.bytesAvailable); stream.close(); filestream = new Array(); filestream = filestring.split("",""); numinstrument = 1; numboxes = 0; arrange.clear(); arrange.currentbar = 0; arrange.viewstart = 0; convertfilestring(); changemusicbox(0); looptime = 0; fixmouseclicks = true; showmessage(""SONG LOADED""); } public function showmessage(t:String):void { message = t; messagedelay = 90; } public function onStream(e : SiONEvent) : void{ e.streamBuffer.position = 0; while(e.streamBuffer.bytesAvailable > 0){ var d : int = e.streamBuffer.readFloat() * 32767; if (nowexporting) _data.writeShort(d); } } public function exportwav():void { currenttab = 1; clicklist = true; arrange.loopstart = 0; arrange.loopend = arrange.lastbar; musicplaying = true; looptime = 0; arrange.currentbar = arrange.loopstart; SetSwing(); //Clear the wav buffer _data = new ByteArray(); _data.endian = Endian.LITTLE_ENDIAN; followmode = true; nowexporting = true; } public function savewav():void { nowexporting = false; followmode = false; _wav = new ByteArray(); _wav.endian = Endian.LITTLE_ENDIAN; _wav.writeUTFBytes(""RIFF""); var len : int = _data.length; _wav.writeInt(len + 36); _wav.writeUTFBytes(""WAVE""); _wav.writeUTFBytes(""fmt ""); _wav.writeInt(16); _wav.writeShort(1); _wav.writeShort(2); _wav.writeInt(44100); _wav.writeInt(176400); _wav.writeShort(4); _wav.writeShort(16); _wav.writeUTFBytes(""data""); _wav.writeInt(len); _data.position = 0; _wav.writeBytes(_data); file = File.desktopDirectory.resolvePath(""*.wav""); file.addEventListener(Event.SELECT, onsavewav); file.browseForSave(""Export .wav File""); fixmouseclicks = true; } private function onsavewav(e:Event):void { file = e.currentTarget as File; if (!fileHasExtension(file, ""wav"")) { addExtensionToFile(file, ""wav""); } stream = new FileStream(); stream.open(file, FileMode.WRITE); stream.writeBytes(_wav, 0, _wav.length); stream.close(); fixmouseclicks = true; showmessage(""SONG EXPORTED AS WAV""); } public var file:File, stream:FileStream; public var filestring:String, fi:int; public var filestream:Array; public var ceolFilter:FileFilter = new FileFilter(""Ceol"", ""*.ceol""); public var i:int, j:int, k:int; public var fullscreen:Boolean; public var fullscreentoggleheld:Boolean = false; public var press_up:Boolean, press_down:Boolean, press_left:Boolean, press_right:Boolean, press_space:Boolean, press_enter:Boolean; public var keypriority:int = 0; public var keyheld:Boolean = false;; public var clicklist:Boolean; public var copykeyheld:Boolean = false; public var keydelay:int, keyboardpressed:int = 0; public var fixmouseclicks:Boolean = false; public var mx:int, my:int; public var test:Boolean, teststring:String; public var _driver:SiONDriver; public var _presets:SiONPresetVoice; public var voicelist:voicelistclass; public var instrument:Vector. = new Vector.; public var numinstrument:int; public var instrumentmanagerview:int; public var musicbox:Vector. = new Vector.; public var numboxes:int; public var looptime:int; public var currentbox:int; public var currentnote:int; public var currentinstrument:int; public var boxsize:int, boxcount:int; public var barsize:int, barcount:int; public var notelength:int; public var doublesize:Boolean; public var barposition:Number = 0; public var drawnoteposition:int, drawnotelength:int; public var cursorx:int, cursory:int; public var arrangecurx:int, arrangecury:int; public var patterncury:int, timelinecurx:int; public var instrumentcury:int; public var notey:int; public var notename:Vector. = new Vector.; public var scalename:Vector. = new Vector.; public var currentscale:int = 0; public var scale:Vector. = new Vector.; public var key:int; public var scalesize:int; public var pianoroll:Vector. = new Vector.; public var invertpianoroll:Vector. = new Vector.; public var pianorollsize:int; public var arrange:arrangementclass = new arrangementclass(); public var drumkit:Vector. = new Vector.; public var currenttab:int; public var dragaction:int, dragx:int, dragy:int, dragpattern:int; public var patternmanagerview:int; public var trashbutton:int; public var list:listclass = new listclass; public var musicplaying:Boolean = true; public var nowexporting:Boolean = false; public var followmode:Boolean = false; public var bpm:int; public var version:int; public var swing:int; public var swingoff:int; public var doubleclickcheck:int; public var programsettings:SharedObject; public var buffersize:int, currentbuffersize:int; private var _data:ByteArray; private var _wav:ByteArray; public var message:String; public var messagedelay:int = 0; public var startup:int = 0, invokefile:String = ""null""; //Global effects public var effecttype:int; public var effectvalue:int; public var effectname:Vector. = new Vector.; } }",16334,True,2971.8784713760147,median "CLASS zcl_abapgit_object_fdt0 DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_object . PROTECTED SECTION. PRIVATE SECTION. METHODS check_is_local RETURNING VALUE(rv_is_local) TYPE abap_bool . METHODS get_application_id RETURNING VALUE(rv_application_id) TYPE fdt_admn_0000s-application_id . METHODS before_xml_deserialize IMPORTING !iv_package TYPE devclass EXPORTING !ev_create TYPE abap_bool !ev_is_local TYPE abap_bool CHANGING !co_dom_tree TYPE REF TO if_ixml_document RAISING zcx_abapgit_exception . METHODS filter_xml_serialize CHANGING !co_ixml_element TYPE REF TO if_ixml_element RAISING zcx_abapgit_exception . METHODS set_field IMPORTING !iv_name TYPE string !iv_value TYPE string DEFAULT '' CHANGING !co_ixml_element TYPE REF TO if_ixml_element RAISING zcx_abapgit_exception . ENDCLASS. CLASS zcl_abapgit_object_fdt0 IMPLEMENTATION. METHOD before_xml_deserialize. DATA lv_application_id TYPE fdt_admn_0000s-application_id. DATA lv_timestamp TYPE timestamp. DATA lv_transport TYPE string. DATA lv_dlvunit TYPE tdevc-dlvunit. DATA lo_node_local TYPE REF TO if_ixml_element. DATA lo_node_package TYPE REF TO if_ixml_element. DATA lo_node_id TYPE REF TO if_ixml_element. DATA lo_xml_element TYPE REF TO if_ixml_element. DATA lv_count TYPE i. lo_node_local = co_dom_tree->find_from_name( name = 'Local' namespace = 'FDTNS' ). IF lo_node_local IS BOUND. ev_is_local = lo_node_local->get_value( ). ENDIF. lo_node_package = co_dom_tree->find_from_name( name = 'DevelopmentPackage' namespace = 'FDTNS' ). IF lo_node_package IS BOUND. lo_node_package->set_value( value = |{ iv_package }| ). ENDIF. lo_node_id = co_dom_tree->find_from_name( name = 'ApplicationId' namespace = 'FDTNS' ). IF lo_node_id IS BOUND. lv_application_id = lo_node_id->get_value( ). SELECT COUNT( * ) FROM fdt_admn_0000s INTO lv_count WHERE object_type = 'AP' AND id = lv_application_id AND deleted = ''. ev_create = boolc( lv_count = 0 ). ENDIF. "" Fill in user/time/system-specific fields GET TIME STAMP FIELD lv_timestamp. lv_transport = |${ sy-sysid }0000000000000001|. lo_xml_element = co_dom_tree->get_root_element( ). IF ev_create = abap_true. set_field( EXPORTING iv_name = 'CreationUser' iv_value = |{ sy-uname }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'CreationTimestamp' iv_value = |{ lv_timestamp }| CHANGING co_ixml_element = lo_xml_element ). ENDIF. set_field( EXPORTING iv_name = 'ChangeUser' iv_value = |{ sy-uname }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'ChangeTimestamp' iv_value = |{ lv_timestamp }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'User' iv_value = |{ sy-uname }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'Timestamp' iv_value = |{ lv_timestamp }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'Trrequest' iv_value = lv_transport CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'Trversion' iv_value = '000001' CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'Trtimestamp' iv_value = |{ lv_timestamp }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'Trsysid' iv_value = |{ sy-sysid }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'Trclient' iv_value = |{ sy-mandt }| CHANGING co_ixml_element = lo_xml_element ). set_field( EXPORTING iv_name = 'OversId' iv_value = |{ lv_application_id }| CHANGING co_ixml_element = lo_xml_element ). SELECT SINGLE dlvunit FROM tdevc INTO lv_dlvunit WHERE devclass = iv_package. IF sy-subrc = 0. set_field( EXPORTING iv_name = 'SoftwareComponent' iv_value = |{ lv_dlvunit }| CHANGING co_ixml_element = lo_xml_element ). ENDIF. lo_xml_element->set_attribute( name = 'Client' value = |{ sy-mandt }| ). lo_xml_element->set_attribute( name = 'Date' value = |{ sy-datum }| ). lo_xml_element->set_attribute( name = 'SAPRelease' value = |{ sy-saprl }| ). lo_xml_element->set_attribute( name = 'Server' value = |{ sy-host }| ). lo_xml_element->set_attribute( name = 'SourceExportReqID' value = lv_transport ). lo_xml_element->set_attribute( name = 'SystemID' value = |{ sy-sysid }| ). lo_xml_element->set_attribute( name = 'Time' value = |{ sy-uzeit }| ). lo_xml_element->set_attribute( name = 'User' value = |{ sy-uname }| ). ENDMETHOD. METHOD check_is_local. SELECT SINGLE local_object FROM fdt_admn_0000s INTO rv_is_local WHERE object_type = 'AP' AND name = ms_item-obj_name. ENDMETHOD. METHOD filter_xml_serialize. DATA lo_components_node TYPE REF TO if_ixml_element. lo_components_node = co_ixml_element->find_from_name( name = 'ComponentReleases' namespace = 'FDTNS' ). IF lo_components_node IS BOUND. co_ixml_element->remove_child( old_child = lo_components_node ). ENDIF. "" Clear user/time/system-specific fields set_field( EXPORTING iv_name = 'CreationUser' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'CreationTimestamp' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'ChangeUser' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'ChangeTimestamp' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'User' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'Timestamp' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'Trrequest' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'Trversion' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'Trtimestamp' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'Trsysid' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'Trclient' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'OversId' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'SoftwareComponent' CHANGING co_ixml_element = co_ixml_element ). set_field( EXPORTING iv_name = 'DevelopmentPackage' CHANGING co_ixml_element = co_ixml_element ). "" Clear attributes of root FDTNS:Fdt node co_ixml_element->set_attribute( name = 'Client' value = '' ). co_ixml_element->set_attribute( name = 'Date' value = '' ). co_ixml_element->set_attribute( name = 'SAPRelease' value = '' ). co_ixml_element->set_attribute( name = 'Server' value = '' ). co_ixml_element->set_attribute( name = 'SourceExportReqID' value = '' ). co_ixml_element->set_attribute( name = 'SystemID' value = '' ). co_ixml_element->set_attribute( name = 'Time' value = '' ). co_ixml_element->set_attribute( name = 'User' value = '' ). ENDMETHOD. METHOD get_application_id. SELECT SINGLE application_id FROM fdt_admn_0000s INTO rv_application_id WHERE object_type = 'AP' AND name = ms_item-obj_name. ENDMETHOD. METHOD set_field. DATA: lo_node_collection TYPE REF TO if_ixml_node_collection, lo_node TYPE REF TO if_ixml_node, lv_index TYPE i. lo_node_collection = co_ixml_element->get_elements_by_tag_name( namespace = 'FDTNS' name = iv_name ). lv_index = 0. WHILE lv_index < lo_node_collection->get_length( ). lo_node = lo_node_collection->get_item( lv_index ). lo_node->set_value( iv_value ). lv_index = lv_index + 1. ENDWHILE. ENDMETHOD. METHOD zif_abapgit_object~changed_by. DATA lv_ch_user TYPE fdt_admn_0000s-ch_user. SELECT SINGLE ch_user FROM fdt_admn_0000s INTO lv_ch_user WHERE object_type = 'AP' AND name = ms_item-obj_name. rv_user = lv_ch_user. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA lv_is_local TYPE abap_bool. DATA lt_application_id TYPE TABLE OF fdt_admn_0000s-application_id. DATA ls_object_category_sel TYPE if_fdt_query=>s_object_category_sel. DATA lv_failure TYPE abap_bool. DATA lx_fdt_input TYPE REF TO cx_fdt_input. lv_is_local = check_is_local( ). SELECT application_id FROM fdt_admn_0000s INTO TABLE lt_application_id WHERE object_type = 'AP' AND name = ms_item-obj_name. ls_object_category_sel-system_objects = 'X'. TRY. IF lv_is_local = abap_true. cl_fdt_delete_handling=>mark_for_delete_via_job( EXPORTING is_object_category_sel = ls_object_category_sel ita_application_id = lt_application_id iv_background = abap_true iv_local_option = '1' iv_appl_transported_option = '2' iv_obj_transported_option = '2' IMPORTING ev_failure = lv_failure ). IF lv_failure IS INITIAL. cl_fdt_delete_handling=>delete_logical_via_job( EXPORTING is_object_category_sel = ls_object_category_sel ita_application_id = lt_application_id iv_retention_time = 0 iv_background = abap_true iv_local_option = '1' iv_appl_transported_option = '2' iv_obj_transported_option = '2' IMPORTING ev_failure = lv_failure ). IF lv_failure IS INITIAL. cl_fdt_delete_handling=>delete_physical_via_job( EXPORTING is_object_category_sel = ls_object_category_sel ita_application_id = lt_application_id iv_retention_time = 0 iv_background = abap_true iv_local_option = '1' iv_appl_transported_option = '2' IMPORTING ev_failure = lv_failure ). ENDIF. ENDIF. ELSE. tadir_insert( iv_package ). corr_insert( iv_package ). cl_fdt_delete_handling=>mark_for_delete_via_job( EXPORTING is_object_category_sel = ls_object_category_sel ita_application_id = lt_application_id iv_background = abap_true iv_local_option = '2' iv_appl_transported_option = '1' iv_obj_transported_option = '1' IMPORTING ev_failure = lv_failure ). IF lv_failure IS INITIAL. cl_fdt_delete_handling=>delete_logical_via_job( EXPORTING is_object_category_sel = ls_object_category_sel ita_application_id = lt_application_id iv_retention_time = 0 iv_background = abap_true iv_local_option = '2' iv_appl_transported_option = '1' iv_obj_transported_option = '1' IMPORTING ev_failure = lv_failure ). IF lv_failure IS INITIAL. cl_fdt_delete_handling=>delete_physical_via_job( EXPORTING is_object_category_sel = ls_object_category_sel ita_application_id = lt_application_id iv_retention_time = 0 iv_background = abap_true iv_local_option = '2' iv_appl_transported_option = '1' IMPORTING ev_failure = lv_failure ). ENDIF. ENDIF. ENDIF. IF lv_failure = abap_true. zcx_abapgit_exception=>raise( |Error deleting { ms_item-obj_type } { ms_item-obj_name }| ). ENDIF. CATCH cx_fdt_input INTO lx_fdt_input. zcx_abapgit_exception=>raise_with_text( lx_fdt_input ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA lo_dexc TYPE REF TO if_fdt_data_exchange. DATA lx_fdt_input TYPE REF TO cx_fdt_input. DATA lo_dom_tree TYPE REF TO if_ixml_document. DATA lv_transportable_package TYPE abap_bool. DATA lv_is_local TYPE abap_bool. DATA lt_message TYPE if_fdt_types=>t_message. DATA lv_create TYPE abap_bool. FIELD-SYMBOLS TYPE if_fdt_types=>s_message. lo_dom_tree = io_xml->get_raw( ). before_xml_deserialize( EXPORTING iv_package = iv_package IMPORTING ev_create = lv_create ev_is_local = lv_is_local CHANGING co_dom_tree = lo_dom_tree ). lv_transportable_package = zcl_abapgit_factory=>get_sap_package( iv_package )->are_changes_recorded_in_tr_req( ). IF lv_transportable_package = abap_true AND lv_is_local = abap_true. zcx_abapgit_exception=>raise( 'Local applications can only be imported into a local package' ). ELSEIF lv_transportable_package = abap_false AND lv_is_local = abap_false. zcx_abapgit_exception=>raise( 'Transportable application can only be imported into transportable package' ). ENDIF. lo_dexc = cl_fdt_factory=>if_fdt_factory~get_instance( )->get_data_exchange( ). TRY. IF lv_is_local = abap_true. ""Local Object lo_dexc->import_xml( EXPORTING io_dom_tree = lo_dom_tree iv_create = lv_create iv_activate = abap_true iv_simulate = abap_false IMPORTING et_message = lt_message ). ELSE. ""Transportable Object tadir_insert( iv_package ). corr_insert( iv_package ). lo_dexc->import_xml( EXPORTING io_dom_tree = lo_dom_tree iv_create = lv_create iv_activate = abap_true iv_simulate = abap_false iv_workbench_trrequest = iv_transport IMPORTING et_message = lt_message ). ENDIF. LOOP AT lt_message ASSIGNING . ii_log->add( iv_msg = -text iv_type = -msgty ). ENDLOOP. CATCH cx_fdt_input INTO lx_fdt_input. zcx_abapgit_exception=>raise_with_text( lx_fdt_input ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA lv_count TYPE i. SELECT COUNT( * ) FROM fdt_admn_0000s INTO lv_count WHERE object_type = 'AP' AND name = ms_item-obj_name AND deleted = ''. rv_bool = boolc( lv_count > 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. DATA lo_local_version_output TYPE REF TO zcl_abapgit_xml_output. DATA lo_local_version_input TYPE REF TO zcl_abapgit_xml_input. CREATE OBJECT lo_local_version_output. zif_abapgit_object~serialize( lo_local_version_output ). CREATE OBJECT lo_local_version_input EXPORTING iv_xml = lo_local_version_output->zif_abapgit_xml_output~render( ). CREATE OBJECT ri_comparator TYPE zcl_abapgit_object_tabl_compar EXPORTING ii_local = lo_local_version_input. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-abap TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. DATA lv_application_id TYPE fdt_admn_0000s-application_id. DATA lx_fdt_input TYPE REF TO cx_fdt_input. DATA lo_instance TYPE REF TO if_fdt_admin_data. DATA lt_version TYPE if_fdt_admin_data=>ts_version. DATA lv_index TYPE sy-tabix. FIELD-SYMBOLS LIKE LINE OF lt_version. lv_application_id = get_application_id( ). TRY. cl_fdt_factory=>get_instance_generic( EXPORTING iv_id = lv_application_id IMPORTING eo_instance = lo_instance ). CATCH cx_fdt_input INTO lx_fdt_input. zcx_abapgit_exception=>raise_with_text( lx_fdt_input ). ENDTRY. lo_instance->get_versions( IMPORTING ets_version = lt_version ). lv_index = lines( lt_version ). READ TABLE lt_version ASSIGNING INDEX lv_index. rv_active = boolc( -state = 'A' ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. DATA lv_application_id TYPE string. lv_application_id = get_application_id( ). rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'FDT_ENQUEUE_ID' iv_argument = |$ST{ lv_application_id }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. DATA lv_application_id TYPE fdt_admn_0000s-application_id. DATA lx_root TYPE REF TO cx_root. DATA lo_fdt_wd TYPE REF TO if_fdt_wd_factory. lv_application_id = get_application_id( ). IF lv_application_id IS NOT INITIAL. TRY. lo_fdt_wd = cl_fdt_wd_factory=>if_fdt_wd_factory~get_instance( ). lo_fdt_wd->get_ui_execution( )->execute_workbench( iv_id = lv_application_id ). CATCH cx_root INTO lx_root. zcx_abapgit_exception=>raise_with_text( lx_root ). ENDTRY. ELSE. zcx_abapgit_exception=>raise( 'Could not open BRF+ Workbench' ). ENDIF. rv_exit = abap_true. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA lo_dexc TYPE REF TO if_fdt_data_exchange. DATA lv_application_id TYPE fdt_admn_0000s-application_id. DATA lx_fdt_input TYPE REF TO cx_fdt_input. DATA lv_xml_fdt0_application TYPE string. DATA lo_xml_document TYPE REF TO if_ixml_document. DATA lo_xml_element TYPE REF TO if_ixml_element. lv_application_id = get_application_id( ). lo_dexc = cl_fdt_factory=>if_fdt_factory~get_instance( )->get_data_exchange( ). TRY. lo_dexc->export_xml_application( EXPORTING iv_application_id = lv_application_id iv_schema = if_fdt_data_exchange=>gc_xml_schema_type_external iv_xml_version = if_fdt_data_exchange=>gc_xml_version IMPORTING ev_string = lv_xml_fdt0_application ). lo_xml_document = cl_ixml_80_20=>parse_to_document( stream_string = lv_xml_fdt0_application ). lo_xml_element = lo_xml_document->get_root_element( ). filter_xml_serialize( CHANGING co_ixml_element = lo_xml_element ). io_xml->set_raw( lo_xml_element ). CATCH cx_fdt_input INTO lx_fdt_input. zcx_abapgit_exception=>raise_with_text( lx_fdt_input ). ENDTRY. ENDMETHOD. ENDCLASS. ",5138,False,1116.3163532631465,median "/* Feathers Copyright 2012-2013 Joshua Tynjala. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls.supportClasses { import feathers.controls.GroupedList; import feathers.controls.Scroller; import feathers.controls.renderers.IGroupedListHeaderOrFooterRenderer; import feathers.controls.renderers.IGroupedListItemRenderer; import feathers.core.FeathersControl; import feathers.core.IFeathersControl; import feathers.core.PropertyProxy; import feathers.data.HierarchicalCollection; import feathers.events.CollectionEventType; import feathers.events.FeathersEventType; import feathers.layout.ILayout; import feathers.layout.IVariableVirtualLayout; import feathers.layout.IVirtualLayout; import feathers.layout.LayoutBoundsResult; import feathers.layout.ViewPortBounds; import flash.geom.Point; import flash.utils.Dictionary; import starling.display.DisplayObject; import starling.events.Event; import starling.events.EventDispatcher; import starling.events.Touch; import starling.events.TouchEvent; import starling.events.TouchPhase; /** * @private * Used internally by GroupedList. Not meant to be used on its own. */ public final class GroupedListDataViewPort extends FeathersControl implements IViewPort { private static const INVALIDATION_FLAG_ITEM_RENDERER_FACTORY:String = ""itemRendererFactory""; private static const HELPER_POINT:Point = new Point(); private static const HELPER_BOUNDS:ViewPortBounds = new ViewPortBounds(); private static const HELPER_LAYOUT_RESULT:LayoutBoundsResult = new LayoutBoundsResult(); private static const HELPER_VECTOR:Vector. = new []; private static const HELPER_TOUCHES_VECTOR:Vector. = new []; public function GroupedListDataViewPort() { super(); this.addEventListener(TouchEvent.TOUCH, touchHandler); this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler); } private var touchPointID:int = -1; private var _minVisibleWidth:Number = 0; public function get minVisibleWidth():Number { return this._minVisibleWidth; } public function set minVisibleWidth(value:Number):void { if(this._minVisibleWidth == value) { return; } if(isNaN(value)) { throw new ArgumentError(""minVisibleWidth cannot be NaN""); } this._minVisibleWidth = value; this.invalidate(INVALIDATION_FLAG_SIZE); } private var _maxVisibleWidth:Number = Number.POSITIVE_INFINITY; public function get maxVisibleWidth():Number { return this._maxVisibleWidth; } public function set maxVisibleWidth(value:Number):void { if(this._maxVisibleWidth == value) { return; } if(isNaN(value)) { throw new ArgumentError(""maxVisibleWidth cannot be NaN""); } this._maxVisibleWidth = value; this.invalidate(INVALIDATION_FLAG_SIZE); } private var actualVisibleWidth:Number = NaN; private var explicitVisibleWidth:Number = NaN; public function get visibleWidth():Number { return this.actualVisibleWidth; } public function set visibleWidth(value:Number):void { if(this.explicitVisibleWidth == value || (isNaN(value) && isNaN(this.explicitVisibleWidth))) { return; } this.explicitVisibleWidth = value; this.invalidate(INVALIDATION_FLAG_SIZE); } private var _minVisibleHeight:Number = 0; public function get minVisibleHeight():Number { return this._minVisibleHeight; } public function set minVisibleHeight(value:Number):void { if(this._minVisibleHeight == value) { return; } if(isNaN(value)) { throw new ArgumentError(""minVisibleHeight cannot be NaN""); } this._minVisibleHeight = value; this.invalidate(INVALIDATION_FLAG_SIZE); } private var _maxVisibleHeight:Number = Number.POSITIVE_INFINITY; public function get maxVisibleHeight():Number { return this._maxVisibleHeight; } public function set maxVisibleHeight(value:Number):void { if(this._maxVisibleHeight == value) { return; } if(isNaN(value)) { throw new ArgumentError(""maxVisibleHeight cannot be NaN""); } this._maxVisibleHeight = value; this.invalidate(INVALIDATION_FLAG_SIZE); } private var actualVisibleHeight:Number; private var explicitVisibleHeight:Number = NaN; public function get visibleHeight():Number { return this.actualVisibleHeight; } public function set visibleHeight(value:Number):void { if(this.explicitVisibleHeight == value || (isNaN(value) && isNaN(this.explicitVisibleHeight))) { return; } this.explicitVisibleHeight = value; this.invalidate(INVALIDATION_FLAG_SIZE); } public function get horizontalScrollStep():Number { return this._typicalItemWidth; } public function get verticalScrollStep():Number { return this._typicalItemHeight; } private var _typicalItemWidth:Number = NaN; public function get typicalItemWidth():Number { return this._typicalItemWidth; } private var _typicalItemHeight:Number = NaN; public function get typicalItemHeight():Number { return this._typicalItemHeight; } private var _typicalHeaderWidth:Number = NaN; public function get typicalHeaderWidth():Number { return this._typicalHeaderWidth; } private var _typicalHeaderHeight:Number = NaN; public function get typicalHeaderHeight():Number { return this._typicalHeaderHeight; } private var _typicalFooterWidth:Number = NaN; public function get typicalFooterWidth():Number { return this._typicalFooterWidth; } private var _typicalFooterHeight:Number = NaN; public function get typicalFooterHeight():Number { return this._typicalFooterHeight; } private var _layoutItems:Vector. = new []; private var _unrenderedItems:Vector. = new []; private var _inactiveItemRenderers:Vector. = new []; private var _activeItemRenderers:Vector. = new []; private var _itemRendererMap:Dictionary = new Dictionary(true); private var _unrenderedFirstItems:Vector.; private var _inactiveFirstItemRenderers:Vector.; private var _activeFirstItemRenderers:Vector.; private var _firstItemRendererMap:Dictionary = new Dictionary(true); private var _unrenderedLastItems:Vector.; private var _inactiveLastItemRenderers:Vector.; private var _activeLastItemRenderers:Vector.; private var _lastItemRendererMap:Dictionary; private var _unrenderedSingleItems:Vector.; private var _inactiveSingleItemRenderers:Vector.; private var _activeSingleItemRenderers:Vector.; private var _singleItemRendererMap:Dictionary; private var _unrenderedHeaders:Vector. = new []; private var _inactiveHeaderRenderers:Vector. = new []; private var _activeHeaderRenderers:Vector. = new []; private var _headerRendererMap:Dictionary = new Dictionary(true); private var _unrenderedFooters:Vector. = new []; private var _inactiveFooterRenderers:Vector. = new []; private var _activeFooterRenderers:Vector. = new []; private var _footerRendererMap:Dictionary = new Dictionary(true); private var _headerIndices:Vector. = new []; private var _footerIndices:Vector. = new []; private var _isScrolling:Boolean = false; private var _owner:GroupedList; public function get owner():GroupedList { return this._owner; } public function set owner(value:GroupedList):void { if(this._owner == value) { return; } if(this._owner) { this._owner.removeEventListener(Event.SCROLL, owner_scrollHandler); } this._owner = value; if(this._owner) { this._owner.addEventListener(Event.SCROLL, owner_scrollHandler); } } private var _dataProvider:HierarchicalCollection; public function get dataProvider():HierarchicalCollection { return this._dataProvider; } public function set dataProvider(value:HierarchicalCollection):void { if(this._dataProvider == value) { return; } if(this._dataProvider) { this._dataProvider.removeEventListener(Event.CHANGE, dataProvider_changeHandler); this._dataProvider.removeEventListener(CollectionEventType.UPDATE_ITEM, dataProvider_updateItemHandler); } this._dataProvider = value; if(this._dataProvider) { this._dataProvider.addEventListener(Event.CHANGE, dataProvider_changeHandler); this._dataProvider.addEventListener(CollectionEventType.UPDATE_ITEM, dataProvider_updateItemHandler); } this.invalidate(INVALIDATION_FLAG_DATA); } private var _isSelectable:Boolean = true; public function get isSelectable():Boolean { return this._isSelectable; } public function set isSelectable(value:Boolean):void { if(this._isSelectable == value) { return; } this._isSelectable = value; if(!this._isSelectable) { this.setSelectedLocation(-1, -1); } this.invalidate(INVALIDATION_FLAG_SELECTED); } private var _selectedGroupIndex:int = -1; public function get selectedGroupIndex():int { return this._selectedGroupIndex; } private var _selectedItemIndex:int = -1; public function get selectedItemIndex():int { return this._selectedItemIndex; } private var _itemRendererType:Class; public function get itemRendererType():Class { return this._itemRendererType; } public function set itemRendererType(value:Class):void { if(this._itemRendererType == value) { return; } this._itemRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _itemRendererFactory:Function; public function get itemRendererFactory():Function { return this._itemRendererFactory; } public function set itemRendererFactory(value:Function):void { if(this._itemRendererFactory === value) { return; } this._itemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _itemRendererName:String; public function get itemRendererName():String { return this._itemRendererName; } public function set itemRendererName(value:String):void { if(this._itemRendererName == value) { return; } this._itemRendererName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _typicalItem:Object = null; public function get typicalItem():Object { return this._typicalItem; } public function set typicalItem(value:Object):void { if(this._typicalItem == value) { return; } this._typicalItem = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _itemRendererProperties:PropertyProxy; public function get itemRendererProperties():PropertyProxy { return this._itemRendererProperties; } public function set itemRendererProperties(value:PropertyProxy):void { if(this._itemRendererProperties == value) { return; } if(this._itemRendererProperties) { this._itemRendererProperties.removeOnChangeCallback(childProperties_onChange); } this._itemRendererProperties = PropertyProxy(value); if(this._itemRendererProperties) { this._itemRendererProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } private var _firstItemRendererType:Class; public function get firstItemRendererType():Class { return this._firstItemRendererType; } public function set firstItemRendererType(value:Class):void { if(this._firstItemRendererType == value) { return; } this._firstItemRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _firstItemRendererFactory:Function; public function get firstItemRendererFactory():Function { return this._firstItemRendererFactory; } public function set firstItemRendererFactory(value:Function):void { if(this._firstItemRendererFactory === value) { return; } this._firstItemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _firstItemRendererName:String; public function get firstItemRendererName():String { return this._firstItemRendererName; } public function set firstItemRendererName(value:String):void { if(this._firstItemRendererName == value) { return; } this._firstItemRendererName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _lastItemRendererType:Class; public function get lastItemRendererType():Class { return this._lastItemRendererType; } public function set lastItemRendererType(value:Class):void { if(this._lastItemRendererType == value) { return; } this._lastItemRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _lastItemRendererFactory:Function; public function get lastItemRendererFactory():Function { return this._lastItemRendererFactory; } public function set lastItemRendererFactory(value:Function):void { if(this._lastItemRendererFactory === value) { return; } this._lastItemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _lastItemRendererName:String; public function get lastItemRendererName():String { return this._lastItemRendererName; } public function set lastItemRendererName(value:String):void { if(this._lastItemRendererName == value) { return; } this._lastItemRendererName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _singleItemRendererType:Class; public function get singleItemRendererType():Class { return this._singleItemRendererType; } public function set singleItemRendererType(value:Class):void { if(this._singleItemRendererType == value) { return; } this._singleItemRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _singleItemRendererFactory:Function; public function get singleItemRendererFactory():Function { return this._singleItemRendererFactory; } public function set singleItemRendererFactory(value:Function):void { if(this._singleItemRendererFactory === value) { return; } this._singleItemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _singleItemRendererName:String; public function get singleItemRendererName():String { return this._singleItemRendererName; } public function set singleItemRendererName(value:String):void { if(this._singleItemRendererName == value) { return; } this._singleItemRendererName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _headerRendererType:Class; public function get headerRendererType():Class { return this._headerRendererType; } public function set headerRendererType(value:Class):void { if(this._headerRendererType == value) { return; } this._headerRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _headerRendererFactory:Function; public function get headerRendererFactory():Function { return this._headerRendererFactory; } public function set headerRendererFactory(value:Function):void { if(this._headerRendererFactory === value) { return; } this._headerRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _headerRendererName:String; public function get headerRendererName():String { return this._headerRendererName; } public function set headerRendererName(value:String):void { if(this._headerRendererName == value) { return; } this._headerRendererName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _typicalHeader:Object = null; public function get typicalHeader():Object { return this._typicalHeader; } public function set typicalHeader(value:Object):void { if(this._typicalHeader == value) { return; } this._typicalHeader = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _headerRendererProperties:PropertyProxy; public function get headerRendererProperties():PropertyProxy { return this._headerRendererProperties; } public function set headerRendererProperties(value:PropertyProxy):void { if(this._headerRendererProperties == value) { return; } if(this._headerRendererProperties) { this._headerRendererProperties.removeOnChangeCallback(childProperties_onChange); } this._headerRendererProperties = PropertyProxy(value); if(this._headerRendererProperties) { this._headerRendererProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } private var _footerRendererType:Class; public function get footerRendererType():Class { return this._footerRendererType; } public function set footerRendererType(value:Class):void { if(this._footerRendererType == value) { return; } this._footerRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _footerRendererFactory:Function; public function get footerRendererFactory():Function { return this._footerRendererFactory; } public function set footerRendererFactory(value:Function):void { if(this._footerRendererFactory === value) { return; } this._footerRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _footerRendererName:String; public function get footerRendererName():String { return this._footerRendererName; } public function set footerRendererName(value:String):void { if(this._footerRendererName == value) { return; } this._footerRendererName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _typicalFooter:Object = null; public function get typicalFooter():Object { return this._typicalFooter; } public function set typicalFooter(value:Object):void { if(this._typicalFooter == value) { return; } this._typicalFooter = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _footerRendererProperties:PropertyProxy; public function get footerRendererProperties():PropertyProxy { return this._footerRendererProperties; } public function set footerRendererProperties(value:PropertyProxy):void { if(this._footerRendererProperties == value) { return; } if(this._footerRendererProperties) { this._footerRendererProperties.removeOnChangeCallback(childProperties_onChange); } this._footerRendererProperties = PropertyProxy(value); if(this._footerRendererProperties) { this._footerRendererProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } private var _ignoreLayoutChanges:Boolean = false; private var _ignoreRendererResizing:Boolean = false; private var _layout:ILayout; public function get layout():ILayout { return this._layout; } public function set layout(value:ILayout):void { if(this._layout == value) { return; } if(this._layout) { EventDispatcher(this._layout).removeEventListener(Event.CHANGE, layout_changeHandler); } this._layout = value; if(this._layout) { if(this._layout is IVariableVirtualLayout) { IVariableVirtualLayout(this._layout).hasVariableItemDimensions = true; } EventDispatcher(this._layout).addEventListener(Event.CHANGE, layout_changeHandler); } this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _horizontalScrollPosition:Number = 0; public function get horizontalScrollPosition():Number { return this._horizontalScrollPosition; } public function set horizontalScrollPosition(value:Number):void { if(this._horizontalScrollPosition == value) { return; } this._horizontalScrollPosition = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _verticalScrollPosition:Number = 0; public function get verticalScrollPosition():Number { return this._verticalScrollPosition; } public function set verticalScrollPosition(value:Number):void { if(this._verticalScrollPosition == value) { return; } this._verticalScrollPosition = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _minimumItemCount:int; private var _minimumHeaderCount:int; private var _minimumFooterCount:int; private var _minimumFirstAndLastItemCount:int; private var _minimumSingleItemCount:int; private var _ignoreSelectionChanges:Boolean = false; public function setSelectedLocation(groupIndex:int, itemIndex:int):void { if(this._selectedGroupIndex == groupIndex && this._selectedItemIndex == itemIndex) { return; } if((groupIndex < 0 && itemIndex >= 0) || (groupIndex >= 0 && itemIndex < 0)) { throw new ArgumentError(""To deselect items, group index and item index must both be < 0.""); } this._selectedGroupIndex = groupIndex; this._selectedItemIndex = itemIndex; this.invalidate(INVALIDATION_FLAG_SELECTED); this.dispatchEventWith(Event.CHANGE); } public function getScrollPositionForIndex(groupIndex:int, itemIndex:int, result:Point = null):Point { if(!result) { result = new Point(); } const displayIndex:int = this.locationToDisplayIndex(groupIndex, itemIndex); return this._layout.getScrollPositionForIndex(displayIndex, this._layoutItems, 0, 0, this.actualVisibleWidth, this.actualVisibleHeight, result); } override protected function draw():void { const dataInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DATA); const scrollInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SCROLL); const sizeInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SIZE); const selectionInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SELECTED); const itemRendererInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); const stylesInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STYLES); const stateInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STATE); if(stylesInvalid || dataInvalid || itemRendererInvalid) { if(this._layout is IVariableVirtualLayout) { IVariableVirtualLayout(this._layout).resetVariableVirtualCache(); } this.calculateTypicalValues(); } if(scrollInvalid || sizeInvalid || dataInvalid || itemRendererInvalid) { this.refreshRenderers(itemRendererInvalid); } if(scrollInvalid || sizeInvalid || dataInvalid || stylesInvalid || itemRendererInvalid) { this.refreshHeaderRendererStyles(); this.refreshFooterRendererStyles(); this.refreshItemRendererStyles(); } if(scrollInvalid || selectionInvalid || sizeInvalid || dataInvalid || itemRendererInvalid) { this.refreshSelection(); } if(scrollInvalid || stateInvalid || sizeInvalid || dataInvalid || itemRendererInvalid) { this.refreshEnabled(); } this.validateRenderers(); if(scrollInvalid || dataInvalid || itemRendererInvalid || sizeInvalid) { this._ignoreRendererResizing = true; this._layout.layout(this._layoutItems, HELPER_BOUNDS, HELPER_LAYOUT_RESULT); this._ignoreRendererResizing = false; this.setSizeInternal(HELPER_LAYOUT_RESULT.contentWidth, HELPER_LAYOUT_RESULT.contentHeight, false); this.actualVisibleWidth = HELPER_LAYOUT_RESULT.viewPortWidth; this.actualVisibleHeight = HELPER_LAYOUT_RESULT.viewPortHeight; } } private function refreshEnabled():void { var rendererCount:int = this._activeItemRenderers.length; for(var i:int = 0; i < rendererCount; i++) { var renderer:DisplayObject = DisplayObject(this._activeItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).isEnabled = this._isEnabled; } } if(this._activeFirstItemRenderers) { rendererCount = this._activeFirstItemRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeFirstItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).isEnabled = this._isEnabled; } } } if(this._activeLastItemRenderers) { rendererCount = this._activeLastItemRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeLastItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).isEnabled = this._isEnabled; } } } if(this._activeSingleItemRenderers) { rendererCount = this._activeSingleItemRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeSingleItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).isEnabled = this._isEnabled; } } } rendererCount = this._activeHeaderRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeHeaderRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).isEnabled = this._isEnabled; } } rendererCount = this._activeFooterRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeFooterRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).isEnabled = this._isEnabled; } } } private function validateRenderers():void { var rendererCount:int = this._activeItemRenderers.length; for(var i:int = 0; i < rendererCount; i++) { var renderer:DisplayObject = DisplayObject(this._activeItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).validate(); } } if(this._activeFirstItemRenderers) { rendererCount = this._activeFirstItemRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeFirstItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).validate(); } } } if(this._activeLastItemRenderers) { rendererCount = this._activeLastItemRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeLastItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).validate(); } } } if(this._activeSingleItemRenderers) { rendererCount = this._activeSingleItemRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeSingleItemRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).validate(); } } } rendererCount = this._activeHeaderRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeHeaderRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).validate(); } } rendererCount = this._activeFooterRenderers.length; for(i = 0; i < rendererCount; i++) { renderer = DisplayObject(this._activeFooterRenderers[i]); if(renderer is FeathersControl) { FeathersControl(renderer).validate(); } } } private function invalidateParent():void { Scroller(this.parent.parent).invalidate(INVALIDATION_FLAG_DATA); } private function calculateTypicalValues():void { var typicalHeader:Object = this._typicalHeader; var typicalFooter:Object = this._typicalFooter; if(!typicalHeader || !typicalFooter) { if(this._dataProvider && this._dataProvider.getLength() > 0) { var group:Object = this._dataProvider.getItemAt(0); if(!typicalHeader) { typicalHeader = this._owner.groupToHeaderData(group); } if(!typicalFooter) { typicalFooter = this._owner.groupToFooterData(group); } } else { this._typicalHeaderWidth = 0; this._typicalFooterWidth = 0; this._typicalFooterHeight= 0; this._typicalHeaderHeight = 0; } } //headers are optional if(typicalHeader) { const typicalHeaderRenderer:IGroupedListHeaderOrFooterRenderer = this.createHeaderRenderer(typicalHeader, 0, 0, true); this.refreshOneHeaderRendererStyles(typicalHeaderRenderer); if(typicalHeaderRenderer is FeathersControl) { FeathersControl(typicalHeaderRenderer).validate(); } var displayRenderer:DisplayObject = DisplayObject(typicalHeaderRenderer); this._typicalHeaderWidth = displayRenderer.width; this._typicalHeaderHeight = displayRenderer.height; this.destroyHeaderRenderer(typicalHeaderRenderer); } //footers are optional if(typicalFooter) { const typicalFooterRenderer:IGroupedListHeaderOrFooterRenderer = this.createFooterRenderer(typicalFooter, 0, 0, true); this.refreshOneFooterRendererStyles(typicalFooterRenderer); if(typicalFooterRenderer is FeathersControl) { FeathersControl(typicalFooterRenderer).validate(); } displayRenderer = DisplayObject(typicalFooterRenderer); this._typicalFooterWidth = displayRenderer.width; this._typicalFooterHeight = displayRenderer.height; this.destroyFooterRenderer(typicalFooterRenderer); } var typicalItem:Object = this._typicalItem; if(!typicalItem) { if(this._dataProvider && this._dataProvider.getLength() > 0) { typicalItem = this._dataProvider.getItemAt(0); } else { this._typicalItemWidth = 0; this._typicalItemHeight = 0; return; } } const typicalItemRenderer:IGroupedListItemRenderer = this.createItemRenderer(this._inactiveItemRenderers, this._activeItemRenderers, this._itemRendererMap, this._itemRendererType, this._itemRendererFactory, this._itemRendererName, typicalItem, 0, 0, 0, true); this.refreshOneItemRendererStyles(typicalItemRenderer); if(typicalItemRenderer is FeathersControl) { FeathersControl(typicalItemRenderer).validate(); } displayRenderer = DisplayObject(typicalItemRenderer); this._typicalItemWidth = displayRenderer.width; this._typicalItemHeight = displayRenderer.height; this.destroyItemRenderer(typicalItemRenderer); } private function refreshItemRendererStyles():void { for each(var renderer:IGroupedListItemRenderer in this._activeItemRenderers) { this.refreshOneItemRendererStyles(renderer); } for each(renderer in this._activeFirstItemRenderers) { this.refreshOneItemRendererStyles(renderer); } for each(renderer in this._activeLastItemRenderers) { this.refreshOneItemRendererStyles(renderer); } for each(renderer in this._activeSingleItemRenderers) { this.refreshOneItemRendererStyles(renderer); } } private function refreshHeaderRendererStyles():void { for each(var renderer:IGroupedListHeaderOrFooterRenderer in this._activeHeaderRenderers) { this.refreshOneHeaderRendererStyles(renderer); } } private function refreshFooterRendererStyles():void { for each(var renderer:IGroupedListHeaderOrFooterRenderer in this._activeFooterRenderers) { this.refreshOneFooterRendererStyles(renderer); } } private function refreshOneItemRendererStyles(renderer:IGroupedListItemRenderer):void { const displayRenderer:DisplayObject = DisplayObject(renderer); for(var propertyName:String in this._itemRendererProperties) { if(displayRenderer.hasOwnProperty(propertyName)) { var propertyValue:Object = this._itemRendererProperties[propertyName]; displayRenderer[propertyName] = propertyValue; } } } private function refreshOneHeaderRendererStyles(renderer:IGroupedListHeaderOrFooterRenderer):void { const displayRenderer:DisplayObject = DisplayObject(renderer); for(var propertyName:String in this._headerRendererProperties) { if(displayRenderer.hasOwnProperty(propertyName)) { var propertyValue:Object = this._headerRendererProperties[propertyName]; displayRenderer[propertyName] = propertyValue; } } } private function refreshOneFooterRendererStyles(renderer:IGroupedListHeaderOrFooterRenderer):void { const displayRenderer:DisplayObject = DisplayObject(renderer); for(var propertyName:String in this._footerRendererProperties) { if(displayRenderer.hasOwnProperty(propertyName)) { var propertyValue:Object = this._footerRendererProperties[propertyName]; displayRenderer[propertyName] = propertyValue; } } } private function refreshSelection():void { this._ignoreSelectionChanges = true; for each(var renderer:IGroupedListItemRenderer in this._activeItemRenderers) { renderer.isSelected = renderer.groupIndex == this._selectedGroupIndex && renderer.itemIndex == this._selectedItemIndex; } for each(renderer in this._activeFirstItemRenderers) { renderer.isSelected = renderer.groupIndex == this._selectedGroupIndex && renderer.itemIndex == this._selectedItemIndex; } for each(renderer in this._activeLastItemRenderers) { renderer.isSelected = renderer.groupIndex == this._selectedGroupIndex && renderer.itemIndex == this._selectedItemIndex; } for each(renderer in this._activeSingleItemRenderers) { renderer.isSelected = renderer.groupIndex == this._selectedGroupIndex && renderer.itemIndex == this._selectedItemIndex; } this._ignoreSelectionChanges = false; } private function refreshRenderers(itemRendererTypeIsInvalid:Boolean):void { var temp:Vector. = this._inactiveItemRenderers; this._inactiveItemRenderers = this._activeItemRenderers; this._activeItemRenderers = temp; this._activeItemRenderers.length = 0; if(this._inactiveFirstItemRenderers) { temp = this._inactiveFirstItemRenderers; this._inactiveFirstItemRenderers = this._activeFirstItemRenderers; this._activeFirstItemRenderers = temp; this._activeFirstItemRenderers.length = 0; } if(this._inactiveLastItemRenderers) { temp = this._inactiveLastItemRenderers; this._inactiveLastItemRenderers = this._activeLastItemRenderers; this._activeLastItemRenderers = temp; this._activeLastItemRenderers.length = 0; } if(this._inactiveSingleItemRenderers) { temp = this._inactiveSingleItemRenderers; this._inactiveSingleItemRenderers = this._activeSingleItemRenderers; this._activeSingleItemRenderers = temp; this._activeSingleItemRenderers.length = 0; } var temp2:Vector. = this._inactiveHeaderRenderers; this._inactiveHeaderRenderers = this._activeHeaderRenderers; this._activeHeaderRenderers = temp2; this._activeHeaderRenderers.length = 0; temp2 = this._inactiveFooterRenderers; this._inactiveFooterRenderers = this._activeFooterRenderers; this._activeFooterRenderers = temp2; this._activeFooterRenderers.length = 0; if(itemRendererTypeIsInvalid) { this.recoverInactiveRenderers(); this.freeInactiveRenderers(); } this._headerIndices.length = 0; this._footerIndices.length = 0; HELPER_BOUNDS.x = HELPER_BOUNDS.y = 0; HELPER_BOUNDS.explicitWidth = this.explicitVisibleWidth; HELPER_BOUNDS.explicitHeight = this.explicitVisibleHeight; HELPER_BOUNDS.minWidth = this._minVisibleWidth; HELPER_BOUNDS.minHeight = this._minVisibleHeight; HELPER_BOUNDS.maxWidth = this._maxVisibleWidth; HELPER_BOUNDS.maxHeight = this._maxVisibleHeight; this.findUnrenderedData(); this.recoverInactiveRenderers(); this.renderUnrenderedData(); this.freeInactiveRenderers(); } private function findUnrenderedData():void { const hasCustomFirstItemRenderer:Boolean = this._firstItemRendererType || this._firstItemRendererFactory != null || this._firstItemRendererName; const hasCustomLastItemRenderer:Boolean = this._lastItemRendererType || this._lastItemRendererFactory != null || this._lastItemRendererName; const hasCustomSingleItemRenderer:Boolean = this._singleItemRendererType || this._singleItemRendererFactory != null || this._singleItemRendererName; if(hasCustomFirstItemRenderer) { if(!this._firstItemRendererMap) { this._firstItemRendererMap = new Dictionary(true); } if(!this._inactiveFirstItemRenderers) { this._inactiveFirstItemRenderers = new []; } if(!this._activeFirstItemRenderers) { this._activeFirstItemRenderers = new []; } if(!this._unrenderedFirstItems) { this._unrenderedFirstItems = new []; } } else { this._firstItemRendererMap = null; this._inactiveFirstItemRenderers = null; this._activeFirstItemRenderers = null; this._unrenderedFirstItems = null; } if(hasCustomLastItemRenderer) { if(!this._lastItemRendererMap) { this._lastItemRendererMap = new Dictionary(true); } if(!this._inactiveLastItemRenderers) { this._inactiveLastItemRenderers = new []; } if(!this._activeLastItemRenderers) { this._activeLastItemRenderers = new []; } if(!this._unrenderedLastItems) { this._unrenderedLastItems = new []; } } else { this._lastItemRendererMap = null; this._inactiveLastItemRenderers = null; this._activeLastItemRenderers = null; this._unrenderedLastItems = null; } if(hasCustomSingleItemRenderer) { if(!this._singleItemRendererMap) { this._singleItemRendererMap = new Dictionary(true); } if(!this._inactiveSingleItemRenderers) { this._inactiveSingleItemRenderers = new []; } if(!this._activeSingleItemRenderers) { this._activeSingleItemRenderers = new []; } if(!this._unrenderedSingleItems) { this._unrenderedSingleItems = new []; } } else { this._singleItemRendererMap = null; this._inactiveSingleItemRenderers = null; this._activeSingleItemRenderers = null; this._unrenderedSingleItems = null; } const groupCount:int = this._dataProvider ? this._dataProvider.getLength() : 0; var totalLayoutCount:int = 0; var totalHeaderCount:int = 0; var totalFooterCount:int = 0; var totalSingleItemCount:int = 0; var averageItemsPerGroup:int = 0; for(var i:int = 0; i < groupCount; i++) { var group:Object = this._dataProvider.getItemAt(i); if(this._owner.groupToHeaderData(group) !== null) { this._headerIndices.push(totalLayoutCount); totalLayoutCount++; totalHeaderCount++; } var currentItemCount:int = this._dataProvider.getLength(i); totalLayoutCount += currentItemCount; averageItemsPerGroup += currentItemCount; if(currentItemCount == 0) { totalSingleItemCount++; } if(this._owner.groupToFooterData(group) !== null) { this._footerIndices.push(totalLayoutCount); totalLayoutCount++; totalFooterCount++; } } this._layoutItems.length = totalLayoutCount; const virtualLayout:IVirtualLayout = this._layout as IVirtualLayout; const useVirtualLayout:Boolean = virtualLayout && virtualLayout.useVirtualLayout; if(useVirtualLayout) { this._ignoreLayoutChanges = true; virtualLayout.typicalItemWidth = this._typicalItemWidth; virtualLayout.typicalItemHeight = this._typicalItemHeight; this._ignoreLayoutChanges = false; virtualLayout.measureViewPort(totalLayoutCount, HELPER_BOUNDS, HELPER_POINT); virtualLayout.getVisibleIndicesAtScrollPosition(this._horizontalScrollPosition, this._verticalScrollPosition, HELPER_POINT.x, HELPER_POINT.y, totalLayoutCount, HELPER_VECTOR); averageItemsPerGroup /= groupCount; this._minimumFirstAndLastItemCount = this._minimumSingleItemCount = this._minimumHeaderCount = this._minimumFooterCount = Math.ceil(HELPER_POINT.y / (this._typicalItemHeight * averageItemsPerGroup)); this._minimumHeaderCount = Math.min(this._minimumHeaderCount, totalHeaderCount); this._minimumFooterCount = Math.min(this._minimumFooterCount, totalFooterCount); this._minimumSingleItemCount = Math.min(this._minimumSingleItemCount, totalSingleItemCount); //assumes that zero headers/footers might be visible this._minimumItemCount = Math.ceil(HELPER_POINT.y / this._typicalItemHeight) + 1; } var currentIndex:int = 0; for(i = 0; i < groupCount; i++) { group = this._dataProvider.getItemAt(i); var header:Object = this._owner.groupToHeaderData(group); if(header !== null) { //the end index is included in the visible items if(useVirtualLayout && HELPER_VECTOR.indexOf(currentIndex) < 0) { this._layoutItems[currentIndex] = null; } else { var headerOrFooterRenderer:IGroupedListHeaderOrFooterRenderer = IGroupedListHeaderOrFooterRenderer(this._headerRendererMap[header]); if(headerOrFooterRenderer) { headerOrFooterRenderer.layoutIndex = currentIndex; headerOrFooterRenderer.groupIndex = i; this._activeHeaderRenderers.push(headerOrFooterRenderer); this._inactiveHeaderRenderers.splice(this._inactiveHeaderRenderers.indexOf(headerOrFooterRenderer), 1); var displayRenderer:DisplayObject = DisplayObject(headerOrFooterRenderer); displayRenderer.visible = true; this._layoutItems[currentIndex] = displayRenderer; } else { this._unrenderedHeaders.push(i); this._unrenderedHeaders.push(currentIndex); } } currentIndex++; } currentItemCount = this._dataProvider.getLength(i); var currentGroupLastIndex:int = currentItemCount - 1; for(var j:int = 0; j < currentItemCount; j++) { if(useVirtualLayout && HELPER_VECTOR.indexOf(currentIndex) < 0) { this._layoutItems[currentIndex] = null; } else { var item:Object = this._dataProvider.getItemAt(i, j); if(hasCustomSingleItemRenderer && j == 0 && j == currentGroupLastIndex) { this.findRendererForItem(item, i, j, currentIndex, this._singleItemRendererMap, this._inactiveSingleItemRenderers, this._activeSingleItemRenderers, this._unrenderedSingleItems); } else if(hasCustomFirstItemRenderer && j == 0) { this.findRendererForItem(item, i, j, currentIndex, this._firstItemRendererMap, this._inactiveFirstItemRenderers, this._activeFirstItemRenderers, this._unrenderedFirstItems); } else if(hasCustomLastItemRenderer && j == currentGroupLastIndex) { this.findRendererForItem(item, i, j, currentIndex, this._lastItemRendererMap, this._inactiveLastItemRenderers, this._activeLastItemRenderers, this._unrenderedLastItems); } else { this.findRendererForItem(item, i, j, currentIndex, this._itemRendererMap, this._inactiveItemRenderers, this._activeItemRenderers, this._unrenderedItems); } } currentIndex++; } var footer:Object = this._owner.groupToFooterData(group); if(footer !== null) { if(useVirtualLayout && HELPER_VECTOR.indexOf(currentIndex) < 0) { this._layoutItems[currentIndex] = null; } else { headerOrFooterRenderer = IGroupedListHeaderOrFooterRenderer(this._footerRendererMap[footer]); if(headerOrFooterRenderer) { headerOrFooterRenderer.groupIndex = i; headerOrFooterRenderer.layoutIndex = currentIndex; this._activeFooterRenderers.push(headerOrFooterRenderer); this._inactiveFooterRenderers.splice(this._inactiveFooterRenderers.indexOf(headerOrFooterRenderer), 1); displayRenderer = DisplayObject(headerOrFooterRenderer); displayRenderer.visible = true; this._layoutItems[currentIndex] = displayRenderer; } else { this._unrenderedFooters.push(i); this._unrenderedFooters.push(currentIndex); } } currentIndex++; } } } private function findRendererForItem(item:Object, groupIndex:int, itemIndex:int, layoutIndex:int, rendererMap:Dictionary, inactiveRenderers:Vector., activeRenderers:Vector., unrenderedItems:Vector.):void { var itemRenderer:IGroupedListItemRenderer = IGroupedListItemRenderer(rendererMap[item]); if(itemRenderer) { itemRenderer.groupIndex = groupIndex; itemRenderer.itemIndex = itemIndex; itemRenderer.layoutIndex = layoutIndex; activeRenderers.push(itemRenderer); inactiveRenderers.splice(inactiveRenderers.indexOf(itemRenderer), 1); var displayRenderer:DisplayObject = DisplayObject(itemRenderer); displayRenderer.visible = true; this._layoutItems[layoutIndex] = displayRenderer; } else { unrenderedItems.push(groupIndex); unrenderedItems.push(itemIndex); unrenderedItems.push(layoutIndex); } } private function renderUnrenderedData():void { var rendererCount:int = this._unrenderedItems.length; for(var i:int = 0; i < rendererCount; i += 3) { var groupIndex:int = this._unrenderedItems.shift(); var itemIndex:int = this._unrenderedItems.shift(); var layoutIndex:int = this._unrenderedItems.shift(); var item:Object = this._dataProvider.getItemAt(groupIndex, itemIndex); var itemRenderer:IGroupedListItemRenderer = this.createItemRenderer(this._inactiveItemRenderers, this._activeItemRenderers, this._itemRendererMap, this._itemRendererType, this._itemRendererFactory, this._itemRendererName, item, groupIndex, itemIndex, layoutIndex, false); this._layoutItems[layoutIndex] = DisplayObject(itemRenderer); } if(this._unrenderedFirstItems) { rendererCount = this._unrenderedFirstItems.length; for(i = 0; i < rendererCount; i += 3) { groupIndex = this._unrenderedFirstItems.shift(); itemIndex = this._unrenderedFirstItems.shift(); layoutIndex = this._unrenderedFirstItems.shift(); item = this._dataProvider.getItemAt(groupIndex, itemIndex); var type:Class = this._firstItemRendererType ? this._firstItemRendererType : this._itemRendererType; var factory:Function = this._firstItemRendererFactory != null ? this._firstItemRendererFactory : this._itemRendererFactory; var name:String = this._firstItemRendererName ? this._firstItemRendererName : this._itemRendererName; itemRenderer = this.createItemRenderer(this._inactiveFirstItemRenderers, this._activeFirstItemRenderers, this._firstItemRendererMap, type, factory, name, item, groupIndex, itemIndex, layoutIndex, false); this._layoutItems[layoutIndex] = DisplayObject(itemRenderer); } } if(this._unrenderedLastItems) { rendererCount = this._unrenderedLastItems.length; for(i = 0; i < rendererCount; i += 3) { groupIndex = this._unrenderedLastItems.shift(); itemIndex = this._unrenderedLastItems.shift(); layoutIndex = this._unrenderedLastItems.shift(); item = this._dataProvider.getItemAt(groupIndex, itemIndex); type = this._lastItemRendererType ? this._lastItemRendererType : this._itemRendererType; factory = this._lastItemRendererFactory != null ? this._lastItemRendererFactory : this._itemRendererFactory; name = this._lastItemRendererName ? this._lastItemRendererName : this._itemRendererName; itemRenderer = this.createItemRenderer(this._inactiveLastItemRenderers, this._activeLastItemRenderers, this._lastItemRendererMap, type, factory, name, item, groupIndex, itemIndex, layoutIndex, false); this._layoutItems[layoutIndex] = DisplayObject(itemRenderer); } } if(this._unrenderedSingleItems) { rendererCount = this._unrenderedSingleItems.length; for(i = 0; i < rendererCount; i += 3) { groupIndex = this._unrenderedSingleItems.shift(); itemIndex = this._unrenderedSingleItems.shift(); layoutIndex = this._unrenderedSingleItems.shift(); item = this._dataProvider.getItemAt(groupIndex, itemIndex); type = this._singleItemRendererType ? this._singleItemRendererType : this._itemRendererType; factory = this._singleItemRendererFactory != null ? this._singleItemRendererFactory : this._itemRendererFactory; name = this._singleItemRendererName ? this._singleItemRendererName : this._itemRendererName; itemRenderer = this.createItemRenderer(this._inactiveSingleItemRenderers, this._activeSingleItemRenderers, this._singleItemRendererMap, type, factory, name, item, groupIndex, itemIndex, layoutIndex, false); this._layoutItems[layoutIndex] = DisplayObject(itemRenderer); } } rendererCount = this._unrenderedHeaders.length; for(i = 0; i < rendererCount; i += 2) { groupIndex = this._unrenderedHeaders.shift(); layoutIndex = this._unrenderedHeaders.shift(); item = this._dataProvider.getItemAt(groupIndex); item = this._owner.groupToHeaderData(item); var headerOrFooterRenderer:IGroupedListHeaderOrFooterRenderer = this.createHeaderRenderer(item, groupIndex, layoutIndex, false); this._layoutItems[layoutIndex] = DisplayObject(headerOrFooterRenderer); } rendererCount = this._unrenderedFooters.length; for(i = 0; i < rendererCount; i += 2) { groupIndex = this._unrenderedFooters.shift(); layoutIndex = this._unrenderedFooters.shift(); item = this._dataProvider.getItemAt(groupIndex); item = this._owner.groupToFooterData(item); headerOrFooterRenderer = this.createFooterRenderer(item, groupIndex, layoutIndex, false); this._layoutItems[layoutIndex] = DisplayObject(headerOrFooterRenderer); } } private function recoverInactiveRenderers():void { var rendererCount:int = this._inactiveItemRenderers.length; for(var i:int = 0; i < rendererCount; i++) { var itemRenderer:IGroupedListItemRenderer = this._inactiveItemRenderers[i]; this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, itemRenderer); delete this._itemRendererMap[itemRenderer.data]; } if(this._inactiveFirstItemRenderers) { rendererCount = this._inactiveFirstItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveFirstItemRenderers[i]; this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, itemRenderer); delete this._firstItemRendererMap[itemRenderer.data]; } } if(this._inactiveLastItemRenderers) { rendererCount = this._inactiveLastItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveLastItemRenderers[i]; this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, itemRenderer); delete this._lastItemRendererMap[itemRenderer.data]; } } if(this._inactiveSingleItemRenderers) { rendererCount = this._inactiveSingleItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveSingleItemRenderers[i]; this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, itemRenderer); delete this._singleItemRendererMap[itemRenderer.data]; } } rendererCount = this._inactiveHeaderRenderers.length; for(i = 0; i < rendererCount; i++) { var headerOrFooterRenderer:IGroupedListHeaderOrFooterRenderer = this._inactiveHeaderRenderers[i]; this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, headerOrFooterRenderer); delete this._headerRendererMap[headerOrFooterRenderer.data]; } rendererCount = this._inactiveFooterRenderers.length; for(i = 0; i < rendererCount; i++) { headerOrFooterRenderer = this._inactiveFooterRenderers[i]; this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, headerOrFooterRenderer); delete this._footerRendererMap[headerOrFooterRenderer.data]; } } private function freeInactiveRenderers():void { //we may keep around some extra renderers to avoid too much //allocation and garbage collection. they'll be hidden. var keepCount:int = Math.min(this._minimumItemCount - this._activeItemRenderers.length, this._inactiveItemRenderers.length); for(var i:int = 0; i < keepCount; i++) { var itemRenderer:IGroupedListItemRenderer = this._inactiveItemRenderers.shift(); DisplayObject(itemRenderer).visible = false; this._activeItemRenderers.push(itemRenderer); } var rendererCount:int = this._inactiveItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveItemRenderers.shift(); this.destroyItemRenderer(itemRenderer); } if(this._activeFirstItemRenderers) { keepCount = Math.min(this._minimumFirstAndLastItemCount - this._activeFirstItemRenderers.length, this._inactiveFirstItemRenderers.length); for(i = 0; i < keepCount; i++) { itemRenderer = this._inactiveFirstItemRenderers.shift(); DisplayObject(itemRenderer).visible = false; this._activeFirstItemRenderers.push(itemRenderer); } rendererCount = this._inactiveFirstItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveFirstItemRenderers.shift(); this.destroyItemRenderer(itemRenderer); } } if(this._activeLastItemRenderers) { keepCount = Math.min(this._minimumFirstAndLastItemCount - this._activeLastItemRenderers.length, this._inactiveLastItemRenderers.length); for(i = 0; i < keepCount; i++) { itemRenderer = this._inactiveLastItemRenderers.shift(); DisplayObject(itemRenderer).visible = false; this._activeLastItemRenderers.push(itemRenderer); } rendererCount = this._inactiveLastItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveLastItemRenderers.shift(); this.destroyItemRenderer(itemRenderer); } } if(this._activeSingleItemRenderers) { keepCount = Math.min(this._minimumSingleItemCount - this._activeSingleItemRenderers.length, this._inactiveSingleItemRenderers.length); for(i = 0; i < keepCount; i++) { itemRenderer = this._inactiveSingleItemRenderers.shift(); DisplayObject(itemRenderer).visible = false; this._activeSingleItemRenderers.push(itemRenderer); } rendererCount = this._inactiveSingleItemRenderers.length; for(i = 0; i < rendererCount; i++) { itemRenderer = this._inactiveSingleItemRenderers.shift(); this.destroyItemRenderer(itemRenderer); } } keepCount = Math.min(this._minimumHeaderCount - this._activeHeaderRenderers.length, this._inactiveHeaderRenderers.length); for(i = 0; i < keepCount; i++) { var headerOrFooterRenderer:IGroupedListHeaderOrFooterRenderer = this._inactiveHeaderRenderers.shift(); DisplayObject(headerOrFooterRenderer).visible = false; this._activeHeaderRenderers.push(headerOrFooterRenderer); } rendererCount = this._inactiveHeaderRenderers.length; for(i = 0; i < rendererCount; i++) { headerOrFooterRenderer = this._inactiveHeaderRenderers.shift(); this.destroyHeaderRenderer(headerOrFooterRenderer); } keepCount = Math.min(this._minimumFooterCount - this._activeFooterRenderers.length, this._inactiveFooterRenderers.length); for(i = 0; i < keepCount; i++) { headerOrFooterRenderer = this._inactiveFooterRenderers.shift(); DisplayObject(headerOrFooterRenderer).visible = false; this._activeFooterRenderers.push(headerOrFooterRenderer); } rendererCount = this._inactiveFooterRenderers.length; for(i = 0; i < rendererCount; i++) { headerOrFooterRenderer = this._inactiveFooterRenderers.shift(); this.destroyFooterRenderer(headerOrFooterRenderer); } } private function createItemRenderer(inactiveRenderers:Vector., activeRenderers:Vector., rendererMap:Dictionary, type:Class, factory:Function, name:String, item:Object, groupIndex:int, itemIndex:int, layoutIndex:int, isTemporary:Boolean = false):IGroupedListItemRenderer { if(isTemporary || inactiveRenderers.length == 0) { var renderer:IGroupedListItemRenderer; if(factory != null) { renderer = IGroupedListItemRenderer(factory()); } else { renderer = new type(); } var uiRenderer:IFeathersControl = IFeathersControl(renderer); if(name && name.length > 0) { uiRenderer.nameList.add(name); } this.addChild(DisplayObject(renderer)); } else { renderer = inactiveRenderers.shift(); } const displayRenderer:DisplayObject = DisplayObject(renderer); renderer.data = item; renderer.groupIndex = groupIndex; renderer.itemIndex = itemIndex; renderer.layoutIndex = layoutIndex; renderer.owner = this._owner; displayRenderer.visible = true; if(!isTemporary) { rendererMap[item] = renderer; activeRenderers.push(renderer); displayRenderer.addEventListener(Event.CHANGE, renderer_changeHandler); displayRenderer.addEventListener(FeathersEventType.RESIZE, itemRenderer_resizeHandler); this._owner.dispatchEventWith(FeathersEventType.RENDERER_ADD, false, renderer); } return renderer; } private function createHeaderRenderer(header:Object, groupIndex:int, layoutIndex:int, isTemporary:Boolean = false):IGroupedListHeaderOrFooterRenderer { if(isTemporary || this._inactiveHeaderRenderers.length == 0) { var renderer:IGroupedListHeaderOrFooterRenderer; if(this._headerRendererFactory != null) { renderer = IGroupedListHeaderOrFooterRenderer(this._headerRendererFactory()); } else { renderer = new this._headerRendererType(); } var uiRenderer:IFeathersControl = IFeathersControl(renderer); if(this._headerRendererName && this._headerRendererName.length > 0) { uiRenderer.nameList.add(this._headerRendererName); } this.addChild(DisplayObject(renderer)); } else { renderer = this._inactiveHeaderRenderers.shift(); } renderer.data = header; renderer.groupIndex = groupIndex; renderer.layoutIndex = layoutIndex; renderer.owner = this._owner; renderer.visible = true; if(!isTemporary) { this._headerRendererMap[header] = renderer; this._activeHeaderRenderers.push(renderer); renderer.addEventListener(FeathersEventType.RESIZE, headerOrFooterRenderer_resizeHandler); this._owner.dispatchEventWith(FeathersEventType.RENDERER_ADD, false, renderer); } return renderer; } private function createFooterRenderer(footer:Object, groupIndex:int, layoutIndex:int, isTemporary:Boolean = false):IGroupedListHeaderOrFooterRenderer { if(isTemporary || this._inactiveFooterRenderers.length == 0) { var renderer:IGroupedListHeaderOrFooterRenderer; if(this._footerRendererFactory != null) { renderer = IGroupedListHeaderOrFooterRenderer(this._footerRendererFactory()); } else { renderer = new this._footerRendererType(); } var uiRenderer:IFeathersControl = IFeathersControl(renderer); if(this._footerRendererName && this._footerRendererName.length > 0) { uiRenderer.nameList.add(this._footerRendererName); } this.addChild(DisplayObject(renderer)); } else { renderer = this._inactiveFooterRenderers.shift(); } renderer.data = footer; renderer.groupIndex = groupIndex; renderer.layoutIndex = layoutIndex; renderer.owner = this._owner; renderer.visible = true; if(!isTemporary) { this._footerRendererMap[footer] = renderer; this._activeFooterRenderers.push(renderer); renderer.addEventListener(FeathersEventType.RESIZE, headerOrFooterRenderer_resizeHandler); this._owner.dispatchEventWith(FeathersEventType.RENDERER_ADD, false, renderer); } return renderer; } private function destroyItemRenderer(renderer:IGroupedListItemRenderer):void { renderer.removeEventListener(Event.CHANGE, renderer_changeHandler); renderer.removeEventListener(FeathersEventType.RESIZE, itemRenderer_resizeHandler); renderer.owner = null; renderer.data = null; this.removeChild(DisplayObject(renderer), true); } private function destroyHeaderRenderer(renderer:IGroupedListHeaderOrFooterRenderer):void { renderer.removeEventListener(FeathersEventType.RESIZE, headerOrFooterRenderer_resizeHandler); renderer.owner = null; renderer.data = null; this.removeChild(DisplayObject(renderer), true); } private function destroyFooterRenderer(renderer:IGroupedListHeaderOrFooterRenderer):void { renderer.removeEventListener(FeathersEventType.RESIZE, headerOrFooterRenderer_resizeHandler); renderer.owner = null; renderer.data = null; this.removeChild(DisplayObject(renderer), true); } private function locationToDisplayIndex(groupIndex:int, itemIndex:int):int { var displayIndex:int = 0; const groupCount:int = this._dataProvider.getLength(); for(var i:int = 0; i < groupCount; i++) { var group:Object = this._dataProvider.getItemAt(i); var header:Object = this._owner.groupToHeaderData(group); if(header) { displayIndex++; } var groupLength:int = this._dataProvider.getLength(i); for(var j:int = 0; j < groupLength; j++) { if(groupIndex == i && itemIndex == j) { return displayIndex; } displayIndex++; } var footer:Object = this._owner.groupToFooterData(group); if(footer) { displayIndex++; } } return -1; } private function childProperties_onChange(proxy:PropertyProxy, name:String):void { this.invalidate(INVALIDATION_FLAG_STYLES); } private function owner_scrollHandler(event:Event):void { this._isScrolling = true; } private function dataProvider_changeHandler(event:Event):void { this.invalidate(INVALIDATION_FLAG_DATA); this.invalidateParent(); } private function dataProvider_updateItemHandler(event:Event, indices:Array):void { const groupIndex:int = indices[0]; const itemIndex:int = indices[1]; const item:Object = this._dataProvider.getItemAt(groupIndex, itemIndex); var renderer:IGroupedListItemRenderer = IGroupedListItemRenderer(this._itemRendererMap[item]); if(!renderer) { renderer = IGroupedListItemRenderer(this._firstItemRendererMap[item]); if(!renderer) { renderer = IGroupedListItemRenderer(this._lastItemRendererMap[item]); if(!renderer) { return; } } } renderer.data = null; renderer.data = item; } private function layout_changeHandler(event:Event):void { if(this._ignoreLayoutChanges) { return; } this.invalidate(INVALIDATION_FLAG_SCROLL); this.invalidateParent(); } private function itemRenderer_resizeHandler(event:Event):void { if(this._ignoreRendererResizing) { return; } const layout:IVariableVirtualLayout = this._layout as IVariableVirtualLayout; if(!layout || !layout.hasVariableItemDimensions) { return; } const renderer:IGroupedListItemRenderer = IGroupedListItemRenderer(event.currentTarget); layout.resetVariableVirtualCacheAtIndex(renderer.layoutIndex, DisplayObject(renderer)); this.invalidate(INVALIDATION_FLAG_SCROLL); this.invalidateParent(); } private function headerOrFooterRenderer_resizeHandler(event:Event):void { if(this._ignoreRendererResizing) { return; } const layout:IVariableVirtualLayout = this._layout as IVariableVirtualLayout; if(!layout || !layout.hasVariableItemDimensions) { return; } const renderer:IGroupedListHeaderOrFooterRenderer = IGroupedListHeaderOrFooterRenderer(event.currentTarget); layout.resetVariableVirtualCacheAtIndex(renderer.layoutIndex, DisplayObject(renderer)); this.invalidate(INVALIDATION_FLAG_SCROLL); } private function renderer_changeHandler(event:Event):void { if(this._ignoreSelectionChanges) { return; } const renderer:IGroupedListItemRenderer = IGroupedListItemRenderer(event.currentTarget); const isAlreadySelected:Boolean = this._selectedGroupIndex == renderer.groupIndex && this._selectedItemIndex == renderer.itemIndex; if(!this._isSelectable || this._isScrolling || isAlreadySelected) { //reset to the old value renderer.isSelected = isAlreadySelected; return; } this.setSelectedLocation(renderer.groupIndex, renderer.itemIndex); } private function removedFromStageHandler(event:Event):void { this.touchPointID = -1; } private function touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } const touches:Vector. = event.getTouches(this, null, HELPER_TOUCHES_VECTOR); if(touches.length == 0) { return; } if(this.touchPointID >= 0) { var touch:Touch; for each(var currentTouch:Touch in touches) { if(currentTouch.id == this.touchPointID) { touch = currentTouch; break; } } if(!touch) { HELPER_TOUCHES_VECTOR.length = 0; return; } if(touch.phase == TouchPhase.ENDED) { this.touchPointID = -1; } } else { for each(touch in touches) { if(touch.phase == TouchPhase.BEGAN) { this.touchPointID = touch.id; this._isScrolling = false; break; } } } HELPER_TOUCHES_VECTOR.length = 0; } } } ",16357,True,3368.0117207902535,median "/* Feathers Copyright 2012-2020 Bowler Hat LLC. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls { import feathers.core.FeathersControl; import feathers.core.IAdvancedNativeFocusOwner; import feathers.core.ITextBaselineControl; import feathers.core.PropertyProxy; import feathers.events.ExclusiveTouch; import feathers.events.FeathersEventType; import feathers.skins.IStyleProvider; import feathers.utils.math.clamp; import feathers.utils.math.roundToNearest; import feathers.utils.math.roundToPrecision; import flash.events.TimerEvent; import flash.ui.Keyboard; import flash.utils.Timer; import starling.display.DisplayObject; import starling.events.Event; import starling.events.KeyboardEvent; import starling.events.Touch; import starling.events.TouchEvent; import starling.events.TouchPhase; /** * How the buttons are positioned relative to the text input. * *

In the following example, the button layout is set to place the * buttons on the right side, stacked vertically, for a desktop * appearance:

* * * stepper.buttonLayoutMode = NumericStepper.StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL; * * @default feathers.controls.StepperButtonLayoutMode.SPLIT_HORIZONTAL * * @see feathers.controls.StepperButtonLayoutMode#SPLIT_HORIZONTAL * @see feathers.controls.StepperButtonLayoutMode#SPLIT_VERTICAL * @see feathers.controls.StepperButtonLayoutMode#RIGHT_SIDE_VERTICAL */ [Style(name=""buttonLayoutMode"",type=""String"")] /** * The gap, in pixels, between the numeric stepper's increment and * decrement buttons when they are both positioned on the same side. If * the buttons are split between two sides, this value is not used. * *

In the following example, the gap between buttons is set to 20 pixels:

* * * stepper.buttonLayoutMode = StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL; * stepper.buttonGap = 20; * * @default 0 * * @see #style:textInputGap * @see #style:buttonLayoutMode */ [Style(name=""buttonGap"",type=""Number"")] /** * A style name to add to the numeric stepper's decrement button * sub-component. Typically used by a theme to provide different styles * to different numeric steppers. * *

In the following example, a custom decrement button style name is * passed to the stepper:

* * * stepper.customDecrementButtonStyleName = ""my-custom-decrement-button""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( Button ).setFunctionForStyleName( ""my-custom-decrement-button"", setCustomDecrementButtonStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON * @see feathers.core.FeathersControl#styleNameList * @see #decrementButtonFactory */ [Style(name=""customDecrementButtonStyleName"",type=""String"")] /** * A style name to add to the numeric stepper's increment button * sub-component. Typically used by a theme to provide different styles * to different numeric steppers. * *

In the following example, a custom increment button style name is * passed to the stepper:

* * * stepper.customIncrementButtonStyleName = ""my-custom-increment-button""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( Button ).setFunctionForStyleName( ""my-custom-increment-button"", setCustomIncrementButtonStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON * @see feathers.core.FeathersControl#styleNameList * @see #incrementButtonFactory */ [Style(name=""customIncrementButtonStyleName"",type=""String"")] /** * A style name to add to the numeric stepper's text input sub-component. * Typically used by a theme to provide different styles to different * text inputs. * *

In the following example, a custom text input style name is passed * to the stepper:

* * * stepper.customTextInputStyleName = ""my-custom-text-input""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( TextInput ).setFunctionForStyleName( ""my-custom-text-input"", setCustomTextInputStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT * @see feathers.core.FeathersControl#styleNameList * @see #textInputFactory */ [Style(name=""customTextInputStyleName"",type=""String"")] /** * The text displayed by the decrement button. Often, there is no text * displayed on this button and an icon is used instead. * *

In the following example, the decrement button's label is customized:

* * * stepper.decrementButtonLabel = ""-""; * * @default null */ [Style(name=""decrementButtonLabel"",type=""String"")] /** * The text displayed by the increment button. Often, there is no text * displayed on this button and an icon is used instead. * *

In the following example, the increment button's label is customized:

* * * stepper.incrementButtonLabel = ""+""; * * @default null */ [Style(name=""incrementButtonLabel"",type=""String"")] /** * The gap, in pixels, between the numeric stepper's text input and its * buttons. If the buttons are split, this gap is used on both sides. If * the buttons both appear on the same side, the gap is used only on * that side. * *

In the following example, the gap between the text input and buttons is set to 20 pixels:

* * * stepper.textInputGap = 20; * * @default 0 * * @see #style:buttonGap * @see #style:buttonLayoutMode */ [Style(name=""textInputGap"",type=""Number"")] /** * Dispatched when the stepper's value changes. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @see #value * * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] /** * Select a value between a minimum and a maximum by using increment and * decrement buttons or typing in a value in a text input. * *

The following example sets the stepper's range and listens for when * the value changes:

* * * var stepper:NumericStepper = new NumericStepper(); * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * stepper.addEventListener( Event.CHANGE, stepper_changeHandler ); * this.addChild( stepper ); * * @see ../../../help/numeric-stepper.html How to use the Feathers NumericStepper component * * @productversion Feathers 1.1.0 */ public class NumericStepper extends FeathersControl implements IRange, IAdvancedNativeFocusOwner, ITextBaselineControl { /** * @private */ protected static const INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY:String = ""decrementButtonFactory""; /** * @private */ protected static const INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY:String = ""incrementButtonFactory""; /** * @private */ protected static const INVALIDATION_FLAG_TEXT_INPUT_FACTORY:String = ""textInputFactory""; /** * The default value added to the styleNameList of the decrement * button. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON:String = ""feathers-numeric-stepper-decrement-button""; /** * The default value added to the styleNameList of the increment * button. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON:String = ""feathers-numeric-stepper-increment-button""; /** * The default value added to the styleNameList of the text * input. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT:String = ""feathers-numeric-stepper-text-input""; /** * The default IStyleProvider for all NumericStepper * components. * * @default null * @see feathers.core.FeathersControl#styleProvider */ public static var globalStyleProvider:IStyleProvider; /** * @private */ protected static function defaultDecrementButtonFactory():Button { return new Button(); } /** * @private */ protected static function defaultIncrementButtonFactory():Button { return new Button(); } /** * @private */ protected static function defaultTextInputFactory():TextInput { return new TextInput(); } /** * Constructor. */ public function NumericStepper() { super(); this.addEventListener(Event.REMOVED_FROM_STAGE, numericStepper_removedFromStageHandler); } /** * The value added to the styleNameList of the decrement * button. This variable is protected so that sub-classes * can customize the decrement button style name in their constructors * instead of using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON. * *

To customize the decrement button name without subclassing, see * customDecrementButtonStyleName.

* * @see #style:customDecrementButtonStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var decrementButtonStyleName:String = DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON; /** * The value added to the styleNameList of the increment * button. This variable is protected so that sub-classes * can customize the increment button style name in their constructors * instead of using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON. * *

To customize the increment button name without subclassing, see * customIncrementButtonStyleName.

* * @see #style:customIncrementButtonStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var incrementButtonStyleName:String = DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON; /** * The value added to the styleNameList of the text input. * This variable is protected so that sub-classes can * customize the text input style name in their constructors instead of * using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT. * *

To customize the text input name without subclassing, see * customTextInputStyleName.

* * @see #style:customTextInputStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var textInputStyleName:String = DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT; /** * The decrement button sub-component. * *

For internal use in subclasses.

* * @see #createDecrementButton() */ protected var decrementButton:Button; /** * The increment button sub-component. * *

For internal use in subclasses.

* * @see #createIncrementButton() */ protected var incrementButton:Button; /** * The text input sub-component. * *

For internal use in subclasses.

* * @see #createTextInput() */ protected var textInput:TextInput; /** * @private */ protected var textInputExplicitWidth:Number; /** * @private */ protected var textInputExplicitHeight:Number; /** * @private */ protected var textInputExplicitMinWidth:Number; /** * @private */ protected var textInputExplicitMinHeight:Number; /** * @private */ protected var touchPointID:int = -1; /** * @private */ protected var _textInputHasFocus:Boolean = false; /** * @private */ override protected function get defaultStyleProvider():IStyleProvider { return NumericStepper.globalStyleProvider; } /** * A text input's text editor may be an INativeFocusOwner, * so we need to return the value of its nativeFocus * property. * * @see feathers.core.INativeFocusOwner */ public function get nativeFocus():Object { if(this.textInput !== null) { return this.textInput.nativeFocus; } return null; } /** * @private */ protected var _value:Number = 0; /** * The value of the numeric stepper, between the minimum and maximum. * *

In the following example, the value is changed to 12:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #minimum * @see #maximum * @see #step * @see #event:change */ public function get value():Number { return this._value; } /** * @private */ public function set value(newValue:Number):void { if(this._step != 0 && newValue != this._maximum && newValue != this._minimum) { //roundToPrecision helps us to avoid numbers like 1.00000000000000001 //caused by the inaccuracies of floating point math. newValue = roundToPrecision(roundToNearest(newValue - this._minimum, this._step) + this._minimum, 10); } newValue = clamp(newValue, this._minimum, this._maximum); if(this._value == newValue) { return; } this._value = newValue; this.invalidate(INVALIDATION_FLAG_DATA); this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _minimum:Number = 0; /** * The numeric stepper's value will not go lower than the minimum. * *

In the following example, the minimum is changed to 0:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #maximum * @see #step */ public function get minimum():Number { return this._minimum; } /** * @private */ public function set minimum(value:Number):void { if(this._minimum == value) { return; } this._minimum = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _maximum:Number = 0; /** * The numeric stepper's value will not go higher than the maximum. * *

In the following example, the maximum is changed to 100:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #minimum * @see #step */ public function get maximum():Number { return this._maximum; } /** * @private */ public function set maximum(value:Number):void { if(this._maximum == value) { return; } this._maximum = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _step:Number = 0; /** * As the numeric stepper's buttons are pressed, the value is snapped to * a multiple of the step. * *

In the following example, the step is changed to 1:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #minimum * @see #maximum */ public function get step():Number { return this._step; } /** * @private */ public function set step(value:Number):void { if(this._step == value) { return; } this._step = value; } /** * @private */ protected var _useLeftAndRightKeys:Boolean = false; /** * Indicates if the Keyboard.LEFT and * Keyboard.RIGHT keys should be used to change the value * of the stepper, instead of the default Keyboard.DOWN and * Keyboard.UP keys. * *

In the following example, the left and right keys are preferred:

* * * stepper.useLeftAndRightKeys = true; * * @default false */ public function get useLeftAndRightKeys():Boolean { return this._useLeftAndRightKeys; } /** * @private */ public function set useLeftAndRightKeys(newValue:Boolean):void { this._useLeftAndRightKeys = newValue; } /** * @private */ protected var _valueFormatFunction:Function; /** * A callback that formats the numeric stepper's value as a string to * display to the user. * *

The function is expected to have the following signature:

*
function(value:Number):String
* *

In the following example, the stepper's value format function is * customized:

* * * stepper.valueFormatFunction = function(value:Number):String * { * return currencyFormatter.format(value, true); * }; * * @default null * * @see #valueParseFunction */ public function get valueFormatFunction():Function { return this._valueFormatFunction; } /** * @private */ public function set valueFormatFunction(value:Function):void { if(this._valueFormatFunction == value) { return; } this._valueFormatFunction = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _valueParseFunction:Function; /** * A callback that accepts the displayed text of the numeric stepper and * converts it to a simple numeric value. * *

The function is expected to have the following signature:

*
function(displayedText:String):Number
* *

In the following example, the stepper's value parse function is * customized:

* * * stepper.valueParseFunction = function(displayedText:String):String * { * return currencyFormatter.parse(displayedText).value; * }; * * @default null * * @see #valueFormatFunction */ public function get valueParseFunction():Function { return this._valueParseFunction; } /** * @private */ public function set valueParseFunction(value:Function):void { this._valueParseFunction = value; } /** * @private */ protected var currentRepeatAction:Function; /** * @private */ protected var _repeatTimer:Timer; /** * @private */ protected var _repeatDelay:Number = 0.05; /** * The time, in seconds, before actions are repeated. The first repeat * happens after a delay that is five times longer than the following * repeats. * *

In the following example, the stepper's repeat delay is set to * 500 milliseconds:

* * * stepper.repeatDelay = 0.5; * * @default 0.05 */ public function get repeatDelay():Number { return this._repeatDelay; } /** * @private */ public function set repeatDelay(value:Number):void { if(this._repeatDelay == value) { return; } this._repeatDelay = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _buttonLayoutMode:String = StepperButtonLayoutMode.SPLIT_HORIZONTAL; [Inspectable(type=""String"",enumeration=""splitHorizontal,splitVertical,rightSideVertical"")] /** * @private */ public function get buttonLayoutMode():String { return this._buttonLayoutMode; } /** * @private */ public function set buttonLayoutMode(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._buttonLayoutMode === value) { return; } this._buttonLayoutMode = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _buttonGap:Number = 0; /** * @private */ public function get buttonGap():Number { return this._buttonGap; } /** * @private */ public function set buttonGap(value:Number):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._buttonGap == value) { return; } this._buttonGap = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _textInputGap:Number = 0; /** * @private */ public function get textInputGap():Number { return this._textInputGap; } /** * @private */ public function set textInputGap(value:Number):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._textInputGap == value) { return; } this._textInputGap = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _decrementButtonFactory:Function; /** * A function used to generate the numeric stepper's decrement button * sub-component. The decrement button must be an instance of * Button. This factory can be used to change properties on * the decrement button when it is first created. For instance, if you * are skinning Feathers components without a theme, you might use this * factory to set skins and other styles on the decrement button. * *

The function should have the following signature:

*
function():Button
* *

In the following example, a custom decrement button factory is passed * to the stepper:

* * * stepper.decrementButtonFactory = function():Button * { * var button:Button = new Button(); * button.defaultSkin = new Image( upTexture ); * button.downSkin = new Image( downTexture ); * return button; * }; * * @default null * * @see feathers.controls.Button */ public function get decrementButtonFactory():Function { return this._decrementButtonFactory; } /** * @private */ public function set decrementButtonFactory(value:Function):void { if(this._decrementButtonFactory == value) { return; } this._decrementButtonFactory = value; this.invalidate(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); } /** * @private */ protected var _customDecrementButtonStyleName:String; /** * @private */ public function get customDecrementButtonStyleName():String { return this._customDecrementButtonStyleName; } /** * @private */ public function set customDecrementButtonStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customDecrementButtonStyleName === value) { return; } this._customDecrementButtonStyleName = value; this.invalidate(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); } /** * @private */ protected var _decrementButtonProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's decrement * button sub-component, and the properties will be passed down to the * decrement button when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.Button. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a decrementButtonFactory * function instead of using decrementButtonProperties will * result in better performance.

* *

In the following example, the stepper's decrement button properties * are updated:

* * * stepper.decrementButtonProperties.defaultSkin = new Image( upTexture ); * stepper.decrementButtonProperties.downSkin = new Image( downTexture ); * * @default null * * @see #decrementButtonFactory * @see feathers.controls.Button */ public function get decrementButtonProperties():Object { if(!this._decrementButtonProperties) { this._decrementButtonProperties = new PropertyProxy(childProperties_onChange); } return this._decrementButtonProperties; } /** * @private */ public function set decrementButtonProperties(value:Object):void { if(this._decrementButtonProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._decrementButtonProperties) { this._decrementButtonProperties.removeOnChangeCallback(childProperties_onChange); } this._decrementButtonProperties = PropertyProxy(value); if(this._decrementButtonProperties) { this._decrementButtonProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _decrementButtonLabel:String = null; /** * @private */ public function get decrementButtonLabel():String { return this._decrementButtonLabel; } /** * @private */ public function set decrementButtonLabel(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._decrementButtonLabel === value) { return; } this._decrementButtonLabel = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _incrementButtonFactory:Function; /** * A function used to generate the numeric stepper's increment button * sub-component. The increment button must be an instance of * Button. This factory can be used to change properties on * the increment button when it is first created. For instance, if you * are skinning Feathers components without a theme, you might use this * factory to set skins and other styles on the increment button. * *

The function should have the following signature:

*
function():Button
* *

In the following example, a custom increment button factory is passed * to the stepper:

* * * stepper.incrementButtonFactory = function():Button * { * var button:Button = new Button(); * button.defaultSkin = new Image( upTexture ); * button.downSkin = new Image( downTexture ); * return button; * }; * * @default null * * @see feathers.controls.Button */ public function get incrementButtonFactory():Function { return this._incrementButtonFactory; } /** * @private */ public function set incrementButtonFactory(value:Function):void { if(this._incrementButtonFactory == value) { return; } this._incrementButtonFactory = value; this.invalidate(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); } /** * @private */ protected var _customIncrementButtonStyleName:String; /** * @private */ public function get customIncrementButtonStyleName():String { return this._customIncrementButtonStyleName; } /** * @private */ public function set customIncrementButtonStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customIncrementButtonStyleName === value) { return; } this._customIncrementButtonStyleName = value; this.invalidate(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); } /** * @private */ protected var _incrementButtonProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's increment * button sub-component, and the properties will be passed down to the * increment button when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.Button. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a incrementButtonFactory * function instead of using incrementButtonProperties will * result in better performance.

* *

In the following example, the stepper's increment button properties * are updated:

* * * stepper.incrementButtonProperties.defaultSkin = new Image( upTexture ); * stepper.incrementButtonProperties.downSkin = new Image( downTexture ); * * @default null * * @see #incrementButtonFactory * @see feathers.controls.Button */ public function get incrementButtonProperties():Object { if(!this._incrementButtonProperties) { this._incrementButtonProperties = new PropertyProxy(childProperties_onChange); } return this._incrementButtonProperties; } /** * @private */ public function set incrementButtonProperties(value:Object):void { if(this._incrementButtonProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._incrementButtonProperties) { this._incrementButtonProperties.removeOnChangeCallback(childProperties_onChange); } this._incrementButtonProperties = PropertyProxy(value); if(this._incrementButtonProperties) { this._incrementButtonProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _incrementButtonLabel:String = null; /** * @private */ public function get incrementButtonLabel():String { return this._incrementButtonLabel; } /** * @private */ public function set incrementButtonLabel(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._incrementButtonLabel === value) { return; } this._incrementButtonLabel = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _textInputFactory:Function; /** * A function used to generate the numeric stepper's text input * sub-component. The text input must be an instance of TextInput. * This factory can be used to change properties on the text input when * it is first created. For instance, if you are skinning Feathers * components without a theme, you might use this factory to set skins * and other styles on the text input. * *

The function should have the following signature:

*
function():TextInput
* *

In the following example, a custom text input factory is passed * to the stepper:

* * * stepper.textInputFactory = function():TextInput * { * var textInput:TextInput = new TextInput(); * textInput.backgroundSkin = new Image( texture ); * return textInput; * }; * * @default null * * @see feathers.controls.TextInput */ public function get textInputFactory():Function { return this._textInputFactory; } /** * @private */ public function set textInputFactory(value:Function):void { if(this._textInputFactory == value) { return; } this._textInputFactory = value; this.invalidate(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); } /** * @private */ protected var _customTextInputStyleName:String; /** * @private */ public function get customTextInputStyleName():String { return this._customTextInputStyleName; } /** * @private */ public function set customTextInputStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customTextInputStyleName === value) { return; } this._customTextInputStyleName = value; this.invalidate(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); } /** * @private */ protected var _textInputProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's text * input sub-component, and the properties will be passed down to the * text input when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.TextInput. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a textInputFactory function * instead of using textInputProperties will result in * better performance.

* *

In the following example, the stepper's text input properties * are updated:

* * * stepper.textInputProperties.backgroundSkin = new Image( texture ); * * @default null * * @see #textInputFactory * @see feathers.controls.TextInput */ public function get textInputProperties():Object { if(!this._textInputProperties) { this._textInputProperties = new PropertyProxy(childProperties_onChange); } return this._textInputProperties; } /** * @private */ public function set textInputProperties(value:Object):void { if(this._textInputProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._textInputProperties) { this._textInputProperties.removeOnChangeCallback(childProperties_onChange); } this._textInputProperties = PropertyProxy(value); if(this._textInputProperties) { this._textInputProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @inheritDoc */ public function get baseline():Number { if(!this.textInput) { return this.scaledActualHeight; } return this.scaleY * (this.textInput.y + this.textInput.baseline); } /** * @private */ public function get hasFocus():Boolean { return this._hasFocus; } /** * @private */ public function setFocus():void { if(this.textInput === null) { return; } this.textInput.setFocus(); } /** * @private */ override protected function draw():void { var dataInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DATA); var stylesInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STYLES); var sizeInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SIZE); var stateInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STATE); var decrementButtonFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); var incrementButtonFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); var textInputFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); var focusInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_FOCUS); if(decrementButtonFactoryInvalid) { this.createDecrementButton(); } if(incrementButtonFactoryInvalid) { this.createIncrementButton(); } if(textInputFactoryInvalid) { this.createTextInput(); } if(decrementButtonFactoryInvalid || stylesInvalid) { this.refreshDecrementButtonStyles(); } if(incrementButtonFactoryInvalid || stylesInvalid) { this.refreshIncrementButtonStyles(); } if(textInputFactoryInvalid || stylesInvalid) { this.refreshTextInputStyles(); } if(textInputFactoryInvalid || dataInvalid) { this.refreshTypicalText(); this.refreshDisplayedText(); } if(decrementButtonFactoryInvalid || stateInvalid) { this.decrementButton.isEnabled = this._isEnabled; } if(incrementButtonFactoryInvalid || stateInvalid) { this.incrementButton.isEnabled = this._isEnabled; } if(textInputFactoryInvalid || stateInvalid) { this.textInput.isEnabled = this._isEnabled; } sizeInvalid = this.autoSizeIfNeeded() || sizeInvalid; this.layoutChildren(); if(sizeInvalid || focusInvalid) { this.refreshFocusIndicator(); } } /** * If the component's dimensions have not been set explicitly, it will * measure its content and determine an ideal size for itself. If the * explicitWidth or explicitHeight member * variables are set, those value will be used without additional * measurement. If one is set, but not the other, the dimension with the * explicit value will not be measured, but the other non-explicit * dimension will still need measurement. * *

Calls saveMeasurements() to set up the * actualWidth and actualHeight member * variables used for layout.

* *

Meant for internal use, and subclasses may override this function * with a custom implementation.

*/ protected function autoSizeIfNeeded():Boolean { var needsWidth:Boolean = this._explicitWidth !== this._explicitWidth; //isNaN var needsHeight:Boolean = this._explicitHeight !== this._explicitHeight; //isNaN var needsMinWidth:Boolean = this._explicitMinWidth !== this._explicitMinWidth; //isNaN var needsMinHeight:Boolean = this._explicitMinHeight !== this._explicitMinHeight; //isNaN if(!needsWidth && !needsHeight && !needsMinWidth && !needsMinHeight) { return false; } var newWidth:Number = this._explicitWidth; var newHeight:Number = this._explicitHeight; var newMinWidth:Number = this._explicitMinWidth; var newMinHeight:Number = this._explicitMinHeight; this.decrementButton.validate(); this.incrementButton.validate(); var decrementButtonWidth:Number = this.decrementButton.width; var decrementButtonHeight:Number = this.decrementButton.height; var decrementButtonMinWidth:Number = this.decrementButton.minWidth; var decrementButtonMinHeight:Number = this.decrementButton.minHeight; var incrementButtonWidth:Number = this.incrementButton.width; var incrementButtonHeight:Number = this.incrementButton.height; var incrementButtonMinWidth:Number = this.incrementButton.minWidth; var incrementButtonMinHeight:Number = this.incrementButton.minHeight; //we'll default to the values set in the textInputFactory var textInputWidth:Number = this.textInputExplicitWidth; var textInputHeight:Number = this.textInputExplicitHeight; var textInputMinWidth:Number = this.textInputExplicitMinWidth; var textInputMinHeight:Number = this.textInputExplicitMinHeight; var textInputMaxWidth:Number = Number.POSITIVE_INFINITY; var textInputMaxHeight:Number = Number.POSITIVE_INFINITY; if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { var maxButtonWidth:Number = decrementButtonWidth; if(incrementButtonWidth > maxButtonWidth) { maxButtonWidth = incrementButtonWidth; } var maxButtonMinWidth:Number = decrementButtonMinWidth; if(incrementButtonMinWidth > maxButtonMinWidth) { maxButtonMinWidth = incrementButtonMinWidth; } if(!needsWidth) { textInputWidth = this._explicitWidth - maxButtonWidth - this._textInputGap; } if(!needsHeight) { textInputHeight = this._explicitHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth - maxButtonMinWidth - this._textInputGap; if(this.textInputExplicitMinWidth > textInputMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxWidth = this._explicitMaxWidth - maxButtonWidth - this._textInputGap; } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { if(!needsWidth) { textInputWidth = this._explicitWidth; } if(!needsHeight) { textInputHeight = this._explicitHeight - decrementButtonHeight - incrementButtonHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth; if(this.textInputExplicitMinWidth > textInputMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight - decrementButtonMinHeight - incrementButtonMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxHeight = this._explicitMaxHeight - decrementButtonHeight - incrementButtonHeight; } else //split horizontal { if(!needsWidth) { textInputWidth = this._explicitWidth - decrementButtonWidth - incrementButtonWidth; } if(!needsHeight) { textInputHeight = this._explicitHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth - decrementButtonMinWidth - incrementButtonMinWidth; if(textInputMinWidth < this.textInputExplicitMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxWidth = this._explicitMaxWidth - decrementButtonWidth - incrementButtonWidth; } if(textInputWidth < 0) { textInputWidth = 0; } if(textInputHeight < 0) { textInputHeight = 0; } if(textInputMinWidth < 0) { textInputMinWidth = 0; } if(textInputMinHeight < 0) { textInputMinHeight = 0; } this.textInput.width = textInputWidth; this.textInput.height = textInputHeight; this.textInput.minWidth = textInputMinWidth; this.textInput.minHeight = textInputMinHeight; this.textInput.maxWidth = textInputMaxWidth; this.textInput.maxHeight = textInputMaxHeight; this.textInput.validate(); if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { if(needsWidth) { newWidth = this.textInput.width + maxButtonWidth + this._textInputGap; } if(needsHeight) { newHeight = decrementButtonHeight + this._buttonGap + incrementButtonHeight; if(this.textInput.height > newHeight) { newHeight = this.textInput.height; } } if(needsMinWidth) { newMinWidth = this.textInput.minWidth + maxButtonMinWidth + this._textInputGap; } if(needsMinHeight) { newMinHeight = decrementButtonMinHeight + this._buttonGap + incrementButtonMinHeight; if(this.textInput.minHeight > newMinHeight) { newMinHeight = this.textInput.minHeight; } } } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { if(needsWidth) { newWidth = this.textInput.width; if(decrementButtonWidth > newWidth) { newWidth = decrementButtonWidth; } if(incrementButtonWidth > newWidth) { newWidth = incrementButtonWidth; } } if(needsHeight) { newHeight = decrementButtonHeight + this.textInput.height + incrementButtonHeight + 2 * this._textInputGap; } if(needsMinWidth) { newMinWidth = this.textInput.minWidth; if(decrementButtonMinWidth > newMinWidth) { newMinWidth = decrementButtonMinWidth; } if(incrementButtonMinWidth > newMinWidth) { newMinWidth = incrementButtonMinWidth; } } if(needsMinHeight) { newMinHeight = decrementButtonMinHeight + this.textInput.minHeight + incrementButtonMinHeight + 2 * this._textInputGap; } } else //split horizontal { if(needsWidth) { newWidth = decrementButtonWidth + this.textInput.width + incrementButtonWidth + 2 * this._textInputGap; } if(needsHeight) { newHeight = this.textInput.height; if(decrementButtonHeight > newHeight) { newHeight = decrementButtonHeight; } if(incrementButtonHeight > newHeight) { newHeight = incrementButtonHeight; } } if(needsMinWidth) { newMinWidth = decrementButtonMinWidth + this.textInput.minWidth + incrementButtonMinWidth + 2 * this._textInputGap; } if(needsMinHeight) { newMinHeight = this.textInput.minHeight; if(decrementButtonMinHeight > newMinHeight) { newMinHeight = decrementButtonMinHeight; } if(incrementButtonMinHeight > newMinHeight) { newMinHeight = incrementButtonMinHeight; } } } return this.saveMeasurements(newWidth, newHeight, newMinWidth, newMinHeight); } /** * @private */ protected function decrement():void { this.value = this._value - this._step; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function increment():void { this.value = this._value + this._step; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function toMinimum():void { this.value = this._minimum; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function toMaximum():void { this.value = this._maximum; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * Creates and adds the decrementButton sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #decrementButton * @see #decrementButtonFactory * @see #style:customDecrementButtonStyleName */ protected function createDecrementButton():void { if(this.decrementButton) { this.decrementButton.removeFromParent(true); this.decrementButton = null; } var factory:Function = this._decrementButtonFactory != null ? this._decrementButtonFactory : defaultDecrementButtonFactory; var decrementButtonStyleName:String = this._customDecrementButtonStyleName != null ? this._customDecrementButtonStyleName : this.decrementButtonStyleName; this.decrementButton = Button(factory()); this.decrementButton.styleNameList.add(decrementButtonStyleName); this.decrementButton.addEventListener(TouchEvent.TOUCH, decrementButton_touchHandler); this.addChild(this.decrementButton); } /** * Creates and adds the incrementButton sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #incrementButton * @see #incrementButtonFactory * @see #style:customIncrementButtonStyleName */ protected function createIncrementButton():void { if(this.incrementButton) { this.incrementButton.removeFromParent(true); this.incrementButton = null; } var factory:Function = this._incrementButtonFactory != null ? this._incrementButtonFactory : defaultIncrementButtonFactory; var incrementButtonStyleName:String = this._customIncrementButtonStyleName != null ? this._customIncrementButtonStyleName : this.incrementButtonStyleName; this.incrementButton = Button(factory()); this.incrementButton.styleNameList.add(incrementButtonStyleName); this.incrementButton.addEventListener(TouchEvent.TOUCH, incrementButton_touchHandler); this.addChild(this.incrementButton); } /** * Creates and adds the textInput sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #textInput * @see #textInputFactory * @see #style:customTextInputStyleName */ protected function createTextInput():void { if(this.textInput) { this.textInput.removeFromParent(true); this.textInput = null; } var factory:Function = this._textInputFactory != null ? this._textInputFactory : defaultTextInputFactory; var textInputStyleName:String = this._customTextInputStyleName != null ? this._customTextInputStyleName : this.textInputStyleName; this.textInput = TextInput(factory()); this.textInput.styleNameList.add(textInputStyleName); this.textInput.addEventListener(FeathersEventType.ENTER, textInput_enterHandler); this.textInput.addEventListener(FeathersEventType.FOCUS_IN, textInput_focusInHandler); this.textInput.addEventListener(FeathersEventType.FOCUS_OUT, textInput_focusOutHandler); //while we're setting isFocusEnabled to false on the text input when //we have a focus manager, we'll still be able to call setFocus() on //the text input manually. this.textInput.isFocusEnabled = !this._focusManager; this.addChild(this.textInput); //we will use these values for measurement, if possible this.textInput.initializeNow(); this.textInputExplicitWidth = this.textInput.explicitWidth; this.textInputExplicitHeight = this.textInput.explicitHeight; this.textInputExplicitMinWidth = this.textInput.explicitMinWidth; this.textInputExplicitMinHeight = this.textInput.explicitMinHeight; } /** * @private */ protected function refreshDecrementButtonStyles():void { for(var propertyName:String in this._decrementButtonProperties) { var propertyValue:Object = this._decrementButtonProperties[propertyName]; this.decrementButton[propertyName] = propertyValue; } this.decrementButton.label = this._decrementButtonLabel; } /** * @private */ protected function refreshIncrementButtonStyles():void { for(var propertyName:String in this._incrementButtonProperties) { var propertyValue:Object = this._incrementButtonProperties[propertyName]; this.incrementButton[propertyName] = propertyValue; } this.incrementButton.label = this._incrementButtonLabel; } /** * @private */ protected function refreshTextInputStyles():void { for(var propertyName:String in this._textInputProperties) { var propertyValue:Object = this._textInputProperties[propertyName]; this.textInput[propertyName] = propertyValue; } } /** * @private */ protected function refreshDisplayedText():void { if(this._valueFormatFunction != null) { this.textInput.text = this._valueFormatFunction(this._value); } else { this.textInput.text = this._value.toString(); } } /** * @private */ protected function refreshTypicalText():void { var typicalText:String = """"; var maxCharactersBeforeDecimal:Number = Math.max(int(this._minimum).toString().length, int(this._maximum).toString().length, int(this._step).toString().length); //roundToPrecision() helps us to avoid numbers like 1.00000000000000001 //caused by the inaccuracies of floating point math. var maxCharactersAfterDecimal:Number = Math.max(roundToPrecision(this._minimum - int(this._minimum), 10).toString().length, roundToPrecision(this._maximum - int(this._maximum), 10).toString().length, roundToPrecision(this._step - int(this._step), 10).toString().length) - 2; if(maxCharactersAfterDecimal < 0) { maxCharactersAfterDecimal = 0; } var characterCount:int = maxCharactersBeforeDecimal + maxCharactersAfterDecimal; for(var i:int = 0; i < characterCount; i++) { typicalText += ""0""; } if(maxCharactersAfterDecimal > 0) { typicalText += "".""; } this.textInput.typicalText = typicalText; } /** * @private */ protected function layoutChildren():void { if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { var buttonHeight:Number = (this.actualHeight - this._buttonGap) / 2; this.incrementButton.y = 0; this.incrementButton.height = buttonHeight; this.incrementButton.validate(); this.decrementButton.y = buttonHeight + this._buttonGap; this.decrementButton.height = buttonHeight; this.decrementButton.validate(); var buttonWidth:Number = Math.max(this.decrementButton.width, this.incrementButton.width); var buttonX:Number = this.actualWidth - buttonWidth; this.decrementButton.x = buttonX; this.incrementButton.x = buttonX; this.textInput.x = 0; this.textInput.y = 0; this.textInput.width = buttonX - this._textInputGap; this.textInput.height = this.actualHeight; } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { this.incrementButton.x = 0; this.incrementButton.y = 0; this.incrementButton.width = this.actualWidth; this.incrementButton.validate(); this.decrementButton.x = 0; this.decrementButton.width = this.actualWidth; this.decrementButton.validate(); this.decrementButton.y = this.actualHeight - this.decrementButton.height; this.textInput.x = 0; this.textInput.y = this.incrementButton.height + this._textInputGap; this.textInput.width = this.actualWidth; this.textInput.height = Math.max(0, this.actualHeight - this.decrementButton.height - this.incrementButton.height - 2 * this._textInputGap); } else //split horizontal { this.decrementButton.x = 0; this.decrementButton.y = 0; this.decrementButton.height = this.actualHeight; this.decrementButton.validate(); this.incrementButton.y = 0; this.incrementButton.height = this.actualHeight; this.incrementButton.validate(); this.incrementButton.x = this.actualWidth - this.incrementButton.width; this.textInput.x = this.decrementButton.width + this._textInputGap; this.textInput.width = this.actualWidth - this.decrementButton.width - this.incrementButton.width - 2 * this._textInputGap; this.textInput.height = this.actualHeight; } //final validation to avoid juggler next frame issues this.textInput.validate(); } /** * @private */ protected function startRepeatTimer(action:Function):void { if(this.touchPointID >= 0) { var exclusiveTouch:ExclusiveTouch = ExclusiveTouch.forStage(this.stage); var claim:DisplayObject = exclusiveTouch.getClaim(this.touchPointID) if(claim != this) { if(claim) { //already claimed by another display object return; } else { exclusiveTouch.claimTouch(this.touchPointID, this); } } } this.currentRepeatAction = action; if(this._repeatDelay > 0) { if(!this._repeatTimer) { this._repeatTimer = new Timer(this._repeatDelay * 1000); this._repeatTimer.addEventListener(TimerEvent.TIMER, repeatTimer_timerHandler); } else { this._repeatTimer.reset(); this._repeatTimer.delay = this._repeatDelay * 1000; } this._repeatTimer.start(); } } /** * @private */ protected function parseTextInputValue():void { if(this._valueParseFunction != null) { var newValue:Number = this._valueParseFunction(this.textInput.text); } else { newValue = parseFloat(this.textInput.text); } if(newValue === newValue) //!isNaN { this.value = newValue; } //we need to force invalidation just to be sure that the text input //is displaying the correct value. this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected function childProperties_onChange(proxy:PropertyProxy, name:Object):void { this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected function numericStepper_removedFromStageHandler(event:Event):void { this.touchPointID = -1; } /** * @private */ override protected function focusInHandler(event:Event):void { super.focusInHandler(event); this.textInput.setFocus(); this.textInput.selectRange(0, this.textInput.text.length); this.stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ override protected function focusOutHandler(event:Event):void { super.focusOutHandler(event); this.textInput.clearFocus(); this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ protected function textInput_enterHandler(event:Event):void { this.parseTextInputValue(); } /** * @private */ protected function textInput_focusInHandler(event:Event):void { this._textInputHasFocus = true; } /** * @private */ protected function textInput_focusOutHandler(event:Event):void { this._textInputHasFocus = false; this.parseTextInputValue(); } /** * @private */ protected function decrementButton_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this.decrementButton, TouchPhase.ENDED, this.touchPointID); if(!touch) { return; } this.touchPointID = -1; this._repeatTimer.stop(); this.dispatchEventWith(FeathersEventType.END_INTERACTION); } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this.decrementButton, TouchPhase.BEGAN); if(!touch) { return; } if(this._textInputHasFocus) { this.parseTextInputValue(); } this.touchPointID = touch.id; this.dispatchEventWith(FeathersEventType.BEGIN_INTERACTION); this.decrement(); this.startRepeatTimer(this.decrement); } } /** * @private */ protected function incrementButton_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this.incrementButton, TouchPhase.ENDED, this.touchPointID); if(!touch) { return; } this.touchPointID = -1; this._repeatTimer.stop(); this.dispatchEventWith(FeathersEventType.END_INTERACTION); } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this.incrementButton, TouchPhase.BEGAN); if(!touch) { return; } if(this._textInputHasFocus) { this.parseTextInputValue(); } this.touchPointID = touch.id; this.dispatchEventWith(FeathersEventType.BEGIN_INTERACTION); this.increment(); this.startRepeatTimer(this.increment); } } /** * @private */ protected function stage_keyDownHandler(event:KeyboardEvent):void { if(event.keyCode == Keyboard.HOME) { //prevent default so that text input selection doesn't change event.preventDefault(); this.toMinimum(); } else if(event.keyCode == Keyboard.END) { //prevent default so that text input selection doesn't change event.preventDefault(); this.toMaximum(); } else if(this._useLeftAndRightKeys) { if(event.keyCode == Keyboard.RIGHT) { //prevent default so that text input selection doesn't change event.preventDefault(); this.increment(); } else if(event.keyCode == Keyboard.LEFT) { //prevent default so that text input selection doesn't change event.preventDefault(); this.decrement(); } } else if(event.keyCode == Keyboard.UP) { //prevent default so that text input selection doesn't change event.preventDefault(); this.increment(); } else if(event.keyCode == Keyboard.DOWN) { //prevent default so that text input selection doesn't change event.preventDefault(); this.decrement(); } } /** * @private */ protected function repeatTimer_timerHandler(event:TimerEvent):void { if(this._repeatTimer.currentCount < 5) { return; } this.currentRepeatAction(); } } } ",16134,True,3077.007907169271,median "class ZCL_GTT_STS_BO_FU_READER definition public inheriting from ZCL_GTT_STS_BO_TOR_READER create public . public section. types: BEGIN OF ts_freight_unit, tor_id TYPE /scmtms/s_em_bo_tor_root-tor_id, shipping_type TYPE /scmtms/s_em_bo_tor_root-shipping_type, inc_class_code TYPE /scmtms/s_em_bo_tor_item-inc_class_code, inc_transf_loc_n TYPE /scmtms/s_em_bo_tor_item-inc_transf_loc_n, trmodcod TYPE /scmtms/s_em_bo_tor_root-trmodcod, total_distance_km TYPE /scmtms/total_distance_km, total_distance_km_uom TYPE meins, pln_grs_duration TYPE /scmtms/total_duration_net, total_duration_net TYPE /scmtms/total_duration_net, dgo_indicator TYPE /scmtms/s_em_bo_tor_root-dgo_indicator, pln_arr_loc_id TYPE /scmtms/s_em_bo_tor_stop-log_locid, pln_arr_loc_type TYPE /saptrx/loc_id_type, pln_arr_timest TYPE char16, pln_arr_timezone TYPE timezone, pln_dep_loc_id TYPE /scmtms/s_em_bo_tor_stop-log_locid, pln_dep_loc_type TYPE /saptrx/loc_id_type, pln_dep_timest TYPE char16, pln_dep_timezone TYPE timezone, tspid TYPE bu_id_number, carrier_ref_value TYPE tt_carrier_ref_value, carrier_ref_type TYPE tt_carrier_ref_type, shipper_ref_value TYPE tt_shipper_ref_value, shipper_ref_type TYPE tt_shipper_ref_type, stop_id TYPE tt_stop_id, ordinal_no TYPE tt_ordinal_no, loc_type TYPE tt_loc_type, loc_id TYPE tt_loc_id, item_id TYPE STANDARD TABLE OF /scmtms/item_id WITH EMPTY KEY, erp_dlv_id TYPE STANDARD TABLE OF /scmtms/erp_shpm_dlv_id WITH EMPTY KEY, erp_dlv_item_id TYPE STANDARD TABLE OF /scmtms/erp_shpm_dlv_item_id WITH EMPTY KEY, itm_qua_pcs_val TYPE STANDARD TABLE OF /scmtms/qua_pcs_val WITH EMPTY KEY, itm_qua_pcs_uni TYPE STANDARD TABLE OF /scmtms/qua_pcs_uni WITH EMPTY KEY, product_id TYPE STANDARD TABLE OF /scmtms/product_id WITH EMPTY KEY, product_txt TYPE STANDARD TABLE OF /scmtms/item_description WITH EMPTY KEY, dlv_item_inb_alt_id TYPE STANDARD TABLE OF char16 WITH EMPTY KEY, dlv_item_oub_alt_id TYPE STANDARD TABLE OF char16 WITH EMPTY KEY, capa_doc_line_no TYPE tt_capacity_doc_line_number, capa_doc_no TYPE tt_capacity_doc_number, capa_doc_first_stop TYPE tt_stop, capa_doc_last_stop TYPE tt_stop, END OF ts_freight_unit . constants CS_BASE_BTD_TCO_INB_DLV type /SCMTMS/BASE_BTD_TCO value '58' ##NO_TEXT. constants CS_BASE_BTD_TCO_OUTB_DLV type /SCMTMS/BASE_BTD_TCO value '73' ##NO_TEXT. constants CS_BASE_BTD_TCO_DELIVERY_ITEM type /SCMTMS/BASE_BTD_ITEM_TCO value '14' ##NO_TEXT. methods GET_DATA_FROM_MAINTAB importing !IR_MAINTAB type ref to DATA !IV_OLD_DATA type ABAP_BOOL default ABAP_FALSE changing !CS_FREIGHT_UNIT type TS_FREIGHT_UNIT raising CX_UDM_MESSAGE . methods CHECK_FO_TRACK_OBJ_CHANGES importing !IS_APP_OBJECT type TRXAS_APPOBJ_CTAB_WA returning value(RV_RESULT) type ZIF_GTT_STS_EF_TYPES=>TV_CONDITION raising CX_UDM_MESSAGE . methods GET_MAINTABREF importing !IS_APP_OBJECT type TRXAS_APPOBJ_CTAB_WA returning value(RR_MAINTABREF) type ref to DATA . methods GET_DATA_FROM_ITEM importing !IR_DATA type ref to DATA !IV_OLD_DATA type ABAP_BOOL default ABAP_FALSE changing !CS_FREIGHT_UNIT type TS_FREIGHT_UNIT raising CX_UDM_MESSAGE . methods GET_CAPACITY_DOC_LIST importing !IR_DATA type ref to DATA !IV_OLD_DATA type ABAP_BOOL default ABAP_FALSE changing !CT_CAPA_DOC_LINE_NO type TT_CAPACITY_DOC_LINE_NUMBER !CT_CAPA_DOC_NO type TT_CAPACITY_DOC_NUMBER !CT_CAPA_DOC_FIRST_STOP type TT_STOP !CT_CAPA_DOC_LAST_STOP type TT_STOP raising CX_UDM_MESSAGE . methods CHECK_FO_ROUTE_CHANGE importing !IS_APP_OBJECT type TRXAS_APPOBJ_CTAB_WA returning value(RV_RESULT) type ZIF_GTT_STS_EF_TYPES=>TV_CONDITION raising CX_UDM_MESSAGE . methods ZIF_GTT_STS_BO_READER~CHECK_RELEVANCE redefinition . methods ZIF_GTT_STS_BO_READER~GET_DATA redefinition . methods ZIF_GTT_STS_BO_READER~GET_TRACK_ID_DATA redefinition . PROTECTED SECTION. METHODS check_non_idoc_fields REDEFINITION . METHODS check_non_idoc_stop_fields REDEFINITION . METHODS get_stop_seq REDEFINITION . PRIVATE SECTION. ENDCLASS. CLASS ZCL_GTT_STS_BO_FU_READER IMPLEMENTATION. METHOD check_fo_route_change. FIELD-SYMBOLS TYPE /scmtms/s_em_bo_tor_root. DATA: lv_stage_num_difference TYPE i, lv_stage_num_difference_bi TYPE i. rv_result = zif_gtt_sts_ef_constants=>cs_condition-false. ASSIGN is_app_object-maintabref->* TO . IF sy-subrc <> 0. RETURN. ENDIF. DATA(lo_tor_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ). lo_tor_srv_mgr->retrieve_by_association( EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-root it_key = VALUE #( ( key = -node_id ) ) iv_association = /scmtms/if_tor_c=>sc_association-root-capa_tor IMPORTING et_target_key = DATA(lt_tor_capa_key) ). /scmtms/cl_tor_helper_stage=>get_stage( EXPORTING it_root_key = VALUE #( ( key = -node_id ) ) IMPORTING et_stage = DATA(lt_req_stage) ). /scmtms/cl_tor_helper_stage=>get_stage( EXPORTING it_root_key = lt_tor_capa_key IMPORTING et_stage = DATA(lt_capa_stage) ). /scmtms/cl_tor_helper_stage=>get_stage( EXPORTING it_root_key = lt_tor_capa_key iv_before_image = abap_true IMPORTING et_stage = DATA(lt_capa_stage_bi) ). DATA(lv_req_stage_count) = lines( lt_req_stage ). DATA(lv_stop_des_key) = lt_req_stage[ lv_req_stage_count ]-dest_stop-assgn_stop_key. DATA(lv_stop_src_key) = lt_req_stage[ 1 ]-source_stop-assgn_stop_key. DO 1 TIMES. ASSIGN lt_capa_stage[ KEY source_stop_key COMPONENTS source_stop_key = lv_stop_src_key ]-seq_num TO FIELD-SYMBOL(). CHECK sy-subrc = 0. ASSIGN lt_capa_stage[ dest_stop_key = lv_stop_des_key ]-seq_num TO FIELD-SYMBOL(). CHECK sy-subrc = 0. lv_stage_num_difference = - . ASSIGN lt_capa_stage_bi[ KEY source_stop_key COMPONENTS source_stop_key = lv_stop_src_key ]-seq_num TO FIELD-SYMBOL(). CHECK sy-subrc = 0. ASSIGN lt_capa_stage_bi[ dest_stop_key = lv_stop_des_key ]-seq_num TO FIELD-SYMBOL(). CHECK sy-subrc = 0. lv_stage_num_difference_bi = - . ENDDO. IF lv_stage_num_difference <> lv_stage_num_difference_bi. rv_result = zif_gtt_sts_ef_constants=>cs_condition-true. ENDIF. ENDMETHOD. METHOD check_fo_track_obj_changes. * * ""FU * DATA: * lr_item_new TYPE REF TO data, * lr_item_old TYPE REF TO data, * lt_track_id_data TYPE zif_gtt_sts_ef_types=>tt_track_id_data, * lt_track_id_data_new TYPE zif_gtt_sts_ef_types=>tt_enh_track_id_data, * lt_track_id_data_old TYPE zif_gtt_sts_ef_types=>tt_enh_track_id_data, * ls_capa_root_fo TYPE /scmtms/s_em_bo_tor_root. * * FIELD-SYMBOLS: * TYPE /scmtms/t_em_bo_tor_item, * TYPE /scmtms/t_em_bo_tor_item, * TYPE /scmtms/s_em_bo_tor_root, * TYPE /scmtms/s_em_bo_tor_root, * TYPE /scmtms/s_em_bo_tor_root, * TYPE /scmtms/t_em_bo_tor_root, * TYPE /scmtms/t_em_bo_tor_root. * * rv_result = zif_gtt_sts_ef_constants=>cs_condition-false. * * ASSIGN is_app_object-maintabref->* TO . * IF sy-subrc <> 0. * MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. * zcl_gtt_sts_tools=>throw_exception( ). * ENDIF. * * DATA(lr_root_capa_new) = mo_ef_parameters->get_appl_table( * iv_tabledef = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root ). * ASSIGN lr_root_capa_new->* TO . * IF sy-subrc <> 0. * MESSAGE e010(zgtt_sts) INTO lv_dummy. * zcl_gtt_sts_tools=>throw_exception( ). * ENDIF. * * DATA(lr_capa_root_old) = mo_ef_parameters->get_appl_table( * iv_tabledef = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root_before ). * ASSIGN lr_capa_root_old->* TO . * IF sy-subrc <> 0. * MESSAGE e010(zgtt_sts) INTO lv_dummy. * zcl_gtt_sts_tools=>throw_exception( ). * ENDIF. * * DATA(lo_tor_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ). * lo_tor_srv_mgr->retrieve_by_association( * EXPORTING * iv_node_key = /scmtms/if_tor_c=>sc_node-root * it_key = VALUE #( ( key = -node_id ) ) * iv_association = /scmtms/if_tor_c=>sc_association-root-capa_tor * IMPORTING * et_key_link = DATA(lt_req2capa_link) ). * * LOOP AT lt_req2capa_link ASSIGNING FIELD-SYMBOL(). * ASSIGN [ node_id = -target_key ] TO . * CHECK sy-subrc = 0. * * ASSIGN [ node_id = -target_key ] TO . * CHECK sy-subrc = 0. * * DATA(ls_app_object) = is_app_object. * ls_capa_root_fo = CORRESPONDING #( MAPPING node_id = node_id ). * GET REFERENCE OF ls_capa_root_fo INTO ls_app_object-maintabref. * * get_container_mobile_track_id( * EXPORTING * is_app_object = ls_app_object * CHANGING * ct_track_id_data = lt_track_id_data_new ). * * get_container_mobile_track_id( * EXPORTING * is_app_object = ls_app_object * iv_old_data = abap_true * CHANGING * ct_track_id_data = lt_track_id_data_old ). * * lr_item_new = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_sts_constants=>cs_tabledef-fo_item_new ). * lr_item_old = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_sts_constants=>cs_tabledef-fo_item_old ). * * DATA(lv_deleted) = zcl_gtt_sts_tools=>check_is_fo_deleted( * is_root_new = * is_root_old = ). * IF lv_deleted = zif_gtt_sts_ef_constants=>cs_condition-true. * CLEAR: lt_track_id_data_old, lr_item_old. * ENDIF. * * ASSIGN lr_item_new->* TO . * IF IS ASSIGNED. * zcl_gtt_sts_tools=>get_fo_tracked_item_obj( * EXPORTING * is_app_object = ls_app_object * is_root = * it_item = * iv_appsys = mo_ef_parameters->get_appsys( ) * iv_old_data = abap_false * CHANGING * ct_track_id_data = lt_track_id_data_new ). * ELSE. * MESSAGE e010(zgtt_sts) INTO lv_dummy. * zcl_gtt_sts_tools=>throw_exception( ). * ENDIF. * * ASSIGN lr_item_old->* TO . * IF sy-subrc = 0 AND lv_deleted = zif_gtt_sts_ef_constants=>cs_condition-false. * zcl_gtt_sts_tools=>get_fo_tracked_item_obj( * EXPORTING * is_app_object = ls_app_object * is_root = * it_item = * iv_appsys = mo_ef_parameters->get_appsys( ) * iv_old_data = abap_true * CHANGING * ct_track_id_data = lt_track_id_data_old ). * ENDIF. * * zcl_gtt_sts_tools=>get_track_obj_changes( * EXPORTING * is_app_object = ls_app_object * iv_appsys = mo_ef_parameters->get_appsys( ) * it_track_id_data_new = lt_track_id_data_new * it_track_id_data_old = lt_track_id_data_old * CHANGING * ct_track_id_data = lt_track_id_data ). * ENDLOOP. * * IF lt_track_id_data IS NOT INITIAL. * rv_result = zif_gtt_sts_ef_constants=>cs_condition-true. * RETURN. * ENDIF. ENDMETHOD. METHOD check_non_idoc_fields. rv_result = check_non_idoc_stop_fields( is_app_object = is_app_object ). IF rv_result = zif_gtt_sts_ef_constants=>cs_condition-true. RETURN. ENDIF. rv_result = check_fo_route_change( is_app_object = is_app_object ). ENDMETHOD. METHOD check_non_idoc_stop_fields. DATA lt_capa_stop_old TYPE /scmtms/t_tor_stop_k. FIELD-SYMBOLS: TYPE /scmtms/t_em_bo_tor_stop, TYPE /scmtms/t_em_bo_tor_stop, TYPE /scmtms/t_em_bo_tor_stop, TYPE /scmtms/s_em_bo_tor_root. rv_result = zif_gtt_sts_ef_constants=>cs_condition-false. DATA(lt_stop_new) = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_sts_constants=>cs_tabledef-fo_stop_new ). DATA(lt_stop_old) = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_sts_constants=>cs_tabledef-fo_stop_old ). DATA(lt_capa_stop_new) = mo_ef_parameters->get_appl_table( /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_stop ). ASSIGN lt_stop_new->* TO . ASSIGN lt_stop_old->* TO . ASSIGN lt_capa_stop_new->* TO . ASSIGN is_app_object-maintabref->* TO . IF IS NOT ASSIGNED OR IS NOT ASSIGNED OR IS NOT ASSIGNED OR IS NOT ASSIGNED. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. DATA(lo_tor_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ). DATA(lt_capa_stop_key) = VALUE /bobf/t_frw_key( FOR IN ( key = -assgn_stop_key ) ). TEST-SEAM lt_capa_stop_old. lo_tor_srv_mgr->retrieve( EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-stop it_key = lt_capa_stop_key iv_before_image = abap_true IMPORTING et_data = lt_capa_stop_old ). END-TEST-SEAM. LOOP AT ASSIGNING FIELD-SYMBOL() USING KEY parent_seqnum WHERE parent_node_id = -node_id. ASSIGN [ node_id = -node_id ] TO FIELD-SYMBOL(). CHECK sy-subrc = 0. IF -assgn_start <> -assgn_start OR -assgn_end <> -assgn_end. rv_result = zif_gtt_sts_ef_constants=>cs_condition-true. EXIT. ENDIF. ASSIGN [ node_id = -assgn_stop_key ] TO FIELD-SYMBOL(). CHECK sy-subrc = 0. ASSIGN lt_capa_stop_old[ key = -assgn_stop_key ] TO FIELD-SYMBOL(). CHECK sy-subrc = 0. IF -plan_trans_time <> -plan_trans_time. rv_result = zif_gtt_sts_ef_constants=>cs_condition-true. EXIT. ENDIF. ENDLOOP. ENDMETHOD. METHOD get_capacity_doc_list. DATA: lv_capa_doc_line_no TYPE int4, lv_tabledef_stop TYPE /saptrx/strucdataname, lv_tabledef_capa_root TYPE /saptrx/strucdataname, lv_tabledef_capa_stop TYPE /saptrx/strucdataname, lt_tor_capa_stop_before TYPE /scmtms/t_tor_stop_k, lt_tor_stop_before TYPE /scmtms/t_tor_stop_k, lt_capa_stop TYPE /scmtms/t_em_bo_tor_stop, lt_stop TYPE /scmtms/t_em_bo_tor_stop, ls_stop_key TYPE /bobf/s_frw_key, lt_fo_stop TYPE /scmtms/t_em_bo_tor_stop, lv_seq_num TYPE /scmtms/seq_num. FIELD-SYMBOLS: TYPE /scmtms/t_em_bo_tor_stop, TYPE /scmtms/s_em_bo_tor_root, TYPE /scmtms/t_em_bo_tor_root, TYPE /scmtms/t_em_bo_tor_stop. DATA(lo_tor_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ). ASSIGN ir_data->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. IF iv_old_data = abap_false. lv_tabledef_stop = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-stop. lv_tabledef_capa_root = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root. lv_tabledef_capa_stop = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_stop. ELSE. lv_tabledef_stop = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-stop_before. lv_tabledef_capa_root = /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root_before. ENDIF. * Get Stop information DATA(lr_stop) = mo_ef_parameters->get_appl_table( lv_tabledef_stop ). ASSIGN lr_stop->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO lv_dummy. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. * Get capacity root information DATA(lr_req_root) = mo_ef_parameters->get_appl_table( iv_tabledef = lv_tabledef_capa_root ). ASSIGN lr_req_root->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO lv_dummy. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. * Get capacity stop information IF iv_old_data = abap_false. DATA(lr_capa_stop) = mo_ef_parameters->get_appl_table( lv_tabledef_capa_stop ). ASSIGN lr_capa_stop->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO lv_dummy. zcl_gtt_sts_tools=>throw_exception( ). ELSE. lt_capa_stop = . ENDIF. ELSE. lo_tor_srv_mgr->retrieve_by_association( EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-root it_key = CORRESPONDING #( MAPPING key = node_id ) iv_association = /scmtms/if_tor_c=>sc_association-root-stop iv_before_image = abap_true iv_fill_data = abap_true IMPORTING et_data = lt_tor_capa_stop_before ). lt_capa_stop = CORRESPONDING #( lt_tor_capa_stop_before MAPPING node_id = key parent_node_id = parent_key ). ENDIF. TEST-SEAM lt_req2capa_link. lo_tor_srv_mgr->retrieve_by_association( EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-root it_key = VALUE #( ( key = -node_id ) ) iv_association = /scmtms/if_tor_c=>sc_association-root-capa_tor IMPORTING et_key_link = DATA(lt_req2capa_link) ). END-TEST-SEAM. LOOP AT lt_req2capa_link ASSIGNING FIELD-SYMBOL(). ASSIGN [ node_id = -target_key ] TO FIELD-SYMBOL(). CHECK sy-subrc = 0. lv_capa_doc_line_no += 1. APPEND lv_capa_doc_line_no TO ct_capa_doc_line_no. APPEND |{ -tor_id ALPHA = OUT }| TO ct_capa_doc_no. TEST-SEAM lt_stop_seq. /scmtms/cl_tor_helper_stop=>get_stop_sequence( EXPORTING it_root_key = VALUE #( ( key = -node_id ) ) iv_before_image = iv_old_data IMPORTING et_stop_seq_d = DATA(lt_stop_seq) ). END-TEST-SEAM. ASSIGN lt_stop_seq[ root_key = -node_id ] TO FIELD-SYMBOL() ##WARN_OK. IF sy-subrc = 0. MOVE-CORRESPONDING -stop_seq TO lt_fo_stop. LOOP AT lt_fo_stop ASSIGNING FIELD-SYMBOL(). -parent_node_id = -node_id. ASSIGN -stop_map[ tabix = -seq_num ]-stop_key TO FIELD-SYMBOL(). CHECK sy-subrc = 0. -node_id = . ENDLOOP. ENDIF. zcl_gtt_sts_tools=>get_stop_points( EXPORTING iv_root_id = -tor_id it_stop = lt_fo_stop IMPORTING et_stop_points = DATA(lt_stop_points) ). LOOP AT lt_fo_stop USING KEY parent_seqnum ASSIGNING . ASSIGN [ assgn_stop_key = -node_id parent_node_id = -node_id ] TO FIELD-SYMBOL(). IF sy-subrc = 0. IF lv_seq_num IS INITIAL. DATA(lv_capa_doc_first_stop) = lt_stop_points[ seq_num = -seq_num ]-stop_id. APPEND |{ lv_capa_doc_first_stop ALPHA = OUT }| TO ct_capa_doc_first_stop. ENDIF. lv_seq_num = -seq_num. ENDIF. ENDLOOP. IF lv_seq_num IS NOT INITIAL. DATA(lv_capa_doc_last_stop) = lt_stop_points[ seq_num = lv_seq_num ]-stop_id. APPEND |{ lv_capa_doc_last_stop ALPHA = OUT }| TO ct_capa_doc_last_stop. ENDIF. CLEAR: lv_seq_num, lt_stop_points. ENDLOOP. ENDMETHOD. METHOD get_data_from_item. DATA: lv_item_id TYPE char6, lv_product_id TYPE /scmtms/product_id, lv_base_btd_id_conv TYPE char10, lv_base_btditem_id_conv TYPE char6, lv_base_btd_alt_item_id TYPE char16. FIELD-SYMBOLS: TYPE /scmtms/t_em_bo_tor_item, TYPE /scmtms/s_em_bo_tor_root. ASSIGN ir_data->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. DATA(lr_item) = mo_ef_parameters->get_appl_table( SWITCH #( iv_old_data WHEN abap_true THEN zif_gtt_sts_constants=>cs_tabledef-fo_item_old ELSE zif_gtt_sts_constants=>cs_tabledef-fo_item_new ) ). ASSIGN lr_item->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO lv_dummy. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. "" POC DATA(lv_item_cat) = SWITCH /scmtms/item_category( -tor_cat WHEN 'FU' THEN /scmtms/if_tor_const=>sc_tor_item_category-fu_root WHEN 'TU' THEN /scmtms/if_tor_const=>sc_tor_item_category-tu_resource ). ASSIGN [ item_cat = lv_item_cat parent_node_id = -node_id ] TO FIELD-SYMBOL(). IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO lv_dummy. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. cs_freight_unit-inc_class_code = -inc_class_code. cs_freight_unit-inc_transf_loc_n = -inc_transf_loc_n. SORT BY item_id. LOOP AT ASSIGNING FIELD-SYMBOL() USING KEY parent_node_track_rel WHERE parent_node_id = -node_id AND item_cat = /scmtms/if_tor_const=>sc_tor_item_category-product. lv_item_id = -item_id+4(6). APPEND lv_item_id TO cs_freight_unit-item_id. IF -base_btd_tco = cs_base_btd_tco_inb_dlv OR -base_btd_tco = cs_base_btd_tco_outb_dlv. DATA(lv_base_btd_id) = -base_btd_id. SHIFT lv_base_btd_id LEFT DELETING LEADING '0'. APPEND lv_base_btd_id TO cs_freight_unit-erp_dlv_id. ELSE. APPEND '' TO cs_freight_unit-erp_dlv_id. ENDIF. IF -base_btditem_tco = cs_base_btd_tco_delivery_item. DATA(lv_base_btditem_id) = -base_btditem_id. SHIFT lv_base_btditem_id LEFT DELETING LEADING '0'. lv_base_btditem_id_conv = lv_base_btditem_id. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = lv_base_btditem_id_conv IMPORTING output = lv_base_btditem_id_conv. APPEND lv_base_btditem_id_conv TO cs_freight_unit-erp_dlv_item_id. ELSE. APPEND '' TO cs_freight_unit-erp_dlv_item_id. ENDIF. lv_base_btd_alt_item_id = lv_base_btd_id && lv_base_btditem_id_conv. IF -base_btd_tco = cs_base_btd_tco_inb_dlv AND -base_btditem_tco = cs_base_btd_tco_delivery_item. APPEND lv_base_btd_alt_item_id TO cs_freight_unit-dlv_item_inb_alt_id. ELSE. APPEND '' TO cs_freight_unit-dlv_item_inb_alt_id. ENDIF. IF -base_btd_tco = cs_base_btd_tco_outb_dlv AND -base_btditem_tco = cs_base_btd_tco_delivery_item. APPEND lv_base_btd_alt_item_id TO cs_freight_unit-dlv_item_oub_alt_id. ELSE. APPEND '' TO cs_freight_unit-dlv_item_oub_alt_id. ENDIF. APPEND -qua_pcs_val TO cs_freight_unit-itm_qua_pcs_val. APPEND -qua_pcs_uni TO cs_freight_unit-itm_qua_pcs_uni. APPEND -item_descr TO cs_freight_unit-product_txt. CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTING input = -product_id IMPORTING output = lv_product_id. APPEND lv_product_id TO cs_freight_unit-product_id. ENDLOOP. ENDMETHOD. METHOD get_data_from_maintab. FIELD-SYMBOLS: TYPE /scmtms/s_em_bo_tor_root, TYPE /scmtms/t_em_bo_tor_root. ASSIGN ir_maintab->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. IF iv_old_data = abap_true. DATA(lr_root_old) = mo_ef_parameters->get_appl_table( zif_gtt_sts_constants=>cs_tabledef-fo_header_old ). ASSIGN lr_root_old->* TO . IF sy-subrc = 0. ASSIGN [ tor_id = -tor_id ] TO . IF sy-subrc <> 0. "" Record was just created RETURN. ENDIF. ENDIF. DATA(lv_before_image) = abap_true. ENDIF. cs_freight_unit-tor_id = -tor_id. SHIFT cs_freight_unit-tor_id LEFT DELETING LEADING '0'. cs_freight_unit-dgo_indicator = -dgo_indicator. cs_freight_unit-tspid = get_carrier_name( iv_tspid = cs_freight_unit-tspid ). TEST-SEAM lt_tor_add_info. /scmtms/cl_tor_helper_root=>det_transient_root_fields( EXPORTING it_key = VALUE #( ( key = -node_id ) ) iv_get_stop_infos = abap_true iv_get_mainitem_info = abap_true iv_before_image = lv_before_image IMPORTING et_tor_add_info = DATA(lt_tor_add_info) ). END-TEST-SEAM. ASSIGN lt_tor_add_info[ 1 ] TO FIELD-SYMBOL(). IF sy-subrc = 0. cs_freight_unit-pln_grs_duration = -tot_duration. ENDIF. cs_freight_unit-total_duration_net = -total_duration_net. cs_freight_unit-total_distance_km = -total_distance_km. IF cs_freight_unit-total_distance_km IS NOT INITIAL. cs_freight_unit-total_distance_km_uom = zif_gtt_sts_constants=>cs_uom-km. ENDIF. cs_freight_unit-shipping_type = -shipping_type. cs_freight_unit-trmodcod = zcl_gtt_sts_tools=>get_trmodcod( iv_trmodcod = -trmodcod ). ENDMETHOD. METHOD get_maintabref. "" FU FIELD-SYMBOLS TYPE ANY TABLE. ASSIGN is_app_object-maintabref->* TO FIELD-SYMBOL(). IF IS ASSIGNED AND zcl_gtt_sts_tools=>is_table( iv_value = ) = abap_true. ASSIGN TO . LOOP AT ASSIGNING FIELD-SYMBOL(). ASSIGN COMPONENT /scmtms/if_tor_c=>sc_node_attribute-root-tor_cat OF STRUCTURE TO FIELD-SYMBOL(). IF sy-subrc = 0 AND = /scmtms/if_tor_const=>sc_tor_category-freight_unit. GET REFERENCE OF INTO rr_maintabref. EXIT. ENDIF. ENDLOOP. ELSEIF IS ASSIGNED. GET REFERENCE OF INTO rr_maintabref. ENDIF. ENDMETHOD. METHOD get_stop_seq. DATA: lv_stop_id_num(4) TYPE n, lv_stop_num(4) TYPE n, lv_stop_id TYPE string, lt_stop_id TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line, lt_tor_capa_stop_before TYPE /scmtms/t_tor_stop_k, lt_capa_stop TYPE /scmtms/t_em_bo_tor_stop, lv_loctype TYPE /saptrx/loc_id_type. FIELD-SYMBOLS: TYPE /scmtms/s_em_bo_tor_root, TYPE /scmtms/t_em_bo_tor_root, TYPE /scmtms/t_em_bo_tor_stop. ASSIGN ir_data->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. DATA(lv_tor_id) = -tor_id. SHIFT lv_tor_id LEFT DELETING LEADING '0'. ASSIGN it_stop_seq[ root_key = -node_id ]-stop_seq TO FIELD-SYMBOL() ##WARN_OK. IF sy-subrc <> 0. RETURN. ENDIF. "" Get Capacity Root DATA(lr_capa_root) = mo_ef_parameters->get_appl_table( SWITCH #( iv_old_data WHEN abap_false THEN /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root ELSE /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root_before ) ). ASSIGN lr_capa_root->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO lv_dummy. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. "" Get Capacity Stop IF iv_old_data = abap_true. DATA(lo_tor_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ). lo_tor_srv_mgr->retrieve_by_association( EXPORTING iv_node_key = /scmtms/if_tor_c=>sc_node-root it_key = CORRESPONDING #( MAPPING key = node_id ) iv_association = /scmtms/if_tor_c=>sc_association-root-stop iv_before_image = abap_true iv_fill_data = abap_true IMPORTING et_data = lt_tor_capa_stop_before ). lt_capa_stop = CORRESPONDING #( lt_tor_capa_stop_before MAPPING node_id = key parent_node_id = parent_key ). ELSE. DATA(lr_capa_stop) = mo_ef_parameters->get_appl_table( /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_stop ). ASSIGN lr_capa_stop->* TO . IF sy-subrc = 0. lt_capa_stop = . ENDIF. ENDIF. LOOP AT ASSIGNING FIELD-SYMBOL(). IF -seq_num = 1 OR zcl_gtt_sts_tools=>is_odd( -seq_num ) = abap_false. lv_stop_id_num += 1. ENDIF. IF -assgn_stop_key IS NOT INITIAL. lv_stop_id = zcl_gtt_sts_tools=>get_capa_match_key( iv_assgn_stop_key = -assgn_stop_key it_capa_stop = lt_capa_stop it_capa_root = iv_before_image = iv_old_data ). ELSE. lv_stop_id = |{ lv_tor_id }{ lv_stop_id_num }|. ENDIF. CHECK NOT line_exists( lt_stop_id[ table_line = lv_stop_id ] ). lv_stop_num += 1. lv_loctype = zcl_gtt_sts_tools=>get_location_type( iv_locno = -log_locid ). APPEND lv_stop_id TO ct_stop_id. APPEND lv_stop_num TO ct_ordinal_no. APPEND lv_loctype TO ct_loc_type. APPEND -log_locid TO ct_loc_id. INSERT lv_stop_id INTO TABLE lt_stop_id. CLEAR lv_loctype. ENDLOOP. ENDMETHOD. METHOD zif_gtt_sts_bo_reader~check_relevance. "" FU relevance function FIELD-SYMBOLS TYPE /scmtms/s_em_bo_tor_root. rv_result = zif_gtt_sts_ef_constants=>cs_condition-false. ASSIGN is_app_object-maintabref->* TO . IF sy-subrc <> 0. RETURN. ENDIF. IF get_customizing_aot( -tor_type ) <> is_app_object-appobjtype. RETURN. ENDIF. IF is_app_object-maintabdef = zif_gtt_sts_constants=>cs_tabledef-fo_header_new AND ( -track_exec_rel = zif_gtt_sts_constants=>cs_track_exec_rel-execution OR -track_exec_rel = zif_gtt_sts_constants=>cs_track_exec_rel-exec_with_extern_event_mngr ). CASE is_app_object-update_indicator. WHEN zif_gtt_sts_ef_constants=>cs_change_mode-insert. rv_result = zif_gtt_sts_ef_constants=>cs_condition-true. WHEN zif_gtt_sts_ef_constants=>cs_change_mode-update OR zif_gtt_sts_ef_constants=>cs_change_mode-undefined. rv_result = zcl_gtt_sts_tools=>are_structures_different( ir_data1 = zif_gtt_sts_bo_reader~get_data( is_app_object = is_app_object ) ir_data2 = zif_gtt_sts_bo_reader~get_data( is_app_object = is_app_object iv_old_data = abap_true ) ). IF rv_result = zif_gtt_sts_ef_constants=>cs_condition-false. rv_result = check_non_idoc_fields( is_app_object ). ENDIF. ENDCASE. ENDIF. ENDMETHOD. METHOD zif_gtt_sts_bo_reader~get_data. FIELD-SYMBOLS TYPE ts_freight_unit. rr_data = NEW ts_freight_unit( ). ASSIGN rr_data->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. DATA(lr_maintabref) = get_maintabref( is_app_object ). get_data_from_maintab( EXPORTING iv_old_data = iv_old_data ir_maintab = lr_maintabref CHANGING cs_freight_unit = ). IF IS INITIAL. RETURN. ENDIF. get_data_from_item( EXPORTING iv_old_data = iv_old_data ir_data = lr_maintabref CHANGING cs_freight_unit = ). IF -item_id IS INITIAL. APPEND '' TO -item_id. ENDIF. get_docref_data( EXPORTING iv_old_data = iv_old_data ir_root = lr_maintabref CHANGING ct_carrier_ref_value = -carrier_ref_value ct_carrier_ref_type = -carrier_ref_type ct_shipper_ref_value = -shipper_ref_value ct_shipper_ref_type = -shipper_ref_type ). IF -carrier_ref_value IS INITIAL. APPEND '' TO -carrier_ref_value. ENDIF. IF -shipper_ref_value IS INITIAL. APPEND '' TO -shipper_ref_value. ENDIF. get_data_from_stop( EXPORTING ir_data = lr_maintabref iv_old_data = iv_old_data CHANGING cv_pln_dep_loc_id = -pln_dep_loc_id cv_pln_dep_loc_type = -pln_dep_loc_type cv_pln_dep_timest = -pln_dep_timest cv_pln_dep_timezone = -pln_dep_timezone cv_pln_arr_loc_id = -pln_arr_loc_id cv_pln_arr_loc_type = -pln_arr_loc_type cv_pln_arr_timest = -pln_arr_timest cv_pln_arr_timezone = -pln_arr_timezone ct_stop_id = -stop_id ct_ordinal_no = -ordinal_no ct_loc_type = -loc_type ct_loc_id = -loc_id ). get_capacity_doc_list( EXPORTING ir_data = lr_maintabref iv_old_data = iv_old_data CHANGING ct_capa_doc_line_no = -capa_doc_line_no ct_capa_doc_no = -capa_doc_no ct_capa_doc_first_stop = -capa_doc_first_stop ct_capa_doc_last_stop = -capa_doc_last_stop ). IF -capa_doc_no IS INITIAL. APPEND '' TO -capa_doc_line_no. ENDIF. ENDMETHOD. METHOD zif_gtt_sts_bo_reader~get_track_id_data. DATA: lt_track_id_data_new TYPE zif_gtt_sts_ef_types=>tt_enh_track_id_data, lt_track_id_data_old TYPE zif_gtt_sts_ef_types=>tt_enh_track_id_data, lv_trxid TYPE /saptrx/trxid, lv_tmp_fotrxcod TYPE /saptrx/trxcod, lv_tmp_futrxcod TYPE /saptrx/trxcod, lv_fotrxcod TYPE /saptrx/trxcod, lv_futrxcod TYPE /saptrx/trxcod. FIELD-SYMBOLS: TYPE /scmtms/t_em_bo_tor_root, TYPE /scmtms/t_em_bo_tor_root, TYPE /scmtms/s_em_bo_tor_root. CLEAR: et_track_id_data. ASSIGN is_app_object-maintabref->* TO . IF sy-subrc <> 0. MESSAGE e010(zgtt_sts) INTO DATA(lv_dummy) ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. lv_futrxcod = zif_gtt_sts_constants=>cs_trxcod-fu_number. lv_fotrxcod = zif_gtt_sts_constants=>cs_trxcod-fo_number. TRY. CALL FUNCTION 'ZGTT_SOF_GET_TRACKID' EXPORTING iv_type = is_app_object-appobjtype iv_app = 'STS' IMPORTING ev_shptrxcod = lv_tmp_fotrxcod ev_futrxcod = lv_tmp_futrxcod. IF lv_tmp_fotrxcod IS NOT INITIAL. lv_fotrxcod = lv_tmp_fotrxcod. ENDIF. IF lv_tmp_futrxcod IS NOT INITIAL. lv_futrxcod = lv_tmp_futrxcod. ENDIF. CATCH cx_sy_dyn_call_illegal_func. ENDTRY. lv_trxid = |{ -tor_id ALPHA = OUT }|. add_track_id_data( EXPORTING is_app_object = is_app_object iv_trxcod = lv_futrxcod iv_trxid = lv_trxid CHANGING ct_track_id = et_track_id_data ). DATA(lr_tor_capa_root_new) = mo_ef_parameters->get_appl_table( /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root ). ASSIGN lr_tor_capa_root_new->* TO . IF IS NOT ASSIGNED. MESSAGE e010(zgtt_sts) INTO lv_dummy ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. LOOP AT ASSIGNING FIELD-SYMBOL(). IF -tor_root_node IS ASSIGNED AND ( -tor_cat = /scmtms/if_tor_const=>sc_tor_category-active OR -tor_cat = /scmtms/if_tor_const=>sc_tor_category-booking ) AND -tor_root_node = -node_id. DATA(lv_tor_id) = |{ -tor_id ALPHA = OUT }|. CONDENSE lv_tor_id. APPEND VALUE #( key = |{ -tor_id ALPHA = OUT }| appsys = mo_ef_parameters->get_appsys( ) appobjtype = is_app_object-appobjtype appobjid = |{ is_app_object-appobjid ALPHA = OUT }| trxcod = lv_fotrxcod trxid = |{ lv_tor_id }| ) TO lt_track_id_data_new. ENDIF. ENDLOOP. DATA(lr_tor_capa_root_old) = mo_ef_parameters->get_appl_table( /scmtms/cl_scem_int_c=>sc_table_definition-bo_tor-capa_root_before ). ASSIGN lr_tor_capa_root_old->* TO . IF IS NOT ASSIGNED. MESSAGE e010(zgtt_sts) INTO lv_dummy ##needed. zcl_gtt_sts_tools=>throw_exception( ). ENDIF. LOOP AT ASSIGNING FIELD-SYMBOL(). IF -tor_root_node IS ASSIGNED AND ( -tor_cat = /scmtms/if_tor_const=>sc_tor_category-active OR -tor_cat = /scmtms/if_tor_const=>sc_tor_category-booking ) AND -tor_root_node = -node_id. lv_tor_id = |{ -tor_id ALPHA = OUT }|. CONDENSE lv_tor_id. APPEND VALUE #( key = |{ -tor_id ALPHA = OUT }| appsys = mo_ef_parameters->get_appsys( ) appobjtype = is_app_object-appobjtype appobjid = |{ is_app_object-appobjid ALPHA = OUT }| trxcod = lv_fotrxcod trxid = |{ lv_tor_id }| ) TO lt_track_id_data_old. ENDIF. ENDLOOP. zcl_gtt_sts_tools=>get_track_obj_changes( EXPORTING is_app_object = is_app_object iv_appsys = mo_ef_parameters->get_appsys( ) it_track_id_data_new = lt_track_id_data_new it_track_id_data_old = lt_track_id_data_old CHANGING ct_track_id_data = et_track_id_data ). ENDMETHOD. ENDCLASS. ",12274,True,2806.4265011776884,median "CLASS zcl_abapgit_oo_class DEFINITION PUBLIC INHERITING FROM zcl_abapgit_oo_base CREATE PUBLIC . PUBLIC SECTION. METHODS zif_abapgit_oo_object_fnc~create REDEFINITION . METHODS zif_abapgit_oo_object_fnc~create_sotr REDEFINITION . METHODS zif_abapgit_oo_object_fnc~delete REDEFINITION . METHODS zif_abapgit_oo_object_fnc~generate_locals REDEFINITION . METHODS zif_abapgit_oo_object_fnc~get_class_properties REDEFINITION . METHODS zif_abapgit_oo_object_fnc~get_includes REDEFINITION . METHODS zif_abapgit_oo_object_fnc~insert_text_pool REDEFINITION . METHODS zif_abapgit_oo_object_fnc~read_sotr REDEFINITION . METHODS zif_abapgit_oo_object_fnc~read_text_pool REDEFINITION . METHODS zif_abapgit_oo_object_fnc~deserialize_source REDEFINITION . PROTECTED SECTION. PRIVATE SECTION. CLASS-METHODS update_source_index IMPORTING !iv_clsname TYPE csequence !io_scanner TYPE REF TO cl_oo_source_scanner_class . CLASS-METHODS update_report IMPORTING !iv_program TYPE programm !it_source TYPE string_table RETURNING VALUE(rv_updated) TYPE abap_bool RAISING zcx_abapgit_exception . CLASS-METHODS generate_classpool IMPORTING !iv_name TYPE seoclsname RAISING zcx_abapgit_exception . CLASS-METHODS update_meta IMPORTING !iv_name TYPE seoclsname !iv_exposure TYPE seoexpose !it_source TYPE rswsourcet RAISING zcx_abapgit_exception . CLASS-METHODS determine_method_include IMPORTING !iv_name TYPE seoclsname !iv_method TYPE seocpdname RETURNING VALUE(rv_program) TYPE programm RAISING zcx_abapgit_exception . CLASS-METHODS init_scanner IMPORTING !it_source TYPE zif_abapgit_definitions=>ty_string_tt !iv_name TYPE seoclsname RETURNING VALUE(ro_scanner) TYPE REF TO cl_oo_source_scanner_class RAISING zcx_abapgit_exception . CLASS-METHODS update_full_class_include IMPORTING !iv_classname TYPE seoclsname !it_source TYPE string_table !it_methods TYPE cl_oo_source_scanner_class=>type_method_implementations . CLASS-METHODS create_report IMPORTING !iv_program TYPE programm !it_source TYPE string_table !iv_extension TYPE sychar02 !iv_program_type TYPE sychar01 !iv_version TYPE r3state . CLASS-METHODS update_cs_number_of_methods IMPORTING !iv_classname TYPE seoclsname !iv_number_of_impl_methods TYPE i . ENDCLASS. CLASS ZCL_ABAPGIT_OO_CLASS IMPLEMENTATION. METHOD create_report. INSERT REPORT iv_program FROM it_source EXTENSION TYPE iv_extension STATE iv_version PROGRAM TYPE iv_program_type. ASSERT sy-subrc = 0. ENDMETHOD. METHOD determine_method_include. DATA: ls_mtdkey TYPE seocpdkey. ls_mtdkey-clsname = iv_name. ls_mtdkey-cpdname = iv_method. cl_oo_classname_service=>get_method_include( EXPORTING mtdkey = ls_mtdkey RECEIVING result = rv_program EXCEPTIONS method_not_existing = 1 ). IF sy-subrc = 0. RETURN. ENDIF. CALL FUNCTION 'SEO_METHOD_GENERATE_INCLUDE' EXPORTING suppress_mtdkey_check = seox_true mtdkey = ls_mtdkey EXCEPTIONS not_existing = 1 model_only = 2 include_existing = 3 method_imp_not_generated = 4 method_imp_not_initialised = 5 _internal_class_not_existing = 6 _internal_method_overflow = 7 cancelled = 8 method_is_abstract_implemented = 9 method_is_final_implemented = 10 internal_error_insert_report = 11 OTHERS = 12. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from SEO_METHOD_GENERATE_INCLUDE' ). ENDIF. rv_program = cl_oo_classname_service=>get_method_include( ls_mtdkey ). ENDMETHOD. METHOD generate_classpool. DATA: ls_clskey TYPE seoclskey. ls_clskey-clsname = iv_name. CALL FUNCTION 'SEO_CLASS_GENERATE_CLASSPOOL' EXPORTING clskey = ls_clskey suppress_corr = seox_true EXCEPTIONS not_existing = 1 model_only = 2 class_pool_not_generated = 3 class_stment_not_generated = 4 locals_not_generated = 5 macros_not_generated = 6 public_sec_not_generated = 7 protected_sec_not_generated = 8 private_sec_not_generated = 9 typeref_not_generated = 10 class_pool_not_initialised = 11 class_stment_not_initialised = 12 locals_not_initialised = 13 macros_not_initialised = 14 public_sec_not_initialised = 15 protected_sec_not_initialised = 16 private_sec_not_initialised = 17 typeref_not_initialised = 18 _internal_class_overflow = 19 OTHERS = 20. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from SEO_CLASS_GENERATE_CLASSPOOL' ). ENDIF. ENDMETHOD. METHOD init_scanner. TRY. ro_scanner = cl_oo_source_scanner_class=>create_class_scanner( clif_name = iv_name source = it_source ). ro_scanner->scan( ). CATCH cx_clif_scan_error. zcx_abapgit_exception=>raise( 'error initializing CLAS scanner' ). ENDTRY. ENDMETHOD. METHOD update_cs_number_of_methods. "" Indirect access to keep downward compatibility DATA lr_cache_entry TYPE REF TO data. FIELD-SYMBOLS: TYPE any, TYPE any. TRY. CREATE DATA lr_cache_entry TYPE ('SEO_CS_CACHE'). CATCH cx_sy_create_data_error. * does not exist in some older systems RETURN. ENDTRY. ASSIGN lr_cache_entry->* TO . ASSERT sy-subrc = 0. ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE TO . ASSERT sy-subrc = 0. = iv_classname. ASSIGN COMPONENT 'NO_OF_METHOD_IMPLS' OF STRUCTURE TO . ASSERT sy-subrc = 0. = iv_number_of_impl_methods. MODIFY ('SEO_CS_CACHE') FROM . ENDMETHOD. METHOD update_full_class_include. CONSTANTS: lc_class_source_extension TYPE sychar02 VALUE 'CS', lc_include_program_type TYPE sychar01 VALUE 'I', lc_active_version TYPE r3state VALUE 'A'. create_report( iv_program = cl_oo_classname_service=>get_cs_name( iv_classname ) it_source = it_source iv_extension = lc_class_source_extension iv_program_type = lc_include_program_type iv_version = lc_active_version ). "" Assuming that all methods that were scanned are implemented update_cs_number_of_methods( iv_classname = iv_classname iv_number_of_impl_methods = lines( it_methods ) ). ENDMETHOD. METHOD update_meta. DATA: lo_update TYPE REF TO cl_oo_class_section_source, ls_clskey TYPE seoclskey, lv_scan_error TYPE seox_boolean. ls_clskey-clsname = iv_name. TRY. CREATE OBJECT lo_update TYPE ('CL_OO_CLASS_SECTION_SOURCE') EXPORTING clskey = ls_clskey exposure = iv_exposure state = 'A' source = it_source suppress_constrctr_generation = seox_true EXCEPTIONS class_not_existing = 1 read_source_error = 2 OTHERS = 3. CATCH cx_sy_dyn_call_param_not_found. * downport to 702, see https://github.com/larshp/abapGit/issues/933 * this will READ REPORT instead of using it_source, which should be okay CREATE OBJECT lo_update TYPE cl_oo_class_section_source EXPORTING clskey = ls_clskey exposure = iv_exposure state = 'A' EXCEPTIONS class_not_existing = 1 read_source_error = 2 OTHERS = 3. ENDTRY. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error instantiating CL_OO_CLASS_SECTION_SOURCE' ). ENDIF. lo_update->set_dark_mode( seox_true ). TRY. CALL METHOD lo_update->('SET_AMDP_SUPPORT') EXPORTING enabled = abap_true. CATCH cx_sy_dyn_call_illegal_method. * AMDP not supported in this system, ignore error ENDTRY. lo_update->scan_section_source( RECEIVING scan_error = lv_scan_error EXCEPTIONS scan_abap_source_error = 1 OTHERS = 2 ). IF sy-subrc <> 0 OR lv_scan_error = abap_true. zcx_abapgit_exception=>raise( 'CLAS, error while scanning source' ). ENDIF. * this will update the SEO* database tables lo_update->revert_scan_result( ). IF iv_exposure = seoc_exposure_public. generate_classpool( iv_name ). ENDIF. ENDMETHOD. METHOD update_report. DATA: lt_old TYPE string_table. READ REPORT iv_program INTO lt_old. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Fatal error. Include { iv_program } should have been created previously!| ). ENDIF. IF lt_old <> it_source. INSERT REPORT iv_program FROM it_source. ASSERT sy-subrc = 0. rv_updated = abap_true. ELSE. rv_updated = abap_false. ENDIF. ENDMETHOD. METHOD update_source_index. CONSTANTS: lc_version_active TYPE r3state VALUE 'A', ""#EC NOTEXT lc_version_inactive TYPE r3state VALUE 'I'. ""#EC NOTEXT "" dynamic invocation, IF_OO_SOURCE_POS_INDEX_HELPER doesn't exist in 702. DATA lo_index_helper TYPE REF TO object. TRY. CREATE OBJECT lo_index_helper TYPE ('CL_OO_SOURCE_POS_INDEX_HELPER'). CALL METHOD lo_index_helper->('IF_OO_SOURCE_POS_INDEX_HELPER~CREATE_INDEX_WITH_SCANNER') EXPORTING class_name = iv_clsname version = lc_version_active scanner = io_scanner. CALL METHOD lo_index_helper->('IF_OO_SOURCE_POS_INDEX_HELPER~DELETE_INDEX') EXPORTING class_name = iv_clsname version = lc_version_inactive. CATCH cx_root. "" it's probably okay to no update the index RETURN. ENDTRY. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~create. DATA: lt_vseoattrib TYPE seoo_attributes_r. FIELD-SYMBOLS: TYPE seoclsname. * same as in super class, but with ""version = seoc_version_active"" ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO . ASSERT sy-subrc = 0. lt_vseoattrib = convert_attrib_to_vseoattrib( iv_clsname = it_attributes = it_attributes ). CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE' EXPORTING devclass = iv_package overwrite = iv_overwrite version = seoc_version_active CHANGING class = cg_properties attributes = lt_vseoattrib EXCEPTIONS existing = 1 is_interface = 2 db_error = 3 component_error = 4 no_access = 5 other = 6 OTHERS = 7. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from SEO_CLASS_CREATE_COMPLETE' ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~create_sotr. DATA: lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt, lt_objects TYPE sotr_objects, ls_paket TYPE sotr_pack, lv_object LIKE LINE OF lt_objects. FIELD-SYMBOLS: LIKE LINE OF lt_sotr. LOOP AT it_sotr ASSIGNING . CALL FUNCTION 'SOTR_OBJECT_GET_OBJECTS' EXPORTING object_vector = -header-objid_vec IMPORTING objects = lt_objects EXCEPTIONS object_not_found = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from SOTR_OBJECT_GET_OBJECTS' ). ENDIF. READ TABLE lt_objects INDEX 1 INTO lv_object. ASSERT sy-subrc = 0. ls_paket-paket = iv_package. CALL FUNCTION 'SOTR_CREATE_CONCEPT' EXPORTING paket = ls_paket crea_lan = -header-crea_lan alias_name = -header-alias_name object = lv_object entries = -entries concept_default = -header-concept EXCEPTIONS package_missing = 1 crea_lan_missing = 2 object_missing = 3 paket_does_not_exist = 4 alias_already_exist = 5 object_type_not_found = 6 langu_missing = 7 identical_context_not_allowed = 8 text_too_long = 9 error_in_update = 10 no_master_langu = 11 error_in_concept_id = 12 alias_not_allowed = 13 tadir_entry_creation_failed = 14 internal_error = 15 error_in_correction = 16 user_cancelled = 17 no_entry_found = 18 OTHERS = 19. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from SOTR_CREATE_CONCEPT' ). ENDIF. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~delete. CALL FUNCTION 'SEO_CLASS_DELETE_COMPLETE' EXPORTING clskey = is_deletion_key EXCEPTIONS not_existing = 1 is_interface = 2 db_error = 3 no_access = 4 other = 5 OTHERS = 6. IF sy-subrc = 1. * ignore deletion of objects that does not exist * this can happen when the SXCI object is deleted before the implementing CLAS RETURN. ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Error from SEO_CLASS_DELETE_COMPLETE: { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~deserialize_source. DATA: lv_updated TYPE abap_bool, lv_program TYPE program, lo_scanner TYPE REF TO cl_oo_source_scanner_class, lt_methods TYPE cl_oo_source_scanner_class=>type_method_implementations, lv_method LIKE LINE OF lt_methods, lt_source TYPE seop_source_string. ""Buffer needs to be refreshed, ""otherwise standard SAP CLIF_SOURCE reorder methods alphabetically CALL FUNCTION 'SEO_BUFFER_INIT'. CALL FUNCTION 'SEO_BUFFER_REFRESH' EXPORTING cifkey = is_key version = seoc_version_inactive. lo_scanner = init_scanner( it_source = it_source iv_name = is_key-clsname ). * public lt_source = lo_scanner->get_public_section_source( ). IF lt_source IS NOT INITIAL. lv_program = cl_oo_classname_service=>get_pubsec_name( is_key-clsname ). lv_updated = update_report( iv_program = lv_program it_source = lt_source ). IF lv_updated = abap_true. update_meta( iv_name = is_key-clsname iv_exposure = seoc_exposure_public it_source = lt_source ). ENDIF. ENDIF. * protected lt_source = lo_scanner->get_protected_section_source( ). IF lt_source IS NOT INITIAL. lv_program = cl_oo_classname_service=>get_prosec_name( is_key-clsname ). lv_updated = update_report( iv_program = lv_program it_source = lt_source ). IF lv_updated = abap_true. update_meta( iv_name = is_key-clsname iv_exposure = seoc_exposure_protected it_source = lt_source ). ENDIF. ENDIF. * private lt_source = lo_scanner->get_private_section_source( ). IF lt_source IS NOT INITIAL. lv_program = cl_oo_classname_service=>get_prisec_name( is_key-clsname ). lv_updated = update_report( iv_program = lv_program it_source = lt_source ). IF lv_updated = abap_true. update_meta( iv_name = is_key-clsname iv_exposure = seoc_exposure_private it_source = lt_source ). ENDIF. ENDIF. * methods lt_methods = lo_scanner->get_method_implementations( ). LOOP AT lt_methods INTO lv_method. TRY. lt_source = lo_scanner->get_method_impl_source( lv_method ). CATCH cx_oo_clif_component. zcx_abapgit_exception=>raise( 'error from GET_METHOD_IMPL_SOURCE' ). ENDTRY. lv_program = determine_method_include( iv_name = is_key-clsname iv_method = lv_method ). update_report( iv_program = lv_program it_source = lt_source ). ENDLOOP. * full class include update_full_class_include( iv_classname = is_key-clsname it_source = it_source it_methods = lt_methods ). update_source_index( iv_clsname = is_key-clsname io_scanner = lo_scanner ). * TODO, perhaps move this call to somewhere else, to be done while cleaning up the CLAS deserialization zcl_abapgit_objects_activation=>add( iv_type = 'CLAS' iv_name = is_key-clsname ). ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~generate_locals. DATA: lv_program TYPE programm. IF lines( it_local_definitions ) > 0. lv_program = cl_oo_classname_service=>get_ccdef_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_definitions ). ENDIF. IF lines( it_local_implementations ) > 0. lv_program = cl_oo_classname_service=>get_ccimp_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_implementations ). ENDIF. IF lines( it_local_macros ) > 0. lv_program = cl_oo_classname_service=>get_ccmac_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_macros ). ENDIF. IF lines( it_local_test_classes ) > 0. lv_program = cl_oo_classname_service=>get_ccau_name( is_key-clsname ). update_report( iv_program = lv_program it_source = it_local_test_classes ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~get_class_properties. CALL FUNCTION 'SEO_CLIF_GET' EXPORTING cifkey = is_class_key version = seoc_version_active IMPORTING class = rs_class_properties EXCEPTIONS not_existing = 1 deleted = 2 model_only = 3 OTHERS = 4. IF sy-subrc = 1. RETURN. "" in case only inactive version exists ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from seo_clif_get' ). ENDIF. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~get_includes. * note: includes returned might not exist * method cl_oo_classname_service=>GET_ALL_CLASS_INCLUDES does not exist in 702 DATA: lv_class_name TYPE seoclsname, lt_methods TYPE seop_methods_w_include. FIELD-SYMBOLS: LIKE LINE OF lt_methods. lv_class_name = iv_object_name. APPEND cl_oo_classname_service=>get_ccdef_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ccmac_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ccimp_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_cl_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ccau_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_pubsec_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_prosec_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_prisec_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_classpool_name( lv_class_name ) TO rt_includes. APPEND cl_oo_classname_service=>get_ct_name( lv_class_name ) TO rt_includes. * skip the CS include, as it is sometimes generated on the fly instead of * when the methods are changed * APPEND cl_oo_classname_service=>get_cs_name( lv_class_name ) TO rt_includes. cl_oo_classname_service=>get_all_method_includes( EXPORTING clsname = lv_class_name RECEIVING result = lt_methods EXCEPTIONS class_not_existing = 1 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Class { lv_class_name } not existing| ). ENDIF. LOOP AT lt_methods ASSIGNING . APPEND -incname TO rt_includes. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~insert_text_pool. DATA: lv_cp TYPE program. lv_cp = cl_oo_classname_service=>get_classpool_name( iv_class_name ). INSERT TEXTPOOL lv_cp FROM it_text_pool LANGUAGE iv_language STATE 'I'. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'REPT' iv_name = lv_cp ). ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~read_sotr. DATA: lv_concept TYPE sotr_head-concept, lt_seocompodf TYPE STANDARD TABLE OF seocompodf WITH DEFAULT KEY, ls_header TYPE sotr_head, lt_entries TYPE sotr_text_tt. FIELD-SYMBOLS: LIKE LINE OF rt_sotr, LIKE LINE OF lt_seocompodf, LIKE LINE OF lt_entries. SELECT * FROM seocompodf INTO TABLE lt_seocompodf WHERE clsname = iv_object_name AND version = '1' AND exposure = '2' AND attdecltyp = '2' AND type = 'SOTR_CONC' ORDER BY PRIMARY KEY. ""#EC CI_SUBRC LOOP AT lt_seocompodf ASSIGNING . lv_concept = translate( val = -attvalue from = '''' to = '' ). CALL FUNCTION 'SOTR_GET_CONCEPT' EXPORTING concept = lv_concept IMPORTING header = ls_header TABLES entries = lt_entries EXCEPTIONS no_entry_found = 1 OTHERS = 2. IF sy-subrc <> 0. CONTINUE. ENDIF. CLEAR: ls_header-paket, ls_header-crea_name, ls_header-crea_tstut, ls_header-chan_name, ls_header-chan_tstut. LOOP AT lt_entries ASSIGNING . CLEAR: -version, -crea_name, -crea_tstut, -chan_name, -chan_tstut. ENDLOOP. APPEND INITIAL LINE TO rt_sotr ASSIGNING . -header = ls_header. -entries = lt_entries. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_oo_object_fnc~read_text_pool. DATA: lv_cp TYPE program. lv_cp = cl_oo_classname_service=>get_classpool_name( iv_class_name ). READ TEXTPOOL lv_cp INTO rt_text_pool LANGUAGE iv_language. ""#EC CI_READ_REP ENDMETHOD. ENDCLASS. ",6071,False,1305.7166244409757,median "/* Copyright 2006 Mark E Shepherd Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.flex.extras.controls.springgraph { import com.adobe.flex.extras.controls.forcelayout.Node; import flash.display.DisplayObject; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.geom.Rectangle; import flash.media.Sound; import flash.media.SoundMixer; import flash.net.URLLoader; import flash.net.URLLoaderDataFormat; import flash.net.URLRequest; import flash.net.URLRequestHeader; import flash.net.URLRequestMethod; import flash.net.URLVariables; import flash.net.navigateToURL; import flash.utils.Timer; import flash.utils.getTimer; import mx.controls.Alert; import mx.controls.Image; import mx.controls.MenuBar; import mx.events.MenuEvent; import mx.styles.StyleManager; /** * Dispatched when there is any change to the nodes and/or links of this graph. * * @eventType flash.events.Event */ [Event(name=""change"", type=""flash.events.Event"")] /** * An extension to SpringGraph that restricts the visible items to a subset of the full graph. * You can control which items are currently visible by using the itemLimit, * maxDistanceFromCurrent, and currentItem properties. */ public class Roamer extends SpringGraph { private var timer:Timer; private var urConfigXML:URLRequest = new URLRequest(); private var ulConfigXML:URLLoader; private var urRightClickMenu:URLRequest = new URLRequest(); private var loaderRightClickMenu:URLLoader; private var urTreeParser:URLRequest = new URLRequest(); private var loaderTreeParser:URLLoader; private var urMenuBarXML:URLRequest = new URLRequest(); private var ulMenuBarXML:URLLoader; private var urTreeXML:URLRequest = new URLRequest(); private var ulTreeXML:URLLoader; private var urStatus:URLRequest = new URLRequest(); private var loaderStatus:URLLoader; private var urRedirect:URLRequest = new URLRequest(); private var loaderRedirect:URLLoader; private var urAttack:URLRequest = new URLRequest(); private var loaderAttack:URLLoader; public var saveCfgPHPName:String = ""saveCfg.php""; private var urSaveConfig:URLRequest = new URLRequest(); private var loaderSaveConfig:URLLoader; private var urLoad:URLRequest = new URLRequest(); private var loaderLoad:URLLoader; private var header:URLRequestHeader = new URLRequestHeader(""pragma"", ""no-cache""); private var treeXml:XML; private var lineXml:XML; private var menuXml:XML; private var attackXml:XML; private var configXml:XML; public var roamerIdx:int; private var locationXml:XML; [Bindable] /** * The maximum number of items that are visible at any time. */ public function get itemLimit(): int { return _itemLimit; } public function set itemLimit(i: int): void { _itemLimit = i; recreateGraph(); } /** * We only display items that are within this distance from the current item. */ public var maxDistanceFromCurrentTmp; public function set maxDistanceFromCurrent(i: int): void { _maxDistanceFromCurrent = i; recreateGraph(); } public function get maxDistanceFromCurrent(): int { return _maxDistanceFromCurrent; } /** * The item that current acts as the 'center' or 'root' of the graph. * This item defines the subset of the graph that will be visible. */ public function set currentItem(item: Item): void { newCurrentItem(item); recreateGraph(); dispatchEvent(new Event(""currentItemChange"")); } [Bindable(""currentItemChange"")] public function get currentItem(): Item { return _currentItem; } /** Find out if a given item has ever been the currentItem. * @param item an Item that is contained in this graph * @returns true if the indicated item has ever been the currentItem of this graph. */ public function hasBeenCurrentItem(item: Item): Boolean { return allCurrentItems.hasOwnProperty(item.id); } [Bindable(""dataProviderChange"")] /** * Defines the data model for this springgraph. See SpringGraph.dataProvider * for more information. */ override public function get dataProvider(): Object { return fullGraph; } /** sets the data provider and chooses the initial currentItem. */ public function setDataProvider(dp: XML, currentId: String): void { var g: Graph = Graph.fromXML(dp, _xmlNames); g.distinguishedItem = g.find(currentId); doSetDataProvider(g); } override public function set dataProvider(obj: Object): void { if(obj is XML) obj = Graph.fromXML(obj as XML, _xmlNames); doSetDataProvider(obj as Graph); } /** Calulate the distance between 2 items. Currently this is a fast-but-cheezy * calculation that returns 0 (if the 2 items are the same), 1 (if the 2 items * are linked), or 99 otherwise. * @return the distance between the two items. */ public function distance(fromItem: Item, toItem: Item): int { if(fromItem == toItem) return 0; if(arrayIncludes(fullGraph.neighbors(fromItem.id), toItem)) return 1; return 99; } /** The total number of items in the dataProvider. */ public function get fullNodeCount(): int { if(fullGraph != null) return fullGraph.nodeCount; return 0; } /** The number of items in the dataProvider that are currently visible. */ public function get visibleNodeCount(): int { if(_graph != null) return _graph.nodeCount; return 0; } /** An array of items that will not be displayed, even if they * are chosen to be visible by the Roamer's other computations. */ private var forceInvisible: Array = null; /** An array of items that will be displayed on the graph, even if they * are not chosen to be visible by the Roamer's other computations. */ private var forceVisible: Array = null; /** Call this function after modifying the forceInvisible or forceVisible properties */ private function recreate(): void { recreateGraph(); } [Bindable(""showHistoryChange"")] /** If true, then all items that have been the 'current item' are made visible. * * */ public function get showHistory(): Boolean { return _showHistory; } public function set showHistory(show: Boolean): void { //this.forceVisible = show ? history : null; dispatchEvent(new Event(""showHistoryChange"")); _showHistory = show; var temp: Item = _currentItem; _currentItem = null; recreate(); _currentItem = temp; recreate(); } /** Forget which items have been the current item. This will affect the history * used by 'showHistory' and 'hasBeenCurrentItem'. * * */ public function resetHistory(): void { allCurrentItems = new Array(); _history = new Array(); dispatchEvent(new Event(""historyChange"")); } /** Force the item to be shown, even if it is outside the limits set by * 'maxDistanceFromCurrent'. * */ public function showItem(item: Item): void { if(forceVisible == null) forceVisible = []; forceVisible.push(item); recreate(); } /** Force the item to not be shown, even if it is inside the limits set by * 'maxDistanceFromCurrent'. * */ public function hideItem(item: Item): void { if(forceInvisible == null) forceInvisible = []; forceInvisible.push(item); recreate(); } /** Cancels the effect of any prior calls to hideItem and/or showItem. * */ public function resetShowHide(): void { forceVisible = null; forceInvisible = null; } /** Sets the currentItem to the previous history Item. ""historyIndex"" will be decremented. * Has no effect if historyIndex is already 0. */ public function back(): void { if (historyCurrentlyViewed > 0) { historyCurrentlyViewed--; _currentItem = _history[historyCurrentlyViewed]; recreateGraph(); dispatchEvent(new Event(""currentItemChange"")); } } /** Sets the currentItem to the next history Item. ""historyIndex"" will be incremented. * Has no effect if historyIndex is already the highest possible index in ""history"". */ public function forward(): void { if(historyCurrentlyViewed < (_history.length - 1)) { historyCurrentlyViewed++; _currentItem = _history[historyCurrentlyViewed]; recreateGraph(); dispatchEvent(new Event(""currentItemChange"")); } } [Bindable(""currentItemChange"")] /** Whether the back() function will have any effect at the moment. */ public function get backOK(): Boolean { return (historyCurrentlyViewed > 0); } [Bindable(""currentItemChange"")] /** Whether the forward() function will have any effect at the moment */ public function get forwardOK(): Boolean { return (historyCurrentlyViewed < (_history.length - 1)); } [Bindable(""historyChange"")] /** An ordered list of all the items that been the current item. */ public function get history(): Array { return _history; } [Bindable(""currentItemChange"")] /** The index into ""history"" that corresponds to the currentItem. * Can be any number between 0 and the index of the most recent history entry. * Usually this is simply the index of the most recent history entry. * However, if you've used back() or forward() then this index will vary. You can also * set this index to any valid value; this will cause currentItem to become * the corresponding history item. */ public function get historyIndex(): int { return historyCurrentlyViewed; } public function set historyIndex(i: int): void { if ((i >= 0) && (i < _history.length)) { historyCurrentlyViewed = i; _currentItem = _history[historyCurrentlyViewed]; recreateGraph(); dispatchEvent(new Event(""currentItemChange"")); } } [Bindable(""tidyHistoryChange"")] /** Keeps all visibleHistoryItems clustered together. If this is set to false, * history items tend to form a long chain that makes the autoFit mode tend * to shrink the repulsionFactor excessively. */ public function get tidyHistory(): Boolean{ return _tidyHistory; } public function set tidyHistory(b: Boolean): void { _tidyHistory = b; recreateGraph(); dispatchEvent(new Event(""tidyHistoryChange"")); } [Bindable(""visibleHistoryItemsChange"")] /** A list of all the items that are currently visible only * because showHistory is enabled. In other words this list * is the entire history minus the items that are currently visible anyway. */ public function get visibleHistoryItems(): Object{ return _visibleHistoryItems; } private function set visibleHistoryItems(o: Object): void { } public var rmVlan:Boolean = false; public var rmGroup:Boolean = false; public var rmLine:Boolean = false; /*to be overrided by roamer*/ override protected function updateCurrentItem(itemID:String):void { var item:Item, itemTmp:Item; item = fullGraphWithVlan.find(itemID); _currentItem = item; if(item != null) { fullGraphWithVlan.updateFromXML(treeXml, lineXml, null, rmVlan, rmGroup, rmLine, item.id); } /*else _maxDistanceFromCurrent = maxDistanceFromCurrentTmp;*/ for each (var location: XML in locationXml.descendants(""location"")) { itemTmp = fullGraphWithVlan.find(location.@id); if(itemTmp != null) { itemTmp.X = location.@x; itemTmp.Y = location.@y; } } //recreateGraph(); doSetDataProvider(fullGraphWithVlan); item = fullGraphWithVlan.find(itemID); _currentItem = item; /*if(item.data.@nodeType == ""Router"") _skipItem = item.parentItem; else _skipItem = item.parentItem;*/ //_maxDistanceFromCurrent = maxDistanceFromCurrentTmp; recreateGraph(); //this.loadRedirect(); refreshRedirTimer = 1; dispatchEvent(new Event(""currentItemChange"")); } /*to be overrided by roamer*/ override protected function itemDoubleClick(event: MouseEvent):void { _currentItem = event.currentTarget.data; recreateGraph(); dispatchEvent(new Event(""currentItemChange"")); } /*to be overrided by roamer*/ override protected function reDrawItems():void { var item:Item = _currentItem; doSetDataProvider(fullGraph); _currentItem = item; recreateGraph(); dispatchEvent(new Event(""currentItemChange"")); } /*to be overrided by roamer*/ override protected function updateDistance(distance:int):void { _maxDistanceFromCurrent = distance; recreateGraph(); } /*to be overrided by roamer*/ override protected function updateMaxNode(maxNode:int):void { _itemLimit = maxNode; recreateGraph(); } /*overwrited by roamer*/ override protected function setItemTxt():void { updateCurrentItem(_currentItem.id); } /*to be overrided by roamer*/ override protected function setHideVlan(hideVlan:Boolean):void { rmVlan = hideVlan; updateCurrentItem(_currentItem.id); } /*to be overrided by roamer*/ override protected function setHideGroup(hideGroup:Boolean):void { rmGroup = hideGroup; updateCurrentItem(_currentItem.id); } /*to be overrided by roamer*/ override protected function setHideLine(hideLine:Boolean):void { rmLine = hideLine; updateCurrentItem(_currentItem.id); } private var dfltCenterID:String = """"; private var dfltShowBG:Boolean = false; private var dfltShowStatus:Boolean = false; private var dfltShowRate:Boolean = false; private var dfltShowRateInfo:Boolean = false; private var dfltShowAttack:Boolean = false; private var dfltAtkIsoX:int = 50; private var dfltAtkIsoY:int = 0; private var dfltIdentify:String = ""ip""; private var dfltDistance:int = 8; private var dfltMaxNode:int = 25; private var dfltManual:Boolean = false; private var dfltAutoFit:Boolean = false; private var dfltAlpha:Number = 1.0; private var dfltFontSize:int = 24; private var dfltDevFontColor:int = 0x000000; private var dfltRateFontColor:int = 0x000000; private var dfltRateLine:int = 2; private var dfltRefreshInterval:int = 5; private var dfltRepulsion:Number = 1.0; private var dfltScale:Number = 0.8; private var dfltNumNodeFontSize:int = 30; private var dfltNumNodeFontColor:int = 0xff00000; private var dfltTreePath:String=""./nbadroute.tree""; private var dfltLinePath:String=""./nbadroute.line""; private var dfltAtkPath:String=""./nbadroute.atk""; private var dfltStatusPath:String=""./nbadroute.status""; private var dfltRedirectPath:String=""./redirect.txt""; public var dfltMrtgPathFlashView:String=""../mrtgdata/""; private var dfltMrtgPathPHPView:String=""./mrtgdata/""; private var dfltEncoding:String=""big5""; private var dfltHideVlan:Boolean=true; private var dfltHideGroup:Boolean=true; private var dfltHideLine:Boolean=true; private var dfltSaveButtonX:int = 180; private var dfltSaveButtonY:int = 0; private var dfltManualButtonX:int = 239; private var dfltManualButtonY:int = 0; private var dfltBackGroundColor:int = 0xffffff; private var dfltBackGroundPic:String; private var backGroundPic:Image; public function initTopology():void { loadDefaultConfig(); } public function loadDefaultConfig():void { urConfigXML.url = dfltPHPDIR + ""dfltConfig"" + roamerIdx + "".xml""; urConfigXML.method = URLRequestMethod.GET; urConfigXML.requestHeaders.push(header); urConfigXML.data = new URLVariables(""time=""+Number(new Date().getTime())); ulConfigXML = new URLLoader(); ulConfigXML.load(urConfigXML); ulConfigXML.addEventListener(Event.COMPLETE, setDefaultConfig); } private function setDefaultConfig(ev:Event):void { configXml = new XML(ulConfigXML.data); dfltCenterID = configXml.dfltCenterID.@value; currentIDLog = configXml.dfltCenterID.@value; if(configXml.showBG.@value == ""true"") dfltShowBG = true; else dfltShowBG = false; showBGLog = configXml.showBG.@value; if(configXml.showStatus.@value == ""true"") dfltShowStatus = true; else dfltShowStatus = false; showStatusLog = configXml.showStatus.@value; if(configXml.showRate.@value == ""true"") dfltShowRate = true; else dfltShowRate = false; showRateLog = configXml.showRate.@value; if(configXml.showRateInfo.@value == ""true"") dfltShowRateInfo = true; else dfltShowRateInfo = false; showRateInfoLog = configXml.showRateInfo.@value; if(configXml.showAttack.@value == ""true"") dfltShowAttack = true; else dfltShowAttack = false; showAttackLog = configXml.showAttack.@value; if(configXml.atkIsoX.@value != null) dfltAtkIsoX = configXml.atkIsoX.@value; if(configXml.atkIsoY.@value != null) dfltAtkIsoY = configXml.atkIsoY.@value; dfltIdentify = configXml.identify.@value; txtLog = configXml.identify.@value; dfltDistance = configXml.distance.@value; distanceLog = configXml.distance.@value; dfltMaxNode = configXml.maxNode.@value; nodeLog = configXml.maxNode.@value; if(configXml.manual.@value == ""true"") dfltManual = true; else dfltManual = false; manualLog = configXml.manual.@value; if(configXml.autoFit.@value == ""true"") dfltAutoFit = true; else dfltAutoFit = false; dfltAlpha = configXml.alpha.@value; alphaLog = configXml.alpha.@value; dfltFontSize = configXml.fontSize.@value; fontSizeLog = configXml.fontSize.@value; dfltDevFontColor = configXml.devFontColor.@value; dfltRateFontColor = configXml.rateFontColor.@value; dfltRateLine = configXml.rateLine.@value; rateLineLog = configXml.rateLine.@value; dfltRepulsion = configXml.repulsion.@value; dfltScale = configXml.scale.@value; scaleLog = configXml.scale.@value; dfltNumNodeFontSize = configXml.numNodeFontSize.@value; dfltNumNodeFontColor = configXml.numNodeFontColor.@value; dfltBackGroundColor = configXml.backGroundColor.@value; dfltTreePath=configXml.treeFilePath.@value; dfltLinePath=configXml.lineFilePath.@value; dfltAtkPath=configXml.atkFilePath.@value; dfltStatusPath=configXml.statusFilePath.@value; dfltRedirectPath=configXml.redirectFilePath.@value; dfltMrtgPathFlashView=configXml.mrtgDirPathFlashView.@value; dfltMrtgPathPHPView=configXml.mrtgDirPathPHPView.@value; dfltEncoding=configXml.charEncoding.@value; if(configXml.hideVlan.@value == ""true"") dfltHideVlan = true; else dfltHideVlan = false; hideVlanLog = configXml.hideVlan.@value; if(configXml.hideGroup.@value == ""true"") dfltHideGroup = true; else dfltHideGroup = false; hideGroupLog = configXml.hideGroup.@value; if(configXml.hideLine.@value == ""true"") dfltHideLine = true; else dfltHideLine = false; hideLineLog = configXml.hideLine.@value; dfltSaveButtonX=configXml.saveButtonX.@value; dfltSaveButtonY=configXml.saveButtonY.@value; dfltManualButtonX=configXml.manualButtonX.@value; dfltManualButtonY=configXml.manualButtonY.@value; sndIdx[""Bad""]=configXml.sndMenu.@Bad; sndIdx[""Alarm""]=configXml.sndMenu.@Alarm; sndIdx[""Victim""]=configXml.sndMenu.@Victim; dfltBackGroundPic=configXml.backGroundPic.@value; if(configXml.backGroundPicMoveEbl.@value != null) this.backGroundPicMoveEbl=configXml.backGroundPicMoveEbl.@value; if(dfltBackGroundPic != null && dfltBackGroundPic != ""none"") { this.backGroundPic = new Image(); this.backGroundPic.source = dfltBackGroundPic; this.backGroundPicX=configXml.backGroundPicX.@value; this.backGroundPicY=configXml.backGroundPicY.@value; this.backGroundPic.x = this.backGroundPicX; this.backGroundPic.y = this.backGroundPicY; this.backGroundPic.enabled = true; var cTmp:DisplayObject; cTmp=this.getChildAt(0); this.removeChildAt(0); this.addChild(this.backGroundPic); this.addChild(cTmp); if(dfltShowBG == false) this.backGroundPic.visible = false; } else this.backGroundPic.enabled = false; if(configXml.wheelScale.@value != null) { wheelScale = configXml.wheelScale.@value; wheelScaleLog = configXml.wheelScale.@value; } if(configXml.wheelLocation.@value != null) { wheelLocation = configXml.wheelLocation.@value; wheelLocationLog = configXml.wheelLocation.@value; } if((dfltBackGroundPic != null && dfltBackGroundPic != ""none"") && dfltShowBG == true) { wheelLocation = 0; } this.infoWinMrtg_width = configXml.infoWinMrtg_width.@value; this.infoWinMrtg_height = configXml.infoWinMrtg_height.@value; this.infoWinDev_width = configXml.infoWinDev_width.@value; this.infoWinDev_height = configXml.infoWinDev_height.@value; updateInfoWindowSize(); ulConfigXML.close(); loadRightClickMenu(); } public var lang:String = """"; private function loadRightClickMenu():void { urRightClickMenu.url = dfltPHPDIR + ""clickEvent"" + lang + "".xml""; trace(""click url "" + urRightClickMenu.url); urRightClickMenu.method = URLRequestMethod.GET; urRightClickMenu.requestHeaders.push(header); urRightClickMenu.data = new URLVariables(""time=""+Number(new Date().getTime())); loaderRightClickMenu = new URLLoader(); loaderRightClickMenu.load(urRightClickMenu); loaderRightClickMenu.addEventListener(Event.COMPLETE, applyDfltConfig); } var clickEventXml:XML; private function applyDfltConfig(ev:Event):void { clickEventXml = new XML(loaderRightClickMenu.data); loaderRightClickMenu.close(); this.showHistory = false; this.setStyle(""backgroundColor"", String(dfltBackGroundColor)); this.itemLimit = dfltMaxNode; this.maxDistanceFromCurrent = dfltDistance; this.maxDistanceFromCurrentTmp = dfltDistance; this.repulsionFactor = dfltRepulsion; this.autoFit = dfltAutoFit; this.rmVlan = dfltHideVlan; this.rmGroup = dfltHideGroup; this.rmLine = dfltHideLine; var viewFactory:myViewFactory = new myViewFactory(); viewFactory.setClickEventXML(clickEventXml); viewFactory.itemScale = dfltScale; viewFactory.showStatus = dfltShowStatus; viewFactory.showAttack = dfltShowAttack; viewFactory.txtInfo = dfltIdentify; viewFactory.txtFontSize = dfltFontSize; viewFactory.txtFontColor = dfltDevFontColor; this.txtFontColor = dfltRateFontColor; if(tfRate != null) tfRate.color = String(dfltRateFontColor); viewFactory.numNodeFontSize = dfltNumNodeFontSize; viewFactory.numNodeFontColor = dfltNumNodeFontColor; viewFactory.viewAlpha = dfltAlpha; viewFactory.mrtgDirPath = dfltMrtgPathFlashView; viewFactory.sessionID = sessionID; viewFactory.atkIsoX = dfltAtkIsoX; viewFactory.atkIsoY = dfltAtkIsoY; this.viewFactory = viewFactory; var edgeRenderer:myEdgeRenderer = new myEdgeRenderer(this); edgeRenderer.rateThickness = dfltRateLine; edgeRenderer.showAttack = dfltShowAttack; edgeRenderer.showRate = dfltShowRate; edgeRenderer.showRateInfo = dfltShowRateInfo; this.edgeRenderer = edgeRenderer; this.mrtgDirPath = dfltMrtgPathFlashView; genTopologyData(); } /*overrided by roamer*/ override protected function doSaveConfig():void { configXml.dfltCenterID.@value = currentIDLog; configXml.showBG.@value = showBGLog; configXml.showStatus.@value = showStatusLog; configXml.showRate.@value = showRateLog; configXml.showRateInfo.@value = showRateInfoLog; configXml.showAttack.@value = showAttackLog; configXml.identify.@value = txtLog; configXml.distance.@value = distanceLog; configXml.maxNode.@value = nodeLog; configXml.manual.@value = manualLog; configXml.alpha.@value = alphaLog; configXml.fontSize.@value = fontSizeLog; configXml.devFontColor.@value = (myViewFactory)(this.viewFactory).txtFontColor; configXml.rateFontColor.@value = this.txtFontColor; configXml.rateLine.@value = rateLineLog; configXml.scale.@value = scaleLog; configXml.hideVlan.@value = hideVlanLog; configXml.hideGroup.@value = hideGroupLog; configXml.hideLine.@value = hideLineLog; configXml.sndMenu.@Bad=sndIdx[""Bad""]; configXml.sndMenu.@Alarm=sndIdx[""Alarm""]; configXml.sndMenu.@Victim=sndIdx[""Victim""]; if(this.backGroundPicMoveEbl != 0) { configXml.backGroundPicX.@value=this.backGroundPicX.toString(); configXml.backGroundPicY.@value=this.backGroundPicY.toString(); } urSaveConfig.url = dfltPHPDIR + saveCfgPHPName; urSaveConfig.method = URLRequestMethod.POST; urSaveConfig.requestHeaders.push(header); urSaveConfig.data = new URLVariables(""newConfig=""+configXml.toString()+""&fileName=""+""dfltConfig"" + roamerIdx + "".xml""+""&time=""+Number(new Date().getTime())); loaderSaveConfig = new URLLoader(); loaderSaveConfig.load(urSaveConfig); } public function genTopologyData(): void { urTreeParser.url = dfltPHPDIR + ""treeParser.php""; urTreeParser.method = URLRequestMethod.GET; urTreeParser.requestHeaders.push(header); urTreeParser.data = new URLVariables(""treepath=""+dfltTreePath+""&mrtgpath=""+dfltMrtgPathPHPView+""&output=tree""+roamerIdx+"".xml""+""&encoding=""+dfltEncoding+""&time=""+Number(new Date().getTime())); loaderTreeParser = new URLLoader(); loaderTreeParser.load(urTreeParser); loaderTreeParser.addEventListener(Event.COMPLETE, loadTopologyData); } private function loadTopologyData(ev:Event):void { var resultStr:String = loaderTreeParser.data; if(resultStr.substr(0,8) == ""Complete"") { urTreeXML.url = dfltPHPDIR + ""tree""+roamerIdx+"".xml"" urTreeXML.method = URLRequestMethod.GET; urTreeXML.requestHeaders.push(header); urTreeXML.data = new URLVariables(""time=""+Number(new Date().getTime())); ulTreeXML = new URLLoader(); ulTreeXML.dataFormat = URLLoaderDataFormat.BINARY; ulTreeXML.load(urTreeXML); ulTreeXML.addEventListener(Event.COMPLETE, genLineData); } loaderTreeParser.close(); } public function genLineData(ev:Event):void { var textTmp:String = ulTreeXML.data.readMultiByte(ulTreeXML.data.length, lang); treeXml = new XML(textTmp); ulTreeXML.close(); urTreeParser.url = dfltPHPDIR + ""lineParser.php""; urTreeParser.method = URLRequestMethod.GET; urTreeParser.requestHeaders.push(header); urTreeParser.data = new URLVariables(""linepath=""+dfltLinePath+""&mrtgpath=""+dfltMrtgPathPHPView+""&output=line""+roamerIdx+"".xml""+""&encoding=""+dfltEncoding+""&time=""+Number(new Date().getTime())); loaderTreeParser = new URLLoader(); loaderTreeParser.load(urTreeParser); loaderTreeParser.addEventListener(Event.COMPLETE, loadLineData); } private function loadLineData(ev:Event):void { var resultStr:String = loaderTreeParser.data; if(resultStr.substr(0,8) == ""Complete"") { urTreeXML.url = dfltPHPDIR + ""line""+roamerIdx+"".xml"" urTreeXML.method = URLRequestMethod.GET; urTreeXML.requestHeaders.push(header); urTreeXML.data = new URLVariables(""time=""+Number(new Date().getTime())); ulTreeXML = new URLLoader(); ulTreeXML.load(urTreeXML); ulTreeXML.addEventListener(Event.COMPLETE, loadLocation); } loaderTreeParser.close(); } public function loadLocation(ev:Event):void { var nodes: Array; lineXml = new XML(ulTreeXML.data); fullGraphWithVlan = new Graph(); fullGraphWithVlan.updateFromXML(treeXml, lineXml, null, rmVlan, rmGroup, rmLine, dfltCenterID); /* fullGraphRmVlan = new Graph(); fullGraphRmVlan.updateFromXMLRmVlan(treeXml, null); */ ulTreeXML.close(); urLoad.url = dfltPHPDIR + this.locationFileName; urLoad.method = URLRequestMethod.GET; urLoad.requestHeaders.push(header); urLoad.data = new URLVariables(""time=""+Number(new Date().getTime())); loaderLoad = new URLLoader(); loaderLoad.load(urLoad); loaderLoad.addEventListener(Event.COMPLETE, setLocation); } private function setLocation(ev:Event):void { var itemTmp : Item; var graphTmp: Graph; graphTmp = fullGraphWithVlan; if(loaderLoad.data != """") { locationXml = new XML(loaderLoad.data); for each (var location: XML in locationXml.descendants(""location"")) { itemTmp = graphTmp.find(location.@id); if(itemTmp != null) { itemTmp.X = location.@x; itemTmp.Y = location.@y; } if(location.@id == ""infoWinMrtg"") { infoWinMrtgX = location.@x; infoWinMrtgY = location.@y; if(infoWinMrtg != null) { infoWinMrtg.x = infoWinMrtgX; infoWinMrtg.y = infoWinMrtgY; } } else if(location.@id == ""infoWinDev"") { infoWinDevX = location.@x; infoWinDevY = location.@y; if(infoWinDev != null) { infoWinDev.x = infoWinDevX; infoWinDev.y = infoWinDevY; } } } } this.dataProvider = fullGraphWithVlan; loadSnd(); } private var urSndConfig:URLRequest = new URLRequest(); private var loaderSnd:URLLoader; private var sndPath:Object; private var dfltSndPath:String =dfltPHPDIR+""Snd/"" private var sndToPlay:String = """"; public function loadSnd(): void{ // Alert.show(""load Snd..................""); dfltSndPath =dfltPHPDIR+""Snd/""; urSndConfig=new URLRequest(); urSndConfig.url = dfltSndPath + ""sndFiles.xml""; urSndConfig.method = URLRequestMethod.GET; urSndConfig.requestHeaders.push(header); urSndConfig.data = new URLVariables(""time=""+Number(new Date().getTime())); loaderSnd = new URLLoader(); loaderSnd.addEventListener(Event.COMPLETE, setSnd); loaderSnd.load(urSndConfig); // Alert.show(""load Snd End""); } private var loaderSnd2 = new URLLoader(); private function setSnd(ev:Event):void{ // Alert.show(""setSnd""); var resXml:XML=new XML(loaderSnd.data); parseSndPath(resXml); /* urSndConfig=new URLRequest(); urSndConfig.url = dfltSndPath + ""sndSelected.sav""; urSndConfig.method = URLRequestMethod.GET; urSndConfig.requestHeaders.push(header); // urSndConfig.data = new URLVariables(""time=""+Number(new Date().getTime())); loaderSnd2.load(urSndConfig); loaderSnd2.addEventListener(Event.COMPLETE, setSelectedSnd);*/ } private function parseSndPath(xml:XML):void{ sndPath=new Object(); // Alert.show(""Alert Message1..................""); for each(var file:XML in xml.descendants(""file"")){ sndPath[file.@idx]=file.@filename; } loadMenuBar(); // Alert.show(""Alert Message2..................""); } /* private function setSelectedSnd(ev:Event):void{ var resString:String=String(loaderSnd2.data); parseSndConfig(resString); loadMenuBar(); } private function parseSndConfig(conf:String):void{ // Alert.show(""Parse Snd Config""); var line:String; sndIdx= {Bad:"""",Alarm:"""",Victim:""""}; for each(line in conf.split(""\\n"")){ var args:Array=line.split(""\\t""); sndIdx[args[0]]=args[1]; } // Alert.show(""Parse Snd Config End""+sndIdx[""Victim""]); } */ private var loaderSndToPlay:URLLoader=new URLLoader(); public function checkAndPlaySnd():void{ var urleq:URLRequest=new URLRequest(); urleq.url = dfltSndPath + ""sndToPlay.php""; urleq.method = URLRequestMethod.GET; urleq.requestHeaders.push(header); urleq.data = new URLVariables(""Bad=""+sndIdx[""Bad""]+""&Alarm=""+sndIdx[""Alarm""]+""&Victim=""+sndIdx[""Victim""]); loaderSndToPlay = new URLLoader(); loaderSndToPlay.load(urleq); loaderSndToPlay.addEventListener(Event.COMPLETE,playSnd); // Alert.show(""Check and play snd end""); } public function playSnd(ev:Event):void{ // Alert.show(""Start Play Snd""); SoundMixer.stopAll(); sndToPlay=String(loaderSndToPlay.data); if (sndToPlay!=""""){ // Alert.show(String(new Date().toLocaleString())+""\\nStatus abnormal?�\\n""+""Status: ""+sndToPlay); var ureq:URLRequest=new URLRequest(); ureq.url=dfltSndPath+sndToPlay; ureq.requestHeaders.push(header); var snd:Sound = new Sound(ureq); snd.play(0, 1); } // Alert.show('PlaySndEnd'); } /* var loaderSaveSnd:URLLoader = new URLLoader(); public function doSaveSndConfig():void { // Alert.show('Saving Sound Configs~~~~~~~~~~~'); // Alert.show(menuBarXml); var alarmLabel:String=sndIdx[""Alarm""]; var badLabel:String=sndIdx[""Bad""]; var victimLabel:String=sndIdx[""Victim""]; var ureq=new URLRequest(); ureq.url = dfltPHPDIR + ""Snd/saveSndConf.php""; ureq.method = URLRequestMethod.GET; ureq.requestHeaders.push(header); ureq.data = new URLVariables(""Alarm=""+alarmLabel+""&Bad=""+badLabel+""&Victim=""+victimLabel); loaderSaveSnd=new URLLoader(); loaderSaveSnd.load(ureq); loaderSaveSnd.addEventListener(Event.COMPLETE,saveSndComplete); } private function saveSndComplete(ev:Event):void{ //Alert.show(""SndSaveOk~""); loaderSaveSnd.close(); // loadSnd(); }*/ private function loadMenuBar():void { urMenuBarXML.url = dfltPHPDIR +""menuBar"" + lang + "".xml""; trace(""menu url "" + urMenuBarXML.url); urMenuBarXML.method = URLRequestMethod.GET; urMenuBarXML.requestHeaders.push(header); urMenuBarXML.data = new URLVariables(""time=""+Number(new Date().getTime())); ulMenuBarXML = new URLLoader(); ulMenuBarXML.load(urMenuBarXML); ulMenuBarXML.addEventListener(Event.COMPLETE, setMenuBar); } public var canSave:Boolean = false; public var sessionID:String = """"; private function setMenuBar(ev:Event):void { //Alert.show(""setMenuBar""); menuXml = new XML(ulMenuBarXML.data); var myParent:Object; myParent = this.parent; myParent.parent.changePanel(menuXml); delete menuXml.panelItem; if(fullGraphWithVlan != null) { //Alert.show(""fullGraphWithVlan""); delete menuXml.menuitem[0].*; var i:int = 0; var group:int = -1; var found:Boolean = false; // Alert.show(fullGraphWithVlan.baseNodeArray.length.toString()); if (fullGraphWithVlan.baseNodeArray.length>0){ for each (var item: Item in fullGraphWithVlan.baseNodeArray) { //Alert.show(""iter baseNodes""); if((i % 10) == 0) { menuXml.menuitem[0].appendChild(); group ++; menuXml.menuitem[0].menuitem[group].@label = menuXml.menuitem[0].@label + "" "" + group*10 + ""-""; } menuXml.menuitem[0].menuitem[group].appendChild(); menuXml.menuitem[0].menuitem[group].menuitem[i%10].@label = item.data.@nodeType+"" ""+item.data.@ip+"" ""+item.data.@name; menuXml.menuitem[0].menuitem[group].menuitem[i%10].@data = ""network_""+item.data.@id; menuXml.menuitem[0].menuitem[group].menuitem[i%10].@type = ""radio""; menuXml.menuitem[0].menuitem[group].menuitem[i%10].@groupName = ""network""; if(dfltCenterID == item.id) { menuXml.menuitem[0].menuitem[group].menuitem[i%10].@toggled = ""true""; found = true; updateCurrentItem(dfltCenterID); } menuXml.menuitem[0].menuitem[group].menuitem[i%10].@id = item.id; if((i % 10) == 9) { menuXml.menuitem[0].menuitem[group].@label = menuXml.menuitem[0].menuitem[group].@label + i; } i ++; } if(found == false) menuXml.menuitem[0].menuitem[0].menuitem[0].@toggled = ""true""; if((i % 10) != 0) { menuXml.menuitem[0].menuitem[group].@label = menuXml.menuitem[0].menuitem[group].@label + i; } } } // Alert.show(""SetMenuItemToggled""); if(dfltShowBG == true) menuXml.menuitem[1].menuitem[0].@toggled = ""true""; else menuXml.menuitem[1].menuitem[0].@toggled = ""false""; if(dfltShowRate == true) menuXml.menuitem[1].menuitem[1].@toggled = ""true""; else menuXml.menuitem[1].menuitem[1].@toggled = ""false""; if(dfltShowRateInfo == true) menuXml.menuitem[1].menuitem[2].@toggled = ""true""; else menuXml.menuitem[1].menuitem[2].@toggled = ""false""; if(dfltShowAttack == true) menuXml.menuitem[1].menuitem[3].@toggled = ""true""; else menuXml.menuitem[1].menuitem[3].@toggled = ""false""; if(dfltShowStatus == true) menuXml.menuitem[1].menuitem[4].@toggled = ""true""; else menuXml.menuitem[1].menuitem[4].@toggled = ""false""; for each (var colorXml: XML in menuXml.menuitem[1].menuitem[5].descendants(""menuitem"")) { if((int)(colorXml.@data) == dfltDevFontColor) colorXml.@toggled = ""true""; else colorXml.@toggled = ""false""; } for each (var colorXml: XML in menuXml.menuitem[1].menuitem[6].descendants(""menuitem"")) { if((int)(colorXml.@data) == dfltRateFontColor) colorXml.@toggled = ""true""; else colorXml.@toggled = ""false""; } if(dfltIdentify == ""ip"") { menuXml.menuitem[1].menuitem[7].menuitem[0].@toggled = ""true""; menuXml.menuitem[1].menuitem[7].menuitem[1].@toggled = ""false""; } else { menuXml.menuitem[1].menuitem[7].menuitem[0].@toggled = ""false""; menuXml.menuitem[1].menuitem[7].menuitem[1].@toggled = ""true""; } if(dfltHideVlan == true) menuXml.menuitem[1].menuitem[8].@toggled = ""true""; else menuXml.menuitem[1].menuitem[8].@toggled = ""false""; if(dfltHideGroup == true) menuXml.menuitem[1].menuitem[9].@toggled = ""true""; else menuXml.menuitem[1].menuitem[9].@toggled = ""false""; if(dfltHideLine == true) menuXml.menuitem[1].menuitem[10].@toggled = ""true""; else menuXml.menuitem[1].menuitem[10].@toggled = ""false""; for each (var distanceXml: XML in menuXml.menuitem[2].menuitem[0].descendants(""menuitem"")) { if(distanceXml.@label == String(dfltDistance)) distanceXml.@toggled = ""true""; else distanceXml.@toggled = ""false""; } for each (var maxNodeXml: XML in menuXml.menuitem[2].menuitem[1].descendants(""menuitem"")) { if(maxNodeXml.@label == String(dfltMaxNode)) maxNodeXml.@toggled = ""true""; else maxNodeXml.@toggled = ""false""; } /*-------------Begin modified for Sound Menu--------------*/ // Alert.show(""setSndMenu""); for each (var menuItem:XML in menuXml.menuitem[3].menuitem) { // Alert.show(menuItem.@label); // Alert.show(menuItem.@name); // if (""Bad"" in sndIdx) // Alert.show(""Bad In sndIdx""); // else // Alert.show(""Bad not in sndIdx""); // Alert.show(""SndIdx Bad ""+sndIdx[""Bad""]); // Alert.show(""SndIdx Alarm ""+sndIdx[""Alarm""]); // Alert.show(""SndIdx Victim ""+sndIdx[""Victim""]); if ((menuItem.@name==""Bad"")){ for each (var radioItem:XML in menuItem.menuitem){ if (radioItem.@label==sndIdx[""Bad""]){ radioItem.@toggled=true; break; } } } else if ((menuItem.@name==""Alarm"")){ for each (var radioItem:XML in menuItem.menuitem){ if (radioItem.@label==sndIdx[""Alarm""]){ radioItem.@toggled=true; break; } } } else if ((menuItem.@name==""Victim"")){ for each (var radioItem:XML in menuItem.menuitem){ if (radioItem.@label==sndIdx[""Victim""]){ radioItem.@toggled=true; break; } } } } // Alert.show(""setUILocation""); /*-------------End modified for Sound menu----------------*/ this.setUI(menuXml, dfltManual, dfltShowRate, dfltShowAttack, dfltShowStatus, dfltAlpha, dfltFontSize, dfltRateLine, canSave); this.updateUILocation(dfltSaveButtonX, dfltSaveButtonY, dfltManualButtonX, dfltManualButtonY); ulMenuBarXML.close(); //Alert.show(""setMenuBar OK""); // checkAndPlaySnd(); // Alert.show(""setMenuBar OK""); //loadRedirect(); /*refreshAttack(); refresStatus();*/ } public function loadRedirect():void { //Alert.show(""loadRedirect""); urRedirect.url = dfltPHPDIR + ""redirectProxy.php""; urRedirect.method = URLRequestMethod.GET; urRedirect.requestHeaders.push(header); if(sessionID != null) { urRedirect.data = new URLVariables(""redirectpath=""+dfltRedirectPath+sessionID+"".redirect.txt""+""&time=""+Number(new Date().getTime())); //Alert.show(""redirectpath=""+dfltRedirectPath+sessionID+"".redirect.txt""+""&time=""+Number(new Date().getTime())); } else { urRedirect.data = new URLVariables(""redirectpath=""+dfltRedirectPath+""redirect.txt""+""&time=""+Number(new Date().getTime())); //Alert.show(""redirectpath=""+dfltRedirectPath+""redirect.txt""+""&time=""+Number(new Date().getTime())); } //urRedirect.data = new URLVariables(""redirectpath=""+dfltRedirectPath+""&time=""+Number(new Date().getTime())); loaderRedirect = new URLLoader(); loaderRedirect.load(urRedirect); loaderRedirect.addEventListener(Event.COMPLETE, setRedirect); } private function setRedirect(ev:Event):void { //var redirectItem:Item = null; //Alert.show(loaderRedirect.data); var redirectItemArray:Array = null; var lines:Array = String(loaderRedirect.data).split(""\\n""); var words:Array; var urlString:String; var patern:RegExp = new RegExp(""\\\\(redirect.\\\\d+\\\\)""); var numPatern:RegExp = new RegExp(""\\\\d+""); for each (var devXML: XML in clickEventXml.descendants(""doubleClick"").descendants(""dev"")) { devXML.@DevIconUrlIdx = ""-1""; devXML.@StatusIconUrlIdx = ""-1""; devXML.@attackUrlIdx = ""-1""; if(""Edge"" == devXML.@type) { if(String(devXML.@EdgeUrl).length != 0) { this.edgeUrlFmt = devXML.@EdgeUrl; } } if(String(devXML.@DevIconUrl).length != 0) { urlString = devXML.@DevIconUrl; if(urlString.search(patern) != -1) { var urlIdx:int = ((String)(urlString.match(patern))).match(numPatern); devXML.@DevIconUrlIdx = urlIdx.toString(); } } if(String(devXML.@StatusIconUrl).length != 0) { urlString = devXML.@StatusIconUrl; if(urlString.search(patern) != -1) { var urlIdx:int = ((String)(urlString.match(patern))).match(numPatern); devXML.@StatusIconUrlIdx = urlIdx.toString(); } } if(String(devXML.@attackUrl).length != 0) { urlString = devXML.@attackUrl; if(urlString.search(patern) != -1) { var urlIdx:int = ((String)(urlString.match(patern))).match(numPatern); devXML.@attackUrlIdx = urlIdx.toString(); } } } for each (var line: String in lines) { words = line.split(""\\t""); if(words[0] == ""ip"") redirectItemArray = super.dataProvider.findItemArrayByIP(words[1]); else if(words[0] == ""idx"") redirectItemArray = super.dataProvider.findItemArrayByIdx(words[1]); else if(words[0] == ""name"") { redirectItemArray = super.dataProvider.findItemArrayByName(words[1]); } else redirectItemArray = null; if(redirectItemArray!=null) { for each (var redirectItem:Item in redirectItemArray) { redirectItem.redirectWords = words; for each (var devXML: XML in clickEventXml.descendants(""doubleClick"").descendants(""dev"")) { if(((String(devXML.@ip).length == 0) && (redirectItem.data.@nodeType == devXML.@type)) || ((String(devXML.@ip).length != 0) && (redirectItem.data.@ip == devXML.@ip) && (redirectItem.data.@nodeType == devXML.@type))) { var idx:int; idx = devXML.@DevIconUrlIdx; if((idx != -1) && (words.length >= idx+3)) redirectItem.devPath = words[idx+2]; else redirectItem.devPath = ""none""; idx = devXML.@StatusIconUrlIdx; if((idx != -1) && (words.length >= idx+3)) redirectItem.statePath = words[idx+2]; else redirectItem.statePath = ""none""; idx = devXML.@attackUrlIdx; if((idx != -1) && (words.length >= idx+3)) redirectItem.atkLinkPath = words[idx+2]; else redirectItem.atkLinkPath = ""none""; } } } } /* if(words[0] == ""ip"") redirectItemArray = fullGraphRmVlan.findItemArrayByIP(words[1]); else if(words[0] == ""idx"") redirectItemArray = fullGraphRmVlan.findItemArrayByIdx(words[1]); else if(words[0] == ""name"") { redirectItemArray = fullGraphRmVlan.findItemArrayByName(words[1].toString()); } else redirectItemArray = null; if(redirectItemArray!=null) { for each (var redirectItem:Item in redirectItemArray) { redirectItem.redirectWords = words; for each (var devXML: XML in clickEventXml.descendants(""doubleClick"").descendants(""dev"")) { if(((String(devXML.@ip).length == 0) && (redirectItem.data.@nodeType == devXML.@type)) || ((String(devXML.@ip).length != 0) && (redirectItem.data.@ip == devXML.@ip) && (redirectItem.data.@nodeType == devXML.@type))) { var idx:int; idx = devXML.@DevIconUrlIdx; if((idx != -1) && (words.length >= idx+3)) redirectItem.devPath = words[idx+2]; else redirectItem.devPath = ""none""; idx = devXML.@StatusIconUrlIdx; if((idx != -1) && (words.length >= idx+3)) redirectItem.statePath = words[idx+2]; else redirectItem.statePath = ""none""; idx = devXML.@attackUrlIdx; if((idx != -1) && (words.length >= idx+3)) redirectItem.atkLinkPath = words[idx+2]; else redirectItem.atkLinkPath = ""none""; } } } } */ } loaderRedirect.close(); refreshAttack(); refresStatus(); } public function refreshAttack():void { //Alert.show(""refreshAttack""); urAttack.url = dfltPHPDIR + ""atkProxy.php""; urAttack.method = URLRequestMethod.GET; urAttack.requestHeaders.push(header); urAttack.data = new URLVariables(""atkpath=""+dfltAtkPath+""&time=""+Number(new Date().getTime())); loaderAttack = new URLLoader(); loaderAttack.load(urAttack); loaderAttack.addEventListener(Event.COMPLETE, parseAttack); } private function parseAttack(ev:Event):void { var isSrc:Boolean; var isVictim:Boolean; var attackSrcItem:Item = null; var atkSrcArrayA: Object = new Object(); var atkSrcArrayB: Object = new Object(); var attackVictimItem:Item = null; attackXml = new XML(loaderAttack.data); this.clearAttack(); for each (var attackSrc: XML in attackXml.descendants(""ATTACK_SRC"")) { attackSrcItem = super.dataProvider.findByIP(attackSrc.@ip); //Alert.show(""find source ""+ attackSrc.@ip + "" result "" + (attackSrcItem==null).toString()); if(attackSrcItem!=null) { attackSrcItem.attackSrcID = attackSrc.@id; atkSrcArrayA[attackSrc.@id] = attackSrcItem; attackSrcItem.atkXML = attackSrc; } /* attackSrcItem = fullGraphRmVlan.findByIP(attackSrc.@ip); if(attackSrcItem!=null) { attackSrcItem.attackSrcID = attackSrc.@id; atkSrcArrayB[attackSrc.@id] = attackSrcItem; attackSrcItem.atkXML = attackSrc; } */ } for each (var attackVictim: XML in attackXml.descendants(""ATTACK_VICTIM"")) { attackVictimItem = super.dataProvider.findByIP(attackVictim.@ip); //Alert.show(""find victim ""+ attackVictim.@ip + "" result "" + (attackVictimItem==null).toString()); if(attackVictimItem!=null) { attackVictimItem.attackVictimID = attackVictim.@id; if(atkSrcArrayA.hasOwnProperty(attackVictim.@id)) { super.dataProvider.setAttackPath(atkSrcArrayA[attackVictim.@id], attackVictimItem, attackVictim.@id, rmVlan, rmGroup); } attackVictimItem.atkXML = attackVictim; } /* attackVictimItem = fullGraphRmVlan.findByIP(attackVictim.@ip); if(attackVictimItem!=null) { attackVictimItem.attackVictimID = attackVictim.@id; if(atkSrcArrayB.hasOwnProperty(attackVictim.@id)) { fullGraphRmVlan.setAttackPathRmVlan(atkSrcArrayB[attackVictim.@id], attackVictimItem, attackVictim.@id); } attackVictimItem.atkXML = attackVictim; } */ } for each (var attackIsoSrc: XML in attackXml.descendants(""ATTACK_ISO_SRC"")) { attackSrcItem = super.dataProvider.findByIP(attackIsoSrc.@ip); if(attackSrcItem!=null) { attackSrcItem.attackSrcID = -1; attackSrcItem.atkXML = attackIsoSrc; } /* attackSrcItem = fullGraphRmVlan.findByIP(attackIsoSrc.@ip); if(attackSrcItem!=null) { attackSrcItem.attackSrcID = -1; attackSrcItem.atkXML = attackIsoSrc; } */ } this.reDrawAttack(); loaderAttack.close(); } public function refresStatus():void { urStatus.url = dfltPHPDIR + ""statusProxy.php""; urStatus.method = URLRequestMethod.GET; urStatus.requestHeaders.push(header); urStatus.data = new URLVariables(""statuspath=""+dfltStatusPath+""&time=""+Number(new Date().getTime())); loaderStatus = new URLLoader(); loaderStatus.load(urStatus); loaderStatus.addEventListener(Event.COMPLETE, parseStatus); } private function parseStatus(ev:Event):void { var statusItem:Item = null; var lines:Array = String(loaderStatus.data).split(""\\n""); var words:Array; //Alert.show(""refreshStatus""); this.clearStatus(); for each (var line: String in lines) { words = line.split("",""); if(words[2] == ""name"") statusItem = super.dataProvider.findByName(words[0]); else statusItem = super.dataProvider.findByIP(words[0]); if(statusItem!=null) { statusItem.status = words[1]; } /* statusItem = fullGraphRmVlan.findByIP(words[0]); if(statusItem!=null) { statusItem.status = words[1]; } */ } this.reDrawStatus(); loaderStatus.close(); checkAndPlaySnd(); } public function refreshRate():void { urTreeParser.url = dfltPHPDIR + ""treeParser.php""; urTreeParser.method = URLRequestMethod.GET; urTreeParser.requestHeaders.push(header); urTreeParser.data = new URLVariables(""treepath=""+dfltTreePath+""&mrtgpath=""+dfltMrtgPathPHPView+""&output=tree""+roamerIdx+"".xml""+""&encoding=""+dfltEncoding+""&time=""+Number(new Date().getTime())); loaderTreeParser = new URLLoader(); loaderTreeParser.load(urTreeParser); loaderTreeParser.addEventListener(Event.COMPLETE, loadRate); } private function loadRate(ev:Event):void { var resultStr:String = loaderTreeParser.data; if(resultStr.substr(0,8) == ""Complete"") { urTreeXML.method = URLRequestMethod.GET; urTreeXML.requestHeaders.push(header); urTreeXML.url = dfltPHPDIR + ""tree""+roamerIdx+"".xml""; urTreeXML.data = new URLVariables(""time=""+Number(new Date().getTime())); ulTreeXML = new URLLoader(); ulTreeXML.dataFormat = URLLoaderDataFormat.BINARY; ulTreeXML.load(urTreeXML); ulTreeXML.addEventListener(Event.COMPLETE, refreshLine); } loaderTreeParser.close(); } public function refreshLine(ev:Event):void { var textTmp:String = ulTreeXML.data.readMultiByte(ulTreeXML.data.length, lang); treeXml = new XML(textTmp); ulTreeXML.close(); urTreeParser.url = dfltPHPDIR + ""lineParser.php""; urTreeParser.method = URLRequestMethod.GET; urTreeParser.requestHeaders.push(header); urTreeParser.data = new URLVariables(""linepath=""+dfltLinePath+""&mrtgpath=""+dfltMrtgPathPHPView+""&output=line""+roamerIdx+"".xml""+""&encoding=""+dfltEncoding+""&time=""+Number(new Date().getTime())); loaderTreeParser = new URLLoader(); loaderTreeParser.load(urTreeParser); loaderTreeParser.addEventListener(Event.COMPLETE, loadLine); } private function loadLine(ev:Event):void { var resultStr:String = loaderTreeParser.data; if(resultStr.substr(0,8) == ""Complete"") { urTreeXML.url = dfltPHPDIR + ""line""+roamerIdx+"".xml"" urTreeXML.method = URLRequestMethod.GET; urTreeXML.requestHeaders.push(header); urTreeXML.data = new URLVariables(""time=""+Number(new Date().getTime())); ulTreeXML = new URLLoader(); ulTreeXML.dataFormat = URLLoaderDataFormat.BINARY; ulTreeXML.load(urTreeXML); ulTreeXML.addEventListener(Event.COMPLETE, updateRate); } loaderTreeParser.close(); } private function updateRate(ev:Event):void { var textTmp:String = ulTreeXML.data.readMultiByte(ulTreeXML.data.length, lang); var nodesTmp: Object; var itemTmp : Item; lineXml = new XML(textTmp); doRecordLocation(); locationXml = new XML(locationLog); //nodesTmp = fullGraphWithVlan.nodes(); //fullGraphWithVlan.updateFromXML(treeXml, lineXml, null, rmVlan, rmGroup, rmLine, _currentItem.id); //this.dataProvider.updateFromXML(treeXml, lineXml, null, rmVlan, rmGroup, rmLine, _currentItem.id); //doSetDataProvider(fullGraphWithVlan); //this.reDrawCurrent(); //this.drawEdges(); updateCurrentItem( _currentItem.id); /* var nodes: Array = _dataProvider.getAllNodes(); for each (var node: Node in nodes) { if((GraphNode)(node).item.specialAlpha != 0) (GraphNode)(node).view.alpha = (GraphNode)(node).item.specialAlpha; else (GraphNode)(node).view.alpha = this.alphaLog; } */ ulTreeXML.close(); } ///// -------- private ------------ private function doSetDataProvider(g: Graph): void { empty(); setFullGraph(g); dispatchEvent(new Event(""dataProviderChange"")); } private function setFullGraph(g: Graph): void { fullGraph = g; resetHistory(); newCurrentItem(g.distinguishedItem); dispatchEvent(new Event(""currentItemChange"")); recreateGraph(); } private function addNodes(newNodes: Array, g: Graph): Object { var newItems: Object = []; var item: Item; var i: int; var id: String; for (id in newNodes) { if(!g.hasNode(id)) { item = fullGraph.find(id); g.add(item); newItems[item.id] = item; } } for (id in newItems) { item = newItems[id] as Item; var neighbors: Object = fullGraph.neighbors(item.id); for(var neighborId: String in neighbors) { if(g.hasNode(neighborId)) { g.link(item, g.find(neighborId)); } } } return newItems; } public function reDrawCurrent():void { recreateGraph(); } private function recreateGraph(): void { var g: Graph = new Graph(); if(_currentItem != null) { fullGraph.clearNumShowChild(); itemCount = 0; addToGraph(_currentItem, 1, g); } _visibleHistoryItems = null; if(_showHistory) { _visibleHistoryItems = addNodes(allCurrentItems, g); } if(forceVisible != null) { addNodes(forceVisible, g); } if(forceInvisible != null) { for (var i: Number = 0; i < forceInvisible.length; i++) { var item: Item = forceInvisible[i] as Item; g.remove(item); } } if(_tidyHistory) doTidyHistory(_visibleHistoryItems, g); super.dataProvider = g; dispatchEvent(new Event(""change"")); dispatchEvent(new Event(""visibleHistoryItemsChange"")); } private static var historySeed: Item = new HistorySeed(); private function doTidyHistory(addedItems: Object, g: Graph): void { if(addedItems == null) return; var historyItemAdded: Boolean = false; var historyItemLinks: int = 0; for (var id: String in addedItems) { var addedItem: Item = addedItems[id] as Item; var neighbors: Object = g.neighbors(id); var connectedToGraph: Boolean = false; for(var neighborID: String in neighbors) { if(!addedItems.hasOwnProperty(neighborID)) { connectedToGraph = true; break; } } if(!connectedToGraph) { if(!historyItemAdded) { g.add(historySeed); historyItemAdded = true; } g.link(addedItem, historySeed, {settings: {alpha: 0, color: 0x0000dd, thickness: 0}}); historyItemLinks++; } } //if(historyItemAdded && (historyItemLinks < 2)) { // g.remove(historySeed); //} } private function arrayIncludes(list: Object, item: Object): Boolean { var result: Boolean = list.hasOwnProperty(item.id); return result; } private function addToGraph(item: Item, generation: int, graph: Graph): Number { var data1:Object; var data2:Object; if(itemCount >= _itemLimit) return 0; //0 = stop if(graph.find(item.id) != null) { return 1; //1= skip and continue } itemCount ++; graph.add(item); if(_skipItem != null && item.id == _skipItem.id) { return 1; //1= skip and continue } if(item.parentItem != null) { item.parentItem.numShownChild ++; } var neighbors: Object = fullGraph.neighbors(item.id); for(var neighborId: String in neighbors) { var neighbor: Item = fullGraph.find(neighborId) if(neighbor.id.length/3 <= _maxDistanceFromCurrent) { if(addToGraph(neighbor, neighbor.id.length/3, graph) == 0) return 2; //2= success, go on data1 = fullGraph.getLinkData(item, neighbor); data2 = fullGraph.getLinkData(neighbor, item); graph.linkDoubleColor(item, neighbor, data1, data2); } } return 2; //2= success, go on } private function newCurrentItem(item: Item): void { _currentItem = item; if(item != null) { allCurrentItems[item.id] = true; //if(historyCurrentlyViewed < (_history.length - 1)) { // var temp: int = historyCurrentlyViewed + 1; // _history.splice(temp); //} _history.push(item); historyCurrentlyViewed = _history.length - 1; dispatchEvent(new Event(""historyChange"")); } } private var _currentItem: Item; private var _skipItem: Item = null; private var _itemLimit: int = 50; public var fullGraphWithVlan: Graph; //public var fullGraphRmVlan: Graph; private var _maxDistanceFromCurrent: int; private var itemCount: int; private var allCurrentItems: Array = new Array(); private var _showHistory: Boolean = false; private var _history: Array = new Array(); private var historyCurrentlyViewed: int = -1; private var _visibleHistoryItems: Object = null; private var _tidyHistory: Boolean = true; } } ",16361,True,2993.535978535755,median "CLASS zcl_abapgit_gui_page_repo_view DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_hotkeys . CONSTANTS: BEGIN OF c_actions, repo_list TYPE string VALUE 'abapgit_home' ##NO_TEXT, change_dir TYPE string VALUE 'change_dir' ##NO_TEXT, toggle_hide_files TYPE string VALUE 'toggle_hide_files' ##NO_TEXT, toggle_folders TYPE string VALUE 'toggle_folders' ##NO_TEXT, toggle_changes TYPE string VALUE 'toggle_changes' ##NO_TEXT, toggle_diff_first TYPE string VALUE 'toggle_diff_first ' ##NO_TEXT, display_more TYPE string VALUE 'display_more' ##NO_TEXT, go_data TYPE string VALUE 'go_data', END OF c_actions . METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RAISING zcx_abapgit_exception . METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION . PROTECTED SECTION. METHODS render_content REDEFINITION. PRIVATE SECTION. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mo_repo_aggregated_state TYPE REF TO zcl_abapgit_item_state. DATA mv_cur_dir TYPE string . DATA mv_hide_files TYPE abap_bool . DATA mv_max_lines TYPE i . DATA mv_max_setting TYPE i . DATA mv_show_folders TYPE abap_bool . DATA mv_changes_only TYPE abap_bool . DATA mv_order_by TYPE string . DATA mv_order_descending TYPE abap_bool . DATA mv_diff_first TYPE abap_bool . DATA mv_key TYPE zif_abapgit_persistence=>ty_value . DATA mv_are_changes_recorded_in_tr TYPE abap_bool . METHODS render_head_line RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_head_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_view_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS render_item IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item !iv_render_transports TYPE abap_bool RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_item_files IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_item_command IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_file_command IMPORTING !is_file TYPE zif_abapgit_definitions=>ty_repo_file RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS get_item_class IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item iv_is_object_row TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rv_html) TYPE string . METHODS get_item_icon IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS render_item_transport IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_parent_dir RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_obj_jump_link IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS build_dir_jump_link IMPORTING !iv_path TYPE string RETURNING VALUE(rv_html) TYPE string . METHODS build_inactive_object_code IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_inactive_html_code) TYPE string . METHODS open_in_main_language RAISING zcx_abapgit_exception . METHODS render_order_by RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS apply_order_by CHANGING !ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt . METHODS build_branch_dropdown RETURNING VALUE(ro_branch_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_tag_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_tag_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_advanced_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_advanced_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_toolbar IMPORTING !iv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout !io_tb_branch TYPE REF TO zcl_abapgit_html_toolbar !io_tb_tag TYPE REF TO zcl_abapgit_html_toolbar !io_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS is_repo_lang_logon_lang RETURNING VALUE(rv_repo_lang_is_logon_lang) TYPE abap_bool . METHODS get_abapgit_tcode RETURNING VALUE(rv_tcode) TYPE tcode . METHODS render_item_changed_by IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception. METHODS order_files CHANGING ct_files TYPE zif_abapgit_definitions=>ty_repo_file_tt. ENDCLASS. CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW IMPLEMENTATION. METHOD apply_order_by. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort, lt_non_code_and_metadata_items LIKE ct_repo_items, lt_code_items LIKE ct_repo_items, lt_diff_items LIKE ct_repo_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_repo_item. IF mv_order_by IS INITIAL. RETURN. ENDIF. "" we want to preserve non-code and metadata files at the top, "" so we isolate them and and sort only the code artifacts LOOP AT ct_repo_items ASSIGNING . IF -obj_type IS INITIAL AND -is_dir = abap_false. INSERT INTO TABLE lt_non_code_and_metadata_items. ELSE. INSERT INTO TABLE lt_code_items. ENDIF. ENDLOOP. IF mv_diff_first = abap_true. "" fix diffs on the top, right after non-code and metadata LOOP AT lt_code_items ASSIGNING WHERE changes > 0. INSERT INTO TABLE lt_diff_items. ENDLOOP. DELETE lt_code_items WHERE changes > 0. ENDIF. CLEAR: ct_repo_items. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. ls_sort-name = mv_order_by. INSERT ls_sort INTO TABLE lt_sort. "" Combine state fields for order of 'Status' column IF mv_order_by = 'LSTATE'. ls_sort-name = 'RSTATE'. INSERT ls_sort INTO TABLE lt_sort. ENDIF. IF mv_order_by = 'TRANSPORT'. ls_sort-name = 'OBJ_NAME'. INSERT ls_sort INTO TABLE lt_sort. ENDIF. SORT lt_code_items STABLE BY (lt_sort). SORT lt_diff_items STABLE BY (lt_sort). INSERT LINES OF lt_non_code_and_metadata_items INTO TABLE ct_repo_items. INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items. INSERT LINES OF lt_code_items INTO TABLE ct_repo_items. IF mv_order_by = 'TRANSPORT'. LOOP AT ct_repo_items ASSIGNING . order_files( CHANGING ct_files = -files ). ENDLOOP. ENDIF. ENDMETHOD. METHOD build_advanced_dropdown. DATA: lv_crossout LIKE zif_abapgit_html=>c_html_opt-crossout. CREATE OBJECT ro_advanced_dropdown. IF mo_repo_aggregated_state->is_unchanged( ) = abap_false. "" In case of asyncronicities ro_advanced_dropdown->add( iv_txt = 'Selective Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_reset }?key={ mv_key }| iv_opt = iv_wp_opt ). ENDIF. IF mo_repo->is_offline( ) = abap_false. "" Online ? ro_advanced_dropdown->add( iv_txt = 'Force Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-transport_to_branch ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Transport to Branch' iv_act = |{ zif_abapgit_definitions=>c_action-repo_transport_to_branch }?key={ mv_key }| iv_opt = lv_crossout ). ENDIF. IF mv_are_changes_recorded_in_tr = abap_true. ro_advanced_dropdown->add( iv_txt = 'Add All Objects to Transport' iv_act = |{ zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req }?key={ mv_key }| ). ENDIF. IF mo_repo->is_offline( ) = abap_true. ro_advanced_dropdown->add( iv_txt = 'Export by Transport' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export_transport }?key={ mv_key }| ). ELSE. ro_advanced_dropdown->add( iv_txt = 'Stage by Transport' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage_transport }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Syntax Check' iv_act = |{ zif_abapgit_definitions=>c_action-repo_syntax_check }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Run Code Inspector' iv_act = |{ zif_abapgit_definitions=>c_action-repo_code_inspector }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-update_local_checksum ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Update Local Checksums' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh_checksums }?key={ mv_key }| iv_opt = lv_crossout ). ro_advanced_dropdown->add( iv_txt = 'Beta - Data' iv_act = |{ c_actions-go_data }?key={ mv_key }| iv_opt = lv_crossout ). IF is_repo_lang_logon_lang( ) = abap_false AND get_abapgit_tcode( ) IS NOT INITIAL. ro_advanced_dropdown->add( iv_txt = 'Open in Main Language' iv_act = |{ zif_abapgit_definitions=>c_action-repo_open_in_master_lang }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Remove' iv_title = `Remove abapGit's records of the repository (the system's ` && `development objects will remain unaffected)` iv_act = |{ zif_abapgit_definitions=>c_action-repo_remove }?key={ mv_key }| ). CLEAR lv_crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true OR zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-uninstall ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Uninstall' iv_title = `Delete all development objects belonging to this package ` && `(and subpackages) from the system` iv_act = |{ zif_abapgit_definitions=>c_action-repo_purge }?key={ mv_key }| iv_opt = lv_crossout ). ENDMETHOD. METHOD build_branch_dropdown. CREATE OBJECT ro_branch_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_branch_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_switch }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_create }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_delete }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Merge' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_merge }?key={ mv_key }| ). ENDMETHOD. METHOD build_dir_jump_link. DATA lv_path TYPE string. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_path = iv_path. REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''. lv_encode = zcl_abapgit_html_action_utils=>dir_encode( lv_path ). "" remove leading and trailing / for display IF lv_path <> '/'. IF lv_path(1) = '/'. lv_path = lv_path+1. ENDIF. IF substring( val = reverse( lv_path ) len = 1 ) = '/'. lv_path = substring( val = lv_path len = strlen( lv_path ) - 1 ). ENDIF. ENDIF. rv_html = li_html->a( iv_txt = lv_path iv_act = |{ c_actions-change_dir }?{ lv_encode }| ). ENDMETHOD. METHOD build_head_menu. DATA: lo_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_branch TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_tag TYPE REF TO zcl_abapgit_html_toolbar, lv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout, lv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true. lv_wp_opt = zif_abapgit_html=>c_html_opt-crossout. lv_pull_opt = zif_abapgit_html=>c_html_opt-crossout. ELSE. lv_pull_opt = zif_abapgit_html=>c_html_opt-strong. ENDIF. lo_tb_branch = build_branch_dropdown( ). lo_tb_tag = build_tag_dropdown( lv_wp_opt ). lo_tb_advanced = build_advanced_dropdown( iv_wp_opt = lv_wp_opt ). ro_toolbar = build_main_toolbar( iv_pull_opt = lv_pull_opt io_tb_branch = lo_tb_branch io_tb_tag = lo_tb_tag io_tb_advanced = lo_tb_advanced ). ENDMETHOD. METHOD build_inactive_object_code. IF is_item-inactive = abap_true. rv_inactive_html_code = zcl_abapgit_html=>icon( iv_name = 'bolt/orange' iv_hint = 'Object or object part is inactive' iv_class = 'inactive' ). ENDIF. ENDMETHOD. METHOD build_main_menu. CREATE OBJECT ro_menu EXPORTING iv_id = 'toolbar-main'. ro_menu->add( iv_txt = zcl_abapgit_gui_buttons=>repo_list( ) iv_act = zif_abapgit_definitions=>c_action-abapgit_home )->add( iv_txt = zcl_abapgit_gui_buttons=>help( ) iv_title = 'Help' io_sub = zcl_abapgit_gui_chunk_lib=>help_submenu( ) ). ENDMETHOD. METHOD build_main_toolbar. DATA: li_log TYPE REF TO zif_abapgit_log. CREATE OBJECT ro_toolbar EXPORTING iv_id = 'toolbar-repo'. IF mo_repo->is_offline( ) = abap_false. IF mo_repo_aggregated_state->remote( ) IS NOT INITIAL OR mo_repo_aggregated_state->is_reassigned( ) = abap_true. "" Something new at remote ro_toolbar->add( iv_txt = 'Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = iv_pull_opt ). ENDIF. IF mo_repo_aggregated_state->local( ) IS NOT INITIAL. "" Something new at local ro_toolbar->add( iv_txt = 'Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. IF mo_repo_aggregated_state->is_unchanged( ) = abap_false. "" Any changes ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ro_toolbar->add( iv_txt = 'Branch' io_sub = io_tb_branch ). ro_toolbar->add( iv_txt = 'Tag' io_sub = io_tb_tag ). ELSE. IF mo_repo->has_remote_source( ) = abap_true AND mo_repo_aggregated_state->remote( ) IS NOT INITIAL. ro_toolbar->add( iv_txt = 'Pull zip' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Import zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_import }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). IF mo_repo->get_local_settings( )-write_protected = abap_true. ro_toolbar->add( iv_txt = 'Compare rfc' iv_act = |{ zif_abapgit_definitions=>c_action-rfc_compare }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Export zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ENDIF. ro_toolbar->add( iv_txt = 'Advanced' io_sub = io_tb_advanced ). ro_toolbar->add( iv_txt = 'View' io_sub = build_view_menu( ) ). ro_toolbar->add( iv_txt = 'Refresh' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Settings' iv_act = |{ zif_abapgit_definitions=>c_action-repo_settings }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong iv_title = `Repository Settings` ). ENDMETHOD. METHOD build_obj_jump_link. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_encode = zcl_abapgit_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type iv_obj_name = is_item-obj_name ). rv_html = li_html->a( iv_txt = |{ is_item-obj_name }| iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). ENDMETHOD. METHOD build_tag_dropdown. CREATE OBJECT ro_tag_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_tag_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_tag_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_create }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_delete }?key={ mv_key }| ). ENDMETHOD. METHOD build_view_menu. CREATE OBJECT ro_toolbar. ro_toolbar->add( iv_txt = 'Changes First' iv_chk = mv_diff_first iv_act = c_actions-toggle_diff_first ). ro_toolbar->add( iv_txt = 'Changes Only' iv_chk = mv_changes_only iv_act = c_actions-toggle_changes ). ro_toolbar->add( iv_txt = 'File Paths' iv_chk = boolc( NOT mv_hide_files = abap_true ) iv_act = c_actions-toggle_hide_files ). ro_toolbar->add( iv_txt = 'Folders' iv_chk = mv_show_folders iv_act = c_actions-toggle_folders ). ENDMETHOD. METHOD constructor. DATA: lo_settings TYPE REF TO zcl_abapgit_settings, lx_error TYPE REF TO zcx_abapgit_exception, lo_persistence_user TYPE REF TO zif_abapgit_persist_user. super->constructor( ). TRY. lo_persistence_user = zcl_abapgit_persistence_user=>get_instance( ). mv_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). mv_cur_dir = '/'. "" Root mv_hide_files = lo_persistence_user->get_hide_files( ). mv_changes_only = lo_persistence_user->get_changes_only( ). mv_order_by = lo_persistence_user->get_order_by( ). mv_order_descending = lo_persistence_user->get_order_descending( ). mv_diff_first = lo_persistence_user->get_diff_first( ). mv_show_folders = lo_persistence_user->get_show_folders( ). ms_control-page_title = 'Repository'. ms_control-page_menu = build_main_menu( ). "" Read global settings to get max # of objects to be listed lo_settings = zcl_abapgit_persist_factory=>get_settings( )->read( ). mv_max_lines = lo_settings->get_max_lines( ). mv_max_setting = mv_max_lines. CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). RAISE EXCEPTION lx_error. ENDTRY. ENDMETHOD. METHOD get_abapgit_tcode. CONSTANTS: lc_report_tcode_hex TYPE x VALUE '80'. DATA: lt_tcodes TYPE STANDARD TABLE OF tcode. SELECT tcode FROM tstc INTO TABLE lt_tcodes WHERE pgmna = sy-cprog AND cinfo = lc_report_tcode_hex. IF lines( lt_tcodes ) > 0. READ TABLE lt_tcodes INDEX 1 INTO rv_tcode. ENDIF. ENDMETHOD. METHOD get_item_class. DATA lt_class TYPE TABLE OF string. IF iv_is_object_row = abap_true. APPEND 'object_row' TO lt_class. ELSE. APPEND 'file_row' TO lt_class. ENDIF. IF is_item-is_dir = abap_true. APPEND 'folder' TO lt_class. ELSEIF is_item-changes > 0. APPEND 'modified' TO lt_class. ELSEIF is_item-obj_name IS INITIAL. APPEND 'unsupported' TO lt_class. ENDIF. IF lines( lt_class ) > 0. rv_html = | class=""{ concat_lines_of( table = lt_class sep = ` ` ) }""|. ENDIF. ENDMETHOD. METHOD get_item_icon. CASE is_item-obj_type. WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' iv_hint = 'Code' ). WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' iv_hint = 'Binary' ). WHEN 'DEVC'. rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' iv_hint = 'Package' ). WHEN ''. rv_html = space. "" no icon WHEN OTHERS. rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). ENDCASE. IF is_item-is_dir = abap_true. rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' iv_hint = 'Folder' ). ENDIF. ENDMETHOD. METHOD is_repo_lang_logon_lang. rv_repo_lang_is_logon_lang = boolc( mo_repo->get_dot_abapgit( )->get_main_language( ) = sy-langu ). ENDMETHOD. METHOD open_in_main_language. DATA: lv_main_language TYPE spras, lt_spagpa TYPE STANDARD TABLE OF rfc_spagpa, ls_spagpa LIKE LINE OF lt_spagpa, ls_item TYPE zif_abapgit_definitions=>ty_item, lv_subrc TYPE syst-subrc, lv_save_sy_langu TYPE sy-langu, lv_tcode TYPE tcode. "" https://blogs.sap.com/2017/01/13/logon-language-sy-langu-and-rfc/ lv_main_language = mo_repo->get_dot_abapgit( )->get_main_language( ). lv_tcode = get_abapgit_tcode( ). ASSERT lv_tcode IS NOT INITIAL. IF lv_main_language = sy-langu. zcx_abapgit_exception=>raise( |Repo already opened in main language| ). ENDIF. ls_item-obj_name = lv_tcode. ls_item-obj_type = |TRAN|. IF zcl_abapgit_objects=>exists( ls_item ) = abap_false. zcx_abapgit_exception=>raise( |Please install the abapGit repository| ). ENDIF. lv_save_sy_langu = sy-langu. SET LOCALE LANGUAGE lv_main_language. ls_spagpa-parid = zif_abapgit_definitions=>c_spagpa_param_repo_key. ls_spagpa-parval = mo_repo->get_key( ). INSERT ls_spagpa INTO TABLE lt_spagpa. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' DESTINATION 'NONE' STARTING NEW TASK 'ABAPGIT' EXPORTING tcode = lv_tcode TABLES spagpa_tab = lt_spagpa EXCEPTIONS call_transaction_denied = 1 tcode_invalid = 2 communication_failure = 3 system_failure = 4 OTHERS = 5. lv_subrc = sy-subrc. SET LOCALE LANGUAGE lv_save_sy_langu. IF lv_subrc <> 0. zcx_abapgit_exception=>raise( |Error from ABAP4_CALL_TRANSACTION. Subrc = { lv_subrc }| ). ENDIF. MESSAGE 'Repository opened in a new window' TYPE 'S'. ENDMETHOD. METHOD order_files. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort. IF lines( ct_files ) = 0. RETURN. ENDIF. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. ls_sort-name = 'TRANSPORT'. INSERT ls_sort INTO TABLE lt_sort. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. ls_sort-name = 'FILENAME'. INSERT ls_sort INTO TABLE lt_sort. SORT ct_files STABLE BY (lt_sort). ENDMETHOD. METHOD render_content. DATA: lt_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt, lo_browser TYPE REF TO zcl_abapgit_repo_content_list, lx_error TYPE REF TO zcx_abapgit_exception, lv_max TYPE abap_bool, lv_max_str TYPE string, lv_add_str TYPE string, li_log TYPE REF TO zif_abapgit_log, lv_msg TYPE string, lo_news TYPE REF TO zcl_abapgit_news. FIELD-SYMBOLS LIKE LINE OF lt_repo_items. gui_services( )->get_hotkeys_ctl( )->register_hotkeys( zif_abapgit_gui_hotkeys~get_hotkey_actions( ) ). gui_services( )->register_event_handler( me ). CREATE OBJECT mo_repo_aggregated_state. TRY. "" Reinit, for the case of type change mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( mo_repo->get_key( ) ). mv_are_changes_recorded_in_tr = zcl_abapgit_factory=>get_sap_package( mo_repo->get_package( ) )->are_changes_recorded_in_tr_req( ). lo_news = zcl_abapgit_news=>create( mo_repo ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo io_news = lo_news iv_show_edit = abap_true iv_interactive_branch = abap_true ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_news( io_news = lo_news ) ). zcl_abapgit_exit=>get_instance( )->wall_message_repo( is_repo_meta = mo_repo->ms_data ii_html = ri_html ). CREATE OBJECT lo_browser EXPORTING io_repo = mo_repo. lt_repo_items = lo_browser->list( iv_path = mv_cur_dir iv_by_folders = mv_show_folders iv_changes_only = mv_changes_only ). apply_order_by( CHANGING ct_repo_items = lt_repo_items ). LOOP AT lt_repo_items ASSIGNING . mo_repo_aggregated_state->sum_with_repo_item( ). ENDLOOP. ri_html->add( render_head_line( ) ). li_log = lo_browser->get_log( ). IF li_log->count( ) > 0. ri_html->add( '
' ). ri_html->add( zcl_abapgit_log_viewer=>to_html( li_log ) ). "" shows eg. list of unsupported objects ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). CLEAR lv_msg. IF mo_repo->is_offline( ) = abap_true AND mo_repo->has_remote_source( ) = abap_true AND mo_repo_aggregated_state->is_unchanged( ) = abap_true. "" Offline match banner lv_msg = 'ZIP source is attached and completely matches the local state'. ELSEIF lines( lt_repo_items ) = 0. "" Online match banner IF mv_changes_only = abap_true. lv_msg = 'Local state completely matches the remote repository'. ELSE. lv_msg = |Package is empty. Show { build_dir_jump_link( 'parent' ) } package|. ENDIF. ELSE. "" Repo content table ri_html->add( '' ). ri_html->add( render_order_by( ) ). IF zcl_abapgit_path=>is_root( mv_cur_dir ) = abap_false. ri_html->add( render_parent_dir( ) ). ENDIF. LOOP AT lt_repo_items ASSIGNING . IF mv_max_lines > 0 AND sy-tabix > mv_max_lines. lv_max = abap_true. EXIT. "" current loop ENDIF. ri_html->add( render_item( is_item = iv_render_transports = mv_are_changes_recorded_in_tr ) ). ENDLOOP. IF mv_changes_only = abap_true. ri_html->add( `` ). ENDIF. ri_html->add( '
` ). ri_html->add( `(Only changes are shown. ` ). ri_html->add( ri_html->a( iv_txt = |Show All| iv_act = |{ c_actions-toggle_changes }| ) ). ri_html->add( `)
' ). ENDIF. IF NOT lv_msg IS INITIAL. ri_html->add( |
{ lv_msg }
| ). ENDIF. IF lv_max = abap_true. ri_html->add( '
' ). IF mv_max_lines = 1. lv_max_str = '1 object'. ELSE. lv_max_str = |first { mv_max_lines } objects|. ENDIF. lv_add_str = |+{ mv_max_setting }|. ri_html->add( |Only { lv_max_str } objects shown in list. Display { ri_html->a( iv_txt = lv_add_str iv_act = c_actions-display_more ) } more (change in Settings > { ri_html->a( iv_txt = 'Personal Settings' iv_act = zif_abapgit_definitions=>c_action-go_settings_personal ) })| ). ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). ri_html->add( render_head_line( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_error( iv_extra_style = 'repo_banner' ix_error = lx_error ) ). ENDTRY. register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_file_command. DATA: lv_difflink TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '
' ). IF is_file-is_changed = abap_true. lv_difflink = zcl_abapgit_html_action_utils=>file_encode( iv_key = mo_repo->get_key( ) ig_file = is_file ). ri_html->add_a( iv_txt = 'diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_file-lstate iv_rstate = is_file-rstate ) ). ELSE. ri_html->add( ' ' ). ENDIF. ri_html->add( '
' ). ENDMETHOD. METHOD render_head_line. DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar. CREATE OBJECT ri_html TYPE zcl_abapgit_html. lo_toolbar = build_head_menu( ). ri_html->add( '
' ). ri_html->add( '' ). IF mv_show_folders = abap_true. ri_html->add( '' ). ENDIF. ri_html->add( '' ). ri_html->add( '
' ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_path( mv_cur_dir ) ). ri_html->add( '' ). ri_html->add( lo_toolbar->render( iv_right = abap_true ) ). ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_item. DATA: lv_link TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( || ). IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false. ri_html->add( || && '' && 'non-code and meta files' && '' ). ELSE. ri_html->add( |{ get_item_icon( is_item ) }| ). IF is_item-is_dir = abap_true. "" Subdir lv_link = build_dir_jump_link( is_item-path ). ri_html->add( |{ lv_link }| ). ELSE. lv_link = build_obj_jump_link( is_item ). ri_html->add( |{ is_item-obj_type }| ). ri_html->add( |{ lv_link } { build_inactive_object_code( is_item ) }| ). ENDIF. ENDIF. "" Changed by ri_html->add( '' ). ri_html->add( render_item_changed_by( is_item ) ). ri_html->add( '' ). IF iv_render_transports = abap_true. ri_html->add( render_item_transport( is_item ) ). ENDIF. "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_item_command( is_item ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ri_html->add( render_item_files( is_item ) ). ENDMETHOD. METHOD render_item_changed_by. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-changes = 0 OR is_item-changed_by IS INITIAL. ri_html->add( ' ' ). ELSE. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_user_name( is_item-changed_by ) ). ENDIF. ENDMETHOD. METHOD render_item_command. DATA: lv_difflink TYPE string, ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-is_dir = abap_true. "" Directory ri_html->add( '
' ). ri_html->add( |{ is_item-changes } changes| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSEIF is_item-changes > 0. IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL. lv_difflink = zcl_abapgit_html_action_utils=>obj_encode( iv_key = mo_repo->get_key( ) ig_object = is_item ). ri_html->add( '
' ). ri_html->add_a( iv_txt = |diff ({ is_item-changes })| iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ENDIF. ENDIF. ENDMETHOD. METHOD render_item_files. DATA: ls_file LIKE LINE OF is_item-files. DATA li_exit TYPE REF TO zif_abapgit_exit. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF mv_hide_files = abap_true AND is_item-obj_type IS NOT INITIAL. RETURN. ENDIF. li_exit = zcl_abapgit_exit=>get_instance( ). LOOP AT is_item-files INTO ls_file. ri_html->add( || ). ri_html->add( || ). ri_html->add( || ). ri_html->add( || ). IF mv_show_folders = abap_true. ri_html->add( |
{ li_exit->adjust_display_filename( ls_file-filename ) }
| ). ELSE. ri_html->add( |
{ li_exit->adjust_display_filename( ls_file-path && ls_file-filename ) }
| ). ENDIF. ri_html->add( || ). "" Changed by (not applicable to file) ri_html->add( '' ). ri_html->add( '' ). "" Transport (not applicable to file) IF mv_are_changes_recorded_in_tr = abap_true. ri_html->add( `` ). ENDIF. "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_file_command( ls_file ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDLOOP. ENDMETHOD. METHOD render_item_transport. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, lv_transport TYPE trkorr. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ls_item-obj_type = is_item-obj_type. ls_item-obj_name = is_item-obj_name. TRY. lv_transport = zcl_abapgit_factory=>get_cts_api( )->get_transport_for_object( ls_item ). IF lv_transport IS NOT INITIAL. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport = lv_transport ) ). ENDIF. CATCH zcx_abapgit_exception ##NO_HANDLER. "" Ignore errors related to object check when trying to get transport ENDTRY. ri_html->add( '' ). ENDMETHOD. METHOD render_order_by. DATA: lv_icon TYPE string, lt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt, ls_col_spec TYPE zif_abapgit_definitions=>ty_col_spec. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" icon APPEND INITIAL LINE TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_TYPE'. ls_col_spec-display_name = 'Type'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_NAME'. ls_col_spec-display_name = 'Name'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'CHANGED_BY'. ls_col_spec-display_name = 'Changed by'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. IF mv_are_changes_recorded_in_tr = abap_true. ls_col_spec-tech_name = 'TRANSPORT'. ls_col_spec-display_name = 'Transport'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ENDIF. ls_col_spec-tech_name = 'LSTATE'. ls_col_spec-display_name = 'Status'. ls_col_spec-allow_order_by = abap_true. ls_col_spec-css_class = 'cmd'. APPEND ls_col_spec TO lt_col_spec. ri_html->add( || ). ri_html->add( || ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_order_by_header_cells( it_col_spec = lt_col_spec iv_order_by = mv_order_by iv_order_descending = mv_order_descending ) ). IF mv_diff_first = abap_true. lv_icon = 'check/blue'. ELSE. lv_icon = 'check/grey'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_parent_dir. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( |{ ri_html->icon( 'folder' ) }| ). ri_html->add( |{ build_dir_jump_link( '..' ) }| ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( || ). "" Dummy for online ENDIF. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_palette( iv_action = zif_abapgit_definitions=>c_action-go_repo ) ). ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA lv_path TYPE string. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-go_repo. "" Switch to another repo CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN c_actions-go_data. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_data EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_actions-toggle_hide_files. "" Toggle file diplay mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->toggle_hide_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-change_dir. "" Change dir lv_path = ii_event->query( )->get( 'PATH' ). mv_cur_dir = zcl_abapgit_path=>change_dir( iv_cur_dir = mv_cur_dir iv_cd = lv_path ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_folders. "" Toggle folder view mv_show_folders = zcl_abapgit_persistence_user=>get_instance( )->toggle_show_folders( ). mv_cur_dir = '/'. "" Root rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_changes. "" Toggle changes only view mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->toggle_changes_only( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_diff_first. mv_diff_first = zcl_abapgit_persistence_user=>get_instance( )->set_diff_first( boolc( mv_diff_first = abap_false ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-display_more. "" Increase MAX lines limit mv_max_lines = mv_max_lines + mv_max_setting. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-change_order_by. mv_order_by = zcl_abapgit_persistence_user=>get_instance( )->set_order_by( ii_event->query( )->get( 'ORDERBY' ) ). mv_order_descending = zcl_abapgit_persistence_user=>get_instance( )->set_order_descending( abap_false ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-direction. mv_order_descending = zcl_abapgit_persistence_user=>get_instance( )->set_order_descending( boolc( ii_event->query( )->get( 'DIRECTION' ) = 'DESCENDING' ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_open_in_master_lang. open_in_main_language( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). "" TODO refactor, move to HOC components ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions. ls_hotkey_action-ui_component = 'Repo'. ls_hotkey_action-description = |Stage Changes|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_stage. ls_hotkey_action-hotkey = |s|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Switch Branch|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_branch_switch. ls_hotkey_action-hotkey = |b|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Repository List|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-abapgit_home. ls_hotkey_action-hotkey = |o|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Refresh Repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_refresh. ls_hotkey_action-hotkey = |r|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Pull|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_pull. ls_hotkey_action-hotkey = |p|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Diff|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_repo_diff. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Uninstall Repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_purge. ls_hotkey_action-hotkey = |u|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run Syntax Check|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_syntax_check. ls_hotkey_action-hotkey = |c|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run Code Inspector|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_code_inspector. ls_hotkey_action-hotkey = |i|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Show Log|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_log. ls_hotkey_action-hotkey = |l|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ENDMETHOD. ENDCLASS. ",12435,True,2617.1124587801087,median "********************************************************************** * UTILS ********************************************************************** CLASS lcl_utils DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS normalize_path IMPORTING iv_path TYPE string RETURNING VALUE(rv_path) TYPE string. CLASS-METHODS split_path IMPORTING iv_path TYPE string RETURNING VALUE(rv_path_name) TYPE /mbtools/if_ajson=>ty_path_name. CLASS-METHODS validate_array_index IMPORTING iv_path TYPE string iv_index TYPE string RETURNING VALUE(rv_index) TYPE i RAISING /mbtools/cx_ajson_error. ENDCLASS. CLASS lcl_utils IMPLEMENTATION. METHOD validate_array_index. IF NOT iv_index CO '0123456789'. /mbtools/cx_ajson_error=>raise( |Cannot add non-numeric key [{ iv_index }] to array [{ iv_path }]| ). ENDIF. rv_index = iv_index. IF rv_index = 0. /mbtools/cx_ajson_error=>raise( |Cannot add zero key to array [{ iv_path }]| ). ENDIF. ENDMETHOD. METHOD normalize_path. rv_path = iv_path. IF strlen( rv_path ) = 0. rv_path = '/'. ENDIF. IF rv_path+0(1) <> '/'. rv_path = '/' && rv_path. ENDIF. IF substring( val = rv_path off = strlen( rv_path ) - 1 ) <> '/'. rv_path = rv_path && '/'. ENDIF. ENDMETHOD. METHOD split_path. DATA lv_offs TYPE i. DATA lv_len TYPE i. DATA lv_trim_slash TYPE i. lv_len = strlen( iv_path ). IF lv_len = 0 OR iv_path = '/'. RETURN. "" empty path is the alias for root item = '' + '' ENDIF. IF substring( val = iv_path off = lv_len - 1 ) = '/'. lv_trim_slash = 1. "" ignore last '/' ENDIF. lv_offs = find( val = reverse( iv_path ) sub = '/' off = lv_trim_slash ). IF lv_offs = -1. lv_offs = lv_len. "" treat whole string as the 'name' part ENDIF. lv_offs = lv_len - lv_offs. rv_path_name-path = normalize_path( substring( val = iv_path len = lv_offs ) ). rv_path_name-name = substring( val = iv_path off = lv_offs len = lv_len - lv_offs - lv_trim_slash ). ENDMETHOD. ENDCLASS. ********************************************************************** * PARSER ********************************************************************** CLASS lcl_json_parser DEFINITION FINAL. PUBLIC SECTION. METHODS parse IMPORTING iv_json TYPE string RETURNING VALUE(rt_json_tree) TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. PRIVATE SECTION. TYPES: ty_stack_tt TYPE STANDARD TABLE OF REF TO /mbtools/if_ajson=>ty_node. DATA mt_stack TYPE ty_stack_tt. CLASS-METHODS join_path IMPORTING it_stack TYPE ty_stack_tt RETURNING VALUE(rv_path) TYPE string. METHODS raise IMPORTING iv_error TYPE string RAISING /mbtools/cx_ajson_error. METHODS _parse IMPORTING iv_json TYPE string RETURNING VALUE(rt_json_tree) TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error cx_sxml_error. METHODS _get_location IMPORTING iv_json TYPE string iv_offset TYPE i RETURNING VALUE(rv_location) TYPE string. ENDCLASS. CLASS lcl_json_parser IMPLEMENTATION. METHOD parse. DATA lx_sxml_parse TYPE REF TO cx_sxml_parse_error. DATA lx_sxml TYPE REF TO cx_sxml_error. DATA lv_location TYPE string. TRY. rt_json_tree = _parse( iv_json ). CATCH cx_sxml_parse_error INTO lx_sxml_parse. lv_location = _get_location( iv_json = iv_json iv_offset = lx_sxml_parse->xml_offset ). /mbtools/cx_ajson_error=>raise( iv_msg = |Json parsing error (SXML): { lx_sxml_parse->get_text( ) }| iv_location = lv_location ). CATCH cx_sxml_error INTO lx_sxml. /mbtools/cx_ajson_error=>raise( iv_msg = |Json parsing error (SXML): { lx_sxml->get_text( ) }| iv_location = '@PARSER' ). ENDTRY. ENDMETHOD. METHOD _get_location. DATA lv_json TYPE string. DATA lv_offset TYPE i. DATA lt_text TYPE TABLE OF string. DATA lv_text TYPE string. DATA lv_line TYPE i. DATA lv_pos TYPE i. lv_offset = iv_offset. IF lv_offset < 0. lv_offset = 0. ENDIF. IF lv_offset > strlen( iv_json ). lv_offset = strlen( iv_json ). ENDIF. lv_json = iv_json(lv_offset). REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN lv_json WITH cl_abap_char_utilities=>newline. SPLIT lv_json AT cl_abap_char_utilities=>newline INTO TABLE lt_text. lv_line = lines( lt_text ). IF lv_line = 0. lv_line = 1. lv_pos = 1. ELSE. READ TABLE lt_text INDEX lv_line INTO lv_text. lv_pos = strlen( lv_text ) + 1. ENDIF. rv_location = |Line { lv_line }, Offset { lv_pos }|. ENDMETHOD. METHOD _parse. DATA lo_reader TYPE REF TO if_sxml_reader. DATA lr_stack_top LIKE LINE OF mt_stack. DATA lo_node TYPE REF TO if_sxml_node. FIELD-SYMBOLS LIKE LINE OF rt_json_tree. CLEAR mt_stack. IF iv_json IS INITIAL. RETURN. ENDIF. lo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( iv_json ) ). "" TODO: self protection, check non-empty, check starting from object ... DO. lo_node = lo_reader->read_next_node( ). IF lo_node IS NOT BOUND. EXIT. ENDIF. CASE lo_node->type. WHEN if_sxml_node=>co_nt_element_open. DATA lt_attributes TYPE if_sxml_attribute=>attributes. DATA lo_attr LIKE LINE OF lt_attributes. DATA lo_open TYPE REF TO if_sxml_open_element. lo_open ?= lo_node. APPEND INITIAL LINE TO rt_json_tree ASSIGNING . -type = to_lower( lo_open->qname-name ). READ TABLE mt_stack INDEX 1 INTO lr_stack_top. IF sy-subrc = 0. -path = join_path( mt_stack ). lr_stack_top->children = lr_stack_top->children + 1. IF lr_stack_top->type = 'array'. -name = |{ lr_stack_top->children }|. -index = lr_stack_top->children. ELSE. lt_attributes = lo_open->get_attributes( ). LOOP AT lt_attributes INTO lo_attr. IF lo_attr->qname-name = 'name' AND lo_attr->value_type = if_sxml_value=>co_vt_text. -name = lo_attr->get_value( ). ENDIF. ENDLOOP. ENDIF. ENDIF. GET REFERENCE OF INTO lr_stack_top. INSERT lr_stack_top INTO mt_stack INDEX 1. WHEN if_sxml_node=>co_nt_element_close. DATA lo_close TYPE REF TO if_sxml_close_element. lo_close ?= lo_node. READ TABLE mt_stack INDEX 1 INTO lr_stack_top. DELETE mt_stack INDEX 1. IF lo_close->qname-name <> lr_stack_top->type. raise( 'Unexpected closing node type' ). ENDIF. WHEN if_sxml_node=>co_nt_value. DATA lo_value TYPE REF TO if_sxml_value_node. lo_value ?= lo_node. -value = lo_value->get_value( ). WHEN OTHERS. raise( 'Unexpected node type' ). ENDCASE. ENDDO. IF lines( mt_stack ) > 0. raise( 'Unexpected end of data' ). ENDIF. ENDMETHOD. METHOD join_path. FIELD-SYMBOLS LIKE LINE OF it_stack. LOOP AT it_stack ASSIGNING . rv_path = ->name && '/' && rv_path. ENDLOOP. ENDMETHOD. METHOD raise. /mbtools/cx_ajson_error=>raise( iv_location = join_path( mt_stack ) iv_msg = |JSON PARSER: { iv_error } @ { join_path( mt_stack ) }| ). ENDMETHOD. ENDCLASS. ********************************************************************** * SERIALIZER ********************************************************************** CLASS lcl_json_serializer DEFINITION FINAL CREATE PRIVATE. PUBLIC SECTION. CLASS-METHODS stringify IMPORTING it_json_tree TYPE /mbtools/if_ajson=>ty_nodes_ts iv_indent TYPE i DEFAULT 0 iv_keep_item_order TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rv_json_string) TYPE string RAISING /mbtools/cx_ajson_error. CLASS-METHODS class_constructor. PRIVATE SECTION. CLASS-DATA gv_comma_with_lf TYPE string. DATA mt_json_tree TYPE /mbtools/if_ajson=>ty_nodes_ts. DATA mv_keep_item_order TYPE abap_bool. DATA mt_buffer TYPE string_table. DATA mv_indent_step TYPE i. DATA mv_level TYPE i. CLASS-METHODS escape IMPORTING iv_unescaped TYPE string RETURNING VALUE(rv_escaped) TYPE string. METHODS _stringify RETURNING VALUE(rv_json_string) TYPE string RAISING /mbtools/cx_ajson_error. METHODS stringify_node IMPORTING is_node TYPE /mbtools/if_ajson=>ty_node RAISING /mbtools/cx_ajson_error. METHODS stringify_set IMPORTING iv_parent_path TYPE string iv_array TYPE abap_bool RAISING /mbtools/cx_ajson_error. ENDCLASS. CLASS lcl_json_serializer IMPLEMENTATION. METHOD class_constructor. gv_comma_with_lf = ',' && cl_abap_char_utilities=>newline. ENDMETHOD. METHOD stringify. DATA lo TYPE REF TO lcl_json_serializer. CREATE OBJECT lo. lo->mt_json_tree = it_json_tree. lo->mv_indent_step = iv_indent. lo->mv_keep_item_order = iv_keep_item_order. rv_json_string = lo->_stringify( ). ENDMETHOD. METHOD _stringify. FIELD-SYMBOLS LIKE LINE OF mt_json_tree. READ TABLE mt_json_tree ASSIGNING WITH KEY path = '' name = ''. "" Root IF sy-subrc <> 0. RETURN. ENDIF. stringify_node( ). rv_json_string = concat_lines_of( table = mt_buffer ). ENDMETHOD. METHOD stringify_node. DATA lv_item TYPE string. DATA lv_indent_prefix TYPE string. IF mv_indent_step > 0. lv_indent_prefix = repeat( val = ` ` occ = mv_indent_step * mv_level ). lv_item = lv_indent_prefix. ENDIF. IF is_node-name IS NOT INITIAL AND is_node-index IS INITIAL. "" Not root, not array item IF mv_indent_step > 0. lv_item = lv_item && |""{ is_node-name }"": |. ELSE. lv_item = |""{ is_node-name }"":|. ENDIF. ENDIF. CASE is_node-type. WHEN /mbtools/if_ajson=>node_type-array. lv_item = lv_item && '['. WHEN /mbtools/if_ajson=>node_type-object. lv_item = lv_item && '{'. WHEN /mbtools/if_ajson=>node_type-string. lv_item = lv_item && |""{ escape( is_node-value ) }""|. WHEN /mbtools/if_ajson=>node_type-boolean OR /mbtools/if_ajson=>node_type-number. lv_item = lv_item && is_node-value. WHEN /mbtools/if_ajson=>node_type-null. lv_item = lv_item && 'null'. WHEN OTHERS. /mbtools/cx_ajson_error=>raise( iv_msg = |Unexpected type [{ is_node-type }]| iv_location = is_node-path && is_node-name ). ENDCASE. IF mv_indent_step > 0 AND ( is_node-type = /mbtools/if_ajson=>node_type-array OR is_node-type = /mbtools/if_ajson=>node_type-object ) AND is_node-children > 0. mv_level = mv_level + 1. lv_item = lv_item && cl_abap_char_utilities=>newline. ENDIF. APPEND lv_item TO mt_buffer. "" finish complex item IF is_node-type = /mbtools/if_ajson=>node_type-array OR is_node-type = /mbtools/if_ajson=>node_type-object. DATA lv_children_path TYPE string. DATA lv_tail TYPE string. lv_children_path = is_node-path && is_node-name && '/'. "" for root: path = '' and name = '', so result is '/' CASE is_node-type. WHEN /mbtools/if_ajson=>node_type-array. IF is_node-children > 0. stringify_set( iv_parent_path = lv_children_path iv_array = abap_true ). ENDIF. lv_tail = ']'. WHEN /mbtools/if_ajson=>node_type-object. IF is_node-children > 0. stringify_set( iv_parent_path = lv_children_path iv_array = abap_false ). ENDIF. lv_tail = '}'. ENDCASE. IF mv_indent_step > 0 AND is_node-children > 0. lv_tail = lv_indent_prefix && lv_tail. mv_level = mv_level - 1. ENDIF. APPEND lv_tail TO mt_buffer. ENDIF. ENDMETHOD. METHOD stringify_set. DATA lv_tab_key TYPE string. DATA lv_first_done TYPE abap_bool. FIELD-SYMBOLS LIKE LINE OF mt_json_tree. IF iv_array = abap_true. lv_tab_key = 'array_index'. "" path + index ELSEIF mv_keep_item_order = abap_true. lv_tab_key = 'item_order'. "" path + order ELSE. lv_tab_key = 'primary_key'. "" path + name ENDIF. LOOP AT mt_json_tree ASSIGNING USING KEY (lv_tab_key) WHERE path = iv_parent_path. IF lv_first_done = abap_false. lv_first_done = abap_true. ELSEIF mv_indent_step > 0. APPEND gv_comma_with_lf TO mt_buffer. ELSE. APPEND ',' TO mt_buffer. ENDIF. stringify_node( ). ENDLOOP. IF mv_indent_step > 0 AND lv_first_done = abap_true. "" only of items were in the list APPEND cl_abap_char_utilities=>newline TO mt_buffer. ENDIF. ENDMETHOD. METHOD escape. rv_escaped = iv_unescaped. IF rv_escaped CA |""\\\\\\t\\n\\r|. "" TODO consider performance ... "" see also https://www.json.org/json-en.html rv_escaped = replace( val = rv_escaped sub = '\\' with = '\\\\' occ = 0 ). rv_escaped = replace( val = rv_escaped sub = |\\n| with = '\\n' occ = 0 ). rv_escaped = replace( val = rv_escaped sub = |\\r| with = '\\r' occ = 0 ). rv_escaped = replace( val = rv_escaped sub = |\\t| with = '\\t' occ = 0 ). rv_escaped = replace( val = rv_escaped sub = '""' with = '\\""' occ = 0 ). ENDIF. ENDMETHOD. ENDCLASS. ********************************************************************** * JSON_TO_ABAP ********************************************************************** CLASS lcl_json_to_abap DEFINITION FINAL. PUBLIC SECTION. METHODS constructor IMPORTING !ii_custom_mapping TYPE REF TO /mbtools/if_ajson_mapping OPTIONAL. METHODS to_abap IMPORTING it_nodes TYPE /mbtools/if_ajson=>ty_nodes_ts CHANGING c_container TYPE any RAISING /mbtools/cx_ajson_error. METHODS to_timestamp IMPORTING iv_value TYPE /mbtools/if_ajson=>ty_node-value RETURNING VALUE(rv_result) TYPE timestamp RAISING /mbtools/cx_ajson_error. METHODS to_date IMPORTING iv_value TYPE /mbtools/if_ajson=>ty_node-value RETURNING VALUE(rv_result) TYPE d RAISING /mbtools/cx_ajson_error. PRIVATE SECTION. TYPES: BEGIN OF ty_type_cache, type_path TYPE string, target_field_name TYPE string, dd TYPE REF TO cl_abap_datadescr, type_kind LIKE cl_abap_typedescr=>typekind_any, tab_item_buf TYPE REF TO data, END OF ty_type_cache. DATA mt_node_type_cache TYPE HASHED TABLE OF ty_type_cache WITH UNIQUE KEY type_path. DATA mr_nodes TYPE REF TO /mbtools/if_ajson=>ty_nodes_ts. DATA mi_custom_mapping TYPE REF TO /mbtools/if_ajson_mapping. METHODS any_to_abap IMPORTING iv_path TYPE string is_parent_type TYPE ty_type_cache OPTIONAL i_container_ref TYPE REF TO data RAISING /mbtools/cx_ajson_error. METHODS value_to_abap IMPORTING is_node TYPE /mbtools/if_ajson=>ty_node is_node_type TYPE ty_type_cache i_container_ref TYPE REF TO data RAISING /mbtools/cx_ajson_error cx_sy_conversion_no_number. METHODS get_node_type IMPORTING is_node TYPE /mbtools/if_ajson=>ty_node OPTIONAL "" Empty for root is_parent_type TYPE ty_type_cache OPTIONAL i_container_ref TYPE REF TO data OPTIONAL RETURNING VALUE(rs_node_type) TYPE ty_type_cache RAISING /mbtools/cx_ajson_error. ENDCLASS. CLASS lcl_json_to_abap IMPLEMENTATION. METHOD constructor. mi_custom_mapping = ii_custom_mapping. ENDMETHOD. METHOD to_abap. DATA lr_ref TYPE REF TO data. CLEAR c_container. "" what about data/obj refs ? CLEAR mt_node_type_cache. GET REFERENCE OF c_container INTO lr_ref. GET REFERENCE OF it_nodes INTO mr_nodes. get_node_type( i_container_ref = lr_ref ). "" Pre-cache root node type any_to_abap( iv_path = '' i_container_ref = lr_ref ). ENDMETHOD. METHOD get_node_type. DATA lv_node_type_path TYPE string. DATA lo_sdescr TYPE REF TO cl_abap_structdescr. DATA lo_tdescr TYPE REF TO cl_abap_tabledescr. DATA lo_ddescr TYPE REF TO cl_abap_datadescr. "" Calculate type path IF is_parent_type-type_kind = cl_abap_typedescr=>typekind_table. lv_node_type_path = is_parent_type-type_path && '/-'. "" table item type ELSEIF is_parent_type-type_kind IS NOT INITIAL. lv_node_type_path = is_parent_type-type_path && '/' && is_node-name. ENDIF. "" For root node lv_node_type_path remains '' "" Get or create cached READ TABLE mt_node_type_cache INTO rs_node_type WITH KEY type_path = lv_node_type_path. IF sy-subrc <> 0. rs_node_type-type_path = lv_node_type_path. IF mi_custom_mapping IS BOUND. rs_node_type-target_field_name = to_upper( mi_custom_mapping->to_abap( iv_path = is_node-path iv_name = is_node-name ) ). IF rs_node_type-target_field_name IS INITIAL. rs_node_type-target_field_name = to_upper( is_node-name ). ENDIF. ELSE. rs_node_type-target_field_name = to_upper( is_node-name ). ENDIF. CASE is_parent_type-type_kind. WHEN 'h'. "" Table lo_tdescr ?= is_parent_type-dd. rs_node_type-dd = lo_tdescr->get_table_line_type( ). WHEN 'u' OR 'v'. "" Structure lo_sdescr ?= is_parent_type-dd. lo_sdescr->get_component_type( EXPORTING p_name = rs_node_type-target_field_name RECEIVING p_descr_ref = rs_node_type-dd EXCEPTIONS component_not_found = 4 ). IF sy-subrc <> 0. /mbtools/cx_ajson_error=>raise( |Path not found| ). ENDIF. WHEN ''. "" Root node rs_node_type-dd ?= cl_abap_typedescr=>describe_by_data_ref( i_container_ref ). WHEN OTHERS. /mbtools/cx_ajson_error=>raise( |Unexpected parent type| ). ENDCASE. rs_node_type-type_kind = rs_node_type-dd->type_kind. "" for caching and cleaner unintialized access IF rs_node_type-type_kind = 'h'. "" Table lo_tdescr ?= rs_node_type-dd. IF lo_tdescr->table_kind <> 'S'. "" standard lo_ddescr = lo_tdescr->get_table_line_type( ). CREATE DATA rs_node_type-tab_item_buf TYPE HANDLE lo_ddescr. ENDIF. ENDIF. INSERT rs_node_type INTO TABLE mt_node_type_cache. ENDIF. ENDMETHOD. METHOD any_to_abap. DATA ls_node_type LIKE LINE OF mt_node_type_cache. DATA lx_ajson TYPE REF TO /mbtools/cx_ajson_error. DATA lx_root TYPE REF TO cx_root. DATA lr_target_field TYPE REF TO data. FIELD-SYMBOLS TYPE /mbtools/if_ajson=>ty_node. FIELD-SYMBOLS TYPE STANDARD TABLE. FIELD-SYMBOLS TYPE ANY TABLE. FIELD-SYMBOLS TYPE any. FIELD-SYMBOLS TYPE any. "" Assign container CASE is_parent_type-type_kind. WHEN 'h'. "" Table IF is_parent_type-tab_item_buf IS BOUND. "" Indirect hint that table was sorted/hashed, see get_node_type. ASSIGN i_container_ref->* TO . ASSERT sy-subrc = 0. lr_target_field = is_parent_type-tab_item_buf. "" For hashed/sorted table - same buffer for all children ASSIGN is_parent_type-tab_item_buf->* TO . ASSERT sy-subrc = 0. ELSE. ASSIGN i_container_ref->* TO . ASSERT sy-subrc = 0. ENDIF. WHEN 'u' OR 'v'. "" Structure ASSIGN i_container_ref->* TO . ASSERT sy-subrc = 0. ENDCASE. TRY. "" array_index because stringified index goes in wrong order [1, 10, 2 ...] LOOP AT mr_nodes->* ASSIGNING USING KEY array_index WHERE path = iv_path. "" Get or create type cache record IF is_parent_type-type_kind <> 'h' OR ls_node_type-type_kind IS INITIAL. "" table records are the same, no need to refetch twice ls_node_type = get_node_type( is_node = is_parent_type = is_parent_type ). ENDIF. "" Validate node type IF ls_node_type-type_kind CA 'lr'. "" data/obj ref "" TODO maybe in future /mbtools/cx_ajson_error=>raise( 'Cannot assign to ref' ). ENDIF. "" Find target field reference CASE is_parent_type-type_kind. WHEN 'h'. "" Table IF NOT ls_node_type-target_field_name CO '0123456789'. "" Does not affect anything actually but for integrity /mbtools/cx_ajson_error=>raise( 'Need index to access tables' ). ENDIF. IF is_parent_type-tab_item_buf IS NOT BOUND. "" Indirect hint that table was srt/hsh, see get_node_type APPEND INITIAL LINE TO REFERENCE INTO lr_target_field. ASSERT sy-subrc = 0. ENDIF. WHEN 'u' OR 'v'. FIELD-SYMBOLS TYPE any. ASSIGN COMPONENT ls_node_type-target_field_name OF STRUCTURE TO . ASSERT sy-subrc = 0. GET REFERENCE OF INTO lr_target_field. WHEN ''. "" Root node lr_target_field = i_container_ref. WHEN OTHERS. /mbtools/cx_ajson_error=>raise( 'Unexpected parent type' ). ENDCASE. "" Process value assignment CASE -type. WHEN /mbtools/if_ajson=>node_type-object. IF NOT ls_node_type-type_kind CO 'uv'. /mbtools/cx_ajson_error=>raise( 'Expected structure' ). ENDIF. any_to_abap( iv_path = -path && -name && '/' is_parent_type = ls_node_type i_container_ref = lr_target_field ). WHEN /mbtools/if_ajson=>node_type-array. IF NOT ls_node_type-type_kind = 'h'. /mbtools/cx_ajson_error=>raise( 'Expected table' ). ENDIF. any_to_abap( iv_path = -path && -name && '/' is_parent_type = ls_node_type i_container_ref = lr_target_field ). WHEN OTHERS. value_to_abap( is_node = is_node_type = ls_node_type i_container_ref = lr_target_field ). ENDCASE. IF is_parent_type-tab_item_buf IS BOUND. "" Indirect hint that table was sorted/hashed, see get_node_type. TRY. INSERT INTO TABLE . CATCH cx_sy_itab_duplicate_key. sy-subrc = 4. ENDTRY. IF sy-subrc <> 0. /mbtools/cx_ajson_error=>raise( 'Duplicate insertion' ). ENDIF. ENDIF. ENDLOOP. CATCH /mbtools/cx_ajson_error INTO lx_ajson. IF lx_ajson->location IS INITIAL. lx_ajson->set_location( -path && -name ). ENDIF. RAISE EXCEPTION lx_ajson. CATCH cx_sy_conversion_no_number. /mbtools/cx_ajson_error=>raise( iv_msg = 'Source is not a number' iv_location = -path && -name ). CATCH cx_root INTO lx_root. /mbtools/cx_ajson_error=>raise( iv_msg = lx_root->get_text( ) iv_location = -path && -name ). ENDTRY. ENDMETHOD. METHOD value_to_abap. FIELD-SYMBOLS TYPE any. IF is_node_type-type_kind CA 'lruvh'. "" refs, table, strucs /mbtools/cx_ajson_error=>raise( |Unsupported target for value [{ is_node_type-type_kind }]| ). ENDIF. ASSIGN i_container_ref->* TO . ASSERT sy-subrc = 0. CASE is_node-type. WHEN /mbtools/if_ajson=>node_type-null. "" Do nothing WHEN /mbtools/if_ajson=>node_type-boolean. "" TODO: check type ? = boolc( is_node-value = 'true' ). WHEN /mbtools/if_ajson=>node_type-number. "" TODO: check type ? = is_node-value. WHEN /mbtools/if_ajson=>node_type-string. "" TODO: check type ? IF is_node_type-type_kind = 'D' AND is_node-value IS NOT INITIAL. = to_date( is_node-value ). ELSEIF is_node_type-type_kind = 'P' AND is_node-value IS NOT INITIAL. = to_timestamp( is_node-value ). ELSE. = is_node-value. ENDIF. WHEN OTHERS. /mbtools/cx_ajson_error=>raise( |Unexpected JSON type [{ is_node-type }]| ). ENDCASE. ENDMETHOD. METHOD to_date. DATA lv_y TYPE c LENGTH 4. DATA lv_m TYPE c LENGTH 2. DATA lv_d TYPE c LENGTH 2. FIND FIRST OCCURRENCE OF REGEX '^(\\d{4})-(\\d{2})-(\\d{2})(T|$)' ""#EC NOTEXT IN iv_value SUBMATCHES lv_y lv_m lv_d. IF sy-subrc <> 0. /mbtools/cx_ajson_error=>raise( 'Unexpected date format' ). ENDIF. CONCATENATE lv_y lv_m lv_d INTO rv_result. ENDMETHOD. METHOD to_timestamp. CONSTANTS lc_utc TYPE c LENGTH 6 VALUE 'UTC'. CONSTANTS lc_regex_ts_with_hour TYPE string VALUE `^(\\d{4})-(\\d{2})-(\\d{2})(T)(\\d{2}):(\\d{2}):(\\d{2})(\\+)(\\d{2}):(\\d{2})`. ""#EC NOTEXT CONSTANTS lc_regex_ts_utc TYPE string VALUE `^(\\d{4})-(\\d{2})-(\\d{2})(T)(\\d{2}):(\\d{2}):(\\d{2})(Z|$)`. ""#EC NOTEXT DATA: BEGIN OF ls_timestamp, year TYPE c LENGTH 4, month TYPE c LENGTH 2, day TYPE c LENGTH 2, t TYPE c LENGTH 1, hour TYPE c LENGTH 2, minute TYPE c LENGTH 2, second TYPE c LENGTH 2, local_sign TYPE c LENGTH 1, local_hour TYPE c LENGTH 2, local_minute TYPE c LENGTH 2, END OF ls_timestamp. DATA lv_date TYPE d. DATA lv_time TYPE t. DATA lv_seconds_conv TYPE i. DATA lv_timestamp TYPE timestampl. FIND FIRST OCCURRENCE OF REGEX lc_regex_ts_with_hour IN iv_value SUBMATCHES ls_timestamp-year ls_timestamp-month ls_timestamp-day ls_timestamp-t ls_timestamp-hour ls_timestamp-minute ls_timestamp-second ls_timestamp-local_sign ls_timestamp-local_hour ls_timestamp-local_minute. IF sy-subrc = 0. lv_seconds_conv = ( ls_timestamp-local_hour * 3600 ) + ( ls_timestamp-local_minute * 60 ). ELSE. FIND FIRST OCCURRENCE OF REGEX lc_regex_ts_utc IN iv_value SUBMATCHES ls_timestamp-year ls_timestamp-month ls_timestamp-day ls_timestamp-t ls_timestamp-hour ls_timestamp-minute ls_timestamp-second. IF sy-subrc <> 0. /mbtools/cx_ajson_error=>raise( 'Unexpected timestamp format' ). ENDIF. ENDIF. CONCATENATE ls_timestamp-year ls_timestamp-month ls_timestamp-day INTO lv_date. CONCATENATE ls_timestamp-hour ls_timestamp-minute ls_timestamp-second INTO lv_time. CONVERT DATE lv_date TIME lv_time INTO TIME STAMP lv_timestamp TIME ZONE lc_utc. TRY. CASE ls_timestamp-local_sign. WHEN '-'. lv_timestamp = cl_abap_tstmp=>add( tstmp = lv_timestamp secs = lv_seconds_conv ). WHEN '+'. lv_timestamp = cl_abap_tstmp=>subtractsecs( tstmp = lv_timestamp secs = lv_seconds_conv ). ENDCASE. CATCH cx_parameter_invalid_range cx_parameter_invalid_type. /mbtools/cx_ajson_error=>raise( 'Unexpected error calculating timestamp' ). ENDTRY. cl_abap_tstmp=>move( EXPORTING tstmp_src = lv_timestamp IMPORTING tstmp_tgt = rv_result ). ENDMETHOD. ENDCLASS. ********************************************************************** * ABAP_TO_JSON ********************************************************************** CLASS lcl_abap_to_json DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS convert IMPORTING iv_data TYPE any is_prefix TYPE /mbtools/if_ajson=>ty_path_name OPTIONAL iv_array_index TYPE i DEFAULT 0 ii_custom_mapping TYPE REF TO /mbtools/if_ajson_mapping OPTIONAL iv_keep_item_order TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rt_nodes) TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. CLASS-METHODS insert_with_type IMPORTING iv_data TYPE any iv_type TYPE string is_prefix TYPE /mbtools/if_ajson=>ty_path_name OPTIONAL iv_array_index TYPE i DEFAULT 0 ii_custom_mapping TYPE REF TO /mbtools/if_ajson_mapping OPTIONAL iv_keep_item_order TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rt_nodes) TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. CLASS-METHODS class_constructor. PRIVATE SECTION. CLASS-DATA gv_ajson_absolute_type_name TYPE string. DATA mi_custom_mapping TYPE REF TO /mbtools/if_ajson_mapping. DATA mv_keep_item_order TYPE abap_bool. METHODS convert_any IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. METHODS convert_ajson IMPORTING io_json TYPE REF TO /mbtools/cl_ajson is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. METHODS convert_value IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. METHODS convert_ref IMPORTING iv_data TYPE any is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. METHODS convert_struc IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt cs_root TYPE /mbtools/if_ajson=>ty_node OPTIONAL RAISING /mbtools/cx_ajson_error. METHODS convert_table IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. METHODS insert_value_with_type IMPORTING iv_data TYPE any iv_type TYPE string io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE /mbtools/if_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE /mbtools/if_ajson=>ty_nodes_tt RAISING /mbtools/cx_ajson_error. ENDCLASS. CLASS lcl_abap_to_json IMPLEMENTATION. METHOD class_constructor. DATA lo_dummy TYPE REF TO /mbtools/cl_ajson. DATA lo_type TYPE REF TO cl_abap_refdescr. lo_type ?= cl_abap_typedescr=>describe_by_data( lo_dummy ). gv_ajson_absolute_type_name = lo_type->get_referenced_type( )->absolute_name. ENDMETHOD. METHOD convert. DATA lo_type TYPE REF TO cl_abap_typedescr. DATA lo_converter TYPE REF TO lcl_abap_to_json. lo_type = cl_abap_typedescr=>describe_by_data( iv_data ). CREATE OBJECT lo_converter. lo_converter->mi_custom_mapping = ii_custom_mapping. lo_converter->mv_keep_item_order = iv_keep_item_order. lo_converter->convert_any( EXPORTING iv_data = iv_data io_type = lo_type is_prefix = is_prefix iv_index = iv_array_index CHANGING ct_nodes = rt_nodes ). ENDMETHOD. METHOD convert_any. CASE io_type->kind. WHEN cl_abap_typedescr=>kind_elem. convert_value( EXPORTING iv_data = iv_data io_type = io_type is_prefix = is_prefix iv_index = iv_index iv_item_order = iv_item_order CHANGING ct_nodes = ct_nodes ). WHEN cl_abap_typedescr=>kind_struct. convert_struc( EXPORTING iv_data = iv_data io_type = io_type is_prefix = is_prefix iv_index = iv_index iv_item_order = iv_item_order CHANGING ct_nodes = ct_nodes ). WHEN cl_abap_typedescr=>kind_table. convert_table( EXPORTING iv_data = iv_data io_type = io_type is_prefix = is_prefix iv_index = iv_index iv_item_order = iv_item_order CHANGING ct_nodes = ct_nodes ). WHEN OTHERS. IF io_type->type_kind = cl_abap_typedescr=>typekind_dref. convert_ref( EXPORTING iv_data = iv_data is_prefix = is_prefix iv_index = iv_index iv_item_order = iv_item_order CHANGING ct_nodes = ct_nodes ). ELSEIF io_type->type_kind = cl_abap_typedescr=>typekind_oref AND cl_abap_typedescr=>describe_by_object_ref( iv_data )->absolute_name = gv_ajson_absolute_type_name. convert_ajson( EXPORTING io_json = iv_data is_prefix = is_prefix iv_index = iv_index CHANGING ct_nodes = ct_nodes ). ELSE. /mbtools/cx_ajson_error=>raise( |Unsupported type [{ io_type->type_kind }] @{ is_prefix-path && is_prefix-name }| ). ENDIF. ENDCASE. ENDMETHOD. METHOD convert_ajson. FIELD-SYMBOLS LIKE LINE OF ct_nodes. FIELD-SYMBOLS LIKE LINE OF ct_nodes. IF io_json IS NOT BOUND. RETURN. ENDIF. LOOP AT io_json->mt_json_tree ASSIGNING . APPEND TO ct_nodes ASSIGNING . IF -path IS INITIAL AND -name IS INITIAL. "" root node -path = is_prefix-path. -name = is_prefix-name. -index = iv_index. ELSE. -path = is_prefix-path && is_prefix-name && -path. ENDIF. ENDLOOP. ENDMETHOD. METHOD convert_value. DATA ls_node LIKE LINE OF ct_nodes. ls_node-path = is_prefix-path. ls_node-name = is_prefix-name. ls_node-index = iv_index. ls_node-order = iv_item_order. IF mi_custom_mapping IS BOUND. ls_node-name = mi_custom_mapping->to_json( iv_path = is_prefix-path iv_name = is_prefix-name ). ENDIF. IF ls_node-name IS INITIAL. ls_node-name = is_prefix-name. ENDIF. IF io_type->absolute_name = '\\TYPE-POOL=ABAP\\TYPE=ABAP_BOOL' OR io_type->absolute_name = '\\TYPE=ABAP_BOOLEAN' OR io_type->absolute_name = '\\TYPE=XSDBOOLEAN' OR io_type->absolute_name = '\\TYPE=FLAG' OR io_type->absolute_name = '\\TYPE=XFELD'. ls_node-type = /mbtools/if_ajson=>node_type-boolean. IF iv_data IS NOT INITIAL. ls_node-value = 'true'. ELSE. ls_node-value = 'false'. ENDIF. ELSEIF io_type->type_kind CO 'CNgXyDT'. "" Char like, date/time, xstring ls_node-type = /mbtools/if_ajson=>node_type-string. ls_node-value = |{ iv_data }|. ELSEIF io_type->type_kind CO 'bsI8PaeF'. "" Numeric ls_node-type = /mbtools/if_ajson=>node_type-number. ls_node-value = |{ iv_data }|. ELSE. /mbtools/cx_ajson_error=>raise( |Unexpected elementary type [{ io_type->type_kind }] @{ is_prefix-path && is_prefix-name }| ). ENDIF. APPEND ls_node TO ct_nodes. ENDMETHOD. METHOD convert_ref. DATA ls_node LIKE LINE OF ct_nodes. ls_node-path = is_prefix-path. ls_node-name = is_prefix-name. ls_node-index = iv_index. ls_node-order = iv_item_order. IF mi_custom_mapping IS BOUND. ls_node-name = mi_custom_mapping->to_json( iv_path = is_prefix-path iv_name = is_prefix-name ). ENDIF. IF ls_node-name IS INITIAL. ls_node-name = is_prefix-name. ENDIF. IF iv_data IS INITIAL. ls_node-type = /mbtools/if_ajson=>node_type-null. ls_node-value = 'null'. ELSE. "" TODO support data references /mbtools/cx_ajson_error=>raise( |Unexpected reference @{ is_prefix-path && is_prefix-name }| ). ENDIF. APPEND ls_node TO ct_nodes. ENDMETHOD. METHOD convert_struc. DATA lo_struc TYPE REF TO cl_abap_structdescr. DATA lt_comps TYPE cl_abap_structdescr=>component_table. DATA ls_next_prefix LIKE is_prefix. DATA lv_item_order TYPE i. DATA ls_root LIKE LINE OF ct_nodes. FIELD-SYMBOLS LIKE ls_root. FIELD-SYMBOLS LIKE LINE OF lt_comps. FIELD-SYMBOLS TYPE any. "" Object root IF cs_root IS SUPPLIED. "" call for include structure ASSIGN cs_root TO . ELSE. "" First call ls_root-path = is_prefix-path. ls_root-name = is_prefix-name. ls_root-type = /mbtools/if_ajson=>node_type-object. ls_root-index = iv_index. IF mi_custom_mapping IS BOUND. ls_root-name = mi_custom_mapping->to_json( iv_path = is_prefix-path iv_name = is_prefix-name ). ENDIF. IF ls_root-name IS INITIAL. ls_root-name = is_prefix-name. ENDIF. ls_root-order = iv_item_order. APPEND ls_root TO ct_nodes ASSIGNING . ENDIF. "" Object attributes lo_struc ?= io_type. lt_comps = lo_struc->get_components( ). "" get_components is potentially much slower than lo_struc->components "" but ! we still need it to identify booleans "" and rtti seems to cache type descriptions really well (https://github.com/sbcgua/benchmarks.git) "" the structures will be repeated in real life ls_next_prefix-path = is_prefix-path && is_prefix-name && '/'. LOOP AT lt_comps ASSIGNING . IF -as_include = abap_true. convert_struc( EXPORTING iv_data = iv_data io_type = -type is_prefix = is_prefix CHANGING cs_root = ct_nodes = ct_nodes ). ELSE. -children = -children + 1. ls_next_prefix-name = to_lower( -name ). ASSIGN COMPONENT -name OF STRUCTURE iv_data TO . ASSERT sy-subrc = 0. IF mv_keep_item_order = abap_true. lv_item_order = -children. ENDIF. convert_any( EXPORTING iv_data = io_type = -type is_prefix = ls_next_prefix iv_item_order = lv_item_order CHANGING ct_nodes = ct_nodes ). ENDIF. ENDLOOP. ENDMETHOD. METHOD convert_table. DATA lo_table TYPE REF TO cl_abap_tabledescr. DATA lo_ltype TYPE REF TO cl_abap_typedescr. DATA ls_next_prefix LIKE is_prefix. DATA lv_tabix TYPE sy-tabix. DATA ls_root LIKE LINE OF ct_nodes. FIELD-SYMBOLS LIKE ls_root. FIELD-SYMBOLS TYPE ANY TABLE. FIELD-SYMBOLS TYPE any. "" Array root ls_root-path = is_prefix-path. ls_root-name = is_prefix-name. ls_root-type = /mbtools/if_ajson=>node_type-array. ls_root-index = iv_index. ls_root-order = iv_item_order. IF mi_custom_mapping IS BOUND. ls_root-name = mi_custom_mapping->to_json( iv_path = is_prefix-path iv_name = is_prefix-name ). ENDIF. IF ls_root-name IS INITIAL. ls_root-name = is_prefix-name. ENDIF. APPEND ls_root TO ct_nodes ASSIGNING . "" Array items lo_table ?= io_type. lo_ltype = lo_table->get_table_line_type( ). ls_next_prefix-path = is_prefix-path && is_prefix-name && '/'. ASSIGN iv_data TO . lv_tabix = 1. LOOP AT ASSIGNING . ls_next_prefix-name = to_lower( |{ lv_tabix }| ). convert_any( EXPORTING iv_data = io_type = lo_ltype is_prefix = ls_next_prefix iv_index = -children + 1 CHANGING ct_nodes = ct_nodes ). -children = -children + 1. lv_tabix = lv_tabix + 1. ENDLOOP. ENDMETHOD. METHOD insert_with_type. DATA lo_type TYPE REF TO cl_abap_typedescr. DATA lo_converter TYPE REF TO lcl_abap_to_json. lo_type = cl_abap_typedescr=>describe_by_data( iv_data ). CREATE OBJECT lo_converter. lo_converter->mi_custom_mapping = ii_custom_mapping. lo_converter->mv_keep_item_order = iv_keep_item_order. lo_converter->insert_value_with_type( EXPORTING iv_data = iv_data iv_type = iv_type io_type = lo_type is_prefix = is_prefix iv_index = iv_array_index CHANGING ct_nodes = rt_nodes ). ENDMETHOD. METHOD insert_value_with_type. DATA lv_prefix TYPE string. DATA ls_node LIKE LINE OF ct_nodes. lv_prefix = is_prefix-path && is_prefix-name. IF io_type->type_kind CO 'CNgXyDT'. "" Char like, date/time, xstring IF iv_type = /mbtools/if_ajson=>node_type-boolean AND iv_data <> 'true' AND iv_data <> 'false'. /mbtools/cx_ajson_error=>raise( |Unexpected boolean value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type = /mbtools/if_ajson=>node_type-null AND iv_data IS NOT INITIAL. /mbtools/cx_ajson_error=>raise( |Unexpected null value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type = /mbtools/if_ajson=>node_type-number AND iv_data CN '0123456789. E+-'. /mbtools/cx_ajson_error=>raise( |Unexpected numeric value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type <> /mbtools/if_ajson=>node_type-string AND iv_type <> /mbtools/if_ajson=>node_type-boolean AND iv_type <> /mbtools/if_ajson=>node_type-null AND iv_type <> /mbtools/if_ajson=>node_type-number. /mbtools/cx_ajson_error=>raise( |Unexpected type for value [{ iv_type },{ iv_data }] @{ lv_prefix }| ). ENDIF. ELSEIF io_type->type_kind CO 'bsI8PaeF'. "" Numeric IF iv_type <> /mbtools/if_ajson=>node_type-number. /mbtools/cx_ajson_error=>raise( |Unexpected value for numeric [{ iv_data }] @{ lv_prefix }| ). ENDIF. ELSE. /mbtools/cx_ajson_error=>raise( |Unexpected type [{ io_type->type_kind }] @{ lv_prefix }| ). ENDIF. ls_node-path = is_prefix-path. ls_node-name = is_prefix-name. ls_node-index = iv_index. ls_node-value = iv_data. ls_node-type = iv_type. ls_node-order = iv_item_order. IF mi_custom_mapping IS BOUND. ls_node-name = mi_custom_mapping->to_json( iv_path = is_prefix-path iv_name = is_prefix-name ). ENDIF. IF ls_node-name IS INITIAL. ls_node-name = is_prefix-name. ENDIF. APPEND ls_node TO ct_nodes. ENDMETHOD. ENDCLASS. ********************************************************************** * FILTER RUNNER ********************************************************************** CLASS lcl_filter_runner DEFINITION FINAL. PUBLIC SECTION. METHODS run IMPORTING ii_filter TYPE REF TO /mbtools/if_ajson_filter it_source_tree TYPE /mbtools/if_ajson=>ty_nodes_ts CHANGING ct_dest_tree TYPE /mbtools/if_ajson=>ty_nodes_ts RAISING /mbtools/cx_ajson_error. PRIVATE SECTION. DATA mi_filter TYPE REF TO /mbtools/if_ajson_filter. DATA mr_source_tree TYPE REF TO /mbtools/if_ajson=>ty_nodes_ts. DATA mr_dest_tree TYPE REF TO /mbtools/if_ajson=>ty_nodes_ts. METHODS walk IMPORTING iv_path TYPE string CHANGING cs_parent TYPE /mbtools/if_ajson=>ty_node OPTIONAL RAISING /mbtools/cx_ajson_error. ENDCLASS. CLASS lcl_filter_runner IMPLEMENTATION. METHOD run. ASSERT ii_filter IS BOUND. mi_filter = ii_filter. CLEAR ct_dest_tree. GET REFERENCE OF it_source_tree INTO mr_source_tree. GET REFERENCE OF ct_dest_tree INTO mr_dest_tree. walk( iv_path = '' ). ENDMETHOD. METHOD walk. DATA ls_node TYPE /mbtools/if_ajson=>ty_node. LOOP AT mr_source_tree->* INTO ls_node WHERE path = iv_path. CASE ls_node-type. WHEN /mbtools/if_ajson=>node_type-boolean OR /mbtools/if_ajson=>node_type-null OR /mbtools/if_ajson=>node_type-number OR /mbtools/if_ajson=>node_type-string. IF mi_filter->keep_node( ls_node ) = abap_false. CONTINUE. ENDIF. WHEN /mbtools/if_ajson=>node_type-array OR /mbtools/if_ajson=>node_type-object. IF mi_filter->keep_node( is_node = ls_node iv_visit = /mbtools/if_ajson_filter=>visit_type-open ) = abap_false. CONTINUE. ENDIF. "" Intentionally clear AFTER ""open"" CLEAR ls_node-children. walk( EXPORTING iv_path = iv_path && ls_node-name && `/` CHANGING cs_parent = ls_node ). IF mi_filter->keep_node( is_node = ls_node iv_visit = /mbtools/if_ajson_filter=>visit_type-close ) = abap_false. CONTINUE. ENDIF. WHEN OTHERS. /mbtools/cx_ajson_error=>raise( |Unexpected node type { ls_node-type }| ). ENDCASE. IF cs_parent IS SUPPLIED. cs_parent-children = cs_parent-children + 1. IF cs_parent-type = /mbtools/if_ajson=>node_type-array. ls_node-name = |{ cs_parent-children }|. ls_node-index = cs_parent-children. ENDIF. ENDIF. INSERT ls_node INTO TABLE mr_dest_tree->*. ENDLOOP. ENDMETHOD. ENDCLASS. ",12360,True,2608.767043218905,median "CLASS zcl_abapgit_popups DEFINITION PUBLIC FINAL CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_ui_factory . PUBLIC SECTION. INTERFACES zif_abapgit_popups . ALIASES branch_list_popup FOR zif_abapgit_popups~branch_list_popup . ALIASES branch_popup_callback FOR zif_abapgit_popups~branch_popup_callback . ALIASES create_branch_popup FOR zif_abapgit_popups~create_branch_popup . ALIASES package_popup_callback FOR zif_abapgit_popups~package_popup_callback . ALIASES popup_folder_logic FOR zif_abapgit_popups~popup_folder_logic . ALIASES popup_object FOR zif_abapgit_popups~popup_object . ALIASES popup_package_export FOR zif_abapgit_popups~popup_package_export . ALIASES popup_proxy_bypass FOR zif_abapgit_popups~popup_proxy_bypass . ALIASES popup_to_confirm FOR zif_abapgit_popups~popup_to_confirm . ALIASES popup_to_create_package FOR zif_abapgit_popups~popup_to_create_package . ALIASES popup_to_create_transp_branch FOR zif_abapgit_popups~popup_to_create_transp_branch . ALIASES popup_to_inform FOR zif_abapgit_popups~popup_to_inform . ALIASES popup_to_select_from_list FOR zif_abapgit_popups~popup_to_select_from_list . ALIASES popup_to_select_transports FOR zif_abapgit_popups~popup_to_select_transports . ALIASES popup_transport_request FOR zif_abapgit_popups~popup_transport_request . ALIASES repo_popup FOR zif_abapgit_popups~repo_popup . CONSTANTS c_default_column TYPE lvc_fname VALUE `DEFAULT_COLUMN` ##NO_TEXT. PROTECTED SECTION. PRIVATE SECTION. TYPES: ty_sval_tt TYPE STANDARD TABLE OF sval WITH DEFAULT KEY. CONSTANTS c_fieldname_selected TYPE lvc_fname VALUE `SELECTED` ##NO_TEXT. CONSTANTS c_answer_cancel TYPE c LENGTH 1 VALUE 'A' ##NO_TEXT. DATA mo_select_list_popup TYPE REF TO cl_salv_table . DATA mr_table TYPE REF TO data . DATA mv_cancel TYPE abap_bool VALUE abap_false. DATA mo_table_descr TYPE REF TO cl_abap_tabledescr . METHODS add_field IMPORTING !iv_tabname TYPE sval-tabname !iv_fieldname TYPE sval-fieldname !iv_fieldtext TYPE sval-fieldtext !iv_value TYPE clike DEFAULT '' !iv_field_attr TYPE sval-field_attr DEFAULT '' !iv_obligatory TYPE spo_obl OPTIONAL CHANGING !ct_fields TYPE ty_sval_tt . METHODS create_new_table IMPORTING !it_list TYPE STANDARD TABLE . METHODS get_selected_rows EXPORTING !et_list TYPE INDEX TABLE . METHODS on_select_list_link_click FOR EVENT link_click OF cl_salv_events_table IMPORTING !row !column . METHODS on_select_list_function_click FOR EVENT added_function OF cl_salv_events_table IMPORTING !e_salv_function . METHODS on_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING !row !column . METHODS extract_field_values IMPORTING it_fields TYPE ty_sval_tt EXPORTING ev_url TYPE abaptxt255-line ev_package TYPE tdevc-devclass ev_branch TYPE textl-line ev_display_name TYPE trm255-text ev_folder_logic TYPE string ev_ign_subpkg TYPE abap_bool ev_master_lang_only TYPE abap_bool. TYPES: ty_lt_fields TYPE STANDARD TABLE OF sval WITH DEFAULT KEY. METHODS _popup_3_get_values IMPORTING iv_popup_title TYPE string iv_no_value_check TYPE abap_bool DEFAULT abap_false EXPORTING ev_value_1 TYPE spo_value ev_value_2 TYPE spo_value ev_value_3 TYPE spo_value CHANGING ct_fields TYPE ty_lt_fields RAISING zcx_abapgit_exception. METHODS popup_get_from_free_selections IMPORTING iv_title TYPE zcl_abapgit_free_sel_dialog=>ty_syst_title OPTIONAL iv_frame_text TYPE zcl_abapgit_free_sel_dialog=>ty_syst_title OPTIONAL CHANGING ct_fields TYPE zcl_abapgit_free_sel_dialog=>ty_free_sel_field_tab RAISING zcx_abapgit_cancel zcx_abapgit_exception. METHODS validate_folder_logic IMPORTING iv_folder_logic TYPE string RAISING zcx_abapgit_exception. ENDCLASS. CLASS ZCL_ABAPGIT_POPUPS IMPLEMENTATION. METHOD add_field. FIELD-SYMBOLS: LIKE LINE OF ct_fields. APPEND INITIAL LINE TO ct_fields ASSIGNING . -tabname = iv_tabname. -fieldname = iv_fieldname. -fieldtext = iv_fieldtext. -value = iv_value. -field_attr = iv_field_attr. -field_obl = iv_obligatory. ENDMETHOD. METHOD create_new_table. "" create and populate a table on the fly derived from "" it_data with a select column DATA: lr_struct TYPE REF TO data, lt_components TYPE cl_abap_structdescr=>component_table, lo_data_descr TYPE REF TO cl_abap_datadescr, lo_elem_descr TYPE REF TO cl_abap_elemdescr, lo_struct_descr TYPE REF TO cl_abap_structdescr, lo_struct_descr2 TYPE REF TO cl_abap_structdescr. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE abap_componentdescr, TYPE data, TYPE any, TYPE any. mo_table_descr ?= cl_abap_tabledescr=>describe_by_data( it_list ). lo_data_descr = mo_table_descr->get_table_line_type( ). CASE lo_data_descr->kind. WHEN cl_abap_elemdescr=>kind_elem. lo_elem_descr ?= mo_table_descr->get_table_line_type( ). INSERT INITIAL LINE INTO lt_components ASSIGNING INDEX 1. -name = c_default_column. -type = lo_elem_descr. WHEN cl_abap_elemdescr=>kind_struct. lo_struct_descr ?= mo_table_descr->get_table_line_type( ). lt_components = lo_struct_descr->get_components( ). ENDCASE. IF lt_components IS INITIAL. RETURN. ENDIF. INSERT INITIAL LINE INTO lt_components ASSIGNING INDEX 1. -name = c_fieldname_selected. -type ?= cl_abap_datadescr=>describe_by_name( 'FLAG' ). lo_struct_descr2 = cl_abap_structdescr=>create( lt_components ). mo_table_descr = cl_abap_tabledescr=>create( lo_struct_descr2 ). CREATE DATA mr_table TYPE HANDLE mo_table_descr. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. CREATE DATA lr_struct TYPE HANDLE lo_struct_descr2. ASSIGN lr_struct->* TO . ASSERT sy-subrc = 0. LOOP AT it_list ASSIGNING . CLEAR . CASE lo_data_descr->kind. WHEN cl_abap_elemdescr=>kind_elem. ASSIGN COMPONENT c_default_column OF STRUCTURE TO . ASSERT IS ASSIGNED. = . WHEN OTHERS. MOVE-CORRESPONDING TO . ENDCASE. INSERT INTO TABLE . ENDLOOP. ENDMETHOD. METHOD extract_field_values. FIELD-SYMBOLS: LIKE LINE OF it_fields. CLEAR: ev_url, ev_package, ev_branch, ev_display_name, ev_folder_logic, ev_ign_subpkg. READ TABLE it_fields INDEX 1 ASSIGNING . ASSERT sy-subrc = 0. ev_url = -value. READ TABLE it_fields INDEX 2 ASSIGNING . ASSERT sy-subrc = 0. ev_package = -value. TRANSLATE ev_package TO UPPER CASE. READ TABLE it_fields INDEX 3 ASSIGNING . ASSERT sy-subrc = 0. ev_branch = -value. READ TABLE it_fields INDEX 4 ASSIGNING . ASSERT sy-subrc = 0. ev_display_name = -value. READ TABLE it_fields INDEX 5 ASSIGNING . ASSERT sy-subrc = 0. ev_folder_logic = -value. TRANSLATE ev_folder_logic TO UPPER CASE. READ TABLE it_fields INDEX 6 ASSIGNING . ASSERT sy-subrc = 0. ev_ign_subpkg = -value. TRANSLATE ev_ign_subpkg TO UPPER CASE. READ TABLE it_fields INDEX 7 ASSIGNING . ASSERT sy-subrc = 0. ev_master_lang_only = -value. ENDMETHOD. METHOD get_selected_rows. DATA: lv_condition TYPE string, lr_exporting TYPE REF TO data. FIELD-SYMBOLS: TYPE any, TYPE STANDARD TABLE, TYPE any, TYPE any, TYPE abap_bool, TYPE LINE OF salv_t_row. DATA: lo_data_descr TYPE REF TO cl_abap_datadescr, lo_selections TYPE REF TO cl_salv_selections, lt_selected_rows TYPE salv_t_row. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. lo_selections = mo_select_list_popup->get_selections( ). IF lo_selections->get_selection_mode( ) = if_salv_c_selection_mode=>single. lt_selected_rows = lo_selections->get_selected_rows( ). LOOP AT lt_selected_rows ASSIGNING . READ TABLE ASSIGNING INDEX . CHECK IS ASSIGNED. ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . CHECK IS ASSIGNED. = abap_true. ENDLOOP. ENDIF. lv_condition = |{ c_fieldname_selected } = ABAP_TRUE|. CREATE DATA lr_exporting LIKE LINE OF et_list. ASSIGN lr_exporting->* TO . mo_table_descr ?= cl_abap_tabledescr=>describe_by_data( et_list ). lo_data_descr = mo_table_descr->get_table_line_type( ). LOOP AT ASSIGNING WHERE (lv_condition). CLEAR . CASE lo_data_descr->kind. WHEN cl_abap_elemdescr=>kind_elem. ASSIGN COMPONENT c_default_column OF STRUCTURE TO . ASSERT IS ASSIGNED. = . WHEN OTHERS. MOVE-CORRESPONDING TO . ENDCASE. APPEND TO et_list. ENDLOOP. ENDMETHOD. METHOD on_double_click. DATA: lo_selections TYPE REF TO cl_salv_selections. lo_selections = mo_select_list_popup->get_selections( ). IF lo_selections->get_selection_mode( ) = if_salv_c_selection_mode=>single. mo_select_list_popup->close_screen( ). ENDIF. ENDMETHOD. METHOD on_select_list_function_click. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE any, TYPE abap_bool. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. CASE e_salv_function. WHEN 'O.K.'. mv_cancel = abap_false. mo_select_list_popup->close_screen( ). WHEN 'ABR'. ""Canceled: clear list to overwrite nothing CLEAR . mv_cancel = abap_true. mo_select_list_popup->close_screen( ). WHEN 'SALL'. LOOP AT ASSIGNING . ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . ASSERT sy-subrc = 0. = abap_true. ENDLOOP. mo_select_list_popup->refresh( ). WHEN 'DSEL'. LOOP AT ASSIGNING . ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . ASSERT sy-subrc = 0. = abap_false. ENDLOOP. mo_select_list_popup->refresh( ). WHEN OTHERS. CLEAR . mo_select_list_popup->close_screen( ). ENDCASE. ENDMETHOD. METHOD on_select_list_link_click. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE any, TYPE abap_bool. ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. READ TABLE ASSIGNING INDEX row. IF sy-subrc = 0. ASSIGN COMPONENT c_fieldname_selected OF STRUCTURE TO . ASSERT sy-subrc = 0. IF = abap_true. = abap_false. ELSE. = abap_true. ENDIF. ENDIF. mo_select_list_popup->refresh( ). ENDMETHOD. METHOD popup_get_from_free_selections. DATA: lo_free_sel_dialog TYPE REF TO zcl_abapgit_free_sel_dialog. CREATE OBJECT lo_free_sel_dialog EXPORTING iv_title = iv_title iv_frame_text = iv_frame_text. lo_free_sel_dialog->set_fields( CHANGING ct_fields = ct_fields ). lo_free_sel_dialog->show( ). ENDMETHOD. METHOD validate_folder_logic. IF iv_folder_logic <> zif_abapgit_dot_abapgit=>c_folder_logic-prefix AND iv_folder_logic <> zif_abapgit_dot_abapgit=>c_folder_logic-full. zcx_abapgit_exception=>raise( |Invalid folder logic { iv_folder_logic }. | && |Choose either { zif_abapgit_dot_abapgit=>c_folder_logic-prefix } | && |or { zif_abapgit_dot_abapgit=>c_folder_logic-full } | ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~branch_list_popup. DATA: lo_branches TYPE REF TO zcl_abapgit_git_branch_list, lt_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt, lv_answer TYPE c LENGTH 1, lv_default TYPE i, lv_head_suffix TYPE string, lv_head_symref TYPE string, lv_text TYPE string, lt_selection TYPE TABLE OF spopli. FIELD-SYMBOLS: LIKE LINE OF lt_selection, LIKE LINE OF lt_branches. lo_branches = zcl_abapgit_git_transport=>branches( iv_url ). lt_branches = lo_branches->get_branches_only( ). lv_head_suffix = | ({ zif_abapgit_definitions=>c_head_name })|. lv_head_symref = lo_branches->get_head_symref( ). IF iv_hide_branch IS NOT INITIAL. DELETE lt_branches WHERE name = iv_hide_branch. ENDIF. IF iv_hide_head IS NOT INITIAL. DELETE lt_branches WHERE name = zif_abapgit_definitions=>c_head_name OR is_head = abap_true. ENDIF. IF lt_branches IS INITIAL. IF iv_hide_head IS NOT INITIAL. lv_text = 'master'. ENDIF. IF iv_hide_branch IS NOT INITIAL AND iv_hide_branch <> zif_abapgit_definitions=>c_git_branch-master. IF lv_text IS INITIAL. lv_text = iv_hide_branch && ' is'. ELSE. CONCATENATE lv_text 'and' iv_hide_branch 'are' INTO lv_text SEPARATED BY space. ENDIF. ELSE. lv_text = lv_text && ' is'. ENDIF. IF lv_text IS NOT INITIAL. zcx_abapgit_exception=>raise( 'No branches available to select (' && lv_text && ' hidden)' ). ELSE. zcx_abapgit_exception=>raise( 'No branches are available to select' ). ENDIF. ENDIF. LOOP AT lt_branches ASSIGNING . CHECK -name IS NOT INITIAL. "" To ensure some below ifs IF -is_head = abap_true. IF -name = zif_abapgit_definitions=>c_head_name. "" HEAD IF -name <> lv_head_symref AND lv_head_symref IS NOT INITIAL. "" HEAD but other HEAD symref exists - ignore CONTINUE. ELSE. INSERT INITIAL LINE INTO lt_selection INDEX 1 ASSIGNING . -varoption = -name. ENDIF. ELSE. INSERT INITIAL LINE INTO lt_selection INDEX 1 ASSIGNING . -varoption = -display_name && lv_head_suffix. ENDIF. IF lv_default > 0. "" Shift down default if set lv_default = lv_default + 1. ENDIF. ELSE. APPEND INITIAL LINE TO lt_selection ASSIGNING . -varoption = -display_name. ENDIF. IF -name = iv_default_branch. IF -is_head = abap_true. lv_default = 1. ELSE. lv_default = sy-tabix. ENDIF. ENDIF. ENDLOOP. IF iv_show_new_option = abap_true. APPEND INITIAL LINE TO lt_selection ASSIGNING . -varoption = zif_abapgit_popups=>c_new_branch_label. ENDIF. CALL FUNCTION 'POPUP_TO_DECIDE_LIST' EXPORTING textline1 = 'Select branch' titel = 'Select branch' start_col = 30 start_row = 5 cursorline = lv_default IMPORTING answer = lv_answer TABLES t_spopli = lt_selection EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_TO_DECIDE_LIST' ). ENDIF. IF lv_answer = c_answer_cancel. RETURN. ENDIF. READ TABLE lt_selection ASSIGNING WITH KEY selflag = abap_true. ASSERT sy-subrc = 0. IF iv_show_new_option = abap_true AND -varoption = zif_abapgit_popups=>c_new_branch_label. rs_branch-name = zif_abapgit_popups=>c_new_branch_label. ELSE. REPLACE FIRST OCCURRENCE OF lv_head_suffix IN -varoption WITH ''. READ TABLE lt_branches WITH KEY display_name = -varoption ASSIGNING . IF sy-subrc <> 0. * branch name longer than 65 characters LOOP AT lt_branches ASSIGNING WHERE display_name CS -varoption. EXIT. "" current loop ENDLOOP. ENDIF. ASSERT IS ASSIGNED. rs_branch = lo_branches->find_by_name( -name ). lv_text = |Branch switched from { zcl_abapgit_git_branch_list=>get_display_name( iv_default_branch ) } to { zcl_abapgit_git_branch_list=>get_display_name( rs_branch-name ) } |. MESSAGE lv_text TYPE 'S'. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~branch_popup_callback. DATA: lv_url TYPE string, ls_package_data TYPE scompkdtln, ls_branch TYPE zif_abapgit_definitions=>ty_git_branch, lv_create TYPE abap_bool, lv_text TYPE string. FIELD-SYMBOLS: LIKE LINE OF ct_fields, LIKE LINE OF ct_fields, LIKE LINE OF ct_fields. CLEAR cs_error. IF iv_code = 'COD1'. cv_show_popup = abap_true. READ TABLE ct_fields ASSIGNING WITH KEY tabname = 'ABAPTXT255'. IF sy-subrc <> 0 OR -value IS INITIAL. MESSAGE 'Fill URL' TYPE 'S' DISPLAY LIKE 'E'. RETURN. ENDIF. lv_url = -value. ls_branch = branch_list_popup( lv_url ). IF ls_branch IS INITIAL. RETURN. ENDIF. READ TABLE ct_fields ASSIGNING WITH KEY tabname = 'TEXTL'. ASSERT sy-subrc = 0. -value = ls_branch-name. ELSEIF iv_code = 'COD2'. cv_show_popup = abap_true. READ TABLE ct_fields ASSIGNING WITH KEY fieldname = 'DEVCLASS'. ASSERT sy-subrc = 0. ls_package_data-devclass = -value. IF zcl_abapgit_factory=>get_sap_package( ls_package_data-devclass )->exists( ) = abap_true. lv_text = |Package { ls_package_data-devclass } already exists|. MESSAGE lv_text TYPE 'I' DISPLAY LIKE 'E'. RETURN. ENDIF. popup_to_create_package( IMPORTING es_package_data = ls_package_data ev_create = lv_create ). IF lv_create = abap_false. RETURN. ENDIF. zcl_abapgit_factory=>get_sap_package( ls_package_data-devclass )->create( ls_package_data ). COMMIT WORK. -value = ls_package_data-devclass. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~choose_pr_popup. DATA lv_answer TYPE c LENGTH 1. DATA lt_selection TYPE TABLE OF spopli. FIELD-SYMBOLS LIKE LINE OF lt_selection. FIELD-SYMBOLS LIKE LINE OF it_pulls. IF lines( it_pulls ) = 0. zcx_abapgit_exception=>raise( 'No pull requests to select from' ). ENDIF. LOOP AT it_pulls ASSIGNING . APPEND INITIAL LINE TO lt_selection ASSIGNING . -varoption = |{ -number } - { -title } @{ -user }|. ENDLOOP. CALL FUNCTION 'POPUP_TO_DECIDE_LIST' EXPORTING textline1 = 'Select pull request' titel = 'Select pull request' start_col = 30 start_row = 5 IMPORTING answer = lv_answer TABLES t_spopli = lt_selection EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_TO_DECIDE_LIST' ). ENDIF. IF lv_answer = c_answer_cancel. RETURN. ENDIF. READ TABLE lt_selection ASSIGNING WITH KEY selflag = abap_true. ASSERT sy-subrc = 0. READ TABLE it_pulls INTO rs_pull INDEX sy-tabix. ASSERT sy-subrc = 0. ENDMETHOD. METHOD zif_abapgit_popups~create_branch_popup. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_name TYPE spo_value. CLEAR: ev_name, ev_cancel. add_field( EXPORTING iv_tabname = 'TEXTL' iv_fieldname = 'LINE' iv_fieldtext = 'Name' iv_value = 'new-branch-name' CHANGING ct_fields = lt_fields ). TRY. _popup_3_get_values( EXPORTING iv_popup_title = |Create branch from { zcl_abapgit_git_branch_list=>get_display_name( iv_source_branch_name ) }| IMPORTING ev_value_1 = lv_name CHANGING ct_fields = lt_fields ). ev_name = zcl_abapgit_git_branch_list=>complete_heads_branch_name( zcl_abapgit_git_branch_list=>normalize_branch_name( lv_name ) ). CATCH zcx_abapgit_cancel. ev_cancel = abap_true. ENDTRY. ENDMETHOD. METHOD zif_abapgit_popups~package_popup_callback. DATA: ls_package_data TYPE scompkdtln, lv_create TYPE abap_bool. FIELD-SYMBOLS: LIKE LINE OF ct_fields. CLEAR cs_error. IF iv_code = 'COD1'. cv_show_popup = abap_true. READ TABLE ct_fields ASSIGNING WITH KEY fieldname = 'DEVCLASS'. ASSERT sy-subrc = 0. ls_package_data-devclass = -value. popup_to_create_package( IMPORTING es_package_data = ls_package_data ev_create = lv_create ). IF lv_create = abap_false. RETURN. ENDIF. zcl_abapgit_factory=>get_sap_package( ls_package_data-devclass )->create( ls_package_data ). COMMIT WORK. -value = ls_package_data-devclass. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_folder_logic. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_folder_logic TYPE spo_value. CLEAR: rv_folder_logic. add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'INTSYS' iv_fieldtext = 'Folder logic' iv_value = 'PREFIX' CHANGING ct_fields = lt_fields ). TRY. _popup_3_get_values( EXPORTING iv_popup_title = 'Export package' iv_no_value_check = abap_true IMPORTING ev_value_1 = lv_folder_logic CHANGING ct_fields = lt_fields ). rv_folder_logic = to_upper( lv_folder_logic ). CATCH zcx_abapgit_cancel. ENDTRY. ENDMETHOD. METHOD zif_abapgit_popups~popup_object. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_object_type TYPE spo_value. DATA: lv_object_name TYPE spo_value. CLEAR: rs_tadir-object, rs_tadir-obj_name. add_field( EXPORTING iv_tabname = 'TADIR' iv_fieldname = 'OBJECT' iv_fieldtext = 'Type' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TADIR' iv_fieldname = 'OBJ_NAME' iv_fieldtext = 'Name' CHANGING ct_fields = lt_fields ). _popup_3_get_values( EXPORTING iv_popup_title = 'Object' iv_no_value_check = abap_true IMPORTING ev_value_1 = lv_object_type ev_value_2 = lv_object_name CHANGING ct_fields = lt_fields ). rs_tadir = zcl_abapgit_factory=>get_tadir( )->read_single( iv_object = to_upper( lv_object_type ) iv_obj_name = to_upper( lv_object_name ) ). ENDMETHOD. METHOD zif_abapgit_popups~popup_package_export. DATA: lt_fields TYPE TABLE OF sval. DATA: lv_package TYPE spo_value. DATA: lv_folder_logic TYPE spo_value. DATA: lv_serialize_master_lang_only TYPE spo_value. add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'DEVCLASS' iv_fieldtext = 'Package' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'INTSYS' iv_fieldtext = 'Folder logic' iv_value = 'PREFIX' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TVDIR' iv_fieldname = 'FLAG' iv_fieldtext = 'Master lang only' CHANGING ct_fields = lt_fields ). TRY. _popup_3_get_values( EXPORTING iv_popup_title = 'Export package' iv_no_value_check = abap_true IMPORTING ev_value_1 = lv_package ev_value_2 = lv_folder_logic ev_value_3 = lv_serialize_master_lang_only CHANGING ct_fields = lt_fields ). ev_package = to_upper( lv_package ). ev_folder_logic = to_upper( lv_folder_logic ). ev_serialize_master_lang_only = boolc( lv_serialize_master_lang_only IS NOT INITIAL ). CATCH zcx_abapgit_cancel. ENDTRY. ENDMETHOD. METHOD zif_abapgit_popups~popup_perf_test_parameters. DATA: lt_fields TYPE zcl_abapgit_free_sel_dialog=>ty_free_sel_field_tab. FIELD-SYMBOLS: TYPE zcl_abapgit_free_sel_dialog=>ty_free_sel_field. APPEND INITIAL LINE TO lt_fields ASSIGNING . -name = 'PACKAGE'. -only_parameter = abap_true. -ddic_tabname = 'TADIR'. -ddic_fieldname = 'DEVCLASS'. -param_obligatory = abap_true. -value = cv_package. APPEND INITIAL LINE TO lt_fields ASSIGNING . -name = 'PGMID'. -only_parameter = abap_true. -ddic_tabname = 'TADIR'. -ddic_fieldname = 'PGMID'. -value = 'R3TR'. APPEND INITIAL LINE TO lt_fields ASSIGNING . -name = 'OBJECT'. -ddic_tabname = 'TADIR'. -ddic_fieldname = 'OBJECT'. APPEND INITIAL LINE TO lt_fields ASSIGNING . -name = 'OBJ_NAME'. -ddic_tabname = 'TADIR'. -ddic_fieldname = 'OBJ_NAME'. APPEND INITIAL LINE TO lt_fields ASSIGNING . -name = 'INCLUDE_SUB_PACKAGES'. -only_parameter = abap_true. -ddic_tabname = 'TDEVC'. -ddic_fieldname = 'IS_ENHANCEABLE'. -text = 'Include subpackages'. -value = cv_include_sub_packages. APPEND INITIAL LINE TO lt_fields ASSIGNING . -name = 'MASTER_LANG_ONLY'. -only_parameter = abap_true. -ddic_tabname = 'TVDIR'. -ddic_fieldname = 'FLAG'. -text = 'Master lang only'. -value = cv_serialize_master_lang_only. popup_get_from_free_selections( EXPORTING iv_title = 'Serialization Performance Test Parameters' iv_frame_text = 'Parameters' CHANGING ct_fields = lt_fields ). LOOP AT lt_fields ASSIGNING . CASE -name. WHEN 'PACKAGE'. cv_package = -value. WHEN 'OBJECT'. et_object_type_filter = -value_range. WHEN 'OBJ_NAME'. et_object_name_filter = -value_range. WHEN 'INCLUDE_SUB_PACKAGES'. cv_include_sub_packages = boolc( -value IS NOT INITIAL ). WHEN 'MASTER_LANG_ONLY'. cv_serialize_master_lang_only = boolc( -value IS NOT INITIAL ). ENDCASE. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_popups~popup_proxy_bypass. rt_proxy_bypass = it_proxy_bypass. CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG' EXPORTING title = 'Bypass proxy settings for these Hosts & Domains' signed = abap_false lower_case = abap_true no_interval_check = abap_true TABLES range = rt_proxy_bypass EXCEPTIONS no_range_tab = 1 cancelled = 2 internal_error = 3 invalid_fieldname = 4 OTHERS = 5. CASE sy-subrc. WHEN 0. WHEN 2. RAISE EXCEPTION TYPE zcx_abapgit_cancel. WHEN OTHERS. zcx_abapgit_exception=>raise( 'Error from COMPLEX_SELECTIONS_DIALOG' ). ENDCASE. ENDMETHOD. METHOD zif_abapgit_popups~popup_search_help. DATA lt_ret TYPE TABLE OF ddshretval. DATA ls_ret LIKE LINE OF lt_ret. DATA lv_tabname TYPE dfies-tabname. DATA lv_fieldname TYPE dfies-fieldname. SPLIT iv_tab_field AT '-' INTO lv_tabname lv_fieldname. lv_tabname = to_upper( lv_tabname ). lv_fieldname = to_upper( lv_fieldname ). CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST' EXPORTING tabname = lv_tabname fieldname = lv_fieldname TABLES return_tab = lt_ret EXCEPTIONS OTHERS = 5. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |F4IF_FIELD_VALUE_REQUEST error [{ iv_tab_field }]| ). ENDIF. IF lines( lt_ret ) > 0. READ TABLE lt_ret INDEX 1 INTO ls_ret. ASSERT sy-subrc = 0. rv_value = ls_ret-fieldval. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_confirm. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = iv_titlebar text_question = iv_text_question text_button_1 = iv_text_button_1 icon_button_1 = iv_icon_button_1 text_button_2 = iv_text_button_2 icon_button_2 = iv_icon_button_2 default_button = iv_default_button display_cancel_button = iv_display_cancel_button IMPORTING answer = rv_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from POPUP_TO_CONFIRM' ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_create_package. CALL FUNCTION 'FUNCTION_EXISTS' EXPORTING funcname = 'PB_POPUP_PACKAGE_CREATE' EXCEPTIONS function_not_exist = 1 OTHERS = 2. IF sy-subrc = 1. * looks like the function module used does not exist on all * versions since 702, so show an error zcx_abapgit_exception=>raise( 'Your system does not support automatic creation of packages.' && 'Please, create the package manually.' ). ENDIF. CALL FUNCTION 'PB_POPUP_PACKAGE_CREATE' CHANGING p_object_data = es_package_data EXCEPTIONS action_cancelled = 1. ev_create = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_popups~popup_to_create_transp_branch. DATA: lt_fields TYPE TABLE OF sval, lv_transports_as_text TYPE string, lv_desc_as_text TYPE string, ls_transport_header LIKE LINE OF it_transport_headers. DATA: lv_branch_name TYPE spo_value. DATA: lv_commit_text TYPE spo_value. CLEAR: rs_transport_branch-branch_name, rs_transport_branch-commit_text. "" If we only have one transport selected set branch name to Transport "" name and commit description to transport description. IF lines( it_transport_headers ) = 1. READ TABLE it_transport_headers INDEX 1 INTO ls_transport_header. lv_transports_as_text = ls_transport_header-trkorr. SELECT SINGLE as4text FROM e07t INTO lv_desc_as_text WHERE trkorr = ls_transport_header-trkorr AND langu = sy-langu. ELSE. "" Else set branch name and commit message to 'Transport(s)_TRXXXXXX_TRXXXXX' lv_transports_as_text = 'Transport(s)'. LOOP AT it_transport_headers INTO ls_transport_header. CONCATENATE lv_transports_as_text '_' ls_transport_header-trkorr INTO lv_transports_as_text. ENDLOOP. lv_desc_as_text = lv_transports_as_text. ENDIF. add_field( EXPORTING iv_tabname = 'TEXTL' iv_fieldname = 'LINE' iv_fieldtext = 'Branch name' iv_value = lv_transports_as_text CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'ABAPTXT255' iv_fieldname = 'LINE' iv_fieldtext = 'Commit text' iv_value = lv_desc_as_text CHANGING ct_fields = lt_fields ). _popup_3_get_values( EXPORTING iv_popup_title = 'Transport to new Branch' IMPORTING ev_value_1 = lv_branch_name ev_value_2 = lv_commit_text CHANGING ct_fields = lt_fields ). rs_transport_branch-branch_name = lv_branch_name. rs_transport_branch-commit_text = lv_commit_text. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_inform. DATA: lv_line1 TYPE c LENGTH 70, lv_line2 TYPE c LENGTH 70. lv_line1 = iv_text_message. IF strlen( iv_text_message ) > 70. lv_line2 = iv_text_message+70. ENDIF. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = iv_titlebar txt1 = lv_line1 txt2 = lv_line2. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_select_from_list. DATA: lv_pfstatus TYPE sypfkey, lo_events TYPE REF TO cl_salv_events_table, lo_columns TYPE REF TO cl_salv_columns_table, lt_columns TYPE salv_t_column_ref, ls_column TYPE salv_s_column_ref, lo_column TYPE REF TO cl_salv_column_list, lo_table_header TYPE REF TO cl_salv_form_text. FIELD-SYMBOLS: TYPE STANDARD TABLE, TYPE zif_abapgit_definitions=>ty_alv_column. CLEAR: et_list. create_new_table( it_list ). ASSIGN mr_table->* TO . ASSERT sy-subrc = 0. TRY. cl_salv_table=>factory( IMPORTING r_salv_table = mo_select_list_popup CHANGING t_table = ). CASE iv_selection_mode. WHEN if_salv_c_selection_mode=>single. lv_pfstatus = '110'. WHEN OTHERS. lv_pfstatus = '102'. ENDCASE. mo_select_list_popup->set_screen_status( pfstatus = lv_pfstatus report = 'SAPMSVIM' ). mo_select_list_popup->set_screen_popup( start_column = iv_start_column end_column = iv_end_column start_line = iv_start_line end_line = iv_end_line ). lo_events = mo_select_list_popup->get_event( ). SET HANDLER on_select_list_link_click FOR lo_events. SET HANDLER on_select_list_function_click FOR lo_events. SET HANDLER on_double_click FOR lo_events. IF iv_title CN ' _0'. mo_select_list_popup->get_display_settings( )->set_list_header( iv_title ). ENDIF. IF iv_header_text CN ' _0'. CREATE OBJECT lo_table_header EXPORTING text = iv_header_text. mo_select_list_popup->set_top_of_list( lo_table_header ). ENDIF. mo_select_list_popup->get_display_settings( )->set_striped_pattern( iv_striped_pattern ). mo_select_list_popup->get_selections( )->set_selection_mode( iv_selection_mode ). lo_columns = mo_select_list_popup->get_columns( ). lt_columns = lo_columns->get( ). lo_columns->set_optimize( iv_optimize_col_width ). LOOP AT lt_columns INTO ls_column. lo_column ?= ls_column-r_column. IF iv_selection_mode = if_salv_c_selection_mode=>multiple AND ls_column-columnname = c_fieldname_selected. lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ). lo_column->set_output_length( 20 ). lo_column->set_short_text( |{ iv_select_column_text }| ). lo_column->set_medium_text( |{ iv_select_column_text }| ). lo_column->set_long_text( |{ iv_select_column_text }| ). CONTINUE. ENDIF. READ TABLE it_columns_to_display ASSIGNING WITH KEY name = ls_column-columnname. CASE sy-subrc. WHEN 0. IF -text CN ' _0'. lo_column->set_short_text( |{ -text }| ). lo_column->set_medium_text( |{ -text }| ). lo_column->set_long_text( |{ -text }| ). ENDIF. IF -length > 0. lo_column->set_output_length( -length ). ENDIF. WHEN OTHERS. "" Hide column lo_column->set_technical( abap_true ). ENDCASE. ENDLOOP. mo_select_list_popup->display( ). CATCH cx_salv_msg. zcx_abapgit_exception=>raise( 'Error from POPUP_TO_SELECT_FROM_LIST' ). ENDTRY. IF mv_cancel = abap_true. mv_cancel = abap_false. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ENDIF. get_selected_rows( IMPORTING et_list = et_list ). CLEAR: mo_select_list_popup, mr_table, mo_table_descr. ENDMETHOD. METHOD zif_abapgit_popups~popup_to_select_transports. * todo, method to be renamed, it only returns one transport DATA: lv_trkorr TYPE e070-trkorr, ls_trkorr LIKE LINE OF rt_trkorr. CALL FUNCTION 'TR_F4_REQUESTS' IMPORTING ev_selected_request = lv_trkorr. IF NOT lv_trkorr IS INITIAL. ls_trkorr-trkorr = lv_trkorr. APPEND ls_trkorr TO rt_trkorr. ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~popup_transport_request. DATA: lt_e071 TYPE STANDARD TABLE OF e071, lt_e071k TYPE STANDARD TABLE OF e071k. CALL FUNCTION 'TRINT_ORDER_CHOICE' EXPORTING wi_order_type = is_transport_type-request wi_task_type = is_transport_type-task IMPORTING we_order = rv_transport TABLES wt_e071 = lt_e071 wt_e071k = lt_e071k EXCEPTIONS no_correction_selected = 1 display_mode = 2 object_append_error = 3 recursive_call = 4 wrong_order_type = 5 OTHERS = 6. IF sy-subrc = 1. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ELSEIF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TRINT_ORDER_CHOICE { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_popups~repo_popup. DATA: lv_returncode TYPE c, lv_icon_ok TYPE icon-name, lv_icon_br TYPE icon-name, lt_fields TYPE TABLE OF sval, lv_uattr TYPE spo_fattr, lv_pattr TYPE spo_fattr, lv_button2 TYPE svalbutton-buttontext, lv_icon2 TYPE icon-name, lv_package TYPE tdevc-devclass, lv_url TYPE abaptxt255-line, lv_branch TYPE textl-line, lv_display_name TYPE trm255-text, lv_folder_logic TYPE string, lv_ign_subpkg TYPE abap_bool, lv_finished TYPE abap_bool, lv_master_lang_only TYPE abap_bool, lx_error TYPE REF TO zcx_abapgit_exception. IF iv_freeze_url = abap_true. lv_uattr = '05'. ENDIF. IF iv_freeze_package = abap_true. lv_pattr = '05'. ENDIF. IF iv_package IS INITIAL. "" Empty package -> can be created lv_button2 = 'Create package'. lv_icon2 = icon_folder. ENDIF. lv_display_name = iv_display_name. lv_package = iv_package. lv_url = iv_url. lv_branch = iv_branch. WHILE lv_finished = abap_false. CLEAR: lt_fields. add_field( EXPORTING iv_tabname = 'ABAPTXT255' iv_fieldname = 'LINE' iv_fieldtext = 'Git clone URL' iv_value = lv_url iv_field_attr = lv_uattr CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'DEVCLASS' iv_fieldtext = 'Package' iv_value = lv_package iv_field_attr = lv_pattr CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TEXTL' iv_fieldname = 'LINE' iv_fieldtext = 'Branch' iv_value = lv_branch iv_field_attr = '05' CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TRM255' iv_fieldname = 'TEXT' iv_fieldtext = 'Display name (opt.)' iv_value = lv_display_name CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TADIR' iv_fieldname = 'AUTHOR' iv_fieldtext = 'Folder logic' iv_obligatory = abap_true iv_value = zif_abapgit_dot_abapgit=>c_folder_logic-prefix CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'IS_ENHANCEABLE' iv_fieldtext = 'Ignore subpackages' iv_value = abap_false CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'DOKIL' iv_fieldname = 'MASTERLANG' iv_fieldtext = 'Master language only' iv_value = abap_true CHANGING ct_fields = lt_fields ). lv_icon_ok = icon_okay. lv_icon_br = icon_workflow_fork. CALL FUNCTION 'POPUP_GET_VALUES_USER_BUTTONS' EXPORTING popup_title = iv_title programname = sy-cprog formname = 'BRANCH_POPUP' ok_pushbuttontext = 'OK' icon_ok_push = lv_icon_ok first_pushbutton = 'Select branch' icon_button_1 = lv_icon_br second_pushbutton = lv_button2 icon_button_2 = lv_icon2 IMPORTING returncode = lv_returncode TABLES fields = lt_fields EXCEPTIONS error_in_fields = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_GET_VALUES' ). ENDIF. IF lv_returncode = c_answer_cancel. rs_popup-cancel = abap_true. RETURN. ENDIF. extract_field_values( EXPORTING it_fields = lt_fields IMPORTING ev_url = lv_url ev_package = lv_package ev_branch = lv_branch ev_display_name = lv_display_name ev_folder_logic = lv_folder_logic ev_ign_subpkg = lv_ign_subpkg ev_master_lang_only = lv_master_lang_only ). lv_finished = abap_true. TRY. IF iv_freeze_url = abap_false. zcl_abapgit_url=>validate( |{ lv_url }| ). ENDIF. IF iv_freeze_package = abap_false. zcl_abapgit_repo_srv=>get_instance( )->validate_package( iv_package = lv_package iv_ign_subpkg = lv_ign_subpkg iv_chk_exists = abap_false ). ENDIF. validate_folder_logic( lv_folder_logic ). CATCH zcx_abapgit_exception INTO lx_error. MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. "" in case of validation errors we display the popup again CLEAR lv_finished. ENDTRY. ENDWHILE. rs_popup-url = lv_url. rs_popup-package = lv_package. rs_popup-branch_name = lv_branch. rs_popup-display_name = lv_display_name. rs_popup-folder_logic = lv_folder_logic. rs_popup-ign_subpkg = lv_ign_subpkg. rs_popup-master_lang_only = lv_master_lang_only. ENDMETHOD. METHOD _popup_3_get_values. DATA lv_answer TYPE c LENGTH 1. FIELD-SYMBOLS: TYPE sval. CALL FUNCTION 'POPUP_GET_VALUES' EXPORTING no_value_check = iv_no_value_check popup_title = iv_popup_title IMPORTING returncode = lv_answer TABLES fields = ct_fields EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Error from POPUP_GET_VALUES' ). ENDIF. IF lv_answer = c_answer_cancel. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ENDIF. IF ev_value_1 IS SUPPLIED. READ TABLE ct_fields INDEX 1 ASSIGNING . ASSERT sy-subrc = 0. ev_value_1 = -value. ENDIF. IF ev_value_2 IS SUPPLIED. READ TABLE ct_fields INDEX 2 ASSIGNING . ASSERT sy-subrc = 0. ev_value_2 = -value. ENDIF. IF ev_value_3 IS SUPPLIED. READ TABLE ct_fields INDEX 3 ASSIGNING . ASSERT sy-subrc = 0. ev_value_3 = -value. ENDIF. ENDMETHOD. ENDCLASS. ",11882,False,2457.585008713779,median "CLASS zcl_abapgit_objects DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. TYPES: ty_types_tt TYPE SORTED TABLE OF tadir-object WITH UNIQUE KEY table_line . TYPES: BEGIN OF ty_serialization, files TYPE zif_abapgit_definitions=>ty_files_tt, item TYPE zif_abapgit_definitions=>ty_item, END OF ty_serialization . CLASS-METHODS serialize IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_language TYPE spras !iv_main_language_only TYPE abap_bool DEFAULT abap_false !it_translation_langs TYPE zif_abapgit_definitions=>ty_languages OPTIONAL RETURNING VALUE(rs_files_and_item) TYPE ty_serialization RAISING zcx_abapgit_exception . CLASS-METHODS deserialize IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo !is_checks TYPE zif_abapgit_definitions=>ty_deserialize_checks !ii_log TYPE REF TO zif_abapgit_log RETURNING VALUE(rt_accessed_files) TYPE zif_abapgit_definitions=>ty_file_signatures_tt RAISING zcx_abapgit_exception . CLASS-METHODS deserialize_checks IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(rs_checks) TYPE zif_abapgit_definitions=>ty_deserialize_checks RAISING zcx_abapgit_exception . CLASS-METHODS delete IMPORTING !it_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt !is_checks TYPE zif_abapgit_definitions=>ty_delete_checks OPTIONAL !ii_log TYPE REF TO zif_abapgit_log OPTIONAL RAISING zcx_abapgit_exception . CLASS-METHODS jump IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_line_number TYPE i OPTIONAL !iv_sub_obj_name TYPE zif_abapgit_definitions=>ty_item-obj_name OPTIONAL !iv_sub_obj_type TYPE zif_abapgit_definitions=>ty_item-obj_type OPTIONAL RAISING zcx_abapgit_exception . CLASS-METHODS changed_by IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item RETURNING VALUE(rv_user) TYPE xubname RAISING zcx_abapgit_exception . CLASS-METHODS is_supported IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_native_only TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rv_bool) TYPE abap_bool . CLASS-METHODS exists IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item RETURNING VALUE(rv_bool) TYPE abap_bool . CLASS-METHODS supported_list RETURNING VALUE(rt_types) TYPE ty_types_tt . CLASS-METHODS is_active IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item RETURNING VALUE(rv_active) TYPE abap_bool RAISING zcx_abapgit_exception . PROTECTED SECTION. PRIVATE SECTION. TYPES: BEGIN OF ty_obj_serializer_item, item TYPE zif_abapgit_definitions=>ty_item, metadata TYPE zif_abapgit_definitions=>ty_metadata, END OF ty_obj_serializer_item . TYPES: ty_obj_serializer_map TYPE SORTED TABLE OF ty_obj_serializer_item WITH UNIQUE KEY item . CLASS-DATA gt_obj_serializer_map TYPE ty_obj_serializer_map . CLASS-DATA gt_supported_obj_types TYPE ty_types_tt . CLASS-METHODS check_duplicates IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_files_tt RAISING zcx_abapgit_exception . CLASS-METHODS class_name IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item RETURNING VALUE(rv_class_name) TYPE string . CLASS-METHODS update_package_tree IMPORTING !iv_package TYPE devclass . CLASS-METHODS delete_object IMPORTING !iv_package TYPE devclass !is_item TYPE zif_abapgit_definitions=>ty_item RAISING zcx_abapgit_exception . CLASS-METHODS compare_remote_to_local IMPORTING !ii_object TYPE REF TO zif_abapgit_object !it_remote TYPE zif_abapgit_definitions=>ty_files_tt !is_result TYPE zif_abapgit_definitions=>ty_result !ii_log TYPE REF TO zif_abapgit_log RAISING zcx_abapgit_exception . CLASS-METHODS deserialize_objects IMPORTING !is_step TYPE zif_abapgit_objects=>ty_step_data !ii_log TYPE REF TO zif_abapgit_log CHANGING !ct_files TYPE zif_abapgit_definitions=>ty_file_signatures_tt RAISING zcx_abapgit_exception . CLASS-METHODS check_objects_locked IMPORTING !iv_language TYPE spras !it_items TYPE zif_abapgit_definitions=>ty_items_tt RAISING zcx_abapgit_exception . CLASS-METHODS create_object IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_language TYPE spras !is_metadata TYPE zif_abapgit_definitions=>ty_metadata OPTIONAL !iv_native_only TYPE abap_bool DEFAULT abap_false RETURNING VALUE(ri_obj) TYPE REF TO zif_abapgit_object RAISING zcx_abapgit_exception . CLASS-METHODS map_tadir_to_items IMPORTING !it_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt RETURNING VALUE(rt_items) TYPE zif_abapgit_definitions=>ty_items_tt . CLASS-METHODS map_results_to_items IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_items) TYPE zif_abapgit_definitions=>ty_items_tt . CLASS-METHODS get_deserialize_steps RETURNING VALUE(rt_steps) TYPE zif_abapgit_objects=>ty_step_data_tt . CLASS-METHODS check_main_package IMPORTING !iv_package TYPE devclass !iv_obj_type TYPE tadir-object RAISING zcx_abapgit_exception . ENDCLASS. CLASS ZCL_ABAPGIT_OBJECTS IMPLEMENTATION. METHOD changed_by. DATA: li_obj TYPE REF TO zif_abapgit_object. IF is_item IS NOT INITIAL. li_obj = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english ). rv_user = li_obj->changed_by( ). ENDIF. IF rv_user IS INITIAL. * eg. "".abapgit.xml"" file rv_user = zcl_abapgit_objects_super=>c_user_unknown. ENDIF. ENDMETHOD. METHOD check_duplicates. DATA: lt_files TYPE zif_abapgit_definitions=>ty_files_tt, lv_path TYPE string, lv_filename TYPE string, lt_duplicates TYPE STANDARD TABLE OF string WITH DEFAULT KEY, lv_duplicates LIKE LINE OF lt_duplicates, lv_all_duplicates TYPE string. FIELD-SYMBOLS: LIKE LINE OF it_files. lt_files = it_files. SORT lt_files BY path ASCENDING filename ASCENDING. LOOP AT lt_files ASSIGNING . IF lv_path = -path AND lv_filename = -filename. CONCATENATE -path -filename INTO lv_duplicates. APPEND lv_duplicates TO lt_duplicates. ENDIF. lv_path = -path. lv_filename = -filename. ENDLOOP. IF lt_duplicates IS NOT INITIAL. CONCATENATE LINES OF lt_duplicates INTO lv_all_duplicates SEPARATED BY `, `. zcx_abapgit_exception=>raise( |Duplicates: { lv_all_duplicates }| ). ENDIF. ENDMETHOD. METHOD check_main_package. "" check package restrictions, closed package, descriptive or "" functional package cl_pak_object_types=>check_object_type( EXPORTING i_working_mode = 'I' i_package_name = iv_package i_pgmid = 'R3TR' i_object_type = iv_obj_type EXCEPTIONS wrong_object_type = 1 package_not_extensible = 2 package_not_loaded = 3 OTHERS = 4 ). CASE sy-subrc. WHEN 0. RETURN. WHEN 2. zcx_abapgit_exception=>raise( |Object type { iv_obj_type } not allowed for package { iv_package }| ). WHEN OTHERS. zcx_abapgit_exception=>raise_t100( ). ENDCASE. ENDMETHOD. METHOD check_objects_locked. DATA: li_obj TYPE REF TO zif_abapgit_object. FIELD-SYMBOLS: LIKE LINE OF it_items. LOOP AT it_items ASSIGNING . "" You should remember that we ignore not supported objects here, "" because otherwise the process aborts which is not desired IF is_supported( ) = abap_false. CONTINUE. ENDIF. li_obj = create_object( is_item = iv_language = iv_language ). IF li_obj->is_locked( ) = abap_true. zcx_abapgit_exception=>raise( |Object { -obj_type } { -obj_name } | && |is locked. Action not possible.| ). ENDIF. ENDLOOP. ENDMETHOD. METHOD class_name. CONCATENATE 'ZCL_ABAPGIT_OBJECT_' is_item-obj_type INTO rv_class_name. ENDMETHOD. METHOD compare_remote_to_local. * this method is used for comparing local with remote objects * before pull, this is useful eg. when overwriting a TABL object. * only the main XML file is used for comparison DATA: ls_remote_file TYPE zif_abapgit_definitions=>ty_file, li_remote_version TYPE REF TO zif_abapgit_xml_input, lv_count TYPE i, ls_result TYPE zif_abapgit_comparator=>ty_result, lv_answer TYPE string, li_comparator TYPE REF TO zif_abapgit_comparator, lv_gui_is_available TYPE abap_bool, ls_item TYPE zif_abapgit_definitions=>ty_item. FIND ALL OCCURRENCES OF '.' IN is_result-filename MATCH COUNT lv_count. IF is_result-filename CS '.XML' AND lv_count = 2. IF ii_object->exists( ) = abap_false. RETURN. ENDIF. READ TABLE it_remote WITH KEY filename = is_result-filename INTO ls_remote_file. IF sy-subrc <> 0. ""if file does not exist in remote, we don't need to validate RETURN. ENDIF. li_comparator = ii_object->get_comparator( ). IF NOT li_comparator IS BOUND. RETURN. ENDIF. CREATE OBJECT li_remote_version TYPE zcl_abapgit_xml_input EXPORTING iv_xml = zcl_abapgit_convert=>xstring_to_string_utf8( ls_remote_file-data ) iv_filename = ls_remote_file-filename. ls_result = li_comparator->compare( ii_remote = li_remote_version ii_log = ii_log ). IF ls_result-text IS INITIAL. RETURN. ENDIF. ""log comparison result ls_item-obj_type = is_result-obj_type. ls_item-obj_name = is_result-obj_name. ii_log->add_warning( iv_msg = ls_result-text is_item = ls_item ). ""continue or abort? lv_gui_is_available = zcl_abapgit_ui_factory=>get_gui_functions( )->gui_is_available( ). IF lv_gui_is_available = abap_true. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = 'Warning' text_question = ls_result-text text_button_1 = 'Abort' icon_button_1 = 'ICON_CANCEL' text_button_2 = 'Pull anyway' icon_button_2 = 'ICON_OKAY' default_button = '2' display_cancel_button = abap_false IMPORTING answer = lv_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. IF sy-subrc <> 0 OR lv_answer = 1. zcx_abapgit_exception=>raise( |Deserialization for object { is_result-obj_name } | & |(type { is_result-obj_type }) aborted by user| ). ENDIF. ELSE. zcx_abapgit_exception=>raise( |Deserialization for object { is_result-obj_name } | & |(type { is_result-obj_type }) aborted, user descision required| ). ENDIF. ENDIF. ENDMETHOD. METHOD create_object. DATA: lv_message TYPE string, lv_class_name TYPE string, ls_obj_serializer_map LIKE LINE OF gt_obj_serializer_map. READ TABLE gt_obj_serializer_map INTO ls_obj_serializer_map WITH KEY item = is_item. IF sy-subrc = 0. lv_class_name = ls_obj_serializer_map-metadata-class. ELSEIF is_metadata IS NOT INITIAL. * Metadata is provided only on serialization * Once this has been triggered, the same serializer shall be used * for subsequent processes. * Thus, buffer the metadata afterwards ls_obj_serializer_map-item = is_item. ls_obj_serializer_map-metadata = is_metadata. INSERT ls_obj_serializer_map INTO TABLE gt_obj_serializer_map. lv_class_name = is_metadata-class. ELSE. lv_class_name = class_name( is_item ). ENDIF. REPLACE FIRST OCCURRENCE OF 'LCL' IN lv_class_name WITH 'ZCL_ABAPGIT'. TRY. CREATE OBJECT ri_obj TYPE (lv_class_name) EXPORTING is_item = is_item iv_language = iv_language. CATCH cx_sy_create_object_error. lv_message = |Object type { is_item-obj_type } is not supported by this system|. IF iv_native_only = abap_false. TRY. "" 2nd step, try looking for plugins CREATE OBJECT ri_obj TYPE zcl_abapgit_objects_bridge EXPORTING is_item = is_item. CATCH cx_sy_create_object_error. zcx_abapgit_exception=>raise( lv_message ). ENDTRY. ELSE. "" No native support? -> fail zcx_abapgit_exception=>raise( lv_message ). ENDIF. ENDTRY. ENDMETHOD. METHOD delete. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, li_progress TYPE REF TO zif_abapgit_progress, lt_tadir LIKE it_tadir, lt_deleted LIKE it_tadir, lt_items TYPE zif_abapgit_definitions=>ty_items_tt, lx_error TYPE REF TO zcx_abapgit_exception, lv_count TYPE i. FIELD-SYMBOLS: LIKE LINE OF it_tadir. lt_tadir = it_tadir. IF is_checks-transport-required = abap_true. zcl_abapgit_default_transport=>get_instance( )->set( is_checks-transport-transport ). ENDIF. TRY. zcl_abapgit_dependencies=>resolve( CHANGING ct_tadir = lt_tadir ). li_progress = zcl_abapgit_progress=>get_instance( lines( lt_tadir ) ). lt_items = map_tadir_to_items( lt_tadir ). check_objects_locked( iv_language = zif_abapgit_definitions=>c_english it_items = lt_items ). CATCH zcx_abapgit_exception INTO lx_error. zcl_abapgit_default_transport=>get_instance( )->reset( ). RAISE EXCEPTION lx_error. ENDTRY. lv_count = 1. DO. CLEAR lt_deleted. LOOP AT lt_tadir ASSIGNING . li_progress->show( iv_current = lv_count iv_text = |Delete { -obj_name }| ). CLEAR ls_item. ls_item-obj_type = -object. ls_item-obj_name = -obj_name. TRY. delete_object( iv_package = -devclass is_item = ls_item ). INSERT INTO TABLE lt_deleted. DELETE lt_tadir. lv_count = lv_count + 1. "" make sure to save object deletions COMMIT WORK. CATCH zcx_abapgit_exception INTO lx_error. IF ii_log IS BOUND. ii_log->add_exception( ix_exc = lx_error is_item = ls_item ). ii_log->add_error( iv_msg = |Deletion of object { ls_item-obj_name } failed| is_item = ls_item ). ENDIF. ENDTRY. ENDLOOP. "" Exit if done or nothing else was deleted IF lines( lt_tadir ) = 0 OR lines( lt_deleted ) = 0. EXIT. ENDIF. ENDDO. zcl_abapgit_default_transport=>get_instance( )->reset( ). IF lx_error IS BOUND AND lines( lt_tadir ) > 0. zcx_abapgit_exception=>raise( 'Error during uninstall. Check the log.' ). ENDIF. li_progress->off( ). ENDMETHOD. METHOD delete_object. DATA: li_obj TYPE REF TO zif_abapgit_object. IF is_supported( is_item ) = abap_true. li_obj = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english ). li_obj->delete( iv_package ). IF li_obj->get_metadata( )-delete_tadir = abap_true. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = is_item-obj_type wi_tadir_obj_name = is_item-obj_name wi_test_modus = abap_false EXCEPTIONS OTHERS = 1 ##FM_SUBRC_OK. "" We deliberately ignore the subrc, because throwing an exception would "" break the deletion of lots of object types. On the other hand we have "" to catch the exceptions because otherwise messages would directly be issued "" by the function module and change the control flow. Thus breaking the "" deletion of TOBJ and other object types. "" TODO: This is not very clean and has to be improved in the future. See PR 2741. ENDIF. ENDIF. ENDMETHOD. METHOD deserialize. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, li_obj TYPE REF TO zif_abapgit_object, lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lv_package TYPE devclass, lo_files TYPE REF TO zcl_abapgit_objects_files, lo_xml TYPE REF TO zif_abapgit_xml_input, lt_results TYPE zif_abapgit_definitions=>ty_results_tt, li_progress TYPE REF TO zif_abapgit_progress, lv_path TYPE string, lt_items TYPE zif_abapgit_definitions=>ty_items_tt, lt_steps_id TYPE zif_abapgit_definitions=>ty_deserialization_step_tt, lt_steps TYPE zif_abapgit_objects=>ty_step_data_tt, lx_exc TYPE REF TO zcx_abapgit_exception. DATA: lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_result, TYPE LINE OF zif_abapgit_definitions=>ty_deserialization_step_tt, TYPE LINE OF zif_abapgit_objects=>ty_step_data_tt, TYPE LINE OF zif_abapgit_objects=>ty_deserialization_tt. lt_steps = get_deserialize_steps( ). lv_package = io_repo->get_package( ). IF is_checks-transport-required = abap_true. zcl_abapgit_default_transport=>get_instance( )->set( is_checks-transport-transport ). ENDIF. zcl_abapgit_objects_activation=>clear( ). lt_remote = io_repo->get_files_remote( ). lt_results = zcl_abapgit_file_deserialize=>get_results( io_repo = io_repo ii_log = ii_log ). zcl_abapgit_objects_check=>checks_adjust( EXPORTING io_repo = io_repo is_checks = is_checks CHANGING ct_results = lt_results ). li_progress = zcl_abapgit_progress=>get_instance( lines( lt_results ) ). lt_items = map_results_to_items( lt_results ). check_objects_locked( iv_language = io_repo->get_dot_abapgit( )->get_main_language( ) it_items = lt_items ). lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). LOOP AT lt_results ASSIGNING . li_progress->show( iv_current = sy-tabix iv_text = |Deserialize { -obj_name }| ). CLEAR ls_item. ls_item-obj_type = -obj_type. ls_item-obj_name = -obj_name. ""error handling & logging added TRY. "" If package does not exist yet, it will be created with this call lv_package = lo_folder_logic->path_to_package( iv_top = io_repo->get_package( ) io_dot = io_repo->get_dot_abapgit( ) iv_path = -path ). check_main_package( iv_package = lv_package iv_obj_type = ls_item-obj_type ). IF ls_item-obj_type = 'DEVC'. "" Packages have the same filename across different folders. The path needs to be supplied "" to find the correct file. lv_path = -path. ENDIF. CREATE OBJECT lo_files EXPORTING is_item = ls_item iv_path = lv_path. lo_files->set_files( lt_remote ). ""analyze XML in order to instantiate the proper serializer lo_xml = lo_files->read_xml( ). li_obj = create_object( is_item = ls_item iv_language = io_repo->get_dot_abapgit( )->get_main_language( ) is_metadata = lo_xml->get_metadata( ) ). compare_remote_to_local( ii_object = li_obj it_remote = lt_remote is_result = ii_log = ii_log ). li_obj->mo_files = lo_files. ""get required steps for deserialize the object lt_steps_id = li_obj->get_deserialize_steps( ). LOOP AT lt_steps_id ASSIGNING . READ TABLE lt_steps WITH KEY step_id = ASSIGNING . ASSERT sy-subrc = 0. IF -is_ddic = abap_true AND li_obj->get_metadata( )-ddic = abap_false. "" DDIC only for DDIC objects zcx_abapgit_exception=>raise( |Step { } is only for DDIC objects| ). ENDIF. APPEND INITIAL LINE TO -objects ASSIGNING . -item = ls_item. -obj = li_obj. -xml = lo_xml. -package = lv_package. ENDLOOP. CLEAR: lv_path, lv_package. CATCH zcx_abapgit_exception INTO lx_exc. ii_log->add_exception( ix_exc = lx_exc is_item = ls_item ). ii_log->add_error( iv_msg = |Import of object { ls_item-obj_name } failed| is_item = ls_item ). ""object should not be part of any deserialization step CONTINUE. ENDTRY. ENDLOOP. ""run deserialize for all steps and it's objects SORT lt_steps BY order. LOOP AT lt_steps ASSIGNING . deserialize_objects( EXPORTING is_step = ii_log = ii_log CHANGING ct_files = rt_accessed_files ). ENDLOOP. update_package_tree( io_repo->get_package( ) ). SORT rt_accessed_files BY path ASCENDING filename ASCENDING. DELETE ADJACENT DUPLICATES FROM rt_accessed_files. "" Just in case zcl_abapgit_default_transport=>get_instance( )->reset( ). li_progress->off( ). ENDMETHOD. METHOD deserialize_checks. rs_checks = zcl_abapgit_objects_check=>deserialize_checks( io_repo ). ENDMETHOD. METHOD deserialize_objects. DATA: li_progress TYPE REF TO zif_abapgit_progress, li_exit TYPE REF TO zif_abapgit_exit, lx_exc TYPE REF TO zcx_abapgit_exception. FIELD-SYMBOLS: LIKE LINE OF is_step-objects. zcl_abapgit_objects_activation=>clear( ). li_progress = zcl_abapgit_progress=>get_instance( lines( is_step-objects ) ). LOOP AT is_step-objects ASSIGNING . li_progress->show( iv_current = sy-tabix iv_text = |Deserialize { is_step-descr } - { -item-obj_name }| ). TRY. -obj->deserialize( iv_package = -package io_xml = -xml iv_step = is_step-step_id ii_log = ii_log ). APPEND LINES OF -obj->mo_files->get_accessed_files( ) TO ct_files. ii_log->add_success( iv_msg = |Object { -item-obj_name } imported| is_item = -item ). CATCH zcx_abapgit_exception INTO lx_exc. ii_log->add_exception( ix_exc = lx_exc is_item = -item ). ii_log->add_error( iv_msg = |Import of object { -item-obj_name } failed| is_item = -item ). ENDTRY. ENDLOOP. CASE is_step-step_id. WHEN zif_abapgit_object=>gc_step_id-ddic. zcl_abapgit_objects_activation=>activate( is_step-is_ddic ). WHEN zif_abapgit_object=>gc_step_id-abap. zcl_abapgit_objects_activation=>activate( is_step-is_ddic ). WHEN zif_abapgit_object=>gc_step_id-late. "" late can have both DDIC (like TABL with REF TO) and non-DDIC objects zcl_abapgit_objects_activation=>activate( abap_true ). zcl_abapgit_objects_activation=>activate( abap_false ). ENDCASE. * Call postprocessing li_exit = zcl_abapgit_exit=>get_instance( ). li_exit->deserialize_postprocess( is_step = is_step ii_log = ii_log ). ENDMETHOD. METHOD exists. DATA: li_obj TYPE REF TO zif_abapgit_object. TRY. li_obj = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english ). rv_bool = li_obj->exists( ). CATCH zcx_abapgit_exception. * ignore all errors and assume the object exists rv_bool = abap_true. ENDTRY. ENDMETHOD. METHOD get_deserialize_steps. FIELD-SYMBOLS: TYPE LINE OF zif_abapgit_objects=>ty_step_data_tt. APPEND INITIAL LINE TO rt_steps ASSIGNING . -step_id = zif_abapgit_object=>gc_step_id-ddic. -descr = 'Import DDIC objects'. -is_ddic = abap_true. -syntax_check = abap_false. -order = 1. APPEND INITIAL LINE TO rt_steps ASSIGNING . -step_id = zif_abapgit_object=>gc_step_id-abap. -descr = 'Import objects main'. -is_ddic = abap_false. -syntax_check = abap_false. -order = 2. APPEND INITIAL LINE TO rt_steps ASSIGNING . -step_id = zif_abapgit_object=>gc_step_id-late. -descr = 'Import late objects'. -is_ddic = abap_false. -syntax_check = abap_true. -order = 3. ENDMETHOD. METHOD is_active. DATA: li_object TYPE REF TO zif_abapgit_object. TRY. li_object = create_object( is_item = is_item iv_language = sy-langu ). rv_active = li_object->is_active( ). CATCH cx_sy_dyn_call_illegal_method cx_sy_ref_is_initial zcx_abapgit_exception. rv_active = abap_true. ENDTRY. ENDMETHOD. METHOD is_supported. TRY. create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english iv_native_only = iv_native_only ). rv_bool = abap_true. CATCH zcx_abapgit_exception. rv_bool = abap_false. ENDTRY. ENDMETHOD. METHOD jump. DATA: li_obj TYPE REF TO zif_abapgit_object, lv_adt_jump_enabled TYPE abap_bool. li_obj = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english ). IF li_obj->exists( ) = abap_false. zcx_abapgit_exception=>raise( |Object { is_item-obj_type } { is_item-obj_name } doesn't exist| ). ENDIF. lv_adt_jump_enabled = zcl_abapgit_persist_factory=>get_settings( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. zcl_abapgit_objects_super=>jump_adt( iv_obj_name = is_item-obj_name iv_obj_type = is_item-obj_type iv_sub_obj_name = iv_sub_obj_name iv_sub_obj_type = iv_sub_obj_type iv_line_number = iv_line_number ). CATCH zcx_abapgit_exception. li_obj->jump( ). ENDTRY. ELSEIF iv_line_number IS NOT INITIAL AND iv_sub_obj_type IS NOT INITIAL AND iv_sub_obj_name IS NOT INITIAL. "" For the line navigation we have to supply the sub object type (i_sub_obj_type). "" If we use is_item-obj_type it navigates only to the object. CALL FUNCTION 'RS_TOOL_ACCESS' EXPORTING operation = 'SHOW' object_name = is_item-obj_name object_type = iv_sub_obj_type include = iv_sub_obj_name position = iv_line_number in_new_window = abap_true EXCEPTIONS not_executed = 1 invalid_object_type = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ELSE. li_obj->jump( ). ENDIF. ENDMETHOD. METHOD map_results_to_items. DATA: ls_item LIKE LINE OF rt_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_result. LOOP AT it_results ASSIGNING . ls_item-devclass = -package. ls_item-obj_type = -obj_type. ls_item-obj_name = -obj_name. INSERT ls_item INTO TABLE rt_items. ENDLOOP. ENDMETHOD. METHOD map_tadir_to_items. DATA: ls_item LIKE LINE OF rt_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_tadir. LOOP AT it_tadir ASSIGNING . ls_item-devclass = -devclass. ls_item-obj_type = -object. ls_item-obj_name = -obj_name. INSERT ls_item INTO TABLE rt_items. ENDLOOP. ENDMETHOD. METHOD serialize. DATA: li_obj TYPE REF TO zif_abapgit_object, li_xml TYPE REF TO zif_abapgit_xml_output, lo_files TYPE REF TO zcl_abapgit_objects_files, ls_i18n_params TYPE zif_abapgit_definitions=>ty_i18n_params. FIELD-SYMBOLS: LIKE LINE OF rs_files_and_item-files. rs_files_and_item-item = is_item. IF is_supported( rs_files_and_item-item ) = abap_false. zcx_abapgit_exception=>raise( |Object type ignored, not supported: { rs_files_and_item-item-obj_type }-{ rs_files_and_item-item-obj_name }| ). ENDIF. CREATE OBJECT lo_files EXPORTING is_item = rs_files_and_item-item. li_obj = create_object( is_item = rs_files_and_item-item iv_language = iv_language ). li_obj->mo_files = lo_files. CREATE OBJECT li_xml TYPE zcl_abapgit_xml_output. ls_i18n_params-main_language = iv_language. ls_i18n_params-main_language_only = iv_main_language_only. ls_i18n_params-translation_languages = it_translation_langs. li_xml->i18n_params( ls_i18n_params ). li_obj->serialize( li_xml ). lo_files->add_xml( ii_xml = li_xml is_metadata = li_obj->get_metadata( ) ). rs_files_and_item-files = lo_files->get_files( ). check_duplicates( rs_files_and_item-files ). rs_files_and_item-item-inactive = boolc( li_obj->is_active( ) = abap_false ). LOOP AT rs_files_and_item-files ASSIGNING . -sha1 = zcl_abapgit_hash=>sha1_blob( -data ). ENDLOOP. ENDMETHOD. METHOD supported_list. DATA: lt_objects TYPE STANDARD TABLE OF ko100, ls_item TYPE zif_abapgit_definitions=>ty_item. FIELD-SYMBOLS LIKE LINE OF lt_objects. IF gt_supported_obj_types IS NOT INITIAL. rt_types = gt_supported_obj_types. RETURN. ENDIF. CALL FUNCTION 'TR_OBJECT_TABLE' TABLES wt_object_text = lt_objects EXCEPTIONS OTHERS = 1 ##FM_SUBRC_OK. LOOP AT lt_objects ASSIGNING WHERE pgmid = 'R3TR'. ls_item-obj_type = -object. IF is_supported( ls_item ) = abap_true. INSERT -object INTO TABLE rt_types. ENDIF. ENDLOOP. gt_supported_obj_types = rt_types. ENDMETHOD. METHOD update_package_tree. DATA: lt_packages TYPE zif_abapgit_sap_package=>ty_devclass_tt, lv_package LIKE LINE OF lt_packages, lv_tree TYPE dirtree-tname. lt_packages = zcl_abapgit_factory=>get_sap_package( iv_package )->list_subpackages( ). APPEND iv_package TO lt_packages. LOOP AT lt_packages INTO lv_package. * update package tree for SE80 lv_tree = 'EU_' && lv_package. CALL FUNCTION 'WB_TREE_ACTUALIZE' EXPORTING tree_name = lv_tree without_crossreference = abap_true with_tcode_index = abap_true. ENDLOOP. ENDMETHOD. ENDCLASS. ",8246,False,1895.8893665026487,median "/* Feathers Copyright 2012-2021 Bowler Hat LLC. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls { import feathers.core.FeathersControl; import feathers.core.IAdvancedNativeFocusOwner; import feathers.core.ITextBaselineControl; import feathers.core.PropertyProxy; import feathers.events.ExclusiveTouch; import feathers.events.FeathersEventType; import feathers.skins.IStyleProvider; import feathers.utils.math.clamp; import feathers.utils.math.roundToNearest; import feathers.utils.math.roundToPrecision; import flash.events.TimerEvent; import flash.ui.Keyboard; import flash.utils.Timer; import starling.display.DisplayObject; import starling.events.Event; import starling.events.KeyboardEvent; import starling.events.Touch; import starling.events.TouchEvent; import starling.events.TouchPhase; /** * How the buttons are positioned relative to the text input. * *

In the following example, the button layout is set to place the * buttons on the right side, stacked vertically, for a desktop * appearance:

* * * stepper.buttonLayoutMode = NumericStepper.StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL; * * @default feathers.controls.StepperButtonLayoutMode.SPLIT_HORIZONTAL * * @see feathers.controls.StepperButtonLayoutMode#SPLIT_HORIZONTAL * @see feathers.controls.StepperButtonLayoutMode#SPLIT_VERTICAL * @see feathers.controls.StepperButtonLayoutMode#RIGHT_SIDE_VERTICAL */ [Style(name=""buttonLayoutMode"",type=""String"")] /** * The gap, in pixels, between the numeric stepper's increment and * decrement buttons when they are both positioned on the same side. If * the buttons are split between two sides, this value is not used. * *

In the following example, the gap between buttons is set to 20 pixels:

* * * stepper.buttonLayoutMode = StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL; * stepper.buttonGap = 20; * * @default 0 * * @see #style:textInputGap * @see #style:buttonLayoutMode */ [Style(name=""buttonGap"",type=""Number"")] /** * A style name to add to the numeric stepper's decrement button * sub-component. Typically used by a theme to provide different styles * to different numeric steppers. * *

In the following example, a custom decrement button style name is * passed to the stepper:

* * * stepper.customDecrementButtonStyleName = ""my-custom-decrement-button""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( Button ).setFunctionForStyleName( ""my-custom-decrement-button"", setCustomDecrementButtonStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON * @see feathers.core.FeathersControl#styleNameList * @see #decrementButtonFactory */ [Style(name=""customDecrementButtonStyleName"",type=""String"")] /** * A style name to add to the numeric stepper's increment button * sub-component. Typically used by a theme to provide different styles * to different numeric steppers. * *

In the following example, a custom increment button style name is * passed to the stepper:

* * * stepper.customIncrementButtonStyleName = ""my-custom-increment-button""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( Button ).setFunctionForStyleName( ""my-custom-increment-button"", setCustomIncrementButtonStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON * @see feathers.core.FeathersControl#styleNameList * @see #incrementButtonFactory */ [Style(name=""customIncrementButtonStyleName"",type=""String"")] /** * A style name to add to the numeric stepper's text input sub-component. * Typically used by a theme to provide different styles to different * text inputs. * *

In the following example, a custom text input style name is passed * to the stepper:

* * * stepper.customTextInputStyleName = ""my-custom-text-input""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( TextInput ).setFunctionForStyleName( ""my-custom-text-input"", setCustomTextInputStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT * @see feathers.core.FeathersControl#styleNameList * @see #textInputFactory */ [Style(name=""customTextInputStyleName"",type=""String"")] /** * The text displayed by the decrement button. Often, there is no text * displayed on this button and an icon is used instead. * *

In the following example, the decrement button's label is customized:

* * * stepper.decrementButtonLabel = ""-""; * * @default null */ [Style(name=""decrementButtonLabel"",type=""String"")] /** * The text displayed by the increment button. Often, there is no text * displayed on this button and an icon is used instead. * *

In the following example, the increment button's label is customized:

* * * stepper.incrementButtonLabel = ""+""; * * @default null */ [Style(name=""incrementButtonLabel"",type=""String"")] /** * The gap, in pixels, between the numeric stepper's text input and its * buttons. If the buttons are split, this gap is used on both sides. If * the buttons both appear on the same side, the gap is used only on * that side. * *

In the following example, the gap between the text input and buttons is set to 20 pixels:

* * * stepper.textInputGap = 20; * * @default 0 * * @see #style:buttonGap * @see #style:buttonLayoutMode */ [Style(name=""textInputGap"",type=""Number"")] /** * Dispatched when the stepper's value changes. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @see #value * * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] /** * Select a value between a minimum and a maximum by using increment and * decrement buttons or typing in a value in a text input. * *

The following example sets the stepper's range and listens for when * the value changes:

* * * var stepper:NumericStepper = new NumericStepper(); * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * stepper.addEventListener( Event.CHANGE, stepper_changeHandler ); * this.addChild( stepper ); * * @see ../../../help/numeric-stepper.html How to use the Feathers NumericStepper component * * @productversion Feathers 1.1.0 */ public class NumericStepper extends FeathersControl implements IRange, IAdvancedNativeFocusOwner, ITextBaselineControl { /** * @private */ protected static const INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY:String = ""decrementButtonFactory""; /** * @private */ protected static const INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY:String = ""incrementButtonFactory""; /** * @private */ protected static const INVALIDATION_FLAG_TEXT_INPUT_FACTORY:String = ""textInputFactory""; /** * The default value added to the styleNameList of the decrement * button. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON:String = ""feathers-numeric-stepper-decrement-button""; /** * The default value added to the styleNameList of the increment * button. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON:String = ""feathers-numeric-stepper-increment-button""; /** * The default value added to the styleNameList of the text * input. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT:String = ""feathers-numeric-stepper-text-input""; /** * The default IStyleProvider for all NumericStepper * components. * * @default null * @see feathers.core.FeathersControl#styleProvider */ public static var globalStyleProvider:IStyleProvider; /** * @private */ protected static function defaultDecrementButtonFactory():Button { return new Button(); } /** * @private */ protected static function defaultIncrementButtonFactory():Button { return new Button(); } /** * @private */ protected static function defaultTextInputFactory():TextInput { return new TextInput(); } /** * Constructor. */ public function NumericStepper() { super(); this.addEventListener(Event.REMOVED_FROM_STAGE, numericStepper_removedFromStageHandler); } /** * The value added to the styleNameList of the decrement * button. This variable is protected so that sub-classes * can customize the decrement button style name in their constructors * instead of using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON. * *

To customize the decrement button name without subclassing, see * customDecrementButtonStyleName.

* * @see #style:customDecrementButtonStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var decrementButtonStyleName:String = DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON; /** * The value added to the styleNameList of the increment * button. This variable is protected so that sub-classes * can customize the increment button style name in their constructors * instead of using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON. * *

To customize the increment button name without subclassing, see * customIncrementButtonStyleName.

* * @see #style:customIncrementButtonStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var incrementButtonStyleName:String = DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON; /** * The value added to the styleNameList of the text input. * This variable is protected so that sub-classes can * customize the text input style name in their constructors instead of * using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT. * *

To customize the text input name without subclassing, see * customTextInputStyleName.

* * @see #style:customTextInputStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var textInputStyleName:String = DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT; /** * The decrement button sub-component. * *

For internal use in subclasses.

* * @see #createDecrementButton() */ protected var decrementButton:Button; /** * The increment button sub-component. * *

For internal use in subclasses.

* * @see #createIncrementButton() */ protected var incrementButton:Button; /** * The text input sub-component. * *

For internal use in subclasses.

* * @see #createTextInput() */ protected var textInput:TextInput; /** * @private */ protected var textInputExplicitWidth:Number; /** * @private */ protected var textInputExplicitHeight:Number; /** * @private */ protected var textInputExplicitMinWidth:Number; /** * @private */ protected var textInputExplicitMinHeight:Number; /** * @private */ protected var touchPointID:int = -1; /** * @private */ protected var _textInputHasFocus:Boolean = false; /** * @private */ override protected function get defaultStyleProvider():IStyleProvider { return NumericStepper.globalStyleProvider; } /** * A text input's text editor may be an INativeFocusOwner, * so we need to return the value of its nativeFocus * property. * * @see feathers.core.INativeFocusOwner */ public function get nativeFocus():Object { if(this.textInput !== null) { return this.textInput.nativeFocus; } return null; } /** * @private */ protected var _value:Number = 0; /** * The value of the numeric stepper, between the minimum and maximum. * *

In the following example, the value is changed to 12:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #minimum * @see #maximum * @see #step * @see #event:change */ public function get value():Number { return this._value; } /** * @private */ public function set value(newValue:Number):void { if(this._step != 0 && newValue != this._maximum && newValue != this._minimum) { //roundToPrecision helps us to avoid numbers like 1.00000000000000001 //caused by the inaccuracies of floating point math. newValue = roundToPrecision(roundToNearest(newValue - this._minimum, this._step) + this._minimum, 10); } newValue = clamp(newValue, this._minimum, this._maximum); if(this._value == newValue) { return; } this._value = newValue; this.invalidate(INVALIDATION_FLAG_DATA); this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _minimum:Number = 0; /** * The numeric stepper's value will not go lower than the minimum. * *

In the following example, the minimum is changed to 0:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #maximum * @see #step */ public function get minimum():Number { return this._minimum; } /** * @private */ public function set minimum(value:Number):void { if(this._minimum == value) { return; } this._minimum = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _maximum:Number = 0; /** * The numeric stepper's value will not go higher than the maximum. * *

In the following example, the maximum is changed to 100:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #minimum * @see #step */ public function get maximum():Number { return this._maximum; } /** * @private */ public function set maximum(value:Number):void { if(this._maximum == value) { return; } this._maximum = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _step:Number = 0; /** * As the numeric stepper's buttons are pressed, the value is snapped to * a multiple of the step. * *

In the following example, the step is changed to 1:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #minimum * @see #maximum */ public function get step():Number { return this._step; } /** * @private */ public function set step(value:Number):void { if(this._step == value) { return; } this._step = value; } /** * @private */ protected var _useLeftAndRightKeys:Boolean = false; /** * Indicates if the Keyboard.LEFT and * Keyboard.RIGHT keys should be used to change the value * of the stepper, instead of the default Keyboard.DOWN and * Keyboard.UP keys. * *

In the following example, the left and right keys are preferred:

* * * stepper.useLeftAndRightKeys = true; * * @default false */ public function get useLeftAndRightKeys():Boolean { return this._useLeftAndRightKeys; } /** * @private */ public function set useLeftAndRightKeys(newValue:Boolean):void { this._useLeftAndRightKeys = newValue; } /** * @private */ protected var _valueFormatFunction:Function; /** * A callback that formats the numeric stepper's value as a string to * display to the user. * *

The function is expected to have the following signature:

*
function(value:Number):String
* *

In the following example, the stepper's value format function is * customized:

* * * stepper.valueFormatFunction = function(value:Number):String * { * return currencyFormatter.format(value, true); * }; * * @default null * * @see #valueParseFunction */ public function get valueFormatFunction():Function { return this._valueFormatFunction; } /** * @private */ public function set valueFormatFunction(value:Function):void { if(this._valueFormatFunction == value) { return; } this._valueFormatFunction = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _valueParseFunction:Function; /** * A callback that accepts the displayed text of the numeric stepper and * converts it to a simple numeric value. * *

The function is expected to have the following signature:

*
function(displayedText:String):Number
* *

In the following example, the stepper's value parse function is * customized:

* * * stepper.valueParseFunction = function(displayedText:String):String * { * return currencyFormatter.parse(displayedText).value; * }; * * @default null * * @see #valueFormatFunction */ public function get valueParseFunction():Function { return this._valueParseFunction; } /** * @private */ public function set valueParseFunction(value:Function):void { this._valueParseFunction = value; } /** * @private */ protected var currentRepeatAction:Function; /** * @private */ protected var _repeatTimer:Timer; /** * @private */ protected var _repeatDelay:Number = 0.05; /** * The time, in seconds, before actions are repeated. The first repeat * happens after a delay that is five times longer than the following * repeats. * *

In the following example, the stepper's repeat delay is set to * 500 milliseconds:

* * * stepper.repeatDelay = 0.5; * * @default 0.05 */ public function get repeatDelay():Number { return this._repeatDelay; } /** * @private */ public function set repeatDelay(value:Number):void { if(this._repeatDelay == value) { return; } this._repeatDelay = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _buttonLayoutMode:String = StepperButtonLayoutMode.SPLIT_HORIZONTAL; [Inspectable(type=""String"",enumeration=""splitHorizontal,splitVertical,rightSideVertical"")] /** * @private */ public function get buttonLayoutMode():String { return this._buttonLayoutMode; } /** * @private */ public function set buttonLayoutMode(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._buttonLayoutMode === value) { return; } this._buttonLayoutMode = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _buttonGap:Number = 0; /** * @private */ public function get buttonGap():Number { return this._buttonGap; } /** * @private */ public function set buttonGap(value:Number):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._buttonGap == value) { return; } this._buttonGap = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _textInputGap:Number = 0; /** * @private */ public function get textInputGap():Number { return this._textInputGap; } /** * @private */ public function set textInputGap(value:Number):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._textInputGap == value) { return; } this._textInputGap = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _decrementButtonFactory:Function; /** * A function used to generate the numeric stepper's decrement button * sub-component. The decrement button must be an instance of * Button. This factory can be used to change properties on * the decrement button when it is first created. For instance, if you * are skinning Feathers components without a theme, you might use this * factory to set skins and other styles on the decrement button. * *

The function should have the following signature:

*
function():Button
* *

In the following example, a custom decrement button factory is passed * to the stepper:

* * * stepper.decrementButtonFactory = function():Button * { * var button:Button = new Button(); * button.defaultSkin = new Image( upTexture ); * button.downSkin = new Image( downTexture ); * return button; * }; * * @default null * * @see feathers.controls.Button */ public function get decrementButtonFactory():Function { return this._decrementButtonFactory; } /** * @private */ public function set decrementButtonFactory(value:Function):void { if(this._decrementButtonFactory == value) { return; } this._decrementButtonFactory = value; this.invalidate(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); } /** * @private */ protected var _customDecrementButtonStyleName:String; /** * @private */ public function get customDecrementButtonStyleName():String { return this._customDecrementButtonStyleName; } /** * @private */ public function set customDecrementButtonStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customDecrementButtonStyleName === value) { return; } this._customDecrementButtonStyleName = value; this.invalidate(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); } /** * @private */ protected var _decrementButtonProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's decrement * button sub-component, and the properties will be passed down to the * decrement button when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.Button. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a decrementButtonFactory * function instead of using decrementButtonProperties will * result in better performance.

* *

In the following example, the stepper's decrement button properties * are updated:

* * * stepper.decrementButtonProperties.defaultSkin = new Image( upTexture ); * stepper.decrementButtonProperties.downSkin = new Image( downTexture ); * * @default null * * @see #decrementButtonFactory * @see feathers.controls.Button */ public function get decrementButtonProperties():Object { if(!this._decrementButtonProperties) { this._decrementButtonProperties = new PropertyProxy(childProperties_onChange); } return this._decrementButtonProperties; } /** * @private */ public function set decrementButtonProperties(value:Object):void { if(this._decrementButtonProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._decrementButtonProperties) { this._decrementButtonProperties.removeOnChangeCallback(childProperties_onChange); } this._decrementButtonProperties = PropertyProxy(value); if(this._decrementButtonProperties) { this._decrementButtonProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _decrementButtonLabel:String = null; /** * @private */ public function get decrementButtonLabel():String { return this._decrementButtonLabel; } /** * @private */ public function set decrementButtonLabel(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._decrementButtonLabel === value) { return; } this._decrementButtonLabel = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _incrementButtonFactory:Function; /** * A function used to generate the numeric stepper's increment button * sub-component. The increment button must be an instance of * Button. This factory can be used to change properties on * the increment button when it is first created. For instance, if you * are skinning Feathers components without a theme, you might use this * factory to set skins and other styles on the increment button. * *

The function should have the following signature:

*
function():Button
* *

In the following example, a custom increment button factory is passed * to the stepper:

* * * stepper.incrementButtonFactory = function():Button * { * var button:Button = new Button(); * button.defaultSkin = new Image( upTexture ); * button.downSkin = new Image( downTexture ); * return button; * }; * * @default null * * @see feathers.controls.Button */ public function get incrementButtonFactory():Function { return this._incrementButtonFactory; } /** * @private */ public function set incrementButtonFactory(value:Function):void { if(this._incrementButtonFactory == value) { return; } this._incrementButtonFactory = value; this.invalidate(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); } /** * @private */ protected var _customIncrementButtonStyleName:String; /** * @private */ public function get customIncrementButtonStyleName():String { return this._customIncrementButtonStyleName; } /** * @private */ public function set customIncrementButtonStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customIncrementButtonStyleName === value) { return; } this._customIncrementButtonStyleName = value; this.invalidate(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); } /** * @private */ protected var _incrementButtonProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's increment * button sub-component, and the properties will be passed down to the * increment button when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.Button. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a incrementButtonFactory * function instead of using incrementButtonProperties will * result in better performance.

* *

In the following example, the stepper's increment button properties * are updated:

* * * stepper.incrementButtonProperties.defaultSkin = new Image( upTexture ); * stepper.incrementButtonProperties.downSkin = new Image( downTexture ); * * @default null * * @see #incrementButtonFactory * @see feathers.controls.Button */ public function get incrementButtonProperties():Object { if(!this._incrementButtonProperties) { this._incrementButtonProperties = new PropertyProxy(childProperties_onChange); } return this._incrementButtonProperties; } /** * @private */ public function set incrementButtonProperties(value:Object):void { if(this._incrementButtonProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._incrementButtonProperties) { this._incrementButtonProperties.removeOnChangeCallback(childProperties_onChange); } this._incrementButtonProperties = PropertyProxy(value); if(this._incrementButtonProperties) { this._incrementButtonProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _incrementButtonLabel:String = null; /** * @private */ public function get incrementButtonLabel():String { return this._incrementButtonLabel; } /** * @private */ public function set incrementButtonLabel(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._incrementButtonLabel === value) { return; } this._incrementButtonLabel = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _textInputFactory:Function; /** * A function used to generate the numeric stepper's text input * sub-component. The text input must be an instance of TextInput. * This factory can be used to change properties on the text input when * it is first created. For instance, if you are skinning Feathers * components without a theme, you might use this factory to set skins * and other styles on the text input. * *

The function should have the following signature:

*
function():TextInput
* *

In the following example, a custom text input factory is passed * to the stepper:

* * * stepper.textInputFactory = function():TextInput * { * var textInput:TextInput = new TextInput(); * textInput.backgroundSkin = new Image( texture ); * return textInput; * }; * * @default null * * @see feathers.controls.TextInput */ public function get textInputFactory():Function { return this._textInputFactory; } /** * @private */ public function set textInputFactory(value:Function):void { if(this._textInputFactory == value) { return; } this._textInputFactory = value; this.invalidate(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); } /** * @private */ protected var _customTextInputStyleName:String; /** * @private */ public function get customTextInputStyleName():String { return this._customTextInputStyleName; } /** * @private */ public function set customTextInputStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customTextInputStyleName === value) { return; } this._customTextInputStyleName = value; this.invalidate(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); } /** * @private */ protected var _textInputProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's text * input sub-component, and the properties will be passed down to the * text input when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.TextInput. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a textInputFactory function * instead of using textInputProperties will result in * better performance.

* *

In the following example, the stepper's text input properties * are updated:

* * * stepper.textInputProperties.backgroundSkin = new Image( texture ); * * @default null * * @see #textInputFactory * @see feathers.controls.TextInput */ public function get textInputProperties():Object { if(!this._textInputProperties) { this._textInputProperties = new PropertyProxy(childProperties_onChange); } return this._textInputProperties; } /** * @private */ public function set textInputProperties(value:Object):void { if(this._textInputProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._textInputProperties) { this._textInputProperties.removeOnChangeCallback(childProperties_onChange); } this._textInputProperties = PropertyProxy(value); if(this._textInputProperties) { this._textInputProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @inheritDoc */ public function get baseline():Number { if(!this.textInput) { return this.scaledActualHeight; } return this.scaleY * (this.textInput.y + this.textInput.baseline); } /** * @private */ public function get hasFocus():Boolean { return this._hasFocus; } /** * @private */ public function setFocus():void { if(this.textInput === null) { return; } this.textInput.setFocus(); } /** * @private */ override protected function draw():void { var dataInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DATA); var stylesInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STYLES); var sizeInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SIZE); var stateInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STATE); var decrementButtonFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); var incrementButtonFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); var textInputFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); var focusInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_FOCUS); if(decrementButtonFactoryInvalid) { this.createDecrementButton(); } if(incrementButtonFactoryInvalid) { this.createIncrementButton(); } if(textInputFactoryInvalid) { this.createTextInput(); } if(decrementButtonFactoryInvalid || stylesInvalid) { this.refreshDecrementButtonStyles(); } if(incrementButtonFactoryInvalid || stylesInvalid) { this.refreshIncrementButtonStyles(); } if(textInputFactoryInvalid || stylesInvalid) { this.refreshTextInputStyles(); } if(textInputFactoryInvalid || dataInvalid) { this.refreshTypicalText(); this.refreshDisplayedText(); } if(decrementButtonFactoryInvalid || stateInvalid) { this.decrementButton.isEnabled = this._isEnabled; } if(incrementButtonFactoryInvalid || stateInvalid) { this.incrementButton.isEnabled = this._isEnabled; } if(textInputFactoryInvalid || stateInvalid) { this.textInput.isEnabled = this._isEnabled; } sizeInvalid = this.autoSizeIfNeeded() || sizeInvalid; this.layoutChildren(); if(sizeInvalid || focusInvalid) { this.refreshFocusIndicator(); } } /** * If the component's dimensions have not been set explicitly, it will * measure its content and determine an ideal size for itself. If the * explicitWidth or explicitHeight member * variables are set, those value will be used without additional * measurement. If one is set, but not the other, the dimension with the * explicit value will not be measured, but the other non-explicit * dimension will still need measurement. * *

Calls saveMeasurements() to set up the * actualWidth and actualHeight member * variables used for layout.

* *

Meant for internal use, and subclasses may override this function * with a custom implementation.

*/ protected function autoSizeIfNeeded():Boolean { var needsWidth:Boolean = this._explicitWidth !== this._explicitWidth; //isNaN var needsHeight:Boolean = this._explicitHeight !== this._explicitHeight; //isNaN var needsMinWidth:Boolean = this._explicitMinWidth !== this._explicitMinWidth; //isNaN var needsMinHeight:Boolean = this._explicitMinHeight !== this._explicitMinHeight; //isNaN if(!needsWidth && !needsHeight && !needsMinWidth && !needsMinHeight) { return false; } var newWidth:Number = this._explicitWidth; var newHeight:Number = this._explicitHeight; var newMinWidth:Number = this._explicitMinWidth; var newMinHeight:Number = this._explicitMinHeight; this.decrementButton.validate(); this.incrementButton.validate(); var decrementButtonWidth:Number = this.decrementButton.width; var decrementButtonHeight:Number = this.decrementButton.height; var decrementButtonMinWidth:Number = this.decrementButton.minWidth; var decrementButtonMinHeight:Number = this.decrementButton.minHeight; var incrementButtonWidth:Number = this.incrementButton.width; var incrementButtonHeight:Number = this.incrementButton.height; var incrementButtonMinWidth:Number = this.incrementButton.minWidth; var incrementButtonMinHeight:Number = this.incrementButton.minHeight; //we'll default to the values set in the textInputFactory var textInputWidth:Number = this.textInputExplicitWidth; var textInputHeight:Number = this.textInputExplicitHeight; var textInputMinWidth:Number = this.textInputExplicitMinWidth; var textInputMinHeight:Number = this.textInputExplicitMinHeight; var textInputMaxWidth:Number = Number.POSITIVE_INFINITY; var textInputMaxHeight:Number = Number.POSITIVE_INFINITY; if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { var maxButtonWidth:Number = decrementButtonWidth; if(incrementButtonWidth > maxButtonWidth) { maxButtonWidth = incrementButtonWidth; } var maxButtonMinWidth:Number = decrementButtonMinWidth; if(incrementButtonMinWidth > maxButtonMinWidth) { maxButtonMinWidth = incrementButtonMinWidth; } if(!needsWidth) { textInputWidth = this._explicitWidth - maxButtonWidth - this._textInputGap; } if(!needsHeight) { textInputHeight = this._explicitHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth - maxButtonMinWidth - this._textInputGap; if(this.textInputExplicitMinWidth > textInputMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxWidth = this._explicitMaxWidth - maxButtonWidth - this._textInputGap; } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { if(!needsWidth) { textInputWidth = this._explicitWidth; } if(!needsHeight) { textInputHeight = this._explicitHeight - decrementButtonHeight - incrementButtonHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth; if(this.textInputExplicitMinWidth > textInputMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight - decrementButtonMinHeight - incrementButtonMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxHeight = this._explicitMaxHeight - decrementButtonHeight - incrementButtonHeight; } else //split horizontal { if(!needsWidth) { textInputWidth = this._explicitWidth - decrementButtonWidth - incrementButtonWidth; } if(!needsHeight) { textInputHeight = this._explicitHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth - decrementButtonMinWidth - incrementButtonMinWidth; if(textInputMinWidth < this.textInputExplicitMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxWidth = this._explicitMaxWidth - decrementButtonWidth - incrementButtonWidth; } if(textInputWidth < 0) { textInputWidth = 0; } if(textInputHeight < 0) { textInputHeight = 0; } if(textInputMinWidth < 0) { textInputMinWidth = 0; } if(textInputMinHeight < 0) { textInputMinHeight = 0; } this.textInput.width = textInputWidth; this.textInput.height = textInputHeight; this.textInput.minWidth = textInputMinWidth; this.textInput.minHeight = textInputMinHeight; this.textInput.maxWidth = textInputMaxWidth; this.textInput.maxHeight = textInputMaxHeight; this.textInput.validate(); if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { if(needsWidth) { newWidth = this.textInput.width + maxButtonWidth + this._textInputGap; } if(needsHeight) { newHeight = decrementButtonHeight + this._buttonGap + incrementButtonHeight; if(this.textInput.height > newHeight) { newHeight = this.textInput.height; } } if(needsMinWidth) { newMinWidth = this.textInput.minWidth + maxButtonMinWidth + this._textInputGap; } if(needsMinHeight) { newMinHeight = decrementButtonMinHeight + this._buttonGap + incrementButtonMinHeight; if(this.textInput.minHeight > newMinHeight) { newMinHeight = this.textInput.minHeight; } } } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { if(needsWidth) { newWidth = this.textInput.width; if(decrementButtonWidth > newWidth) { newWidth = decrementButtonWidth; } if(incrementButtonWidth > newWidth) { newWidth = incrementButtonWidth; } } if(needsHeight) { newHeight = decrementButtonHeight + this.textInput.height + incrementButtonHeight + 2 * this._textInputGap; } if(needsMinWidth) { newMinWidth = this.textInput.minWidth; if(decrementButtonMinWidth > newMinWidth) { newMinWidth = decrementButtonMinWidth; } if(incrementButtonMinWidth > newMinWidth) { newMinWidth = incrementButtonMinWidth; } } if(needsMinHeight) { newMinHeight = decrementButtonMinHeight + this.textInput.minHeight + incrementButtonMinHeight + 2 * this._textInputGap; } } else //split horizontal { if(needsWidth) { newWidth = decrementButtonWidth + this.textInput.width + incrementButtonWidth + 2 * this._textInputGap; } if(needsHeight) { newHeight = this.textInput.height; if(decrementButtonHeight > newHeight) { newHeight = decrementButtonHeight; } if(incrementButtonHeight > newHeight) { newHeight = incrementButtonHeight; } } if(needsMinWidth) { newMinWidth = decrementButtonMinWidth + this.textInput.minWidth + incrementButtonMinWidth + 2 * this._textInputGap; } if(needsMinHeight) { newMinHeight = this.textInput.minHeight; if(decrementButtonMinHeight > newMinHeight) { newMinHeight = decrementButtonMinHeight; } if(incrementButtonMinHeight > newMinHeight) { newMinHeight = incrementButtonMinHeight; } } } return this.saveMeasurements(newWidth, newHeight, newMinWidth, newMinHeight); } /** * @private */ protected function decrement():void { this.value = this._value - this._step; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function increment():void { this.value = this._value + this._step; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function toMinimum():void { this.value = this._minimum; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function toMaximum():void { this.value = this._maximum; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * Creates and adds the decrementButton sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #decrementButton * @see #decrementButtonFactory * @see #style:customDecrementButtonStyleName */ protected function createDecrementButton():void { if(this.decrementButton) { this.decrementButton.removeFromParent(true); this.decrementButton = null; } var factory:Function = this._decrementButtonFactory != null ? this._decrementButtonFactory : defaultDecrementButtonFactory; var decrementButtonStyleName:String = this._customDecrementButtonStyleName != null ? this._customDecrementButtonStyleName : this.decrementButtonStyleName; this.decrementButton = Button(factory()); this.decrementButton.styleNameList.add(decrementButtonStyleName); this.decrementButton.addEventListener(TouchEvent.TOUCH, decrementButton_touchHandler); this.addChild(this.decrementButton); } /** * Creates and adds the incrementButton sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #incrementButton * @see #incrementButtonFactory * @see #style:customIncrementButtonStyleName */ protected function createIncrementButton():void { if(this.incrementButton) { this.incrementButton.removeFromParent(true); this.incrementButton = null; } var factory:Function = this._incrementButtonFactory != null ? this._incrementButtonFactory : defaultIncrementButtonFactory; var incrementButtonStyleName:String = this._customIncrementButtonStyleName != null ? this._customIncrementButtonStyleName : this.incrementButtonStyleName; this.incrementButton = Button(factory()); this.incrementButton.styleNameList.add(incrementButtonStyleName); this.incrementButton.addEventListener(TouchEvent.TOUCH, incrementButton_touchHandler); this.addChild(this.incrementButton); } /** * Creates and adds the textInput sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #textInput * @see #textInputFactory * @see #style:customTextInputStyleName */ protected function createTextInput():void { if(this.textInput) { this.textInput.removeFromParent(true); this.textInput = null; } var factory:Function = this._textInputFactory != null ? this._textInputFactory : defaultTextInputFactory; var textInputStyleName:String = this._customTextInputStyleName != null ? this._customTextInputStyleName : this.textInputStyleName; this.textInput = TextInput(factory()); this.textInput.styleNameList.add(textInputStyleName); this.textInput.addEventListener(FeathersEventType.ENTER, textInput_enterHandler); this.textInput.addEventListener(FeathersEventType.FOCUS_IN, textInput_focusInHandler); this.textInput.addEventListener(FeathersEventType.FOCUS_OUT, textInput_focusOutHandler); //while we're setting isFocusEnabled to false on the text input when //we have a focus manager, we'll still be able to call setFocus() on //the text input manually. this.textInput.isFocusEnabled = !this._focusManager; this.addChild(this.textInput); //we will use these values for measurement, if possible this.textInput.initializeNow(); this.textInputExplicitWidth = this.textInput.explicitWidth; this.textInputExplicitHeight = this.textInput.explicitHeight; this.textInputExplicitMinWidth = this.textInput.explicitMinWidth; this.textInputExplicitMinHeight = this.textInput.explicitMinHeight; } /** * @private */ protected function refreshDecrementButtonStyles():void { for(var propertyName:String in this._decrementButtonProperties) { var propertyValue:Object = this._decrementButtonProperties[propertyName]; this.decrementButton[propertyName] = propertyValue; } this.decrementButton.label = this._decrementButtonLabel; } /** * @private */ protected function refreshIncrementButtonStyles():void { for(var propertyName:String in this._incrementButtonProperties) { var propertyValue:Object = this._incrementButtonProperties[propertyName]; this.incrementButton[propertyName] = propertyValue; } this.incrementButton.label = this._incrementButtonLabel; } /** * @private */ protected function refreshTextInputStyles():void { for(var propertyName:String in this._textInputProperties) { var propertyValue:Object = this._textInputProperties[propertyName]; this.textInput[propertyName] = propertyValue; } } /** * @private */ protected function refreshDisplayedText():void { if(this._valueFormatFunction != null) { this.textInput.text = this._valueFormatFunction(this._value); } else { this.textInput.text = this._value.toString(); } } /** * @private */ protected function refreshTypicalText():void { var typicalText:String = """"; var maxCharactersBeforeDecimal:Number = Math.max(int(this._minimum).toString().length, int(this._maximum).toString().length, int(this._step).toString().length); //roundToPrecision() helps us to avoid numbers like 1.00000000000000001 //caused by the inaccuracies of floating point math. var maxCharactersAfterDecimal:Number = Math.max(roundToPrecision(this._minimum - int(this._minimum), 10).toString().length, roundToPrecision(this._maximum - int(this._maximum), 10).toString().length, roundToPrecision(this._step - int(this._step), 10).toString().length) - 2; if(maxCharactersAfterDecimal < 0) { maxCharactersAfterDecimal = 0; } var characterCount:int = maxCharactersBeforeDecimal + maxCharactersAfterDecimal; for(var i:int = 0; i < characterCount; i++) { typicalText += ""0""; } if(maxCharactersAfterDecimal > 0) { typicalText += "".""; } this.textInput.typicalText = typicalText; } /** * @private */ protected function layoutChildren():void { if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { var buttonHeight:Number = (this.actualHeight - this._buttonGap) / 2; this.incrementButton.y = 0; this.incrementButton.height = buttonHeight; this.incrementButton.validate(); this.decrementButton.y = buttonHeight + this._buttonGap; this.decrementButton.height = buttonHeight; this.decrementButton.validate(); var buttonWidth:Number = Math.max(this.decrementButton.width, this.incrementButton.width); var buttonX:Number = this.actualWidth - buttonWidth; this.decrementButton.x = buttonX; this.incrementButton.x = buttonX; this.textInput.x = 0; this.textInput.y = 0; this.textInput.width = buttonX - this._textInputGap; this.textInput.height = this.actualHeight; } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { this.incrementButton.x = 0; this.incrementButton.y = 0; this.incrementButton.width = this.actualWidth; this.incrementButton.validate(); this.decrementButton.x = 0; this.decrementButton.width = this.actualWidth; this.decrementButton.validate(); this.decrementButton.y = this.actualHeight - this.decrementButton.height; this.textInput.x = 0; this.textInput.y = this.incrementButton.height + this._textInputGap; this.textInput.width = this.actualWidth; this.textInput.height = Math.max(0, this.actualHeight - this.decrementButton.height - this.incrementButton.height - 2 * this._textInputGap); } else //split horizontal { this.decrementButton.x = 0; this.decrementButton.y = 0; this.decrementButton.height = this.actualHeight; this.decrementButton.validate(); this.incrementButton.y = 0; this.incrementButton.height = this.actualHeight; this.incrementButton.validate(); this.incrementButton.x = this.actualWidth - this.incrementButton.width; this.textInput.x = this.decrementButton.width + this._textInputGap; this.textInput.width = this.actualWidth - this.decrementButton.width - this.incrementButton.width - 2 * this._textInputGap; this.textInput.height = this.actualHeight; } //final validation to avoid juggler next frame issues this.textInput.validate(); } /** * @private */ protected function startRepeatTimer(action:Function):void { if(this.touchPointID >= 0) { var exclusiveTouch:ExclusiveTouch = ExclusiveTouch.forStage(this.stage); var claim:DisplayObject = exclusiveTouch.getClaim(this.touchPointID) if(claim != this) { if(claim) { //already claimed by another display object return; } else { exclusiveTouch.claimTouch(this.touchPointID, this); } } } this.currentRepeatAction = action; if(this._repeatDelay > 0) { if(!this._repeatTimer) { this._repeatTimer = new Timer(this._repeatDelay * 1000); this._repeatTimer.addEventListener(TimerEvent.TIMER, repeatTimer_timerHandler); } else { this._repeatTimer.reset(); this._repeatTimer.delay = this._repeatDelay * 1000; } this._repeatTimer.start(); } } /** * @private */ protected function parseTextInputValue():void { if(this._valueParseFunction != null) { var newValue:Number = this._valueParseFunction(this.textInput.text); } else { newValue = parseFloat(this.textInput.text); } if(newValue === newValue) //!isNaN { this.value = newValue; } //we need to force invalidation just to be sure that the text input //is displaying the correct value. this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected function childProperties_onChange(proxy:PropertyProxy, name:Object):void { this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected function numericStepper_removedFromStageHandler(event:Event):void { this.touchPointID = -1; } /** * @private */ override protected function focusInHandler(event:Event):void { super.focusInHandler(event); this.textInput.setFocus(); this.textInput.selectRange(0, this.textInput.text.length); this.stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ override protected function focusOutHandler(event:Event):void { super.focusOutHandler(event); this.textInput.clearFocus(); this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ protected function textInput_enterHandler(event:Event):void { this.parseTextInputValue(); } /** * @private */ protected function textInput_focusInHandler(event:Event):void { this._textInputHasFocus = true; } /** * @private */ protected function textInput_focusOutHandler(event:Event):void { this._textInputHasFocus = false; this.parseTextInputValue(); } /** * @private */ protected function decrementButton_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this.decrementButton, TouchPhase.ENDED, this.touchPointID); if(!touch) { return; } this.touchPointID = -1; this._repeatTimer.stop(); this.dispatchEventWith(FeathersEventType.END_INTERACTION); } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this.decrementButton, TouchPhase.BEGAN); if(!touch) { return; } if(this._textInputHasFocus) { this.parseTextInputValue(); } this.touchPointID = touch.id; this.dispatchEventWith(FeathersEventType.BEGIN_INTERACTION); this.decrement(); this.startRepeatTimer(this.decrement); } } /** * @private */ protected function incrementButton_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this.incrementButton, TouchPhase.ENDED, this.touchPointID); if(!touch) { return; } this.touchPointID = -1; this._repeatTimer.stop(); this.dispatchEventWith(FeathersEventType.END_INTERACTION); } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this.incrementButton, TouchPhase.BEGAN); if(!touch) { return; } if(this._textInputHasFocus) { this.parseTextInputValue(); } this.touchPointID = touch.id; this.dispatchEventWith(FeathersEventType.BEGIN_INTERACTION); this.increment(); this.startRepeatTimer(this.increment); } } /** * @private */ protected function stage_keyDownHandler(event:KeyboardEvent):void { if(event.keyCode == Keyboard.HOME) { //prevent default so that text input selection doesn't change event.preventDefault(); this.toMinimum(); } else if(event.keyCode == Keyboard.END) { //prevent default so that text input selection doesn't change event.preventDefault(); this.toMaximum(); } else if(this._useLeftAndRightKeys) { if(event.keyCode == Keyboard.RIGHT) { //prevent default so that text input selection doesn't change event.preventDefault(); this.increment(); } else if(event.keyCode == Keyboard.LEFT) { //prevent default so that text input selection doesn't change event.preventDefault(); this.decrement(); } } else if(event.keyCode == Keyboard.UP) { //prevent default so that text input selection doesn't change event.preventDefault(); this.increment(); } else if(event.keyCode == Keyboard.DOWN) { //prevent default so that text input selection doesn't change event.preventDefault(); this.decrement(); } } /** * @private */ protected function repeatTimer_timerHandler(event:TimerEvent):void { if(this._repeatTimer.currentCount < 5) { return; } this.currentRepeatAction(); } } } ",16134,True,3079.45876735051,median "CLASS zcl_abapgit_gui_page_repo_view DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_page FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_hotkeys . CONSTANTS: BEGIN OF c_actions, repo_list TYPE string VALUE 'abapgit_home' ##NO_TEXT, change_dir TYPE string VALUE 'change_dir' ##NO_TEXT, toggle_hide_files TYPE string VALUE 'toggle_hide_files' ##NO_TEXT, toggle_folders TYPE string VALUE 'toggle_folders' ##NO_TEXT, toggle_changes TYPE string VALUE 'toggle_changes' ##NO_TEXT, toggle_diff_first TYPE string VALUE 'toggle_diff_first ' ##NO_TEXT, display_more TYPE string VALUE 'display_more' ##NO_TEXT, go_data TYPE string VALUE 'go_data', END OF c_actions . METHODS constructor IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RAISING zcx_abapgit_exception . METHODS zif_abapgit_gui_event_handler~on_event REDEFINITION . PROTECTED SECTION. METHODS render_content REDEFINITION. PRIVATE SECTION. DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA mo_repo_aggregated_state TYPE REF TO zcl_abapgit_item_state. DATA mv_cur_dir TYPE string . DATA mv_hide_files TYPE abap_bool . DATA mv_max_lines TYPE i . DATA mv_max_setting TYPE i . DATA mv_show_folders TYPE abap_bool . DATA mv_changes_only TYPE abap_bool . DATA mv_order_by TYPE string . DATA mv_order_descending TYPE abap_bool . DATA mv_diff_first TYPE abap_bool . DATA mv_key TYPE zif_abapgit_persistence=>ty_value . DATA mv_are_changes_recorded_in_tr TYPE abap_bool . METHODS render_head_line RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_head_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_view_menu RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS render_item IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item !iv_render_transports TYPE abap_bool RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_item_files IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_item_command IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS render_file_command IMPORTING !is_file TYPE zif_abapgit_definitions=>ty_repo_file RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS get_item_class IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item iv_is_object_row TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rv_html) TYPE string . METHODS get_item_icon IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS render_item_transport IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS render_parent_dir RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS build_obj_jump_link IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string . METHODS build_dir_jump_link IMPORTING !iv_path TYPE string RETURNING VALUE(rv_html) TYPE string . METHODS build_inactive_object_code IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_inactive_html_code) TYPE string . METHODS build_srcsystem_code IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_srcsystem_html_code) TYPE string . METHODS open_in_main_language RAISING zcx_abapgit_exception . METHODS render_order_by RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . METHODS apply_order_by CHANGING !ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt . METHODS build_branch_dropdown RETURNING VALUE(ro_branch_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_tag_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_tag_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_advanced_dropdown IMPORTING !iv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout RETURNING VALUE(ro_advanced_dropdown) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_toolbar IMPORTING !iv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout !io_tb_branch TYPE REF TO zcl_abapgit_html_toolbar !io_tb_tag TYPE REF TO zcl_abapgit_html_toolbar !io_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar RETURNING VALUE(ro_toolbar) TYPE REF TO zcl_abapgit_html_toolbar RAISING zcx_abapgit_exception . METHODS build_main_menu RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar . METHODS render_scripts RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . METHODS is_repo_lang_logon_lang RETURNING VALUE(rv_repo_lang_is_logon_lang) TYPE abap_bool . METHODS render_item_changed_by IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception. METHODS order_files CHANGING ct_files TYPE zif_abapgit_definitions=>ty_repo_file_tt. ENDCLASS. CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. METHOD apply_order_by. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort, lt_non_code_and_metadata_items LIKE ct_repo_items, lt_code_items LIKE ct_repo_items, lt_diff_items LIKE ct_repo_items. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_repo_item. IF mv_order_by IS INITIAL. RETURN. ENDIF. "" we want to preserve non-code and metadata files at the top, "" so we isolate them and and sort only the code artifacts LOOP AT ct_repo_items ASSIGNING . IF -obj_type IS INITIAL AND -is_dir = abap_false. INSERT INTO TABLE lt_non_code_and_metadata_items. ELSE. INSERT INTO TABLE lt_code_items. ENDIF. ENDLOOP. IF mv_diff_first = abap_true. "" fix diffs on the top, right after non-code and metadata LOOP AT lt_code_items ASSIGNING WHERE changes > 0. INSERT INTO TABLE lt_diff_items. ENDLOOP. DELETE lt_code_items WHERE changes > 0. ENDIF. CLEAR: ct_repo_items. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. ls_sort-name = mv_order_by. INSERT ls_sort INTO TABLE lt_sort. "" Combine state fields for order of 'Status' column IF mv_order_by = 'LSTATE'. ls_sort-name = 'RSTATE'. INSERT ls_sort INTO TABLE lt_sort. ENDIF. "" Use object name as secondary sort criteria IF mv_order_by <> 'OBJ_NAME'. ls_sort-name = 'OBJ_NAME'. INSERT ls_sort INTO TABLE lt_sort. ENDIF. SORT lt_code_items STABLE BY (lt_sort). SORT lt_diff_items STABLE BY (lt_sort). INSERT LINES OF lt_non_code_and_metadata_items INTO TABLE ct_repo_items. INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items. INSERT LINES OF lt_code_items INTO TABLE ct_repo_items. "" Files are listed under the object names so we always sort them by name LOOP AT ct_repo_items ASSIGNING . order_files( CHANGING ct_files = -files ). ENDLOOP. ENDMETHOD. METHOD build_advanced_dropdown. DATA: lv_crossout LIKE zif_abapgit_html=>c_html_opt-crossout. CREATE OBJECT ro_advanced_dropdown. IF mo_repo_aggregated_state->is_unchanged( ) = abap_false. "" In case of asyncronicities ro_advanced_dropdown->add( iv_txt = 'Selective Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_reset }?key={ mv_key }| iv_opt = iv_wp_opt ). ENDIF. IF mo_repo->is_offline( ) = abap_false. "" Online ? ro_advanced_dropdown->add( iv_txt = 'Force Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-transport_to_branch ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Transport to Branch' iv_act = |{ zif_abapgit_definitions=>c_action-repo_transport_to_branch }?key={ mv_key }| iv_opt = lv_crossout ). ENDIF. IF mv_are_changes_recorded_in_tr = abap_true. ro_advanced_dropdown->add( iv_txt = 'Add All Objects to Transport' iv_act = |{ zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req }?key={ mv_key }| ). ENDIF. IF mo_repo->is_offline( ) = abap_true. ro_advanced_dropdown->add( iv_txt = 'Export by Transport' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export_transport }?key={ mv_key }| ). ELSE. ro_advanced_dropdown->add( iv_txt = 'Stage by Transport' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage_transport }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Syntax Check' iv_act = |{ zif_abapgit_definitions=>c_action-repo_syntax_check }?key={ mv_key }| ). ro_advanced_dropdown->add( iv_txt = 'Run Code Inspector' iv_act = |{ zif_abapgit_definitions=>c_action-repo_code_inspector }?key={ mv_key }| ). CLEAR lv_crossout. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-update_local_checksum ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Update Local Checksums' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh_checksums }?key={ mv_key }| iv_opt = lv_crossout ). ro_advanced_dropdown->add( iv_txt = 'Beta - Data' iv_act = |{ c_actions-go_data }?key={ mv_key }| iv_opt = lv_crossout ). IF is_repo_lang_logon_lang( ) = abap_false AND zcl_abapgit_services_abapgit=>get_abapgit_tcode( ) IS NOT INITIAL. ro_advanced_dropdown->add( iv_txt = 'Open in Main Language' iv_act = |{ zif_abapgit_definitions=>c_action-repo_open_in_master_lang }?key={ mv_key }| ). ENDIF. ro_advanced_dropdown->add( iv_txt = 'Remove' iv_title = `Remove abapGit's records of the repository (the system's ` && `development objects will remain unaffected)` iv_act = |{ zif_abapgit_definitions=>c_action-repo_remove }?key={ mv_key }| ). CLEAR lv_crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true OR zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-uninstall ) = abap_false. lv_crossout = zif_abapgit_html=>c_html_opt-crossout. ENDIF. ro_advanced_dropdown->add( iv_txt = 'Uninstall' iv_title = `Delete all development objects belonging to this package ` && `(and subpackages) from the system` iv_act = |{ zif_abapgit_definitions=>c_action-repo_purge }?key={ mv_key }| iv_opt = lv_crossout ). ENDMETHOD. METHOD build_branch_dropdown. CREATE OBJECT ro_branch_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_branch_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_switch }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_create }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_delete }?key={ mv_key }| ). ro_branch_dropdown->add( iv_txt = 'Merge' iv_act = |{ zif_abapgit_definitions=>c_action-git_branch_merge }?key={ mv_key }| ). ENDMETHOD. METHOD build_dir_jump_link. DATA lv_path TYPE string. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_path = iv_path. REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''. lv_encode = zcl_abapgit_html_action_utils=>dir_encode( lv_path ). "" remove leading and trailing / for display IF lv_path <> '/'. IF lv_path(1) = '/'. lv_path = lv_path+1. ENDIF. IF substring( val = reverse( lv_path ) len = 1 ) = '/'. lv_path = substring( val = lv_path len = strlen( lv_path ) - 1 ). ENDIF. ENDIF. rv_html = li_html->a( iv_txt = lv_path iv_act = |{ c_actions-change_dir }?{ lv_encode }| ). ENDMETHOD. METHOD build_head_menu. DATA: lo_tb_advanced TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_branch TYPE REF TO zcl_abapgit_html_toolbar, lo_tb_tag TYPE REF TO zcl_abapgit_html_toolbar, lv_wp_opt LIKE zif_abapgit_html=>c_html_opt-crossout, lv_pull_opt LIKE zif_abapgit_html=>c_html_opt-crossout. IF mo_repo->get_local_settings( )-write_protected = abap_true. lv_wp_opt = zif_abapgit_html=>c_html_opt-crossout. lv_pull_opt = zif_abapgit_html=>c_html_opt-crossout. ELSE. lv_pull_opt = zif_abapgit_html=>c_html_opt-strong. ENDIF. lo_tb_branch = build_branch_dropdown( ). lo_tb_tag = build_tag_dropdown( lv_wp_opt ). lo_tb_advanced = build_advanced_dropdown( iv_wp_opt = lv_wp_opt ). ro_toolbar = build_main_toolbar( iv_pull_opt = lv_pull_opt io_tb_branch = lo_tb_branch io_tb_tag = lo_tb_tag io_tb_advanced = lo_tb_advanced ). ENDMETHOD. METHOD build_inactive_object_code. IF is_item-inactive = abap_true. rv_inactive_html_code = zcl_abapgit_html=>icon( iv_name = 'bolt/orange' iv_hint = 'Object or object part is inactive' iv_class = 'inactive' ). ENDIF. ENDMETHOD. METHOD build_main_menu. CREATE OBJECT ro_menu EXPORTING iv_id = 'toolbar-main'. ro_menu->add( iv_txt = zcl_abapgit_gui_buttons=>repo_list( ) iv_act = zif_abapgit_definitions=>c_action-abapgit_home )->add( iv_txt = zcl_abapgit_gui_buttons=>help( ) iv_title = 'Help' io_sub = zcl_abapgit_gui_chunk_lib=>help_submenu( ) ). ENDMETHOD. METHOD build_main_toolbar. DATA: li_log TYPE REF TO zif_abapgit_log. CREATE OBJECT ro_toolbar EXPORTING iv_id = 'toolbar-repo'. IF mo_repo->is_offline( ) = abap_false. IF mo_repo_aggregated_state->remote( ) IS NOT INITIAL OR mo_repo_aggregated_state->is_reassigned( ) = abap_true. "" Something new at remote ro_toolbar->add( iv_txt = 'Pull' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = iv_pull_opt ). ENDIF. IF mo_repo_aggregated_state->local( ) IS NOT INITIAL. "" Something new at local ro_toolbar->add( iv_txt = 'Stage' iv_act = |{ zif_abapgit_definitions=>c_action-go_stage }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. IF mo_repo_aggregated_state->is_unchanged( ) = abap_false. "" Any changes ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ro_toolbar->add( iv_txt = 'Branch' io_sub = io_tb_branch ). ro_toolbar->add( iv_txt = 'Tag' io_sub = io_tb_tag ). ELSE. IF mo_repo->has_remote_source( ) = abap_true AND mo_repo_aggregated_state->remote( ) IS NOT INITIAL. ro_toolbar->add( iv_txt = 'Pull zip' iv_act = |{ zif_abapgit_definitions=>c_action-git_pull }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_repo_diff }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Import zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_import }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). IF mo_repo->get_local_settings( )-write_protected = abap_true. ro_toolbar->add( iv_txt = 'Compare rfc' iv_act = |{ zif_abapgit_definitions=>c_action-rfc_compare }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ENDIF. ro_toolbar->add( iv_txt = 'Export zip' iv_act = |{ zif_abapgit_definitions=>c_action-zip_export }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). li_log = mo_repo->get_log( ). IF li_log IS BOUND AND li_log->count( ) > 0. ro_toolbar->add( iv_txt = 'Log' iv_act = |{ zif_abapgit_definitions=>c_action-repo_log }?key={ mv_key }| ). ENDIF. ENDIF. ro_toolbar->add( iv_txt = 'Advanced' io_sub = io_tb_advanced ). ro_toolbar->add( iv_txt = 'View' io_sub = build_view_menu( ) ). ro_toolbar->add( iv_txt = 'Refresh' iv_act = |{ zif_abapgit_definitions=>c_action-repo_refresh }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong ). ro_toolbar->add( iv_txt = 'Settings' iv_act = |{ zif_abapgit_definitions=>c_action-repo_settings }?key={ mv_key }| iv_opt = zif_abapgit_html=>c_html_opt-strong iv_title = `Repository Settings` ). ENDMETHOD. METHOD build_obj_jump_link. DATA lv_encode TYPE string. DATA li_html TYPE REF TO zif_abapgit_html. CREATE OBJECT li_html TYPE zcl_abapgit_html. lv_encode = zcl_abapgit_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type iv_obj_name = is_item-obj_name ). rv_html = li_html->a( iv_txt = |{ is_item-obj_name }| iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). ENDMETHOD. METHOD build_srcsystem_code. IF is_item-srcsystem IS NOT INITIAL AND is_item-srcsystem <> sy-sysid. rv_srcsystem_html_code = zcl_abapgit_html=>icon( iv_name = 'server-solid/grey' iv_hint = |Original system: { is_item-srcsystem }| iv_class = 'cursor-pointer' ). ENDIF. ENDMETHOD. METHOD build_tag_dropdown. CREATE OBJECT ro_tag_dropdown. IF mo_repo->is_offline( ) = abap_true. RETURN. ENDIF. ro_tag_dropdown->add( iv_txt = 'Switch' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_switch }?key={ mv_key }| iv_opt = iv_wp_opt ). ro_tag_dropdown->add( iv_txt = 'Create' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_create }?key={ mv_key }| ). ro_tag_dropdown->add( iv_txt = 'Delete' iv_act = |{ zif_abapgit_definitions=>c_action-git_tag_delete }?key={ mv_key }| ). ENDMETHOD. METHOD build_view_menu. CREATE OBJECT ro_toolbar. ro_toolbar->add( iv_txt = 'Changes First' iv_chk = mv_diff_first iv_act = c_actions-toggle_diff_first ). ro_toolbar->add( iv_txt = 'Changes Only' iv_chk = mv_changes_only iv_act = c_actions-toggle_changes ). ro_toolbar->add( iv_txt = 'File Paths' iv_chk = boolc( NOT mv_hide_files = abap_true ) iv_act = c_actions-toggle_hide_files ). ro_toolbar->add( iv_txt = 'Folders' iv_chk = mv_show_folders iv_act = c_actions-toggle_folders ). ENDMETHOD. METHOD constructor. DATA: lo_settings TYPE REF TO zcl_abapgit_settings, lx_error TYPE REF TO zcx_abapgit_exception, lo_persistence_user TYPE REF TO zif_abapgit_persist_user. super->constructor( ). TRY. lo_persistence_user = zcl_abapgit_persistence_user=>get_instance( ). mv_key = iv_key. mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). mv_cur_dir = '/'. "" Root mv_hide_files = lo_persistence_user->get_hide_files( ). mv_changes_only = lo_persistence_user->get_changes_only( ). mv_order_by = lo_persistence_user->get_order_by( ). mv_order_descending = lo_persistence_user->get_order_descending( ). mv_diff_first = lo_persistence_user->get_diff_first( ). mv_show_folders = lo_persistence_user->get_show_folders( ). ms_control-page_title = 'Repository'. ms_control-page_menu = build_main_menu( ). "" Read global settings to get max # of objects to be listed lo_settings = zcl_abapgit_persist_factory=>get_settings( )->read( ). mv_max_lines = lo_settings->get_max_lines( ). mv_max_setting = mv_max_lines. CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). RAISE EXCEPTION lx_error. ENDTRY. ENDMETHOD. METHOD get_item_class. DATA lt_class TYPE TABLE OF string. IF iv_is_object_row = abap_true. APPEND 'object_row' TO lt_class. ELSE. APPEND 'file_row' TO lt_class. ENDIF. IF is_item-is_dir = abap_true. APPEND 'folder' TO lt_class. ELSEIF is_item-changes > 0. APPEND 'modified' TO lt_class. ELSEIF is_item-obj_name IS INITIAL. APPEND 'unsupported' TO lt_class. ENDIF. IF lines( lt_class ) > 0. rv_html = | class=""{ concat_lines_of( table = lt_class sep = ` ` ) }""|. ENDIF. ENDMETHOD. METHOD get_item_icon. CASE is_item-obj_type. WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' iv_hint = 'Code' ). WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' iv_hint = 'Binary' ). WHEN 'DEVC'. rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' iv_hint = 'Package' ). WHEN ''. rv_html = space. "" no icon WHEN OTHERS. rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). ENDCASE. IF is_item-is_dir = abap_true. rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' iv_hint = 'Folder' ). ENDIF. ENDMETHOD. METHOD is_repo_lang_logon_lang. rv_repo_lang_is_logon_lang = boolc( mo_repo->get_dot_abapgit( )->get_main_language( ) = sy-langu ). ENDMETHOD. METHOD open_in_main_language. DATA: lv_main_language TYPE spras, lt_spagpa TYPE STANDARD TABLE OF rfc_spagpa, ls_spagpa LIKE LINE OF lt_spagpa, ls_item TYPE zif_abapgit_definitions=>ty_item, lv_subrc TYPE syst-subrc, lv_save_sy_langu TYPE sy-langu, lv_tcode TYPE tcode. "" https://blogs.sap.com/2017/01/13/logon-language-sy-langu-and-rfc/ lv_main_language = mo_repo->get_dot_abapgit( )->get_main_language( ). lv_tcode = zcl_abapgit_services_abapgit=>get_abapgit_tcode( ). ASSERT lv_tcode IS NOT INITIAL. IF lv_main_language = sy-langu. zcx_abapgit_exception=>raise( |Repo already opened in main language| ). ENDIF. ls_item-obj_name = lv_tcode. ls_item-obj_type = |TRAN|. IF zcl_abapgit_objects=>exists( ls_item ) = abap_false. zcx_abapgit_exception=>raise( |Please install the abapGit repository| ). ENDIF. lv_save_sy_langu = sy-langu. SET LOCALE LANGUAGE lv_main_language. ls_spagpa-parid = zif_abapgit_definitions=>c_spagpa_param_repo_key. ls_spagpa-parval = mo_repo->get_key( ). INSERT ls_spagpa INTO TABLE lt_spagpa. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' DESTINATION 'NONE' STARTING NEW TASK 'ABAPGIT' EXPORTING tcode = lv_tcode TABLES spagpa_tab = lt_spagpa EXCEPTIONS call_transaction_denied = 1 tcode_invalid = 2 communication_failure = 3 system_failure = 4 OTHERS = 5. lv_subrc = sy-subrc. SET LOCALE LANGUAGE lv_save_sy_langu. IF lv_subrc <> 0. zcx_abapgit_exception=>raise( |Error from ABAP4_CALL_TRANSACTION. Subrc = { lv_subrc }| ). ENDIF. MESSAGE 'Repository opened in a new window' TYPE 'S'. ENDMETHOD. METHOD order_files. DATA: lt_sort TYPE abap_sortorder_tab, ls_sort LIKE LINE OF lt_sort. IF lines( ct_files ) = 0. RETURN. ENDIF. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. ls_sort-name = 'PATH'. INSERT ls_sort INTO TABLE lt_sort. ls_sort-descending = mv_order_descending. ls_sort-astext = abap_true. ls_sort-name = 'FILENAME'. INSERT ls_sort INTO TABLE lt_sort. SORT ct_files STABLE BY (lt_sort). ENDMETHOD. METHOD render_content. DATA: lt_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt, lo_browser TYPE REF TO zcl_abapgit_repo_content_list, lx_error TYPE REF TO zcx_abapgit_exception, lv_max TYPE abap_bool, lv_max_str TYPE string, lv_add_str TYPE string, li_log TYPE REF TO zif_abapgit_log, lv_msg TYPE string, lo_news TYPE REF TO zcl_abapgit_news. FIELD-SYMBOLS LIKE LINE OF lt_repo_items. gui_services( )->get_hotkeys_ctl( )->register_hotkeys( zif_abapgit_gui_hotkeys~get_hotkey_actions( ) ). gui_services( )->register_event_handler( me ). CREATE OBJECT mo_repo_aggregated_state. TRY. "" Reinit, for the case of type change mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( mo_repo->get_key( ) ). mv_are_changes_recorded_in_tr = zcl_abapgit_factory=>get_sap_package( mo_repo->get_package( ) )->are_changes_recorded_in_tr_req( ). lo_news = zcl_abapgit_news=>create( mo_repo ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( |
| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo io_news = lo_news iv_show_edit = abap_true iv_interactive_branch = abap_true ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_news( io_news = lo_news ) ). zcl_abapgit_exit=>get_instance( )->wall_message_repo( is_repo_meta = mo_repo->ms_data ii_html = ri_html ). CREATE OBJECT lo_browser EXPORTING io_repo = mo_repo. lt_repo_items = lo_browser->list( iv_path = mv_cur_dir iv_by_folders = mv_show_folders iv_changes_only = mv_changes_only iv_transports = mv_are_changes_recorded_in_tr ). apply_order_by( CHANGING ct_repo_items = lt_repo_items ). LOOP AT lt_repo_items ASSIGNING . mo_repo_aggregated_state->sum_with_repo_item( ). ENDLOOP. ri_html->add( render_head_line( ) ). li_log = lo_browser->get_log( ). IF li_log->count( ) > 0. ri_html->add( '
' ). ri_html->add( zcl_abapgit_log_viewer=>to_html( li_log ) ). "" shows eg. list of unsupported objects ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). CLEAR lv_msg. IF mo_repo->is_offline( ) = abap_true AND mo_repo->has_remote_source( ) = abap_true AND mo_repo_aggregated_state->is_unchanged( ) = abap_true. "" Offline match banner lv_msg = 'ZIP source is attached and completely matches the local state'. ELSEIF lines( lt_repo_items ) = 0. "" Online match banner IF mv_changes_only = abap_true. lv_msg = 'Local state completely matches the remote repository'. ELSE. lv_msg = |Package is empty. Show { build_dir_jump_link( 'parent' ) } package|. ENDIF. ELSE. "" Repo content table ri_html->add( '' ). ri_html->add( render_order_by( ) ). IF zcl_abapgit_path=>is_root( mv_cur_dir ) = abap_false. ri_html->add( render_parent_dir( ) ). ENDIF. LOOP AT lt_repo_items ASSIGNING . IF mv_max_lines > 0 AND sy-tabix > mv_max_lines. lv_max = abap_true. EXIT. "" current loop ENDIF. ri_html->add( render_item( is_item = iv_render_transports = mv_are_changes_recorded_in_tr ) ). ENDLOOP. IF mv_changes_only = abap_true. ri_html->add( `` ). ENDIF. ri_html->add( '
` ). ri_html->add( `(Only changes are shown. ` ). ri_html->add( ri_html->a( iv_txt = |Show All| iv_act = |{ c_actions-toggle_changes }| ) ). ri_html->add( `)
' ). ENDIF. IF NOT lv_msg IS INITIAL. ri_html->add( |
{ lv_msg }
| ). ENDIF. IF lv_max = abap_true. ri_html->add( '
' ). IF mv_max_lines = 1. lv_max_str = '1 object'. ELSE. lv_max_str = |first { mv_max_lines } objects|. ENDIF. lv_add_str = |+{ mv_max_setting }|. ri_html->add( |Only { lv_max_str } objects shown in list. Display { ri_html->a( iv_txt = lv_add_str iv_act = c_actions-display_more ) } more (change in Settings > { ri_html->a( iv_txt = 'Personal Settings' iv_act = zif_abapgit_definitions=>c_action-go_settings_personal ) })| ). ri_html->add( '
' ). ENDIF. ri_html->add( '
' ). ri_html->add( '
' ). CATCH zcx_abapgit_exception INTO lx_error. "" Reset 'last shown repo' so next start will go to repo overview "" and allow troubleshooting of issue zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( || ). ri_html->add( render_head_line( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_error( iv_extra_style = 'repo_banner' ix_error = lx_error ) ). ENDTRY. register_deferred_script( render_scripts( ) ). ENDMETHOD. METHOD render_file_command. DATA: lv_difflink TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '
' ). IF is_file-is_changed = abap_true. lv_difflink = zcl_abapgit_html_action_utils=>file_encode( iv_key = mo_repo->get_key( ) ig_file = is_file ). ri_html->add_a( iv_txt = 'diff' iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_file-lstate iv_rstate = is_file-rstate ) ). ELSE. ri_html->add( ' ' ). ENDIF. ri_html->add( '
' ). ENDMETHOD. METHOD render_head_line. DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar. CREATE OBJECT ri_html TYPE zcl_abapgit_html. lo_toolbar = build_head_menu( ). ri_html->add( '
' ). ri_html->add( '' ). IF mv_show_folders = abap_true. ri_html->add( '' ). ENDIF. ri_html->add( '' ). ri_html->add( '
' ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_path( mv_cur_dir ) ). ri_html->add( '' ). ri_html->add( lo_toolbar->render( iv_right = abap_true ) ). ri_html->add( '
' ). ri_html->add( '
' ). ENDMETHOD. METHOD render_item. DATA: lv_link TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( || ). IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false. ri_html->add( || && '' && 'non-code and meta files' && '' ). ELSE. ri_html->add( |{ get_item_icon( is_item ) }| ). IF is_item-is_dir = abap_true. "" Subdir lv_link = build_dir_jump_link( is_item-path ). ri_html->add( |{ lv_link }| ). ELSE. lv_link = build_obj_jump_link( is_item ). ri_html->add( |{ is_item-obj_type }| ). ri_html->add( |{ lv_link } { build_inactive_object_code( is_item ) } { build_srcsystem_code( is_item ) }| ). ENDIF. ENDIF. "" Changed by ri_html->add( '' ). ri_html->add( render_item_changed_by( is_item ) ). ri_html->add( '' ). IF iv_render_transports = abap_true. ri_html->add( render_item_transport( is_item ) ). ENDIF. "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_item_command( is_item ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ri_html->add( render_item_files( is_item ) ). ENDMETHOD. METHOD render_item_changed_by. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-changes = 0 OR is_item-changed_by IS INITIAL. ri_html->add( ' ' ). ELSE. ri_html->add( zcl_abapgit_gui_chunk_lib=>render_user_name( is_item-changed_by ) ). ENDIF. ENDMETHOD. METHOD render_item_command. DATA: lv_difflink TYPE string, ls_file LIKE LINE OF is_item-files. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF is_item-is_dir = abap_true. "" Directory ri_html->add( '
' ). ri_html->add( |{ is_item-changes } changes| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ELSEIF is_item-changes > 0. IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL. lv_difflink = zcl_abapgit_html_action_utils=>obj_encode( iv_key = mo_repo->get_key( ) ig_object = is_item ). ri_html->add( '
' ). ri_html->add_a( iv_txt = |diff ({ is_item-changes })| iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate iv_rstate = is_item-rstate ) ). ri_html->add( '
' ). ENDIF. ENDIF. ENDMETHOD. METHOD render_item_files. DATA: ls_file LIKE LINE OF is_item-files. DATA li_exit TYPE REF TO zif_abapgit_exit. CREATE OBJECT ri_html TYPE zcl_abapgit_html. IF mv_hide_files = abap_true AND is_item-obj_type IS NOT INITIAL. RETURN. ENDIF. li_exit = zcl_abapgit_exit=>get_instance( ). LOOP AT is_item-files INTO ls_file. ri_html->add( || ). ri_html->add( || ). ri_html->add( || ). ri_html->add( || ). IF mv_show_folders = abap_true. ri_html->add( |
{ li_exit->adjust_display_filename( ls_file-filename ) }
| ). ELSE. ri_html->add( |
{ li_exit->adjust_display_filename( ls_file-path && ls_file-filename ) }
| ). ENDIF. ri_html->add( || ). "" Changed by (not applicable to file) ri_html->add( '' ). ri_html->add( '' ). "" Transport (not applicable to file) IF mv_are_changes_recorded_in_tr = abap_true. ri_html->add( `` ). ENDIF. "" Command ri_html->add( '' ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( render_file_command( ls_file ) ). ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDLOOP. ENDMETHOD. METHOD render_item_transport. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( is_item-transport ) ). ri_html->add( '' ). ENDMETHOD. METHOD render_order_by. DATA: lv_icon TYPE string, lt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt, ls_col_spec TYPE zif_abapgit_definitions=>ty_col_spec. CREATE OBJECT ri_html TYPE zcl_abapgit_html. "" icon APPEND INITIAL LINE TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_TYPE'. ls_col_spec-display_name = 'Type'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'OBJ_NAME'. ls_col_spec-display_name = 'Name'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ls_col_spec-tech_name = 'CHANGED_BY'. ls_col_spec-display_name = 'Changed by'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. IF mv_are_changes_recorded_in_tr = abap_true. ls_col_spec-tech_name = 'TRANSPORT'. ls_col_spec-display_name = 'Transport'. ls_col_spec-allow_order_by = abap_true. APPEND ls_col_spec TO lt_col_spec. ENDIF. ls_col_spec-tech_name = 'LSTATE'. ls_col_spec-display_name = 'Status'. ls_col_spec-allow_order_by = abap_true. ls_col_spec-css_class = 'cmd'. APPEND ls_col_spec TO lt_col_spec. ri_html->add( || ). ri_html->add( || ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_order_by_header_cells( it_col_spec = lt_col_spec iv_order_by = mv_order_by iv_order_descending = mv_order_descending ) ). IF mv_diff_first = abap_true. lv_icon = 'check/blue'. ELSE. lv_icon = 'check/grey'. ENDIF. ri_html->add( '' ). ri_html->add( '' ). ENDMETHOD. METHOD render_parent_dir. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( '' ). ri_html->add( |{ ri_html->icon( 'folder' ) }| ). ri_html->add( |{ build_dir_jump_link( '..' ) }| ). IF mo_repo->has_remote_source( ) = abap_true. ri_html->add( || ). "" Dummy for online ENDIF. ri_html->add( '' ). ENDMETHOD. METHOD render_scripts. CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->set_title( cl_abap_typedescr=>describe_by_object_ref( me )->get_relative_name( ) ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_palette( iv_action = zif_abapgit_definitions=>c_action-go_repo ) ). ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA lv_path TYPE string. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-go_repo. "" Switch to another repo CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN c_actions-go_data. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_data EXPORTING iv_key = |{ ii_event->query( )->get( 'KEY' ) }|. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN c_actions-toggle_hide_files. "" Toggle file diplay mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->toggle_hide_files( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-change_dir. "" Change dir lv_path = ii_event->query( )->get( 'PATH' ). mv_cur_dir = zcl_abapgit_path=>change_dir( iv_cur_dir = mv_cur_dir iv_cd = lv_path ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_folders. "" Toggle folder view mv_show_folders = zcl_abapgit_persistence_user=>get_instance( )->toggle_show_folders( ). mv_cur_dir = '/'. "" Root rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_changes. "" Toggle changes only view mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->toggle_changes_only( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-toggle_diff_first. mv_diff_first = zcl_abapgit_persistence_user=>get_instance( )->set_diff_first( boolc( mv_diff_first = abap_false ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN c_actions-display_more. "" Increase MAX lines limit mv_max_lines = mv_max_lines + mv_max_setting. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-change_order_by. mv_order_by = zcl_abapgit_persistence_user=>get_instance( )->set_order_by( ii_event->query( )->get( 'ORDERBY' ) ). mv_order_descending = zcl_abapgit_persistence_user=>get_instance( )->set_order_descending( abap_false ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-direction. mv_order_descending = zcl_abapgit_persistence_user=>get_instance( )->set_order_descending( boolc( ii_event->query( )->get( 'DIRECTION' ) = 'DESCENDING' ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_open_in_master_lang. open_in_main_language( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). "" TODO refactor, move to HOC components ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions. ls_hotkey_action-ui_component = 'Repo'. ls_hotkey_action-description = |Stage Changes|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_stage. ls_hotkey_action-hotkey = |s|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Switch Branch|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_branch_switch. ls_hotkey_action-hotkey = |b|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Repository List|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-abapgit_home. ls_hotkey_action-hotkey = |o|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Refresh Repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_refresh. ls_hotkey_action-hotkey = |r|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Pull|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_pull. ls_hotkey_action-hotkey = |p|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Diff|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_repo_diff. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Uninstall Repository|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_purge. ls_hotkey_action-hotkey = |u|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run Syntax Check|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_syntax_check. ls_hotkey_action-hotkey = |c|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Run Code Inspector|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_code_inspector. ls_hotkey_action-hotkey = |i|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ls_hotkey_action-description = |Show Log|. ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_log. ls_hotkey_action-hotkey = |l|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. ENDMETHOD. ENDCLASS. ",12366,True,2586.6781750034133,median "/* Feathers Copyright 2012-2016 Bowler Hat LLC. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls { import feathers.core.FeathersControl; import feathers.core.IAdvancedNativeFocusOwner; import feathers.core.ITextBaselineControl; import feathers.core.PropertyProxy; import feathers.events.ExclusiveTouch; import feathers.events.FeathersEventType; import feathers.skins.IStyleProvider; import feathers.utils.math.clamp; import feathers.utils.math.roundToNearest; import feathers.utils.math.roundToPrecision; import flash.events.TimerEvent; import flash.ui.Keyboard; import flash.utils.Timer; import starling.display.DisplayObject; import starling.events.Event; import starling.events.KeyboardEvent; import starling.events.Touch; import starling.events.TouchEvent; import starling.events.TouchPhase; /** * How the buttons are positioned relative to the text input. * *

In the following example, the button layout is set to place the * buttons on the right side, stacked vertically, for a desktop * appearance:

* * * stepper.buttonLayoutMode = NumericStepper.StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL; * * @default feathers.controls.StepperButtonLayoutMode.SPLIT_HORIZONTAL * * @see feathers.controls.StepperButtonLayoutMode#SPLIT_HORIZONTAL * @see feathers.controls.StepperButtonLayoutMode#SPLIT_VERTICAL * @see feathers.controls.StepperButtonLayoutMode#RIGHT_SIDE_VERTICAL */ [Style(name=""buttonLayoutMode"",type=""String"")] /** * The gap, in pixels, between the numeric stepper's increment and * decrement buttons when they are both positioned on the same side. If * the buttons are split between two sides, this value is not used. * *

In the following example, the gap between buttons is set to 20 pixels:

* * * stepper.buttonLayoutMode = StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL; * stepper.buttonGap = 20; * * @default 0 * * @see #style:textInputGap * @see #style:buttonLayoutMode */ [Style(name=""buttonGap"",type=""Number"")] /** * A style name to add to the numeric stepper's decrement button * sub-component. Typically used by a theme to provide different styles * to different numeric steppers. * *

In the following example, a custom decrement button style name is * passed to the stepper:

* * * stepper.customDecrementButtonStyleName = ""my-custom-decrement-button""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( Button ).setFunctionForStyleName( ""my-custom-decrement-button"", setCustomDecrementButtonStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON * @see feathers.core.FeathersControl#styleNameList * @see #decrementButtonFactory */ [Style(name=""customDecrementButtonStyleName"",type=""String"")] /** * A style name to add to the numeric stepper's increment button * sub-component. Typically used by a theme to provide different styles * to different numeric steppers. * *

In the following example, a custom increment button style name is * passed to the stepper:

* * * stepper.customIncrementButtonStyleName = ""my-custom-increment-button""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( Button ).setFunctionForStyleName( ""my-custom-increment-button"", setCustomIncrementButtonStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON * @see feathers.core.FeathersControl#styleNameList * @see #incrementButtonFactory */ [Style(name=""customIncrementButtonStyleName"",type=""String"")] /** * A style name to add to the numeric stepper's text input sub-component. * Typically used by a theme to provide different styles to different * text inputs. * *

In the following example, a custom text input style name is passed * to the stepper:

* * * stepper.customTextInputStyleName = ""my-custom-text-input""; * *

In your theme, you can target this sub-component style name to * provide different styles than the default:

* * * getStyleProviderForClass( TextInput ).setFunctionForStyleName( ""my-custom-text-input"", setCustomTextInputStyles ); * * @default null * * @see #DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT * @see feathers.core.FeathersControl#styleNameList * @see #textInputFactory */ [Style(name=""customTextInputStyleName"",type=""String"")] /** * The text displayed by the decrement button. Often, there is no text * displayed on this button and an icon is used instead. * *

In the following example, the decrement button's label is customized:

* * * stepper.decrementButtonLabel = ""-""; * * @default null */ [Style(name=""decrementButtonLabel"",type=""String"")] /** * The text displayed by the increment button. Often, there is no text * displayed on this button and an icon is used instead. * *

In the following example, the increment button's label is customized:

* * * stepper.incrementButtonLabel = ""+""; * * @default null */ [Style(name=""incrementButtonLabel"",type=""String"")] /** * The gap, in pixels, between the numeric stepper's text input and its * buttons. If the buttons are split, this gap is used on both sides. If * the buttons both appear on the same side, the gap is used only on * that side. * *

In the following example, the gap between the text input and buttons is set to 20 pixels:

* * * stepper.textInputGap = 20; * * @default 0 * * @see #style:buttonGap * @see #style:buttonLayoutMode */ [Style(name=""textInputGap"",type=""Number"")] /** * Dispatched when the stepper's value changes. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] /** * Select a value between a minimum and a maximum by using increment and * decrement buttons or typing in a value in a text input. * *

The following example sets the stepper's range and listens for when * the value changes:

* * * var stepper:NumericStepper = new NumericStepper(); * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * stepper.addEventListener( Event.CHANGE, stepper_changeHandler ); * this.addChild( stepper ); * * @see ../../../help/numeric-stepper.html How to use the Feathers NumericStepper component */ public class NumericStepper extends FeathersControl implements IRange, IAdvancedNativeFocusOwner, ITextBaselineControl { /** * @private */ protected static const INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY:String = ""decrementButtonFactory""; /** * @private */ protected static const INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY:String = ""incrementButtonFactory""; /** * @private */ protected static const INVALIDATION_FLAG_TEXT_INPUT_FACTORY:String = ""textInputFactory""; /** * The default value added to the styleNameList of the decrement * button. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON:String = ""feathers-numeric-stepper-decrement-button""; /** * The default value added to the styleNameList of the increment * button. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON:String = ""feathers-numeric-stepper-increment-button""; /** * The default value added to the styleNameList of the text * input. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT:String = ""feathers-numeric-stepper-text-input""; /** * @private * DEPRECATED: Replaced by feathers.controls.StepperButtonLayoutMode.SPLIT_HORIZONTAL. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const BUTTON_LAYOUT_MODE_SPLIT_HORIZONTAL:String = ""splitHorizontal""; /** * @private * DEPRECATED: Replaced by feathers.controls.StepperButtonLayoutMode.SPLIT_VERTICAL. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const BUTTON_LAYOUT_MODE_SPLIT_VERTICAL:String = ""splitVertical""; /** * @private * DEPRECATED: Replaced by feathers.controls.StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const BUTTON_LAYOUT_MODE_RIGHT_SIDE_VERTICAL:String = ""rightSideVertical""; /** * The default IStyleProvider for all NumericStepper * components. * * @default null * @see feathers.core.FeathersControl#styleProvider */ public static var globalStyleProvider:IStyleProvider; /** * @private */ protected static function defaultDecrementButtonFactory():Button { return new Button(); } /** * @private */ protected static function defaultIncrementButtonFactory():Button { return new Button(); } /** * @private */ protected static function defaultTextInputFactory():TextInput { return new TextInput(); } /** * Constructor. */ public function NumericStepper() { super(); this.addEventListener(Event.REMOVED_FROM_STAGE, numericStepper_removedFromStageHandler); } /** * The value added to the styleNameList of the decrement * button. This variable is protected so that sub-classes * can customize the decrement button style name in their constructors * instead of using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON. * *

To customize the decrement button name without subclassing, see * customDecrementButtonStyleName.

* * @see #style:customDecrementButtonStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var decrementButtonStyleName:String = DEFAULT_CHILD_STYLE_NAME_DECREMENT_BUTTON; /** * The value added to the styleNameList of the increment * button. This variable is protected so that sub-classes * can customize the increment button style name in their constructors * instead of using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON. * *

To customize the increment button name without subclassing, see * customIncrementButtonStyleName.

* * @see #style:customIncrementButtonStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var incrementButtonStyleName:String = DEFAULT_CHILD_STYLE_NAME_INCREMENT_BUTTON; /** * The value added to the styleNameList of the text input. * This variable is protected so that sub-classes can * customize the text input style name in their constructors instead of * using the default style name defined by * DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT. * *

To customize the text input name without subclassing, see * customTextInputStyleName.

* * @see #style:customTextInputStyleName * @see feathers.core.FeathersControl#styleNameList */ protected var textInputStyleName:String = DEFAULT_CHILD_STYLE_NAME_TEXT_INPUT; /** * The decrement button sub-component. * *

For internal use in subclasses.

* * @see #createDecrementButton() */ protected var decrementButton:Button; /** * The increment button sub-component. * *

For internal use in subclasses.

* * @see #createIncrementButton() */ protected var incrementButton:Button; /** * The text input sub-component. * *

For internal use in subclasses.

* * @see #createTextInput() */ protected var textInput:TextInput; /** * @private */ protected var textInputExplicitWidth:Number; /** * @private */ protected var textInputExplicitHeight:Number; /** * @private */ protected var textInputExplicitMinWidth:Number; /** * @private */ protected var textInputExplicitMinHeight:Number; /** * @private */ protected var touchPointID:int = -1; /** * @private */ protected var _textInputHasFocus:Boolean = false; /** * @private */ override protected function get defaultStyleProvider():IStyleProvider { return NumericStepper.globalStyleProvider; } /** * A text input's text editor may be an INativeFocusOwner, * so we need to return the value of its nativeFocus * property. * * @see feathers.core.INativeFocusOwner */ public function get nativeFocus():Object { if(this.textInput !== null) { return this.textInput.nativeFocus; } return null; } /** * @private */ protected var _value:Number = 0; /** * The value of the numeric stepper, between the minimum and maximum. * *

In the following example, the value is changed to 12:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #minimum * @see #maximum * @see #step * @see #event:change */ public function get value():Number { return this._value; } /** * @private */ public function set value(newValue:Number):void { if(this._step != 0 && newValue != this._maximum && newValue != this._minimum) { //roundToPrecision helps us to avoid numbers like 1.00000000000000001 //caused by the inaccuracies of floating point math. newValue = roundToPrecision(roundToNearest(newValue - this._minimum, this._step) + this._minimum, 10); } newValue = clamp(newValue, this._minimum, this._maximum); if(this._value == newValue) { return; } this._value = newValue; this.invalidate(INVALIDATION_FLAG_DATA); this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _minimum:Number = 0; /** * The numeric stepper's value will not go lower than the minimum. * *

In the following example, the minimum is changed to 0:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #maximum * @see #step */ public function get minimum():Number { return this._minimum; } /** * @private */ public function set minimum(value:Number):void { if(this._minimum == value) { return; } this._minimum = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _maximum:Number = 0; /** * The numeric stepper's value will not go higher than the maximum. * *

In the following example, the maximum is changed to 100:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #minimum * @see #step */ public function get maximum():Number { return this._maximum; } /** * @private */ public function set maximum(value:Number):void { if(this._maximum == value) { return; } this._maximum = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _step:Number = 0; /** * As the numeric stepper's buttons are pressed, the value is snapped to * a multiple of the step. * *

In the following example, the step is changed to 1:

* * * stepper.minimum = 0; * stepper.maximum = 100; * stepper.step = 1; * stepper.value = 12; * * @default 0 * * @see #value * @see #minimum * @see #maximum */ public function get step():Number { return this._step; } /** * @private */ public function set step(value:Number):void { if(this._step == value) { return; } this._step = value; } /** * @private */ protected var _valueFormatFunction:Function; /** * A callback that formats the numeric stepper's value as a string to * display to the user. * *

The function is expected to have the following signature:

*
function(value:Number):String
* *

In the following example, the stepper's value format function is * customized:

* * * stepper.valueFormatFunction = function(value:Number):String * { * return currencyFormatter.format(value, true); * }; * * @default null * * @see #valueParseFunction */ public function get valueFormatFunction():Function { return this._valueFormatFunction; } /** * @private */ public function set valueFormatFunction(value:Function):void { if(this._valueFormatFunction == value) { return; } this._valueFormatFunction = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _valueParseFunction:Function; /** * A callback that accepts the displayed text of the numeric stepper and * converts it to a simple numeric value. * *

The function is expected to have the following signature:

*
function(displayedText:String):Number
* *

In the following example, the stepper's value parse function is * customized:

* * * stepper.valueParseFunction = function(displayedText:String):String * { * return currencyFormatter.parse(displayedText).value; * }; * * @default null * * @see #valueFormatFunction */ public function get valueParseFunction():Function { return this._valueParseFunction; } /** * @private */ public function set valueParseFunction(value:Function):void { this._valueParseFunction = value; } /** * @private */ protected var currentRepeatAction:Function; /** * @private */ protected var _repeatTimer:Timer; /** * @private */ protected var _repeatDelay:Number = 0.05; /** * The time, in seconds, before actions are repeated. The first repeat * happens after a delay that is five times longer than the following * repeats. * *

In the following example, the stepper's repeat delay is set to * 500 milliseconds:

* * * stepper.repeatDelay = 0.5; * * @default 0.05 */ public function get repeatDelay():Number { return this._repeatDelay; } /** * @private */ public function set repeatDelay(value:Number):void { if(this._repeatDelay == value) { return; } this._repeatDelay = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _buttonLayoutMode:String = StepperButtonLayoutMode.SPLIT_HORIZONTAL; [Inspectable(type=""String"",enumeration=""splitHorizontal,splitVertical,rightSideVertical"")] /** * @private */ public function get buttonLayoutMode():String { return this._buttonLayoutMode; } /** * @private */ public function set buttonLayoutMode(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._buttonLayoutMode === value) { return; } this._buttonLayoutMode = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _buttonGap:Number = 0; /** * @private */ public function get buttonGap():Number { return this._buttonGap; } /** * @private */ public function set buttonGap(value:Number):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._buttonGap === value) { return; } this._buttonGap = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _textInputGap:Number = 0; /** * @private */ public function get textInputGap():Number { return this._textInputGap; } /** * @private */ public function set textInputGap(value:Number):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._textInputGap === value) { return; } this._textInputGap = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _decrementButtonFactory:Function; /** * A function used to generate the numeric stepper's decrement button * sub-component. The decrement button must be an instance of * Button. This factory can be used to change properties on * the decrement button when it is first created. For instance, if you * are skinning Feathers components without a theme, you might use this * factory to set skins and other styles on the decrement button. * *

The function should have the following signature:

*
function():Button
* *

In the following example, a custom decrement button factory is passed * to the stepper:

* * * stepper.decrementButtonFactory = function():Button * { * var button:Button = new Button(); * button.defaultSkin = new Image( upTexture ); * button.downSkin = new Image( downTexture ); * return button; * }; * * @default null * * @see feathers.controls.Button */ public function get decrementButtonFactory():Function { return this._decrementButtonFactory; } /** * @private */ public function set decrementButtonFactory(value:Function):void { if(this._decrementButtonFactory == value) { return; } this._decrementButtonFactory = value; this.invalidate(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); } /** * @private */ protected var _customDecrementButtonStyleName:String; /** * @private */ public function get customDecrementButtonStyleName():String { return this._customDecrementButtonStyleName; } /** * @private */ public function set customDecrementButtonStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customDecrementButtonStyleName === value) { return; } this._customDecrementButtonStyleName = value; this.invalidate(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); } /** * @private */ protected var _decrementButtonProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's decrement * button sub-component, and the properties will be passed down to the * decrement button when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.Button. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a decrementButtonFactory * function instead of using decrementButtonProperties will * result in better performance.

* *

In the following example, the stepper's decrement button properties * are updated:

* * * stepper.decrementButtonProperties.defaultSkin = new Image( upTexture ); * stepper.decrementButtonProperties.downSkin = new Image( downTexture ); * * @default null * * @see #decrementButtonFactory * @see feathers.controls.Button */ public function get decrementButtonProperties():Object { if(!this._decrementButtonProperties) { this._decrementButtonProperties = new PropertyProxy(childProperties_onChange); } return this._decrementButtonProperties; } /** * @private */ public function set decrementButtonProperties(value:Object):void { if(this._decrementButtonProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._decrementButtonProperties) { this._decrementButtonProperties.removeOnChangeCallback(childProperties_onChange); } this._decrementButtonProperties = PropertyProxy(value); if(this._decrementButtonProperties) { this._decrementButtonProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _decrementButtonLabel:String = null; /** * @private */ public function get decrementButtonLabel():String { return this._decrementButtonLabel; } /** * @private */ public function set decrementButtonLabel(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._decrementButtonLabel === value) { return; } this._decrementButtonLabel = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _incrementButtonFactory:Function; /** * A function used to generate the numeric stepper's increment button * sub-component. The increment button must be an instance of * Button. This factory can be used to change properties on * the increment button when it is first created. For instance, if you * are skinning Feathers components without a theme, you might use this * factory to set skins and other styles on the increment button. * *

The function should have the following signature:

*
function():Button
* *

In the following example, a custom increment button factory is passed * to the stepper:

* * * stepper.incrementButtonFactory = function():Button * { * var button:Button = new Button(); * button.defaultSkin = new Image( upTexture ); * button.downSkin = new Image( downTexture ); * return button; * }; * * @default null * * @see feathers.controls.Button */ public function get incrementButtonFactory():Function { return this._incrementButtonFactory; } /** * @private */ public function set incrementButtonFactory(value:Function):void { if(this._incrementButtonFactory == value) { return; } this._incrementButtonFactory = value; this.invalidate(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); } /** * @private */ protected var _customIncrementButtonStyleName:String; /** * @private */ public function get customIncrementButtonStyleName():String { return this._customIncrementButtonStyleName; } /** * @private */ public function set customIncrementButtonStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customIncrementButtonStyleName === value) { return; } this._customIncrementButtonStyleName = value; this.invalidate(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); } /** * @private */ protected var _incrementButtonProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's increment * button sub-component, and the properties will be passed down to the * increment button when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.Button. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a incrementButtonFactory * function instead of using incrementButtonProperties will * result in better performance.

* *

In the following example, the stepper's increment button properties * are updated:

* * * stepper.incrementButtonProperties.defaultSkin = new Image( upTexture ); * stepper.incrementButtonProperties.downSkin = new Image( downTexture ); * * @default null * * @see #incrementButtonFactory * @see feathers.controls.Button */ public function get incrementButtonProperties():Object { if(!this._incrementButtonProperties) { this._incrementButtonProperties = new PropertyProxy(childProperties_onChange); } return this._incrementButtonProperties; } /** * @private */ public function set incrementButtonProperties(value:Object):void { if(this._incrementButtonProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._incrementButtonProperties) { this._incrementButtonProperties.removeOnChangeCallback(childProperties_onChange); } this._incrementButtonProperties = PropertyProxy(value); if(this._incrementButtonProperties) { this._incrementButtonProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _incrementButtonLabel:String = null; /** * @private */ public function get incrementButtonLabel():String { return this._incrementButtonLabel; } /** * @private */ public function set incrementButtonLabel(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._incrementButtonLabel === value) { return; } this._incrementButtonLabel = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _textInputFactory:Function; /** * A function used to generate the numeric stepper's text input * sub-component. The text input must be an instance of TextInput. * This factory can be used to change properties on the text input when * it is first created. For instance, if you are skinning Feathers * components without a theme, you might use this factory to set skins * and other styles on the text input. * *

The function should have the following signature:

*
function():TextInput
* *

In the following example, a custom text input factory is passed * to the stepper:

* * * stepper.textInputFactory = function():TextInput * { * var textInput:TextInput = new TextInput(); * textInput.backgroundSkin = new Image( texture ); * return textInput; * }; * * @default null * * @see feathers.controls.TextInput */ public function get textInputFactory():Function { return this._textInputFactory; } /** * @private */ public function set textInputFactory(value:Function):void { if(this._textInputFactory == value) { return; } this._textInputFactory = value; this.invalidate(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); } /** * @private */ protected var _customTextInputStyleName:String; /** * @private */ public function get customTextInputStyleName():String { return this._customTextInputStyleName; } /** * @private */ public function set customTextInputStyleName(value:String):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._customTextInputStyleName === value) { return; } this._customTextInputStyleName = value; this.invalidate(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); } /** * @private */ protected var _textInputProperties:PropertyProxy; /** * An object that stores properties for the numeric stepper's text * input sub-component, and the properties will be passed down to the * text input when the numeric stepper validates. For a list of * available properties, refer to feathers.controls.TextInput. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb which is in a SimpleScrollBar, * which is in a List, you can use the following syntax:

*
list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* *

Setting properties in a textInputFactory function * instead of using textInputProperties will result in * better performance.

* *

In the following example, the stepper's text input properties * are updated:

* * * stepper.textInputProperties.backgroundSkin = new Image( texture ); * * @default null * * @see #textInputFactory * @see feathers.controls.TextInput */ public function get textInputProperties():Object { if(!this._textInputProperties) { this._textInputProperties = new PropertyProxy(childProperties_onChange); } return this._textInputProperties; } /** * @private */ public function set textInputProperties(value:Object):void { if(this._textInputProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { var newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._textInputProperties) { this._textInputProperties.removeOnChangeCallback(childProperties_onChange); } this._textInputProperties = PropertyProxy(value); if(this._textInputProperties) { this._textInputProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @inheritDoc */ public function get baseline():Number { if(!this.textInput) { return this.scaledActualHeight; } return this.scaleY * (this.textInput.y + this.textInput.baseline); } /** * @private */ public function get hasFocus():Boolean { return this._hasFocus; } /** * @private */ public function setFocus():void { if(this.textInput === null) { return; } this.textInput.setFocus(); } /** * @private */ override protected function draw():void { var dataInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DATA); var stylesInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STYLES); var sizeInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SIZE); var stateInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STATE); var decrementButtonFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DECREMENT_BUTTON_FACTORY); var incrementButtonFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_INCREMENT_BUTTON_FACTORY); var textInputFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_TEXT_INPUT_FACTORY); var focusInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_FOCUS); if(decrementButtonFactoryInvalid) { this.createDecrementButton(); } if(incrementButtonFactoryInvalid) { this.createIncrementButton(); } if(textInputFactoryInvalid) { this.createTextInput(); } if(decrementButtonFactoryInvalid || stylesInvalid) { this.refreshDecrementButtonStyles(); } if(incrementButtonFactoryInvalid || stylesInvalid) { this.refreshIncrementButtonStyles(); } if(textInputFactoryInvalid || stylesInvalid) { this.refreshTextInputStyles(); } if(textInputFactoryInvalid || dataInvalid) { this.refreshTypicalText(); this.refreshDisplayedText(); } if(decrementButtonFactoryInvalid || stateInvalid) { this.decrementButton.isEnabled = this._isEnabled; } if(incrementButtonFactoryInvalid || stateInvalid) { this.incrementButton.isEnabled = this._isEnabled; } if(textInputFactoryInvalid || stateInvalid) { this.textInput.isEnabled = this._isEnabled; } sizeInvalid = this.autoSizeIfNeeded() || sizeInvalid; this.layoutChildren(); if(sizeInvalid || focusInvalid) { this.refreshFocusIndicator(); } } /** * If the component's dimensions have not been set explicitly, it will * measure its content and determine an ideal size for itself. If the * explicitWidth or explicitHeight member * variables are set, those value will be used without additional * measurement. If one is set, but not the other, the dimension with the * explicit value will not be measured, but the other non-explicit * dimension will still need measurement. * *

Calls saveMeasurements() to set up the * actualWidth and actualHeight member * variables used for layout.

* *

Meant for internal use, and subclasses may override this function * with a custom implementation.

*/ protected function autoSizeIfNeeded():Boolean { var needsWidth:Boolean = this._explicitWidth !== this._explicitWidth; //isNaN var needsHeight:Boolean = this._explicitHeight !== this._explicitHeight; //isNaN var needsMinWidth:Boolean = this._explicitMinWidth !== this._explicitMinWidth; //isNaN var needsMinHeight:Boolean = this._explicitMinHeight !== this._explicitMinHeight; //isNaN if(!needsWidth && !needsHeight && !needsMinWidth && !needsMinHeight) { return false; } var newWidth:Number = this._explicitWidth; var newHeight:Number = this._explicitHeight; var newMinWidth:Number = this._explicitMinWidth; var newMinHeight:Number = this._explicitMinHeight; this.decrementButton.validate(); this.incrementButton.validate(); var decrementButtonWidth:Number = this.decrementButton.width; var decrementButtonHeight:Number = this.decrementButton.height; var decrementButtonMinWidth:Number = this.decrementButton.minWidth; var decrementButtonMinHeight:Number = this.decrementButton.minHeight; var incrementButtonWidth:Number = this.incrementButton.width; var incrementButtonHeight:Number = this.incrementButton.height; var incrementButtonMinWidth:Number = this.incrementButton.minWidth; var incrementButtonMinHeight:Number = this.incrementButton.minHeight; //we'll default to the values set in the textInputFactory var textInputWidth:Number = this.textInputExplicitWidth; var textInputHeight:Number = this.textInputExplicitHeight; var textInputMinWidth:Number = this.textInputExplicitMinWidth; var textInputMinHeight:Number = this.textInputExplicitMinHeight; var textInputMaxWidth:Number = Number.POSITIVE_INFINITY; var textInputMaxHeight:Number = Number.POSITIVE_INFINITY; if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { var maxButtonWidth:Number = decrementButtonWidth; if(incrementButtonWidth > maxButtonWidth) { maxButtonWidth = incrementButtonWidth; } var maxButtonMinWidth:Number = decrementButtonMinWidth; if(incrementButtonMinWidth > maxButtonMinWidth) { maxButtonMinWidth = incrementButtonMinWidth; } if(!needsWidth) { textInputWidth = this._explicitWidth - maxButtonWidth - this._textInputGap; } if(!needsHeight) { textInputHeight = this._explicitHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth - maxButtonMinWidth - this._textInputGap; if(this.textInputExplicitMinWidth > textInputMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxWidth = this._explicitMaxWidth - maxButtonWidth - this._textInputGap; } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { if(!needsWidth) { textInputWidth = this._explicitWidth; } if(!needsHeight) { textInputHeight = this._explicitHeight - decrementButtonHeight - incrementButtonHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth; if(this.textInputExplicitMinWidth > textInputMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight - decrementButtonMinHeight - incrementButtonMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxHeight = this._explicitMaxHeight - decrementButtonHeight - incrementButtonHeight; } else //split horizontal { if(!needsWidth) { textInputWidth = this._explicitWidth - decrementButtonWidth - incrementButtonWidth; } if(!needsHeight) { textInputHeight = this._explicitHeight; } if(!needsMinWidth) { textInputMinWidth = this._explicitMinWidth - decrementButtonMinWidth - incrementButtonMinWidth; if(textInputMinWidth < this.textInputExplicitMinWidth) { textInputMinWidth = this.textInputExplicitMinWidth; } } if(!needsMinHeight) { textInputMinHeight = this._explicitMinHeight; if(this.textInputExplicitMinHeight > textInputMinHeight) { textInputMinHeight = this.textInputExplicitMinHeight; } } textInputMaxWidth = this._explicitMaxWidth - decrementButtonWidth - incrementButtonWidth; } if(textInputWidth < 0) { textInputWidth = 0; } if(textInputHeight < 0) { textInputHeight = 0; } if(textInputMinWidth < 0) { textInputMinWidth = 0; } if(textInputMinHeight < 0) { textInputMinHeight = 0; } this.textInput.width = textInputWidth; this.textInput.height = textInputHeight; this.textInput.minWidth = textInputMinWidth; this.textInput.minHeight = textInputMinHeight; this.textInput.maxWidth = textInputMaxWidth; this.textInput.maxHeight = textInputMaxHeight; this.textInput.validate(); if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { if(needsWidth) { newWidth = this.textInput.width + maxButtonWidth + this._textInputGap; } if(needsHeight) { newHeight = decrementButtonHeight + this._buttonGap + incrementButtonHeight; if(this.textInput.height > newHeight) { newHeight = this.textInput.height; } } if(needsMinWidth) { newMinWidth = this.textInput.minWidth + maxButtonMinWidth + this._textInputGap; } if(needsMinHeight) { newMinHeight = decrementButtonMinHeight + this._buttonGap + incrementButtonMinHeight; if(this.textInput.minHeight > newMinHeight) { newMinHeight = this.textInput.minHeight; } } } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { if(needsWidth) { newWidth = this.textInput.width; if(decrementButtonWidth > newWidth) { newWidth = decrementButtonWidth; } if(incrementButtonWidth > newWidth) { newWidth = incrementButtonWidth; } } if(needsHeight) { newHeight = decrementButtonHeight + this.textInput.height + incrementButtonHeight + 2 * this._textInputGap; } if(needsMinWidth) { newMinWidth = this.textInput.minWidth; if(decrementButtonMinWidth > newMinWidth) { newMinWidth = decrementButtonMinWidth; } if(incrementButtonMinWidth > newMinWidth) { newMinWidth = incrementButtonMinWidth; } } if(needsMinHeight) { newMinHeight = decrementButtonMinHeight + this.textInput.minHeight + incrementButtonMinHeight + 2 * this._textInputGap; } } else //split horizontal { if(needsWidth) { newWidth = decrementButtonWidth + this.textInput.width + incrementButtonWidth + 2 * this._textInputGap; } if(needsHeight) { newHeight = this.textInput.height; if(decrementButtonHeight > newHeight) { newHeight = decrementButtonHeight; } if(incrementButtonHeight > newHeight) { newHeight = incrementButtonHeight; } } if(needsMinWidth) { newMinWidth = decrementButtonMinWidth + this.textInput.minWidth + incrementButtonMinWidth + 2 * this._textInputGap; } if(needsMinHeight) { newMinHeight = this.textInput.minHeight; if(decrementButtonMinHeight > newMinHeight) { newMinHeight = decrementButtonMinHeight; } if(incrementButtonMinHeight > newMinHeight) { newMinHeight = incrementButtonMinHeight; } } } return this.saveMeasurements(newWidth, newHeight, newMinWidth, newMinHeight); } /** * @private */ protected function decrement():void { this.value = this._value - this._step; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function increment():void { this.value = this._value + this._step; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function toMinimum():void { this.value = this._minimum; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * @private */ protected function toMaximum():void { this.value = this._maximum; this.validate(); this.textInput.selectRange(0, this.textInput.text.length); } /** * Creates and adds the decrementButton sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #decrementButton * @see #decrementButtonFactory * @see #style:customDecrementButtonStyleName */ protected function createDecrementButton():void { if(this.decrementButton) { this.decrementButton.removeFromParent(true); this.decrementButton = null; } var factory:Function = this._decrementButtonFactory != null ? this._decrementButtonFactory : defaultDecrementButtonFactory; var decrementButtonStyleName:String = this._customDecrementButtonStyleName != null ? this._customDecrementButtonStyleName : this.decrementButtonStyleName; this.decrementButton = Button(factory()); this.decrementButton.styleNameList.add(decrementButtonStyleName); this.decrementButton.addEventListener(TouchEvent.TOUCH, decrementButton_touchHandler); this.addChild(this.decrementButton); } /** * Creates and adds the incrementButton sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #incrementButton * @see #incrementButtonFactory * @see #style:customIncrementButtonStyleName */ protected function createIncrementButton():void { if(this.incrementButton) { this.incrementButton.removeFromParent(true); this.incrementButton = null; } var factory:Function = this._incrementButtonFactory != null ? this._incrementButtonFactory : defaultIncrementButtonFactory; var incrementButtonStyleName:String = this._customIncrementButtonStyleName != null ? this._customIncrementButtonStyleName : this.incrementButtonStyleName; this.incrementButton = Button(factory()); this.incrementButton.styleNameList.add(incrementButtonStyleName); this.incrementButton.addEventListener(TouchEvent.TOUCH, incrementButton_touchHandler); this.addChild(this.incrementButton); } /** * Creates and adds the textInput sub-component and * removes the old instance, if one exists. * *

Meant for internal use, and subclasses may override this function * with a custom implementation.

* * @see #textInput * @see #textInputFactory * @see #style:customTextInputStyleName */ protected function createTextInput():void { if(this.textInput) { this.textInput.removeFromParent(true); this.textInput = null; } var factory:Function = this._textInputFactory != null ? this._textInputFactory : defaultTextInputFactory; var textInputStyleName:String = this._customTextInputStyleName != null ? this._customTextInputStyleName : this.textInputStyleName; this.textInput = TextInput(factory()); this.textInput.styleNameList.add(textInputStyleName); this.textInput.addEventListener(FeathersEventType.ENTER, textInput_enterHandler); this.textInput.addEventListener(FeathersEventType.FOCUS_IN, textInput_focusInHandler); this.textInput.addEventListener(FeathersEventType.FOCUS_OUT, textInput_focusOutHandler); //while we're setting isFocusEnabled to false on the text input when //we have a focus manager, we'll still be able to call setFocus() on //the text input manually. this.textInput.isFocusEnabled = !this._focusManager; this.addChild(this.textInput); //we will use these values for measurement, if possible this.textInput.initializeNow(); this.textInputExplicitWidth = this.textInput.explicitWidth; this.textInputExplicitHeight = this.textInput.explicitHeight; this.textInputExplicitMinWidth = this.textInput.explicitMinWidth; this.textInputExplicitMinHeight = this.textInput.explicitMinHeight; } /** * @private */ protected function refreshDecrementButtonStyles():void { for(var propertyName:String in this._decrementButtonProperties) { var propertyValue:Object = this._decrementButtonProperties[propertyName]; this.decrementButton[propertyName] = propertyValue; } this.decrementButton.label = this._decrementButtonLabel; } /** * @private */ protected function refreshIncrementButtonStyles():void { for(var propertyName:String in this._incrementButtonProperties) { var propertyValue:Object = this._incrementButtonProperties[propertyName]; this.incrementButton[propertyName] = propertyValue; } this.incrementButton.label = this._incrementButtonLabel; } /** * @private */ protected function refreshTextInputStyles():void { for(var propertyName:String in this._textInputProperties) { var propertyValue:Object = this._textInputProperties[propertyName]; this.textInput[propertyName] = propertyValue; } } /** * @private */ protected function refreshDisplayedText():void { if(this._valueFormatFunction != null) { this.textInput.text = this._valueFormatFunction(this._value); } else { this.textInput.text = this._value.toString(); } } /** * @private */ protected function refreshTypicalText():void { var typicalText:String = """"; var maxCharactersBeforeDecimal:Number = Math.max(int(this._minimum).toString().length, int(this._maximum).toString().length, int(this._step).toString().length); //roundToPrecision() helps us to avoid numbers like 1.00000000000000001 //caused by the inaccuracies of floating point math. var maxCharactersAfterDecimal:Number = Math.max(roundToPrecision(this._minimum - int(this._minimum), 10).toString().length, roundToPrecision(this._maximum - int(this._maximum), 10).toString().length, roundToPrecision(this._step - int(this._step), 10).toString().length) - 2; if(maxCharactersAfterDecimal < 0) { maxCharactersAfterDecimal = 0; } var characterCount:int = maxCharactersBeforeDecimal + maxCharactersAfterDecimal; for(var i:int = 0; i < characterCount; i++) { typicalText += ""0""; } if(maxCharactersAfterDecimal > 0) { typicalText += "".""; } this.textInput.typicalText = typicalText; } /** * @private */ protected function layoutChildren():void { if(this._buttonLayoutMode === StepperButtonLayoutMode.RIGHT_SIDE_VERTICAL) { var buttonHeight:Number = (this.actualHeight - this._buttonGap) / 2; this.incrementButton.y = 0; this.incrementButton.height = buttonHeight; this.incrementButton.validate(); this.decrementButton.y = buttonHeight + this._buttonGap; this.decrementButton.height = buttonHeight; this.decrementButton.validate(); var buttonWidth:Number = Math.max(this.decrementButton.width, this.incrementButton.width); var buttonX:Number = this.actualWidth - buttonWidth; this.decrementButton.x = buttonX; this.incrementButton.x = buttonX; this.textInput.x = 0; this.textInput.y = 0; this.textInput.width = buttonX - this._textInputGap; this.textInput.height = this.actualHeight; } else if(this._buttonLayoutMode === StepperButtonLayoutMode.SPLIT_VERTICAL) { this.incrementButton.x = 0; this.incrementButton.y = 0; this.incrementButton.width = this.actualWidth; this.incrementButton.validate(); this.decrementButton.x = 0; this.decrementButton.width = this.actualWidth; this.decrementButton.validate(); this.decrementButton.y = this.actualHeight - this.decrementButton.height; this.textInput.x = 0; this.textInput.y = this.incrementButton.height + this._textInputGap; this.textInput.width = this.actualWidth; this.textInput.height = Math.max(0, this.actualHeight - this.decrementButton.height - this.incrementButton.height - 2 * this._textInputGap); } else //split horizontal { this.decrementButton.x = 0; this.decrementButton.y = 0; this.decrementButton.height = this.actualHeight; this.decrementButton.validate(); this.incrementButton.y = 0; this.incrementButton.height = this.actualHeight; this.incrementButton.validate(); this.incrementButton.x = this.actualWidth - this.incrementButton.width; this.textInput.x = this.decrementButton.width + this._textInputGap; this.textInput.width = this.actualWidth - this.decrementButton.width - this.incrementButton.width - 2 * this._textInputGap; this.textInput.height = this.actualHeight; } //final validation to avoid juggler next frame issues this.textInput.validate(); } /** * @private */ protected function startRepeatTimer(action:Function):void { if(this.touchPointID >= 0) { var exclusiveTouch:ExclusiveTouch = ExclusiveTouch.forStage(this.stage); var claim:DisplayObject = exclusiveTouch.getClaim(this.touchPointID) if(claim != this) { if(claim) { //already claimed by another display object return; } else { exclusiveTouch.claimTouch(this.touchPointID, this); } } } this.currentRepeatAction = action; if(this._repeatDelay > 0) { if(!this._repeatTimer) { this._repeatTimer = new Timer(this._repeatDelay * 1000); this._repeatTimer.addEventListener(TimerEvent.TIMER, repeatTimer_timerHandler); } else { this._repeatTimer.reset(); this._repeatTimer.delay = this._repeatDelay * 1000; } this._repeatTimer.start(); } } /** * @private */ protected function parseTextInputValue():void { if(this._valueParseFunction != null) { var newValue:Number = this._valueParseFunction(this.textInput.text); } else { newValue = parseFloat(this.textInput.text); } if(newValue === newValue) //!isNaN { this.value = newValue; } //we need to force invalidation just to be sure that the text input //is displaying the correct value. this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected function childProperties_onChange(proxy:PropertyProxy, name:Object):void { this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected function numericStepper_removedFromStageHandler(event:Event):void { this.touchPointID = -1; } /** * @private */ override protected function focusInHandler(event:Event):void { super.focusInHandler(event); this.textInput.setFocus(); this.textInput.selectRange(0, this.textInput.text.length); this.stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ override protected function focusOutHandler(event:Event):void { super.focusOutHandler(event); this.textInput.clearFocus(); this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ protected function textInput_enterHandler(event:Event):void { this.parseTextInputValue(); } /** * @private */ protected function textInput_focusInHandler(event:Event):void { this._textInputHasFocus = true; } /** * @private */ protected function textInput_focusOutHandler(event:Event):void { this._textInputHasFocus = false; this.parseTextInputValue(); } /** * @private */ protected function decrementButton_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this.decrementButton, TouchPhase.ENDED, this.touchPointID); if(!touch) { return; } this.touchPointID = -1; this._repeatTimer.stop(); this.dispatchEventWith(FeathersEventType.END_INTERACTION); } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this.decrementButton, TouchPhase.BEGAN); if(!touch) { return; } if(this._textInputHasFocus) { this.parseTextInputValue(); } this.touchPointID = touch.id; this.dispatchEventWith(FeathersEventType.BEGIN_INTERACTION); this.decrement(); this.startRepeatTimer(this.decrement); } } /** * @private */ protected function incrementButton_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this.incrementButton, TouchPhase.ENDED, this.touchPointID); if(!touch) { return; } this.touchPointID = -1; this._repeatTimer.stop(); this.dispatchEventWith(FeathersEventType.END_INTERACTION); } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this.incrementButton, TouchPhase.BEGAN); if(!touch) { return; } if(this._textInputHasFocus) { this.parseTextInputValue(); } this.touchPointID = touch.id; this.dispatchEventWith(FeathersEventType.BEGIN_INTERACTION); this.increment(); this.startRepeatTimer(this.increment); } } /** * @private */ protected function stage_keyDownHandler(event:KeyboardEvent):void { if(event.keyCode == Keyboard.HOME) { //prevent default so that text input selection doesn't change event.preventDefault(); this.toMinimum(); } else if(event.keyCode == Keyboard.END) { //prevent default so that text input selection doesn't change event.preventDefault(); this.toMaximum(); } else if(event.keyCode == Keyboard.UP) { //prevent default so that text input selection doesn't change event.preventDefault(); this.increment(); } else if(event.keyCode == Keyboard.DOWN) { //prevent default so that text input selection doesn't change event.preventDefault(); this.decrement(); } } /** * @private */ protected function repeatTimer_timerHandler(event:TimerEvent):void { if(this._repeatTimer.currentCount < 5) { return; } this.currentRepeatAction(); } } } ",16186,True,3036.900752782809,median "CLASS lcl_parse DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS: parse IMPORTING iv_code TYPE string RETURNING VALUE(ro_tokens) TYPE REF TO zcl_aoc_boolean_tokens. ENDCLASS. CLASS lcl_parse IMPLEMENTATION. METHOD parse. DATA: lt_code TYPE string_table, lt_statements TYPE sstmnt_tab ##NEEDED, lt_tokens TYPE stokesx_tab. APPEND iv_code TO lt_code. SCAN ABAP-SOURCE lt_code TOKENS INTO lt_tokens STATEMENTS INTO lt_statements WITH ANALYSIS WITH COMMENTS WITH PRAGMAS abap_true. cl_abap_unit_assert=>assert_subrc( ). CREATE OBJECT ro_tokens EXPORTING it_tokens = lt_tokens. ENDMETHOD. ENDCLASS. CLASS ltcl_parse DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: parse IMPORTING iv_string TYPE string RETURNING VALUE(rv_result) TYPE string, test001 FOR TESTING, test002 FOR TESTING, test003 FOR TESTING, test004 FOR TESTING, test005 FOR TESTING, test006 FOR TESTING, test007 FOR TESTING, test008 FOR TESTING, test009 FOR TESTING, test010 FOR TESTING, test011 FOR TESTING, test012 FOR TESTING, test013 FOR TESTING, test014 FOR TESTING, test015 FOR TESTING, test016 FOR TESTING, test017 FOR TESTING, test018 FOR TESTING, test019 FOR TESTING, test020 FOR TESTING, test021 FOR TESTING, test022 FOR TESTING, test023 FOR TESTING, test024 FOR TESTING, test025 FOR TESTING, test026 FOR TESTING, test027 FOR TESTING, test028 FOR TESTING, test029 FOR TESTING, test030 FOR TESTING, test031 FOR TESTING, test032 FOR TESTING, test033 FOR TESTING, test034 FOR TESTING, test035 FOR TESTING, test036 FOR TESTING, test037 FOR TESTING, test038 FOR TESTING, test039 FOR TESTING, test040 FOR TESTING, test041 FOR TESTING, test042 FOR TESTING, test043 FOR TESTING, test044 FOR TESTING, test045 FOR TESTING, test046 FOR TESTING, test047 FOR TESTING, test048 FOR TESTING, test049 FOR TESTING, test050 FOR TESTING, test051 FOR TESTING, test052 FOR TESTING. ENDCLASS. ""ltcl_Test CLASS ltcl_parse IMPLEMENTATION. METHOD parse. DATA: lt_tokens TYPE stokesx_tab, lo_node TYPE REF TO zcl_aoc_boolean_node. lt_tokens = lcl_parse=>parse( iv_string )->remove( 1 )->get_tokens( ). lo_node = zcl_aoc_boolean=>parse( lt_tokens ). cl_abap_unit_assert=>assert_bound( lo_node ). rv_result = lo_node->to_string( ). ENDMETHOD. METHOD test001. DATA: lv_result TYPE string. lv_result = parse( 'IF foo = bar.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test002. DATA: lv_result TYPE string. lv_result = parse( 'IF foo NE bar.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test003. DATA: lv_result TYPE string. lv_result = parse( 'IF foo <> bar.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test004. DATA: lv_result TYPE string. lv_result = parse( 'IF foo( ) = bar( ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test005. DATA: lv_result TYPE string. lv_result = parse( 'IF ( foo = bar ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = '( COMPARE )' ). ENDMETHOD. METHOD test006. DATA: lv_result TYPE string. lv_result = parse( 'IF foo = bar AND moo = boo.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( COMPARE COMPARE )' ). ENDMETHOD. METHOD test007. DATA: lv_result TYPE string. lv_result = parse( 'IF ( foo = bar AND moo = boo ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = '( AND( COMPARE COMPARE ) )' ). ENDMETHOD. METHOD test008. DATA: lv_result TYPE string. lv_result = parse( 'IF ( foo = bar ) AND ( moo = boo ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( ( COMPARE ) ( COMPARE ) )' ). ENDMETHOD. METHOD test009. DATA: lv_result TYPE string. lv_result = parse( 'IF ( ( foo = bar ) AND ( moo = boo ) ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = '( AND( ( COMPARE ) ( COMPARE ) ) )' ). ENDMETHOD. METHOD test010. DATA: lv_result TYPE string. lv_result = parse( 'IF method( value ) = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test011. DATA: lv_result TYPE string. lv_result = parse( 'IF method( field = value ) = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test012. DATA: lv_result TYPE string. lv_result = parse( 'IF method( VALUE #( foo = bar ) ) = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test013. DATA: lv_result TYPE string. lv_result = parse( 'IF foo->method( field = value ) = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test014. DATA: lv_result TYPE string. lv_result = parse( 'IF moo-foo->method( field = value ) = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test015. DATA: lv_result TYPE string. lv_result = parse( 'IF method1( method2( ) ) = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test016. DATA: lv_result TYPE string. lv_result = parse( 'IF NOT 2 = 3.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'NOT( COMPARE )' ). ENDMETHOD. METHOD test017. DATA: lv_result TYPE string. lv_result = parse( 'IF NOT 2 = 3 AND NOT 1 = 2.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( NOT( COMPARE ) NOT( COMPARE ) )' ). ENDMETHOD. METHOD test018. DATA: lv_result TYPE string. lv_result = parse( 'IF NOT ( 2 = 3 AND NOT 1 = 2 ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'NOT( ( AND( COMPARE NOT( COMPARE ) ) ) )' ). ENDMETHOD. METHOD test019. DATA: lv_result TYPE string. lv_result = parse( 'IF 2 = 3 AND NOT 1 = 2.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( COMPARE NOT( COMPARE ) )' ). ENDMETHOD. METHOD test020. DATA: lv_result TYPE string. lv_result = parse( 'IF 2 = 3 AND NOT 1 = 2 AND 3 = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( COMPARE AND( NOT( COMPARE ) COMPARE ) )' ). ENDMETHOD. METHOD test021. DATA: lv_result TYPE string. lv_result = parse( 'IF 2 = 3 OR 3 = 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'OR( COMPARE COMPARE )' ). ENDMETHOD. METHOD test022. DATA: lv_result TYPE string. lv_result = parse( 'IF foo IS INITLAL.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test023. DATA: lv_result TYPE string. lv_result = parse( 'IF foo IS NOT INITIAL.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test024. DATA: lv_result TYPE string. lv_result = parse( 'IF foo = moo + 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test025. DATA: lv_result TYPE string. lv_result = parse( 'IF foo = moo - boo + 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test026. DATA: lv_result TYPE string. lv_result = parse( 'IF lines( lt_cache ) > 0.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test027. DATA: lv_result TYPE string. lv_result = parse( 'IF -object->type( ) = 2.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test028. DATA: lv_result TYPE string. lv_result = parse( 'IF foo IN bar.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test029. DATA: lv_result TYPE string. lv_result = parse( 'IF foo NOT IN bar.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test030. DATA: lv_result TYPE string. lv_result = parse( 'IF var + strlen( var ) >= 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test031. DATA: lv_result TYPE string. lv_result = parse( 'IF lo_object->zif_name~method( ) = 2.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test032. DATA: lv_result TYPE string. lv_result = parse( 'IF lv_x BIT-AND lc_128 = lc_128.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test033. DATA: lv_result TYPE string. lv_result = parse( 'IF var BETWEEN moo AND foo.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test034. DATA: lv_result TYPE string. lv_result = parse( 'IF ( lv_offset + 1 ) MOD 8 = 0.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test035. DATA: lv_result TYPE string. lv_result = parse( 'IF lv_foo+0(1) EQ foo.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test036. DATA: lv_result TYPE string. lv_result = parse( 'IF foo EQ |A|.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test037. DATA: lv_result TYPE string. lv_result = parse( 'IF lv_path = mv_base && mv_swagger_html.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test038. DATA: lv_result TYPE string. lv_result = parse( 'IF foo < bar * ( moo + 1 ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test039. DATA: lv_result TYPE string. lv_result = parse( 'IF lt_foo[ 1 ]-address CS ''bar''.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test040. DATA: lv_result TYPE string. lv_result = parse( 'IF boolean_function( bar ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test041. DATA: lv_result TYPE string. lv_result = parse( 'IF boolean_function( bar ) AND another( ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( COMPARE COMPARE )' ). ENDMETHOD. METHOD test042. DATA: lv_result TYPE string. lv_result = parse( 'IF method( )-field = 2.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test043. DATA: lv_result TYPE string. lv_result = parse( 'IF lv_line CS |FOO({ lv_name })|.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test044. DATA: lv_result TYPE string. lv_result = parse( 'IF lv_blah IS INSTANCE OF if_sxml_value_node.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test045. DATA: lv_result TYPE string. lv_result = parse( 'IF moo EQ foo OR ( baa EQ bar AND lr_object->/ui2/moo~method( ) = space ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'OR( COMPARE ( AND( COMPARE COMPARE ) ) )' ). ENDMETHOD. METHOD test046. DATA: lv_result TYPE string. lv_result = parse( 'IF lr_object->/ui2/if_edm_model_entity~get_entity_name( ) = space.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test047. DATA: lv_result TYPE string. lv_result = parse( 'IF SY-DATUM + 1 > + SY-DATUM.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test048. DATA: lv_result TYPE string. lv_result = parse( 'IF abap_true = lines( tab ) AND ( NOT line_' && 'exists( tab[ bname = ''ASDF'' ] ) OR sy-abcde = abap_true ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'AND( COMPARE ( OR( NOT( COMPARE ) COMPARE ) ) )' ). ENDMETHOD. METHOD test049. DATA: lv_result TYPE string. lv_result = parse( 'IF ( lv_req_date = 0 OR lv_req_date IS INITIAL ) O' && 'R ( lv_req_date NOT BETWEEN lv_date_from AND lv_date_to ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'OR( ( OR( COMPARE COMPARE ) ) ( COMPARE ) )' ). ENDMETHOD. METHOD test050. DATA: lv_result TYPE string. lv_result = parse( 'IF var NOT BETWEEN moo AND foo.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test051. DATA: lv_result TYPE string. lv_result = parse( 'IF var Z foo.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD test052. DATA: lv_result TYPE string. lv_result = parse( 'IF lv_blah IS NOT INSTANCE OF if_sxml_value_node.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. ENDCLASS. CLASS ltcl_parse2 DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: parse IMPORTING iv_string TYPE string RETURNING VALUE(rv_result) TYPE string, compare_ge FOR TESTING, compare_le FOR TESTING, compare_ne FOR TESTING, dereference_tbl_exprssn_cmpnnt FOR TESTING, structure_component FOR TESTING, double_negation_01 FOR TESTING, double_negation_02 FOR TESTING, reduction_01 FOR TESTING. ENDCLASS. ""ltcl_parse2 definition CLASS ltcl_parse2 IMPLEMENTATION. METHOD parse. DATA: lt_tokens TYPE stokesx_tab, lo_node TYPE REF TO zcl_aoc_boolean_node. lt_tokens = lcl_parse=>parse( iv_string )->remove( 1 )->get_tokens( ). lo_node = zcl_aoc_boolean=>parse( lt_tokens ). cl_abap_unit_assert=>assert_bound( lo_node ). rv_result = lo_node->to_string( ). ENDMETHOD. METHOD compare_ge. DATA: lv_result TYPE string. lv_result = parse( 'IF 2 GE 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). lv_result = parse( 'IF 2 >= 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). lv_result = parse( 'IF 2 => 1.' ). ""Obsolete, but not forbidden outside ABAP Objects cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD compare_le. DATA: lv_result TYPE string. lv_result = parse( 'IF 2 LE 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). lv_result = parse( 'IF 2 <= 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). lv_result = parse( 'IF 2 =< 1.' ). ""Obsolete, but not forbidden outside ABAP Objects cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD compare_ne. DATA: lv_result TYPE string. lv_result = parse( 'IF 2 NE 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). lv_result = parse( 'IF 2 <> 1.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). lv_result = parse( 'IF 2 >< 1.' ). ""Obsolete, but not forbidden outside ABAP Objects cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD dereference_tbl_exprssn_cmpnnt. DATA: lv_result TYPE string. lv_result = parse( 'IF data_ref->*[ 1 ]-component = value.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. METHOD structure_component. DATA: lv_result TYPE string. lv_result = parse( 'IF ( structure-component < 1000 AND structure-component > -1000 ).' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = '( AND( COMPARE COMPARE ) )' ). ENDMETHOD. METHOD double_negation_01. DATA: lv_result TYPE string. lv_result = parse( 'IF NOT NOT range IS INITIAL.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'NOT( NOT( COMPARE ) )' ). ENDMETHOD. METHOD double_negation_02. DATA: lv_result TYPE string. lv_result = parse( 'IF NOT NOT a < 10 OR b > 10.' ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'OR( NOT( NOT( COMPARE ) ) COMPARE )' ). ENDMETHOD. METHOD reduction_01. DATA lv_code TYPE string. DATA lv_result TYPE string. lv_code = |IF ( REDUCE i( INIT x = 0 FOR wa IN table| && | WHERE ( flag = 'X' )| && | NEXT x = x + 1 ) )| && | GT integer_value.|. lv_result = parse( lv_code ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = 'COMPARE' ). ENDMETHOD. ENDCLASS. ""ltcl_parse2 implementation CLASS ltcl_remove_strings DEFINITION DEFERRED. CLASS zcl_aoc_boolean DEFINITION LOCAL FRIENDS ltcl_remove_strings. CLASS ltcl_remove_strings DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: test IMPORTING iv_code TYPE string iv_exp TYPE string, test01 FOR TESTING, test02 FOR TESTING, test03 FOR TESTING. ENDCLASS. CLASS ltcl_remove_strings IMPLEMENTATION. METHOD test. DATA: lv_result TYPE string, lo_tokens TYPE REF TO zcl_aoc_boolean_tokens. lo_tokens = lcl_parse=>parse( iv_code ). zcl_aoc_boolean=>remove_strings( lo_tokens ). cl_abap_unit_assert=>assert_bound( lo_tokens ). lv_result = lo_tokens->to_string( ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = to_upper( iv_exp ) ). ENDMETHOD. METHOD test01. test( iv_code = 'bar' iv_exp = 'bar' ). ENDMETHOD. METHOD test02. test( iv_code = '''bar''' iv_exp = 'str' ). ENDMETHOD. METHOD test03. test( iv_code = '`bar`' iv_exp = 'str' ). ENDMETHOD. ENDCLASS. CLASS ltcl_remove_method_calls DEFINITION DEFERRED. CLASS zcl_aoc_boolean DEFINITION LOCAL FRIENDS ltcl_remove_method_calls. CLASS ltcl_remove_method_calls DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: test IMPORTING iv_code TYPE string iv_exp TYPE string, test01 FOR TESTING, test02 FOR TESTING, test03 FOR TESTING, test04 FOR TESTING, test05 FOR TESTING, test06 FOR TESTING, test07 FOR TESTING, test08 FOR TESTING, test09 FOR TESTING, test10 FOR TESTING, test11 FOR TESTING, test12 FOR TESTING. METHODS: reduction_01 FOR TESTING. ENDCLASS. ""ltcl_Remove_Method_Calls CLASS ltcl_remove_method_calls IMPLEMENTATION. METHOD test. DATA: lv_result TYPE string, lo_tokens TYPE REF TO zcl_aoc_boolean_tokens. lo_tokens = lcl_parse=>parse( iv_code ). zcl_aoc_boolean=>remove_method_calls( lo_tokens ). cl_abap_unit_assert=>assert_bound( lo_tokens ). lv_result = lo_tokens->to_string( ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = to_upper( iv_exp ) ). ENDMETHOD. METHOD test01. test( iv_code = 'foo( )' iv_exp = 'method' ). ENDMETHOD. METHOD test02. test( iv_code = 'foo( )->bar( )' iv_exp = 'method' ). ENDMETHOD. METHOD test03. test( iv_code = 'foo( bar( ) )' iv_exp = 'method' ). ENDMETHOD. METHOD test04. test( iv_code = 'bar->method( )' iv_exp = 'method' ). ENDMETHOD. METHOD test05. test( iv_code = 'bar=>method( )' iv_exp = 'method' ). ENDMETHOD. METHOD test06. test( iv_code = 'foo-bar->method( )' iv_exp = 'method' ). ENDMETHOD. METHOD test07. test( iv_code = 'foo( ) = bar( )' iv_exp = 'method = method' ). ENDMETHOD. METHOD test08. test( iv_code = 'NEW zcl_foo( )->bar( )' iv_exp = 'method' ). ENDMETHOD. METHOD test09. test( iv_code = 'CONV integer( lv_date )' iv_exp = 'method' ). ENDMETHOD. METHOD test10. test( iv_code = 'VALUE #( lt_tab[ id = 2 ] OPTIONAL )' iv_exp = 'method' ). ENDMETHOD. METHOD test11. test( iv_code = 'lr_object->/ui2/if_edm_model_entity~get_entity_name( )' iv_exp = 'method' ). ENDMETHOD. METHOD test12. test( iv_code = 'REF DATA( lt_tab )' iv_exp = 'method' ). ENDMETHOD. METHOD reduction_01. test( iv_code = |REDUCE i( INIT x = 0 FOR wa IN table WHERE ( flag = 'X' ) NEXT x = x + 1 )| iv_exp = 'reduction' ). ENDMETHOD. ENDCLASS. CLASS ltcl_remove_templates DEFINITION DEFERRED. CLASS zcl_aoc_boolean DEFINITION LOCAL FRIENDS ltcl_remove_templates. CLASS ltcl_remove_templates DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: test IMPORTING iv_code TYPE string iv_exp TYPE string, test01 FOR TESTING, test02 FOR TESTING, test03 FOR TESTING, test04 FOR TESTING. ENDCLASS. CLASS ltcl_remove_templates IMPLEMENTATION. METHOD test. DATA: lv_result TYPE string, lo_tokens TYPE REF TO zcl_aoc_boolean_tokens. lo_tokens = lcl_parse=>parse( iv_code ). zcl_aoc_boolean=>remove_templates( lo_tokens ). cl_abap_unit_assert=>assert_bound( lo_tokens ). lv_result = lo_tokens->to_string( ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = to_upper( iv_exp ) ). ENDMETHOD. METHOD test01. test( iv_code = 'lv_offset' iv_exp = 'lv_offset' ). ENDMETHOD. METHOD test02. test( iv_code = '|foobar|' iv_exp = 'TEMPLATE' ). ENDMETHOD. METHOD test03. test( iv_code = '|foobar { bar }|' iv_exp = 'TEMPLATE' ). ENDMETHOD. METHOD test04. test( iv_code = '|foobar { moo( |blah| ) }|' iv_exp = 'TEMPLATE' ). ENDMETHOD. ENDCLASS. CLASS ltcl_remove_calculations DEFINITION DEFERRED. CLASS zcl_aoc_boolean DEFINITION LOCAL FRIENDS ltcl_remove_calculations. CLASS ltcl_remove_calculations DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: test IMPORTING iv_code TYPE string iv_exp TYPE string, test01 FOR TESTING, test02 FOR TESTING, test03 FOR TESTING, test04 FOR TESTING, test05 FOR TESTING. ENDCLASS. CLASS ltcl_remove_calculations IMPLEMENTATION. METHOD test. DATA: lv_result TYPE string, lo_tokens TYPE REF TO zcl_aoc_boolean_tokens. lo_tokens = lcl_parse=>parse( iv_code ). zcl_aoc_boolean=>remove_calculations( lo_tokens ). cl_abap_unit_assert=>assert_bound( lo_tokens ). lv_result = lo_tokens->to_string( ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = to_upper( iv_exp ) ). ENDMETHOD. METHOD test01. test( iv_code = 'lv_offset + 1' iv_exp = 'lv_offset' ). ENDMETHOD. METHOD test02. test( iv_code = 'lv_offset + 1 - 1' iv_exp = 'lv_offset' ). ENDMETHOD. METHOD test03. test( iv_code = '( lv_offset + 1 )' iv_exp = 'lv_offset' ). ENDMETHOD. METHOD test04. test( iv_code = 'bar * ( moo + 1 )' iv_exp = 'bar' ). ENDMETHOD. METHOD test05. test( iv_code = 'IF SY-DATUM + 1 > + SY-DATUM' iv_exp = 'IF SY-DATUM > + SY-DATUM' ). ENDMETHOD. ENDCLASS. CLASS ltcl_remove_table_expressions DEFINITION DEFERRED. CLASS zcl_aoc_boolean DEFINITION LOCAL FRIENDS ltcl_remove_table_expressions. CLASS ltcl_remove_table_expressions DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: test IMPORTING iv_code TYPE string iv_exp TYPE string, test10 FOR TESTING, test11 FOR TESTING, test12 FOR TESTING, test13 FOR TESTING, test20 FOR TESTING, test21 FOR TESTING, test_dereference FOR TESTING. ENDCLASS. CLASS ltcl_remove_table_expressions IMPLEMENTATION. METHOD test. DATA: lv_result TYPE string, lo_tokens TYPE REF TO zcl_aoc_boolean_tokens. lo_tokens = lcl_parse=>parse( iv_code ). zcl_aoc_boolean=>remove_table_expressions( lo_tokens ). cl_abap_unit_assert=>assert_bound( lo_tokens ). lv_result = lo_tokens->to_string( ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = to_upper( iv_exp ) ). ENDMETHOD. METHOD test10. test( iv_code = 'IF table[ 1 ] = some_value' iv_exp = 'IF TABLE = some_value' ). ENDMETHOD. METHOD test11. test( iv_code = 'IF table[ 1 ]-component = some_value' iv_exp = 'IF TABLE-COMPONENT = some_value' ). ENDMETHOD. METHOD test12. test( iv_code = 'IF table[ 1 ] - 50 < some_value' iv_exp = 'IF TABLE - 50 < some_value' ). ENDMETHOD. METHOD test13. test( iv_code = 'IF table[ 1 ]-component - 50 > some_value' iv_exp = 'IF TABLE-COMPONENT - 50 > some_value' ). ENDMETHOD. METHOD test20. test( iv_code = 'IF subtable[ 1 ][ 1 ] = some_value' iv_exp = 'IF subtable = some_value' ). ENDMETHOD. METHOD test21. test( iv_code = 'IF subtable[ 1 ][ 1 ]-component = some_value' iv_exp = 'IF subtable-component = some_value' ). ENDMETHOD. METHOD test_dereference. test( iv_code = 'IF root_data->*[ 1 ]-chm_nature = if_ehfnd_chm_impl_c=>gc_chm_nature-substance' iv_exp = 'IF root_data->*-chm_nature = if_ehfnd_chm_impl_c=>gc_chm_nature-substance' ). ENDMETHOD. ENDCLASS. CLASS ltcl_remove_dereferences DEFINITION DEFERRED. CLASS zcl_aoc_boolean DEFINITION LOCAL FRIENDS ltcl_remove_dereferences. CLASS ltcl_remove_dereferences DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. PRIVATE SECTION. METHODS: test IMPORTING iv_code TYPE string iv_exp TYPE string, test01 FOR TESTING. ENDCLASS. CLASS ltcl_remove_dereferences IMPLEMENTATION. METHOD test. DATA: lv_result TYPE string, lo_tokens TYPE REF TO zcl_aoc_boolean_tokens. lo_tokens = lcl_parse=>parse( iv_code ). zcl_aoc_boolean=>remove_dereferences( lo_tokens ). cl_abap_unit_assert=>assert_bound( lo_tokens ). lv_result = lo_tokens->to_string( ). cl_abap_unit_assert=>assert_equals( act = lv_result exp = to_upper( iv_exp ) ). ENDMETHOD. METHOD test01. test( iv_code = 'IF root_data->*-chm_nature = if_ehfnd_chm_impl_c=>gc_chm_nature-substance' iv_exp = 'IF root_data-chm_nature = if_ehfnd_chm_impl_c=>gc_chm_nature-substance' ). ENDMETHOD. ENDCLASS. ",7962,False,1875.726561868676,median "/* Feathers Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.layout { import feathers.core.IValidating; import flash.errors.IllegalOperationError; import flash.geom.Point; import starling.display.DisplayObject; import starling.events.Event; import starling.events.EventDispatcher; /** * Dispatched when a property of the layout changes, indicating that a * redraw is probably needed. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] /** * Positions items as tiles (equal width and height) from top to bottom * in multiple columns. Constrained to the suggested height, the tiled * columns layout will change in width as the number of items increases or * decreases. * * @see http://wiki.starling-framework.org/feathers/tiled-columns-layout */ public class TiledColumnsLayout extends EventDispatcher implements IVirtualLayout { /** * If the total item height is smaller than the height of the bounds, * the items will be aligned to the top. * * @see #verticalAlign */ public static const VERTICAL_ALIGN_TOP:String = ""top""; /** * If the total item height is smaller than the height of the bounds, * the items will be aligned to the middle. * * @see #verticalAlign */ public static const VERTICAL_ALIGN_MIDDLE:String = ""middle""; /** * If the total item height is smaller than the height of the bounds, * the items will be aligned to the bottom. * * @see #verticalAlign */ public static const VERTICAL_ALIGN_BOTTOM:String = ""bottom""; /** * If the total item width is smaller than the width of the bounds, the * items will be aligned to the left. * * @see #horizontalAlign */ public static const HORIZONTAL_ALIGN_LEFT:String = ""left""; /** * If the total item width is smaller than the width of the bounds, the * items will be aligned to the center. * * @see #horizontalAlign */ public static const HORIZONTAL_ALIGN_CENTER:String = ""center""; /** * If the total item width is smaller than the width of the bounds, the * items will be aligned to the right. * * @see #horizontalAlign */ public static const HORIZONTAL_ALIGN_RIGHT:String = ""right""; /** * If an item height is smaller than the height of a tile, the item will * be aligned to the top edge of the tile. * * @see #tileVerticalAlign */ public static const TILE_VERTICAL_ALIGN_TOP:String = ""top""; /** * If an item height is smaller than the height of a tile, the item will * be aligned to the middle of the tile. * * @see #tileVerticalAlign */ public static const TILE_VERTICAL_ALIGN_MIDDLE:String = ""middle""; /** * If an item height is smaller than the height of a tile, the item will * be aligned to the bottom edge of the tile. * * @see #tileVerticalAlign */ public static const TILE_VERTICAL_ALIGN_BOTTOM:String = ""bottom""; /** * The item will be resized to fit the height of the tile. * * @see #tileVerticalAlign */ public static const TILE_VERTICAL_ALIGN_JUSTIFY:String = ""justify""; /** * If an item width is smaller than the width of a tile, the item will * be aligned to the left edge of the tile. * * @see #tileHorizontalAlign */ public static const TILE_HORIZONTAL_ALIGN_LEFT:String = ""left""; /** * If an item width is smaller than the width of a tile, the item will * be aligned to the center of the tile. * * @see #tileHorizontalAlign */ public static const TILE_HORIZONTAL_ALIGN_CENTER:String = ""center""; /** * If an item width is smaller than the width of a tile, the item will * be aligned to the right edge of the tile. * * @see #tileHorizontalAlign */ public static const TILE_HORIZONTAL_ALIGN_RIGHT:String = ""right""; /** * The item will be resized to fit the width of the tile. * * @see #tileHorizontalAlign */ public static const TILE_HORIZONTAL_ALIGN_JUSTIFY:String = ""justify""; /** * The items will be positioned in pages horizontally from left to right. * * @see #paging */ public static const PAGING_HORIZONTAL:String = ""horizontal""; /** * The items will be positioned in pages vertically from top to bottom. * * @see #paging */ public static const PAGING_VERTICAL:String = ""vertical""; /** * The items will not be paged. In other words, they will be positioned * in a continuous set of columns without gaps. * * @see #paging */ public static const PAGING_NONE:String = ""none""; /** * Constructor. */ public function TiledColumnsLayout() { } /** * @private */ protected var _discoveredItemsCache:Vector. = new []; /** * Quickly sets both horizontalGap and verticalGap * to the same value. The gap getter always returns the * value of verticalGap, but the value of * horizontalGap may be different. * * @default 0 * * @see #horizontalGap * @see #verticalGap */ public function get gap():Number { return this._verticalGap; } /** * @private */ public function set gap(value:Number):void { this.horizontalGap = value; this.verticalGap = value; } /** * @private */ protected var _horizontalGap:Number = 0; /** * The horizontal space, in pixels, between tiles. * * @default 0 */ public function get horizontalGap():Number { return this._horizontalGap; } /** * @private */ public function set horizontalGap(value:Number):void { if(this._horizontalGap == value) { return; } this._horizontalGap = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _verticalGap:Number = 0; /** * The vertical space, in pixels, between tiles. * * @default 0 */ public function get verticalGap():Number { return this._verticalGap; } /** * @private */ public function set verticalGap(value:Number):void { if(this._verticalGap == value) { return; } this._verticalGap = value; this.dispatchEventWith(Event.CHANGE); } /** * Quickly sets all padding properties to the same value. The * padding getter always returns the value of * paddingTop, but the other padding values may be * different. * * @default 0 * * @see #paddingTop * @see #paddingRight * @see #paddingBottom * @see #paddingLeft */ public function get padding():Number { return this._paddingTop; } /** * @private */ public function set padding(value:Number):void { this.paddingTop = value; this.paddingRight = value; this.paddingBottom = value; this.paddingLeft = value; } /** * @private */ protected var _paddingTop:Number = 0; /** * The space, in pixels, above of items. * * @default 0 */ public function get paddingTop():Number { return this._paddingTop; } /** * @private */ public function set paddingTop(value:Number):void { if(this._paddingTop == value) { return; } this._paddingTop = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _paddingRight:Number = 0; /** * The space, in pixels, to the right of the items. * * @default 0 */ public function get paddingRight():Number { return this._paddingRight; } /** * @private */ public function set paddingRight(value:Number):void { if(this._paddingRight == value) { return; } this._paddingRight = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _paddingBottom:Number = 0; /** * The space, in pixels, below the items. * * @default 0 */ public function get paddingBottom():Number { return this._paddingBottom; } /** * @private */ public function set paddingBottom(value:Number):void { if(this._paddingBottom == value) { return; } this._paddingBottom = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _paddingLeft:Number = 0; /** * The space, in pixels, to the left of the items. * * @default 0 */ public function get paddingLeft():Number { return this._paddingLeft; } /** * @private */ public function set paddingLeft(value:Number):void { if(this._paddingLeft == value) { return; } this._paddingLeft = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _requestedRowCount:int = 0; /** * Requests that the layout uses a specific number of rows in a column, * if possible. If the view port's explicit or maximum height is not * large enough to fit the requested number of rows, it will use fewer. * Set to 0 to calculate the number of rows automatically * based on width and height. * *

If paging is enabled, this value will be used to calculate the * number of rows in a page. If paging isn't enabled, this value will * be used to calculate a minimum number of rows, even if there aren't * enough items to fill each row.

* * @default 0 */ public function get requestedRowCount():int { return this._requestedRowCount; } /** * @private */ public function set requestedRowCount(value:int):void { if(value < 0) { throw RangeError(""requestedRowCount requires a value >= 0""); } if(this._requestedRowCount == value) { return; } this._requestedRowCount = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _requestedColumnCount:int = 0; /** * Requests that the layout uses a specific number of columns in a row, * if possible. If the view port's explicit or maximum width is not large * enough to fit the requested number of columns, it will use fewer. Set * to 0 to calculate the number of columns automatically * based on width and height. * *

If paging is enabled, this value will be used to calculate the * number of columns in a page. If paging isn't enabled, this value will * be used to calculate a minimum number of columns, even if there * aren't enough items to fill each column.

* * @default 0 */ public function get requestedColumnCount():int { return this._requestedColumnCount; } /** * @private */ public function set requestedColumnCount(value:int):void { if(value < 0) { throw RangeError(""requestedColumnCount requires a value >= 0""); } if(this._requestedColumnCount == value) { return; } this._requestedColumnCount = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _verticalAlign:String = VERTICAL_ALIGN_TOP; [Inspectable(type=""String"",enumeration=""top,middle,bottom"")] /** * If the total column height is less than the bounds, the items in the * column can be aligned vertically. * * @default TiledColumnsLayout.VERTICAL_ALIGN_TOP * * @see #VERTICAL_ALIGN_TOP * @see #VERTICAL_ALIGN_MIDDLE * @see #VERTICAL_ALIGN_BOTTOM */ public function get verticalAlign():String { return this._verticalAlign; } /** * @private */ public function set verticalAlign(value:String):void { if(this._verticalAlign == value) { return; } this._verticalAlign = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _horizontalAlign:String = HORIZONTAL_ALIGN_CENTER; [Inspectable(type=""String"",enumeration=""left,center,right"")] /** * If the total row width is less than the bounds, the items in the row * can be aligned horizontally. * * @default TiledColumnsLayout.HORIZONTAL_ALIGN_CENTER * * @see #HORIZONTAL_ALIGN_LEFT * @see #HORIZONTAL_ALIGN_CENTER * @see #HORIZONTAL_ALIGN_RIGHT */ public function get horizontalAlign():String { return this._horizontalAlign; } /** * @private */ public function set horizontalAlign(value:String):void { if(this._horizontalAlign == value) { return; } this._horizontalAlign = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _tileVerticalAlign:String = TILE_VERTICAL_ALIGN_MIDDLE; [Inspectable(type=""String"",enumeration=""top,middle,bottom,justify"")] /** * If an item's height is less than the tile bounds, the position of the * item can be aligned vertically. * * @default TiledColumnsLayout.TILE_VERTICAL_ALIGN_MIDDLE * * @see #TILE_VERTICAL_ALIGN_TOP * @see #TILE_VERTICAL_ALIGN_MIDDLE * @see #TILE_VERTICAL_ALIGN_BOTTOM * @see #TILE_VERTICAL_ALIGN_JUSTIFY */ public function get tileVerticalAlign():String { return this._tileVerticalAlign; } /** * @private */ public function set tileVerticalAlign(value:String):void { if(this._tileVerticalAlign == value) { return; } this._tileVerticalAlign = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _tileHorizontalAlign:String = TILE_HORIZONTAL_ALIGN_CENTER; [Inspectable(type=""String"",enumeration=""left,center,right,justify"")] /** * If the item's width is less than the tile bounds, the position of the * item can be aligned horizontally. * * @default TiledColumnsLayout.TILE_HORIZONTAL_ALIGN_CENTER * * @see #TILE_HORIZONTAL_ALIGN_LEFT * @see #TILE_HORIZONTAL_ALIGN_CENTER * @see #TILE_HORIZONTAL_ALIGN_RIGHT * @see #TILE_HORIZONTAL_ALIGN_JUSTIFY */ public function get tileHorizontalAlign():String { return this._tileHorizontalAlign; } /** * @private */ public function set tileHorizontalAlign(value:String):void { if(this._tileHorizontalAlign == value) { return; } this._tileHorizontalAlign = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _paging:String = PAGING_NONE; /** * If the total combined width of the columns is larger than the width * of the view port, the layout will be split into pages where each * page is filled with the maximum number of columns that may be * displayed without cutting off any items. * * @default TiledColumnsLayout.PAGING_NONE * * @see #PAGING_NONE * @see #PAGING_HORIZONTAL * @see #PAGING_VERTICAL */ public function get paging():String { return this._paging; } /** * @private */ public function set paging(value:String):void { if(this._paging == value) { return; } this._paging = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _useSquareTiles:Boolean = true; /** * Determines if the tiles must be square or if their width and height * may have different values. * * @default true */ public function get useSquareTiles():Boolean { return this._useSquareTiles; } /** * @private */ public function set useSquareTiles(value:Boolean):void { if(this._useSquareTiles == value) { return; } this._useSquareTiles = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _manageVisibility:Boolean = false; /** * Determines if items will be set invisible if they are outside the * view port. If true, you will not be able to manually * change the visible property of any items in the layout. * *

DEPRECATION WARNING: This property is deprecated * starting with Feathers 2.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy. * Originally, the manageVisibility property could be used * to improve performance of non-virtual layouts by hiding items that * were outside the view port. However, other performance improvements * have made it so that setting manageVisibility can now * sometimes hurt performance instead of improving it.

* * @default false */ public function get manageVisibility():Boolean { return this._manageVisibility; } /** * @private */ public function set manageVisibility(value:Boolean):void { if(this._manageVisibility == value) { return; } this._manageVisibility = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _useVirtualLayout:Boolean = true; /** * @inheritDoc * * @default true */ public function get useVirtualLayout():Boolean { return this._useVirtualLayout; } /** * @private */ public function set useVirtualLayout(value:Boolean):void { if(this._useVirtualLayout == value) { return; } this._useVirtualLayout = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _typicalItem:DisplayObject; /** * @inheritDoc */ public function get typicalItem():DisplayObject { return this._typicalItem; } /** * @private */ public function set typicalItem(value:DisplayObject):void { if(this._typicalItem == value) { return; } this._typicalItem = value; } /** * @private */ protected var _resetTypicalItemDimensionsOnMeasure:Boolean = false; /** * If set to true, the width and height of the * typicalItem will be reset to typicalItemWidth * and typicalItemHeight, respectively, whenever the * typical item needs to be measured. The measured dimensions of the * typical item are used to fill in the blanks of a virtualized layout * for virtual items that don't have their own display objects to * measure yet. * * @default false * * @see #typicalItemWidth * @see #typicalItemHeight * @see #typicalItem */ public function get resetTypicalItemDimensionsOnMeasure():Boolean { return this._resetTypicalItemDimensionsOnMeasure; } /** * @private */ public function set resetTypicalItemDimensionsOnMeasure(value:Boolean):void { if(this._resetTypicalItemDimensionsOnMeasure == value) { return; } this._resetTypicalItemDimensionsOnMeasure = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _typicalItemWidth:Number = NaN; /** * Used to reset the width, in pixels, of the typicalItem * for measurement. The measured dimensions of the typical item are used * to fill in the blanks of a virtualized layout for virtual items that * don't have their own display objects to measure yet. * *

This value is only used when resetTypicalItemDimensionsOnMeasure * is set to true. If resetTypicalItemDimensionsOnMeasure * is set to false, this value will be ignored and the * typicalItem dimensions will not be reset before * measurement.

* *

If typicalItemWidth is set to NaN, the * typical item will auto-size itself to its preferred width. If you * pass a valid Number value, the typical item's width will * be set to a fixed size. May be used in combination with * typicalItemHeight.

* * @default NaN * * @see #resetTypicalItemDimensionsOnMeasure * @see #typicalItemHeight * @see #typicalItem */ public function get typicalItemWidth():Number { return this._typicalItemWidth; } /** * @private */ public function set typicalItemWidth(value:Number):void { if(this._typicalItemWidth == value) { return; } this._typicalItemWidth = value; this.dispatchEventWith(Event.CHANGE); } /** * @private */ protected var _typicalItemHeight:Number = NaN; /** * Used to reset the height, in pixels, of the typicalItem * for measurement. The measured dimensions of the typical item are used * to fill in the blanks of a virtualized layout for virtual items that * don't have their own display objects to measure yet. * *

This value is only used when resetTypicalItemDimensionsOnMeasure * is set to true. If resetTypicalItemDimensionsOnMeasure * is set to false, this value will be ignored and the * typicalItem dimensions will not be reset before * measurement.

* *

If typicalItemHeight is set to NaN, the * typical item will auto-size itself to its preferred height. If you * pass a valid Number value, the typical item's height will * be set to a fixed size. May be used in combination with * typicalItemWidth.

* * @default NaN * * @see #resetTypicalItemDimensionsOnMeasure * @see #typicalItemWidth * @see #typicalItem */ public function get typicalItemHeight():Number { return this._typicalItemHeight; } /** * @private */ public function set typicalItemHeight(value:Number):void { if(this._typicalItemHeight == value) { return; } this._typicalItemHeight = value; this.dispatchEventWith(Event.CHANGE); } /** * @inheritDoc */ public function get requiresLayoutOnScroll():Boolean { return this._manageVisibility || this._useVirtualLayout; } /** * @inheritDoc */ public function layout(items:Vector., viewPortBounds:ViewPortBounds = null, result:LayoutBoundsResult = null):LayoutBoundsResult { if(!result) { result = new LayoutBoundsResult(); } if(items.length == 0) { result.contentX = 0; result.contentY = 0; result.contentWidth = 0; result.contentHeight = 0; result.viewPortWidth = 0; result.viewPortHeight = 0; return result; } var scrollX:Number = viewPortBounds ? viewPortBounds.scrollX : 0; var scrollY:Number = viewPortBounds ? viewPortBounds.scrollY : 0; var boundsX:Number = viewPortBounds ? viewPortBounds.x : 0; var boundsY:Number = viewPortBounds ? viewPortBounds.y : 0; var minWidth:Number = viewPortBounds ? viewPortBounds.minWidth : 0; var minHeight:Number = viewPortBounds ? viewPortBounds.minHeight : 0; var maxWidth:Number = viewPortBounds ? viewPortBounds.maxWidth : Number.POSITIVE_INFINITY; var maxHeight:Number = viewPortBounds ? viewPortBounds.maxHeight : Number.POSITIVE_INFINITY; var explicitWidth:Number = viewPortBounds ? viewPortBounds.explicitWidth : NaN; var explicitHeight:Number = viewPortBounds ? viewPortBounds.explicitHeight : NaN; if(this._useVirtualLayout) { this.prepareTypicalItem(); var calculatedTypicalItemWidth:Number = this._typicalItem ? this._typicalItem.width : 0; var calculatedTypicalItemHeight:Number = this._typicalItem ? this._typicalItem.height : 0; } this.validateItems(items); this._discoveredItemsCache.length = 0; var itemCount:int = items.length; var tileWidth:Number = this._useVirtualLayout ? calculatedTypicalItemWidth : 0; var tileHeight:Number = this._useVirtualLayout ? calculatedTypicalItemHeight : 0; //a virtual layout assumes that all items are the same size as //the typical item, so we don't need to measure every item in //that case if(!this._useVirtualLayout) { for(var i:int = 0; i < itemCount; i++) { var item:DisplayObject = items[i]; if(!item) { continue; } if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } var itemWidth:Number = item.width; var itemHeight:Number = item.height; if(itemWidth > tileWidth) { tileWidth = itemWidth; } if(itemHeight > tileHeight) { tileHeight = itemHeight; } } } if(tileWidth < 0) { tileWidth = 0; } if(tileHeight < 0) { tileHeight = 0; } if(this._useSquareTiles) { if(tileWidth > tileHeight) { tileHeight = tileWidth; } else if(tileHeight > tileWidth) { tileWidth = tileHeight; } } var availableWidth:Number = NaN; var availableHeight:Number = NaN; var verticalTileCount:int; if(explicitHeight === explicitHeight) //!isNaN { availableHeight = explicitHeight; verticalTileCount = (explicitHeight - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); } else if(maxHeight === maxHeight && //!isNaN maxHeight < Number.POSITIVE_INFINITY) { availableHeight = maxHeight; verticalTileCount = (maxHeight - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); } else { //put everything in one column verticalTileCount = itemCount; } if(verticalTileCount < 1) { //we must have at least one tile per column verticalTileCount = 1; } else if(this._requestedRowCount > 0) { if(availableHeight !== availableHeight) //isNaN { verticalTileCount = this._requestedRowCount; availableHeight = verticalTileCount * (tileHeight + this._verticalGap) - this._verticalGap - this._paddingTop - this._paddingBottom; } else if(verticalTileCount > this._requestedRowCount) { verticalTileCount = this._requestedRowCount; } } var horizontalTileCount:int; if(explicitWidth === explicitWidth) //!isNaN { availableWidth = explicitWidth; horizontalTileCount = (explicitWidth - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); } else if(maxWidth === maxWidth && //!isNaN maxWidth < Number.POSITIVE_INFINITY) { availableWidth = maxWidth; horizontalTileCount = (maxWidth - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); } else { //using the vertical tile count, calculate how many rows will //be required for the total number of items. horizontalTileCount = Math.ceil(itemCount / verticalTileCount); } if(horizontalTileCount < 1) { //we must have at least one tile per row horizontalTileCount = 1; } else if(this._requestedColumnCount > 0) { if(availableWidth !== availableWidth) //isNaN { horizontalTileCount = this._requestedColumnCount; availableWidth = horizontalTileCount * (tileWidth + this._horizontalGap) - this._horizontalGap - this._paddingLeft - this._paddingRight; } else if(horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } } var totalPageWidth:Number = horizontalTileCount * (tileWidth + this._horizontalGap) - this._horizontalGap + this._paddingLeft + this._paddingRight; var totalPageHeight:Number = verticalTileCount * (tileHeight + this._verticalGap) - this._verticalGap + this._paddingTop + this._paddingBottom; var availablePageWidth:Number = availableWidth; if(availablePageWidth !== availablePageWidth) //isNaN { availablePageWidth = totalPageWidth; } var availablePageHeight:Number = availableHeight; if(availablePageHeight !== availablePageHeight) //isNaN { availablePageHeight = totalPageHeight; } var startX:Number = boundsX + this._paddingLeft; var startY:Number = boundsY + this._paddingTop; var perPage:int = horizontalTileCount * verticalTileCount; var pageIndex:int = 0; var nextPageStartIndex:int = perPage; var pageStartY:Number = startY; var positionX:Number = startX; var positionY:Number = startY; var itemIndex:int = 0; var discoveredItemsCachePushIndex:int = 0; for(i = 0; i < itemCount; i++) { item = items[i]; if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } if(itemIndex != 0 && i % verticalTileCount == 0) { positionX += tileWidth + this._horizontalGap; positionY = pageStartY; } if(itemIndex == nextPageStartIndex) { //we're starting a new page, so handle alignment of the //items on the current page and update the positions if(this._paging != PAGING_NONE) { var discoveredItems:Vector. = this._useVirtualLayout ? this._discoveredItemsCache : items; var discoveredItemsFirstIndex:int = this._useVirtualLayout ? 0 : (itemIndex - perPage); var discoveredItemsLastIndex:int = this._useVirtualLayout ? (this._discoveredItemsCache.length - 1) : (itemIndex - 1); this.applyHorizontalAlign(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, totalPageWidth, availablePageWidth); this.applyVerticalAlign(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, totalPageHeight, availablePageHeight); if(this._manageVisibility) { this.applyVisible(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, boundsX + scrollX, scrollX + availableWidth, boundsY + scrollY, scrollY + availableHeight); } this._discoveredItemsCache.length = 0; discoveredItemsCachePushIndex = 0; } pageIndex++; nextPageStartIndex += perPage; //we can use availableWidth and availableHeight here without //checking if they're NaN because we will never reach a //new page without them already being calculated. if(this._paging == PAGING_HORIZONTAL) { positionX = startX + availableWidth * pageIndex; } else if(this._paging == PAGING_VERTICAL) { positionX = startX; positionY = pageStartY = startY + availableHeight * pageIndex; } } if(item) { switch(this._tileHorizontalAlign) { case TILE_HORIZONTAL_ALIGN_JUSTIFY: { item.x = item.pivotX + positionX; item.width = tileWidth; break; } case TILE_HORIZONTAL_ALIGN_LEFT: { item.x = item.pivotX + positionX; break; } case TILE_HORIZONTAL_ALIGN_RIGHT: { item.x = item.pivotX + positionX + tileWidth - item.width; break; } default: //center or unknown { item.x = item.pivotX + positionX + Math.round((tileWidth - item.width) / 2); } } switch(this._tileVerticalAlign) { case TILE_VERTICAL_ALIGN_JUSTIFY: { item.y = item.pivotY + positionY; item.height = tileHeight; break; } case TILE_VERTICAL_ALIGN_TOP: { item.y = item.pivotY + positionY; break; } case TILE_VERTICAL_ALIGN_BOTTOM: { item.y = item.pivotY + positionY + tileHeight - item.height; break; } default: //middle or unknown { item.y = item.pivotY + positionY + Math.round((tileHeight - item.height) / 2); } } if(this._useVirtualLayout) { this._discoveredItemsCache[discoveredItemsCachePushIndex] = item; discoveredItemsCachePushIndex++; } } positionY += tileHeight + this._verticalGap; itemIndex++; } //align the last page if(this._paging != PAGING_NONE) { discoveredItems = this._useVirtualLayout ? this._discoveredItemsCache : items; discoveredItemsFirstIndex = this._useVirtualLayout ? 0 : (nextPageStartIndex - perPage); discoveredItemsLastIndex = this._useVirtualLayout ? (this._discoveredItemsCache.length - 1) : (i - 1); this.applyHorizontalAlign(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, totalPageWidth, availablePageWidth); this.applyVerticalAlign(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, totalPageHeight, availablePageHeight); if(this._manageVisibility) { this.applyVisible(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, boundsX + scrollX, scrollX + availableWidth, boundsY + scrollY, scrollY + availableHeight); } } var totalWidth:Number = positionX + tileWidth + this._paddingRight; if(availableWidth === availableWidth) //!isNaN { if(this._paging == PAGING_VERTICAL) { totalWidth = availableWidth; } else if(this._paging == PAGING_HORIZONTAL) { totalWidth = Math.ceil(itemCount / perPage) * availableWidth; } } var totalHeight:Number = totalPageHeight; if(availableHeight === availableHeight && //!isNaN this._paging == PAGING_VERTICAL) { totalHeight = Math.ceil(itemCount / perPage) * availableHeight; } if(availableWidth !== availableWidth) //isNaN { availableWidth = totalWidth; } if(availableHeight !== availableHeight) //isNaN { availableHeight = totalHeight; } if(availableWidth < minWidth) { availableWidth = minWidth; } if(availableHeight < minHeight) { availableHeight = minHeight; } if(this._paging == PAGING_NONE) { discoveredItems = this._useVirtualLayout ? this._discoveredItemsCache : items; discoveredItemsLastIndex = discoveredItems.length - 1; this.applyHorizontalAlign(discoveredItems, 0, discoveredItemsLastIndex, totalWidth, availableWidth); this.applyVerticalAlign(discoveredItems, 0, discoveredItemsLastIndex, totalHeight, availableHeight); if(this._manageVisibility) { this.applyVisible(discoveredItems, discoveredItemsFirstIndex, discoveredItemsLastIndex, boundsX + scrollX, scrollX + availableWidth, boundsY + scrollY, scrollY + availableHeight); } } this._discoveredItemsCache.length = 0; if(!result) { result = new LayoutBoundsResult(); } result.contentX = 0; result.contentY = 0; result.contentWidth = totalWidth; result.contentHeight = totalHeight; result.viewPortWidth = availableWidth; result.viewPortHeight = availableHeight; return result; } /** * @inheritDoc */ public function measureViewPort(itemCount:int, viewPortBounds:ViewPortBounds = null, result:Point = null):Point { if(!result) { result = new Point(); } if(!this._useVirtualLayout) { throw new IllegalOperationError(""measureViewPort() may be called only if useVirtualLayout is true."") } var explicitWidth:Number = viewPortBounds ? viewPortBounds.explicitWidth : NaN; var explicitHeight:Number = viewPortBounds ? viewPortBounds.explicitHeight : NaN; var needsWidth:Boolean = explicitWidth !== explicitWidth; //isNaN var needsHeight:Boolean = explicitHeight !== explicitHeight; //isNaN if(!needsWidth && !needsHeight) { result.x = explicitWidth; result.y = explicitHeight; return result; } var boundsX:Number = viewPortBounds ? viewPortBounds.x : 0; var boundsY:Number = viewPortBounds ? viewPortBounds.y : 0; var minWidth:Number = viewPortBounds ? viewPortBounds.minWidth : 0; var minHeight:Number = viewPortBounds ? viewPortBounds.minHeight : 0; var maxWidth:Number = viewPortBounds ? viewPortBounds.maxWidth : Number.POSITIVE_INFINITY; var maxHeight:Number = viewPortBounds ? viewPortBounds.maxHeight : Number.POSITIVE_INFINITY; this.prepareTypicalItem(); var calculatedTypicalItemWidth:Number = this._typicalItem ? this._typicalItem.width : 0; var calculatedTypicalItemHeight:Number = this._typicalItem ? this._typicalItem.height : 0; var tileWidth:Number = calculatedTypicalItemWidth; var tileHeight:Number = calculatedTypicalItemHeight; if(tileWidth < 0) { tileWidth = 0; } if(tileHeight < 0) { tileHeight = 0; } if(this._useSquareTiles) { if(tileWidth > tileHeight) { tileHeight = tileWidth; } else if(tileHeight > tileWidth) { tileWidth = tileHeight; } } var availableWidth:Number = NaN; var availableHeight:Number = NaN; var verticalTileCount:int; if(explicitHeight === explicitHeight) //!isNaN { availableHeight = explicitHeight; verticalTileCount = (explicitHeight - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); } else if(maxHeight === maxHeight && //!isNaN maxHeight < Number.POSITIVE_INFINITY) { availableHeight = maxHeight; verticalTileCount = (maxHeight - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); } else { verticalTileCount = itemCount; } if(verticalTileCount < 1) { verticalTileCount = 1; } else if(this._requestedRowCount > 0) { if(availableHeight !== availableHeight) //isNaN { verticalTileCount = this._requestedRowCount; availableHeight = verticalTileCount * (tileHeight + this._verticalGap) - this._verticalGap - this._paddingTop - this._paddingBottom; } else if(verticalTileCount > this._requestedRowCount) { verticalTileCount = this._requestedRowCount; } } var horizontalTileCount:int; if(explicitWidth === explicitWidth) //!isNaN { availableWidth = explicitWidth; horizontalTileCount = (explicitWidth - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); } else if(maxWidth === maxWidth && //!isNaN maxWidth < Number.POSITIVE_INFINITY) { availableWidth = maxWidth; horizontalTileCount = (maxWidth - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); } else { horizontalTileCount = Math.ceil(itemCount / verticalTileCount); } if(horizontalTileCount < 1) { horizontalTileCount = 1; } else if(this._requestedColumnCount > 0) { if(availableWidth !== availableWidth) //isNaN { horizontalTileCount = this._requestedColumnCount; availableWidth = horizontalTileCount * (tileWidth + this._horizontalGap) - this._horizontalGap - this._paddingLeft - this._paddingRight; } else if(horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } } var totalPageHeight:Number = verticalTileCount * (tileHeight + this._verticalGap) - this._verticalGap + this._paddingTop + this._paddingBottom; var startX:Number = boundsX + this._paddingLeft; var perPage:int = horizontalTileCount * verticalTileCount; var pageIndex:int = 0; var nextPageStartIndex:int = perPage; var positionX:Number = startX; for(var i:int = 0; i < itemCount; i++) { if(i != 0 && i % verticalTileCount == 0) { positionX += tileWidth + this._horizontalGap; } if(i == nextPageStartIndex) { pageIndex++; nextPageStartIndex += perPage; //we can use availableWidth and availableHeight here without //checking if they're NaN because we will never reach a //new page without them already being calculated. if(this._paging == PAGING_HORIZONTAL) { positionX = startX + availableWidth * pageIndex; } else if(this._paging == PAGING_VERTICAL) { positionX = startX; } } } var totalWidth:Number = positionX + tileWidth + this._paddingRight; if(availableWidth === availableWidth) //!isNaN { if(this._paging == PAGING_VERTICAL) { totalWidth = availableWidth; } else if(this._paging == PAGING_HORIZONTAL) { totalWidth = Math.ceil(itemCount / perPage) * availableWidth; } } var totalHeight:Number = totalPageHeight; if(availableHeight === availableHeight && //!isNaN this._paging == PAGING_VERTICAL) { totalHeight = Math.ceil(itemCount / perPage) * availableHeight; } if(needsWidth) { var resultX:Number = totalWidth; if(resultX < minWidth) { resultX = minWidth; } else if(resultX > maxWidth) { resultX = maxWidth; } result.x = resultX; } else { result.x = explicitWidth; } if(needsHeight) { var resultY:Number = totalHeight; if(resultY < minHeight) { resultY = minHeight; } else if(resultY > maxHeight) { resultY = maxHeight; } result.y = resultY; } else { result.y = explicitHeight; } return result; } /** * @inheritDoc */ public function getVisibleIndicesAtScrollPosition(scrollX:Number, scrollY:Number, width:Number, height:Number, itemCount:int, result:Vector. = null):Vector. { if(result) { result.length = 0; } else { result = new []; } if(!this._useVirtualLayout) { throw new IllegalOperationError(""getVisibleIndicesAtScrollPosition() may be called only if useVirtualLayout is true."") } if(this._paging == PAGING_HORIZONTAL) { this.getVisibleIndicesAtScrollPositionWithHorizontalPaging(scrollX, scrollY, width, height, itemCount, result); } else if(this._paging == PAGING_VERTICAL) { this.getVisibleIndicesAtScrollPositionWithVerticalPaging(scrollX, scrollY, width, height, itemCount, result); } else { this.getVisibleIndicesAtScrollPositionWithoutPaging(scrollX, scrollY, width, height, itemCount, result); } return result; } /** * @inheritDoc */ public function getNearestScrollPositionForIndex(index:int, scrollX:Number, scrollY:Number, items:Vector., x:Number, y:Number, width:Number, height:Number, result:Point = null):Point { return this.calculateScrollPositionForIndex(index, items, x, y, width, height, result, true, scrollX, scrollY); } /** * @inheritDoc */ public function getScrollPositionForIndex(index:int, items:Vector., x:Number, y:Number, width:Number, height:Number, result:Point = null):Point { return this.calculateScrollPositionForIndex(index, items, x, y, width, height, result, false); } /** * @private */ protected function applyVisible(items:Vector., startIndex:int, endIndex:int, startX:Number, endX:Number, startY:Number, endY:Number):void { for(var i:int = startIndex; i <= endIndex; i++) { var item:DisplayObject = items[i]; if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } var itemX:Number = item.x - item.pivotX; var itemY:Number = item.y - item.pivotY; item.visible = ((itemX + item.width) >= startX) && (itemX < endX) && ((itemY + item.height) >= startY) && (itemY < endY); } } /** * @private */ protected function applyHorizontalAlign(items:Vector., startIndex:int, endIndex:int, totalItemWidth:Number, availableWidth:Number):void { if(totalItemWidth >= availableWidth) { return; } var horizontalAlignOffsetX:Number = 0; if(this._horizontalAlign == HORIZONTAL_ALIGN_RIGHT) { horizontalAlignOffsetX = availableWidth - totalItemWidth; } else if(this._horizontalAlign != HORIZONTAL_ALIGN_LEFT) { //we're going to default to center if we encounter an //unknown value horizontalAlignOffsetX = Math.round((availableWidth - totalItemWidth) / 2); } if(horizontalAlignOffsetX != 0) { for(var i:int = startIndex; i <= endIndex; i++) { var item:DisplayObject = items[i]; if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } item.x += horizontalAlignOffsetX; } } } /** * @private */ protected function applyVerticalAlign(items:Vector., startIndex:int, endIndex:int, totalItemHeight:Number, availableHeight:Number):void { if(totalItemHeight >= availableHeight) { return; } var verticalAlignOffsetY:Number = 0; if(this._verticalAlign == VERTICAL_ALIGN_BOTTOM) { verticalAlignOffsetY = availableHeight - totalItemHeight; } else if(this._verticalAlign == VERTICAL_ALIGN_MIDDLE) { verticalAlignOffsetY = Math.round((availableHeight - totalItemHeight) / 2); } if(verticalAlignOffsetY != 0) { for(var i:int = startIndex; i <= endIndex; i++) { var item:DisplayObject = items[i]; if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } item.y += verticalAlignOffsetY; } } } /** * @private */ protected function getVisibleIndicesAtScrollPositionWithHorizontalPaging(scrollX:Number, scrollY:Number, width:Number, height:Number, itemCount:int, result:Vector.):void { this.prepareTypicalItem(); var calculatedTypicalItemWidth:Number = this._typicalItem ? this._typicalItem.width : 0; var calculatedTypicalItemHeight:Number = this._typicalItem ? this._typicalItem.height : 0; var tileWidth:Number = calculatedTypicalItemWidth; var tileHeight:Number = calculatedTypicalItemHeight; if(tileWidth < 0) { tileWidth = 0; } if(tileHeight < 0) { tileHeight = 0; } if(this._useSquareTiles) { if(tileWidth > tileHeight) { tileHeight = tileWidth; } else if(tileHeight > tileWidth) { tileWidth = tileHeight; } } var horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } else if(this._requestedRowCount > 0 && verticalTileCount > this._requestedRowCount) { verticalTileCount = this._requestedRowCount; } var perPage:int = horizontalTileCount * verticalTileCount; var minimumItemCount:int = perPage + 2 * verticalTileCount; if(minimumItemCount > itemCount) { minimumItemCount = itemCount; } var startPageIndex:int = Math.round(scrollX / width); var minimum:int = startPageIndex * perPage; var totalRowWidth:Number = horizontalTileCount * (tileWidth + this._horizontalGap) - this._horizontalGap; var leftSideOffset:Number = 0; var rightSideOffset:Number = 0; if(totalRowWidth < width) { if(this._horizontalAlign == HORIZONTAL_ALIGN_RIGHT) { leftSideOffset = width - this._paddingLeft - this._paddingRight - totalRowWidth; rightSideOffset = 0; } else if(this._horizontalAlign == HORIZONTAL_ALIGN_CENTER) { leftSideOffset = rightSideOffset = Math.round((width - this._paddingLeft - this._paddingRight - totalRowWidth) / 2); } else if(this._horizontalAlign == HORIZONTAL_ALIGN_LEFT) { leftSideOffset = 0; rightSideOffset = width - this._paddingLeft - this._paddingRight - totalRowWidth; } } var columnOffset:int = 0; var pageStartPosition:Number = startPageIndex * width; var partialPageSize:Number = scrollX - pageStartPosition; if(partialPageSize < 0) { partialPageSize = -partialPageSize - this._paddingRight - rightSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } columnOffset = -Math.floor(partialPageSize / (tileWidth + this._horizontalGap)) - 1; minimum += columnOffset * verticalTileCount; } else if(partialPageSize > 0) { partialPageSize = partialPageSize - this._paddingLeft - leftSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } columnOffset = Math.floor(partialPageSize / (tileWidth + this._horizontalGap)); minimum += columnOffset * verticalTileCount; } if(minimum < 0) { minimum = 0; columnOffset = 0; } var maximum:int = minimum + minimumItemCount; if(maximum > itemCount) { maximum = itemCount; } minimum = maximum - minimumItemCount; var resultPushIndex:int = result.length; for(var i:int = minimum; i < maximum; i++) { result[resultPushIndex] = i; resultPushIndex++; } } /** * @private */ protected function getVisibleIndicesAtScrollPositionWithVerticalPaging(scrollX:Number, scrollY:Number, width:Number, height:Number, itemCount:int, result:Vector.):void { this.prepareTypicalItem(); var calculatedTypicalItemWidth:Number = this._typicalItem ? this._typicalItem.width : 0; var calculatedTypicalItemHeight:Number = this._typicalItem ? this._typicalItem.height : 0; var tileWidth:Number = calculatedTypicalItemWidth; var tileHeight:Number = calculatedTypicalItemHeight; if(tileWidth < 0) { tileWidth = 0; } if(tileHeight < 0) { tileHeight = 0; } if(this._useSquareTiles) { if(tileWidth > tileHeight) { tileHeight = tileWidth; } else if(tileHeight > tileWidth) { tileWidth = tileHeight; } } var horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } else if(this._requestedRowCount > 0 && verticalTileCount > this._requestedRowCount) { verticalTileCount = this._requestedRowCount; } var perPage:int = horizontalTileCount * verticalTileCount; var minimumItemCount:int = perPage + 2 * verticalTileCount; if(minimumItemCount > itemCount) { minimumItemCount = itemCount; } var startPageIndex:int = Math.round(scrollY / height); var minimum:int = startPageIndex * perPage; var totalColumnHeight:Number = verticalTileCount * (tileHeight + this._verticalGap) - this._verticalGap; var topSideOffset:Number = 0; var bottomSideOffset:Number = 0; if(totalColumnHeight < height) { if(this._verticalAlign == VERTICAL_ALIGN_BOTTOM) { topSideOffset = height - this._paddingTop - this._paddingBottom - totalColumnHeight; bottomSideOffset = 0; } else if(this._horizontalAlign == VERTICAL_ALIGN_MIDDLE) { topSideOffset = bottomSideOffset = Math.round((height - this._paddingTop - this._paddingBottom - totalColumnHeight) / 2); } else if(this._horizontalAlign == VERTICAL_ALIGN_TOP) { topSideOffset = 0; bottomSideOffset = height - this._paddingTop - this._paddingBottom - totalColumnHeight; } } var rowOffset:int = 0; var pageStartPosition:Number = startPageIndex * height; var partialPageSize:Number = scrollY - pageStartPosition; if(partialPageSize < 0) { partialPageSize = -partialPageSize - this._paddingBottom - bottomSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } rowOffset = -Math.floor(partialPageSize / (tileWidth + this._verticalGap)) - 1; minimum += -perPage + horizontalTileCount + rowOffset; } else if(partialPageSize > 0) { partialPageSize = partialPageSize - this._paddingTop - topSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } rowOffset = Math.floor(partialPageSize / (tileWidth + this._verticalGap)); minimum += rowOffset; } if(minimum < 0) { minimum = 0; rowOffset = 0; } if(minimum + minimumItemCount >= itemCount) { //an optimized path when we're on or near the last page minimum = itemCount - minimumItemCount; var resultPushIndex:int = result.length; for(var i:int = minimum; i < itemCount; i++) { result[resultPushIndex] = i; resultPushIndex++; } } else { var columnIndex:int = 0; var rowIndex:int = (verticalTileCount + rowOffset) % verticalTileCount; var pageStart:int = int(minimum / perPage) * perPage; i = minimum; var resultLength:int = 0; do { if(i < itemCount) { result[resultLength] = i; resultLength++; } columnIndex++; if(columnIndex == horizontalTileCount) { columnIndex = 0; rowIndex++; if(rowIndex == verticalTileCount) { rowIndex = 0; pageStart += perPage; } i = pageStart + rowIndex - verticalTileCount; } i += verticalTileCount; } while(resultLength < minimumItemCount && pageStart < itemCount) } } /** * @private */ protected function getVisibleIndicesAtScrollPositionWithoutPaging(scrollX:Number, scrollY:Number, width:Number, height:Number, itemCount:int, result:Vector.):void { this.prepareTypicalItem(); var calculatedTypicalItemWidth:Number = this._typicalItem ? this._typicalItem.width : 0; var calculatedTypicalItemHeight:Number = this._typicalItem ? this._typicalItem.height : 0; var tileWidth:Number = calculatedTypicalItemWidth; var tileHeight:Number = calculatedTypicalItemHeight; if(tileWidth < 0) { tileWidth = 0; } if(tileHeight < 0) { tileHeight = 0; } if(this._useSquareTiles) { if(tileWidth > tileHeight) { tileHeight = tileWidth; } else if(tileHeight > tileWidth) { tileWidth = tileHeight; } } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } else if(this._requestedRowCount > 0 && verticalTileCount > this._requestedRowCount) { verticalTileCount = this._requestedRowCount; } var horizontalTileCount:int = Math.ceil((width + this._horizontalGap) / (tileWidth + this._horizontalGap)) + 1; var minimumItemCount:int = verticalTileCount * horizontalTileCount; if(minimumItemCount > itemCount) { minimumItemCount = itemCount; } var columnIndexOffset:int = 0; var totalColumnWidth:Number = Math.ceil(itemCount / verticalTileCount) * (tileWidth + this._horizontalGap) - this._horizontalGap; if(totalColumnWidth < width) { if(this._verticalAlign == VERTICAL_ALIGN_BOTTOM) { columnIndexOffset = Math.ceil((width - totalColumnWidth) / (tileWidth + this._horizontalGap)); } else if(this._verticalAlign == VERTICAL_ALIGN_MIDDLE) { columnIndexOffset = Math.ceil((width - totalColumnWidth) / (tileWidth + this._horizontalGap) / 2); } } var columnIndex:int = -columnIndexOffset + Math.floor((scrollX - this._paddingLeft + this._horizontalGap) / (tileWidth + this._horizontalGap)); var minimum:int = columnIndex * verticalTileCount; if(minimum < 0) { minimum = 0; } var maximum:int = minimum + minimumItemCount; if(maximum > itemCount) { maximum = itemCount; } minimum = maximum - minimumItemCount; var resultPushIndex:int = result.length; for(var i:int = minimum; i < maximum; i++) { result[resultPushIndex] = i; resultPushIndex++; } } /** * @private */ protected function validateItems(items:Vector.):void { var itemCount:int = items.length; for(var i:int = 0; i < itemCount; i++) { var item:DisplayObject = items[i]; if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } if(item is IValidating) { IValidating(item).validate(); } } } /** * @private */ protected function prepareTypicalItem():void { if(!this._typicalItem) { return; } if(this._resetTypicalItemDimensionsOnMeasure) { this._typicalItem.width = this._typicalItemWidth; this._typicalItem.height = this._typicalItemHeight; } if(this._typicalItem is IValidating) { IValidating(this._typicalItem).validate(); } } /** * @private */ protected function calculateScrollPositionForIndex(index:int, items:Vector., x:Number, y:Number, width:Number, height:Number, result:Point = null, nearest:Boolean = false, scrollX:Number = 0, scrollY:Number = 0):Point { if(!result) { result = new Point(); } if(this._useVirtualLayout) { this.prepareTypicalItem(); var calculatedTypicalItemWidth:Number = this._typicalItem ? this._typicalItem.width : 0; var calculatedTypicalItemHeight:Number = this._typicalItem ? this._typicalItem.height : 0; } var itemCount:int = items.length; var tileWidth:Number = this._useVirtualLayout ? calculatedTypicalItemWidth : 0; var tileHeight:Number = this._useVirtualLayout ? calculatedTypicalItemHeight : 0; //a virtual layout assumes that all items are the same size as //the typical item, so we don't need to measure every item in //that case if(!this._useVirtualLayout) { for(var i:int = 0; i < itemCount; i++) { var item:DisplayObject = items[i]; if(!item) { continue; } if(item is ILayoutDisplayObject && !ILayoutDisplayObject(item).includeInLayout) { continue; } var itemWidth:Number = item.width; var itemHeight:Number = item.height; if(itemWidth > tileWidth) { tileWidth = itemWidth; } if(itemHeight > tileHeight) { tileHeight = itemHeight; } } } if(tileWidth < 0) { tileWidth = 0; } if(tileHeight < 0) { tileHeight = 0; } if(this._useSquareTiles) { if(tileWidth > tileHeight) { tileHeight = tileWidth; } else if(tileHeight > tileWidth) { tileWidth = tileHeight; } } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } else if(this._requestedRowCount > 0 && verticalTileCount > this._requestedRowCount) { verticalTileCount = this._requestedRowCount; } if(this._paging != PAGING_NONE) { var horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } var perPage:Number = horizontalTileCount * verticalTileCount; var pageIndex:int = index / perPage; if(this._paging == PAGING_HORIZONTAL) { result.x = pageIndex * width; result.y = 0; } else { result.x = 0; result.y = pageIndex * height; } } else { var resultX:Number = this._paddingLeft + ((tileWidth + this._horizontalGap) * int(index / verticalTileCount)); if(nearest) { var rightPosition:Number = resultX - (width - tileWidth); if(scrollX >= rightPosition && scrollX <= resultX) { //keep the current scroll position because the item is already //fully visible resultX = scrollX; } else { var leftDifference:Number = Math.abs(resultX - scrollX); var rightDifference:Number = Math.abs(rightPosition - scrollX); if(rightDifference < leftDifference) { resultX = rightPosition; } } } else { resultX -= Math.round((width - tileWidth) / 2) } result.x = resultX; result.y = 0; } return result; } } } ",16134,True,2935.4282219306956,median "class ZCUR_CURRENCY_BO_DP definition public final create public . public section. types: gtt_country_key_rng TYPE RANGE OF t005x-land . types: gtt_currency_key_rng TYPE RANGE OF tcurc-waers . types GTS_CURRENCY type ZCUR_CURRENCY_BO=>GTS_DATA . types: gtt_currency_list TYPE STANDARD TABLE OF gts_currency WITH DEFAULT KEY . types: BEGIN OF gts_currency_1. INCLUDE TYPE gts_currency. TYPES country_name TYPE t005t-landx50. TYPES currency_text TYPE tcurt-ltext. TYPES END OF gts_currency_1 . types: gtt_currency_list_1 TYPE STANDARD TABLE OF gts_currency_1 WITH DEFAULT KEY . class-methods CLASS_CONSTRUCTOR . class-methods GET_CURRENCY_LIST_1 importing !IT_COUNTRY_KEY_RNG type GTT_COUNTRY_KEY_RNG !IT_CURRENCY_KEY_RNG type GTT_CURRENCY_KEY_RNG returning value(RT_CURRENCY_LIST) type GTT_CURRENCY_LIST_1 . methods GET_CURRENCY importing !IV_COUNTRY_KEY type T005X-LAND !IV_CURRENCY_KEY type TCURC-WAERS returning value(RS_CURRENCY) type GTS_CURRENCY raising CX_BAPI_ERROR . PROTECTED SECTION. CLASS-DATA gt_currency_list TYPE gtt_currency_list . ENDCLASS. CLASS ZCUR_CURRENCY_BO_DP IMPLEMENTATION. METHOD class_constructor. gt_currency_list = VALUE #( ( country_key = 'AD' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'AE' currency_key = 'AED' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AF' currency_key = 'AFN' symbol = |؋| left_symbol = || right_symbol = || ) ( country_key = 'AG' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AI' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AL' currency_key = 'ALL' symbol = |Lek| left_symbol = || right_symbol = || ) ( country_key = 'AM' currency_key = 'AMD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AO' currency_key = 'AOA' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AQ' currency_key = '' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AR' currency_key = 'ARS' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'AS' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'AT' currency_key = 'EUR' symbol = |€| left_symbol = |€ | right_symbol = || ) ( country_key = 'AU' currency_key = 'AUD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'AW' currency_key = 'AWG' symbol = |ƒ| left_symbol = || right_symbol = || ) ( country_key = 'AX' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'AZ' currency_key = 'AZN' symbol = |₼| left_symbol = || right_symbol = || ) ( country_key = 'BA' currency_key = 'BAM' symbol = |KM| left_symbol = || right_symbol = || ) ( country_key = 'BB' currency_key = 'BBD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'BD' currency_key = 'BDT' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BE' currency_key = 'EUR' symbol = |€| left_symbol = |€| right_symbol = || ) ( country_key = 'BF' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BG' currency_key = 'BGN' symbol = |лв| left_symbol = || right_symbol = || ) ( country_key = 'BH' currency_key = 'BHD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BI' currency_key = 'BIF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BJ' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BL' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'BM' currency_key = 'BMD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BN' currency_key = 'BND' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'BO' currency_key = 'BOB' symbol = |$b| left_symbol = || right_symbol = || ) ( country_key = 'BQ' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BR' currency_key = 'BRL' symbol = |R$| left_symbol = || right_symbol = || ) ( country_key = 'BS' currency_key = 'BSD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'BT' currency_key = 'BTN' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BV' currency_key = 'NOK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'BW' currency_key = 'BWP' symbol = |P| left_symbol = || right_symbol = || ) ( country_key = 'BY' currency_key = 'BYR' symbol = |Br| left_symbol = || right_symbol = || ) ( country_key = 'BZ' currency_key = 'BZD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'CA' currency_key = 'CAD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'CC' currency_key = 'AUD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CD' currency_key = 'CDF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CF' currency_key = 'XAF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CG' currency_key = 'XAF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CH' currency_key = 'CHF' symbol = |CHF| left_symbol = || right_symbol = || ) ( country_key = 'CI' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CK' currency_key = 'NZD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CL' currency_key = 'CLP' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'CM' currency_key = 'XAF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CN' currency_key = 'CNY' symbol = |¥| left_symbol = || right_symbol = || ) ( country_key = 'CO' currency_key = 'COP' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'CR' currency_key = 'CRC' symbol = |₡| left_symbol = || right_symbol = || ) ( country_key = 'CU' currency_key = 'CUP' symbol = |₱| left_symbol = || right_symbol = || ) ( country_key = 'CV' currency_key = 'CVE' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CW' currency_key = 'ANG' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CX' currency_key = 'AUD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'CY' currency_key = 'EUR' symbol = |€| left_symbol = |€| right_symbol = || ) ( country_key = 'CZ' currency_key = 'CZK' symbol = |Kč| left_symbol = || right_symbol = || ) ( country_key = 'DE' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'DJ' currency_key = 'DJF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'DK' currency_key = 'DKK' symbol = |kr| left_symbol = || right_symbol = || ) ( country_key = 'DM' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'DO' currency_key = 'DOP' symbol = |RD$| left_symbol = || right_symbol = || ) ( country_key = 'DZ' currency_key = 'DZD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'EC' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'EE' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'EG' currency_key = 'EGP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'EH' currency_key = 'MAD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'ER' currency_key = 'ERN' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'ES' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'ET' currency_key = 'ETB' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'EU' currency_key = '' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'FI' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'FJ' currency_key = 'FJD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'FK' currency_key = 'FKP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'FM' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'FO' currency_key = 'DKK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'FR' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'GA' currency_key = 'XAF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GB' currency_key = 'GBP' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GD' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GE' currency_key = 'GEL' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GF' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'GG' currency_key = 'GBP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'GH' currency_key = 'GHS' symbol = |¢| left_symbol = || right_symbol = || ) ( country_key = 'GI' currency_key = 'GIP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'GL' currency_key = 'DKK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GM' currency_key = 'GMD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GN' currency_key = 'GNF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GP' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'GQ' currency_key = 'XAF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GR' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'GS' currency_key = 'GBP' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GT' currency_key = 'GTQ' symbol = |Q| left_symbol = || right_symbol = || ) ( country_key = 'GU' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GW' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'GY' currency_key = 'GYD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'HK' currency_key = 'HKD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'HM' currency_key = 'AUD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'HN' currency_key = 'HNL' symbol = |L| left_symbol = || right_symbol = || ) ( country_key = 'HR' currency_key = 'HRK' symbol = |kn| left_symbol = || right_symbol = || ) ( country_key = 'HT' currency_key = 'HTG' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'HU' currency_key = 'HUF' symbol = |Ft| left_symbol = || right_symbol = || ) ( country_key = 'ID' currency_key = 'IDR' symbol = |Rp| left_symbol = || right_symbol = || ) ( country_key = 'IE' currency_key = 'EUR' symbol = |€| left_symbol = |€| right_symbol = || ) ( country_key = 'IL' currency_key = 'ILS' symbol = |₪| left_symbol = || right_symbol = || ) ( country_key = 'IM' currency_key = 'GBP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'IN' currency_key = 'INR' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'IO' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'IQ' currency_key = 'IQD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'IR' currency_key = 'IRR' symbol = |﷼| left_symbol = || right_symbol = || ) ( country_key = 'IS' currency_key = 'ISK' symbol = |kr| left_symbol = || right_symbol = || ) ( country_key = 'IT' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'JE' currency_key = 'GBP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'JM' currency_key = 'JMD' symbol = |J$| left_symbol = || right_symbol = || ) ( country_key = 'JO' currency_key = 'JOD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'JP' currency_key = 'JPY' symbol = |¥| left_symbol = || right_symbol = || ) ( country_key = 'KE' currency_key = 'KES' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KG' currency_key = 'KGS' symbol = |лв| left_symbol = || right_symbol = || ) ( country_key = 'KH' currency_key = 'KHR' symbol = |៛| left_symbol = || right_symbol = || ) ( country_key = 'KI' currency_key = 'AUD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KM' currency_key = 'KMF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KN' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KP' currency_key = 'KPW' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KR' currency_key = 'KRW' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KW' currency_key = 'KWD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'KY' currency_key = 'KYD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'KZ' currency_key = 'KZT' symbol = |лв| left_symbol = || right_symbol = || ) ( country_key = 'LA' currency_key = 'LAK' symbol = |₭| left_symbol = || right_symbol = || ) ( country_key = 'LB' currency_key = 'LBP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'LC' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'LI' currency_key = 'CHF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'LK' currency_key = 'LKR' symbol = |₨| left_symbol = || right_symbol = || ) ( country_key = 'LR' currency_key = 'LRD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'LS' currency_key = 'LSL' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'LT' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'LU' currency_key = 'EUR' symbol = |€| left_symbol = |€| right_symbol = || ) ( country_key = 'LV' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'LY' currency_key = 'LYD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MA' currency_key = 'MAD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MC' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'MD' currency_key = 'MDL' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'ME' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'MF' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'MG' currency_key = 'MGA' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MH' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MK' currency_key = 'MKD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'ML' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MM' currency_key = 'MMK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MN' currency_key = 'MNT' symbol = |₮| left_symbol = || right_symbol = || ) ( country_key = 'MO' currency_key = 'MOP' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MP' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MQ' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'MR' currency_key = 'MRO' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MS' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MT' currency_key = 'EUR' symbol = |€| left_symbol = |€| right_symbol = || ) ( country_key = 'MU' currency_key = 'MUR' symbol = |₨| left_symbol = || right_symbol = || ) ( country_key = 'MV' currency_key = 'MVR' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MW' currency_key = 'MWK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'MX' currency_key = 'MXN' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'MY' currency_key = 'MYR' symbol = |RM| left_symbol = || right_symbol = || ) ( country_key = 'MZ' currency_key = 'MZN' symbol = |MT| left_symbol = || right_symbol = || ) ( country_key = 'NA' currency_key = 'NAD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'NC' currency_key = 'XPF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'NE' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'NF' currency_key = 'AUD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'NG' currency_key = 'NGN' symbol = |₦| left_symbol = || right_symbol = || ) ( country_key = 'NI' currency_key = 'NIO' symbol = |C$| left_symbol = || right_symbol = || ) ( country_key = 'NL' currency_key = 'EUR' symbol = |€| left_symbol = |€ | right_symbol = || ) ( country_key = 'NO' currency_key = 'NOK' symbol = |kr| left_symbol = || right_symbol = || ) ( country_key = 'NP' currency_key = 'NPR' symbol = |₨| left_symbol = || right_symbol = || ) ( country_key = 'NR' currency_key = 'AUD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'NT' currency_key = '' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'NU' currency_key = 'NZD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'NZ' currency_key = 'NZD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'OM' currency_key = 'OMR' symbol = |﷼| left_symbol = || right_symbol = || ) ( country_key = 'OR' currency_key = '' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PA' currency_key = 'PAB' symbol = |B/.| left_symbol = || right_symbol = || ) ( country_key = 'PE' currency_key = 'PEN' symbol = |S/.| left_symbol = || right_symbol = || ) ( country_key = 'PF' currency_key = 'XPF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PG' currency_key = 'PGK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PH' currency_key = 'PHP' symbol = |₱| left_symbol = || right_symbol = || ) ( country_key = 'PK' currency_key = 'PKR' symbol = |₨| left_symbol = || right_symbol = || ) ( country_key = 'PL' currency_key = 'PLN' symbol = |zł| left_symbol = || right_symbol = || ) ( country_key = 'PM' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'PN' currency_key = 'NZD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PR' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PS' currency_key = '' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PT' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'PW' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'PY' currency_key = 'PYG' symbol = |Gs| left_symbol = || right_symbol = || ) ( country_key = 'QA' currency_key = 'QAR' symbol = |﷼| left_symbol = || right_symbol = || ) ( country_key = 'RE' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'RO' currency_key = 'RON' symbol = |lei| left_symbol = || right_symbol = || ) ( country_key = 'RS' currency_key = 'RSD' symbol = |Дин.| left_symbol = || right_symbol = || ) ( country_key = 'RU' currency_key = 'RUB' symbol = |₽| left_symbol = || right_symbol = || ) ( country_key = 'RW' currency_key = 'RWF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SA' currency_key = 'SAR' symbol = |﷼| left_symbol = || right_symbol = || ) ( country_key = 'SB' currency_key = 'SBD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'SC' currency_key = 'SCR' symbol = |₨| left_symbol = || right_symbol = || ) ( country_key = 'SD' currency_key = 'SDG' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SE' currency_key = 'SEK' symbol = |kr| left_symbol = || right_symbol = || ) ( country_key = 'SG' currency_key = 'SGD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'SH' currency_key = 'SHP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'SI' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'SJ' currency_key = 'NOK' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SK' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = | €| ) ( country_key = 'SL' currency_key = 'SLL' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SM' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'SN' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SO' currency_key = 'SOS' symbol = |S| left_symbol = || right_symbol = || ) ( country_key = 'SR' currency_key = 'SRD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'SS' currency_key = 'SSP' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'ST' currency_key = 'STN' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SV' currency_key = 'SVC' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'SX' currency_key = 'ANG' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'SY' currency_key = 'SYP' symbol = |£| left_symbol = || right_symbol = || ) ( country_key = 'SZ' currency_key = 'SZL' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TC' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TD' currency_key = 'XAF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TF' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'TG' currency_key = 'XOF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TH' currency_key = 'THB' symbol = |฿| left_symbol = || right_symbol = || ) ( country_key = 'TJ' currency_key = 'TJS' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TK' currency_key = 'NZD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TL' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TM' currency_key = 'TMT' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TN' currency_key = 'TND' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TO' currency_key = 'TOP' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TR' currency_key = 'TRY' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'TT' currency_key = 'TTD' symbol = |TT$| left_symbol = || right_symbol = || ) ( country_key = 'TV' currency_key = 'AUD' symbol = |$| left_symbol = || right_symbol = || ) ( country_key = 'TW' currency_key = 'TWD' symbol = |NT$| left_symbol = || right_symbol = || ) ( country_key = 'TZ' currency_key = 'TZS' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'UA' currency_key = 'UAH' symbol = |₴| left_symbol = || right_symbol = || ) ( country_key = 'UG' currency_key = 'UGX' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'UM' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'UN' currency_key = '' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'US' currency_key = 'USD' symbol = || left_symbol = |$| right_symbol = || ) ( country_key = 'UY' currency_key = 'UYU' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'UZ' currency_key = 'UZS' symbol = |лв| left_symbol = || right_symbol = || ) ( country_key = 'VA' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'VC' currency_key = 'XCD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'VE' currency_key = 'VES' symbol = |Bs| left_symbol = || right_symbol = || ) ( country_key = 'VG' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'VI' currency_key = 'USD' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'VN' currency_key = 'VND' symbol = |₫| left_symbol = || right_symbol = || ) ( country_key = 'VU' currency_key = 'VUV' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'WF' currency_key = 'XPF' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'WS' currency_key = 'WST' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'YE' currency_key = 'YER' symbol = |﷼| left_symbol = || right_symbol = || ) ( country_key = 'YT' currency_key = 'EUR' symbol = |€| left_symbol = || right_symbol = || ) ( country_key = 'ZA' currency_key = 'ZAR' symbol = |R| left_symbol = || right_symbol = || ) ( country_key = 'ZM' currency_key = 'ZMW' symbol = || left_symbol = || right_symbol = || ) ( country_key = 'ZW' currency_key = 'USD' symbol = |Z$| left_symbol = || right_symbol = || ) ). SORT gt_currency_list BY country_key currency_key. SELECT waers AS currency_key, isocd AS iso_code, tcurx~currdec AS decimal_count FROM tcurc LEFT JOIN tcurx ON tcurx~currkey = tcurc~waers FOR ALL ENTRIES IN @gt_currency_list WHERE waers = @gt_currency_list-currency_key INTO TABLE @DATA(lt_tcurc). SORT lt_tcurc BY currency_key. LOOP AT gt_currency_list ASSIGNING FIELD-SYMBOL(). READ TABLE lt_tcurc WITH KEY currency_key = -currency_key BINARY SEARCH ASSIGNING FIELD-SYMBOL(). IF sy-subrc = 0. -iso_code = -iso_code. IF -decimal_count IS INITIAL. -decimal_count = 2. ELSE. -decimal_count = -decimal_count. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. METHOD get_currency. READ TABLE gt_currency_list WITH KEY country_key = iv_country_key currency_key = iv_currency_key BINARY SEARCH INTO rs_currency. IF sy-subrc <> 0. ""Currency with country &1 currency &2 does not exist. MESSAGE e001 WITH iv_country_key iv_currency_key INTO DATA(lv_dummy). RAISE EXCEPTION TYPE cx_bapi_error EXPORTING t100_msgid = sy-msgid t100_msgno = sy-msgno t100_msgv1 = sy-msgv1 t100_msgv2 = sy-msgv2 t100_msgv3 = sy-msgv3 t100_msgv4 = sy-msgv4. ENDIF. ENDMETHOD. METHOD get_currency_list_1. ""Read land texts IF gt_currency_list[] IS NOT INITIAL. SELECT land1 AS country_key, landx50 AS country_name FROM t005t FOR ALL ENTRIES IN @gt_currency_list WHERE land1 = @gt_currency_list-country_key AND spras = @sy-langu INTO TABLE @DATA(lt_t005t). SORT lt_t005t BY country_key. ENDIF. ""Read currency texts IF gt_currency_list[] IS NOT INITIAL. SELECT waers AS currency_key, ltext AS currency_text FROM tcurt FOR ALL ENTRIES IN @gt_currency_list WHERE waers = @gt_currency_list-currency_key AND spras = @sy-langu INTO TABLE @DATA(lt_tcurt). SORT lt_tcurt BY currency_key. ENDIF. LOOP AT gt_currency_list ASSIGNING FIELD-SYMBOL() WHERE country_key IN it_country_key_rng AND currency_key IN it_currency_key_rng. APPEND INITIAL LINE TO rt_currency_list ASSIGNING FIELD-SYMBOL(). MOVE-CORRESPONDING TO . ""Country name READ TABLE lt_t005t WITH KEY country_key = -country_key BINARY SEARCH ASSIGNING FIELD-SYMBOL(). IF sy-subrc = 0. -country_name = -country_name. ENDIF. ""Currency text READ TABLE lt_tcurt WITH KEY currency_key = -currency_key BINARY SEARCH ASSIGNING FIELD-SYMBOL(). IF sy-subrc = 0. -currency_text = -currency_text. ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. ",8116,True,2616.473262374682,median "/** * VERSION: 1.6 * DATE: 2010-10-02 * AS3 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/ **/ package com.greensock.loading { import com.greensock.events.LoaderEvent; import com.greensock.loading.core.DisplayObjectLoader; import com.greensock.loading.core.LoaderCore; import flash.display.AVM1Movie; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.MovieClip; import flash.events.Event; import flash.events.ProgressEvent; import flash.media.SoundTransform; import flash.utils.getQualifiedClassName; /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches an OPEN event. **/ [Event(name=""childOpen"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a PROGRESS event. **/ [Event(name=""childProgress"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a COMPLETE event. **/ [Event(name=""childComplete"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a FAIL event. **/ [Event(name=""childFail"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when any loader that the SWFLoader discovered in the subloaded swf dispatches a CANCEL event. **/ [Event(name=""childCancel"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when the loader is denied script access to the swf which can happen if it is loaded from another domain and there's no crossdomain.xml file in place. **/ [Event(name=""scriptAccessDenied"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when the loader's httpStatus value changes. **/ [Event(name=""httpStatus"", type=""com.greensock.events.LoaderEvent"")] /** Dispatched when the loader experiences a SECURITY_ERROR while loading or auditing its size. **/ [Event(name=""securityError"", type=""com.greensock.events.LoaderEvent"")] /** * Loads a swf file and automatically searches for active loaders in that swf that have * the requireWithRoot vars property set to that swf's root. If it finds any, * it will factor those loaders' progress into its own progress and not dispatch its * COMPLETE event until the nested loaders have finished.

* * The SWFLoader's content refers to a ContentDisplay (a Sprite) that * is created immediately so that you can position/scale/rotate it or add ROLL_OVER/ROLL_OUT/CLICK listeners * before (or while) the swf loads. Use the SWFLoader's content property to get the ContentDisplay * Sprite, or use the rawContent property to get the actual root of the loaded swf file itself. * If a container is defined in the vars object, the ContentDisplay will * immediately be added to that container).

* * If you define a width and height, it will draw a rectangle * in the ContentDisplay so that interactive events fire appropriately (rollovers, etc.) and width/height/bounds * get reported accurately. This rectangle is invisible by default, but you can control its color and alpha * with the bgColor and bgAlpha properties. When the swf loads, it will be * added to the ContentDisplay at index 0 with addChildAt() and scaled to fit the width/height according to * the scaleMode. These are all optional features - you do not need to define a * width or height in which case the swf will load at its native size. * See the list below for all the special properties that can be passed through the vars * parameter but don't let the list overwhelm you - these are all optional and they are intended to make * your job as a developer much easier.

* * By default, the SWFLoader will attempt to load the swf in a way that allows full script * access (same SecurityDomain and child ApplicationDomain). However, if a security error is thrown because * the swf is being loaded from another domain and the appropriate crossdomain.xml file isn't in place * to grant access, the SWFLoader will automatically adjust the default LoaderContext so that it falls * back to the more restricted mode which will have the following effect: *
    *
  • A LoaderEvent.SCRIPT_ACCESS_DENIED event will be dispatched and the scriptAccessDenied property of the SWFLoader will be set to true. You can check this value before performing any restricted operations on the content like BitmapData.draw().
  • *
  • Other LoaderMax-related loaders inside the swf will not be recognized or integrated into the SWFLoader's overall progress.
  • *
  • A Loader instance will be added to the ContentDisplay Sprite instead of the swf's root.
  • *
  • The getClass() and getSWFChild() methods will always return null.
  • *
  • BitmapData operations like draw() will not be able to be performed on the swf.
  • *
* * If the loaded swf is an AVM1Movie (built in AS1 or AS2), scriptAccessDenied will be true * and a Loader instance will be added to the content Sprite instead of the swf's root.

* * To maximize the likelihood of your swf loading without any security problems, consider taking the following steps: *
    *
  • Use a crossdomain.xml file - See Adobe's docs for details, but here is an example that grants full access (put this in a crossdomain.xml file that is at the root of the remote domain):
    * <?xml version=""1.0"" encoding=""utf-8""?>
    * <cross-domain-policy>
    * <allow-access-from domain=""~~"" />
    * </cross-domain-policy>
  • *
  • In the embed code of any HTML wrapper, set AllowScriptAccess to ""always""
  • *
  • If possible, in the remote swf make sure you explicitly allow script access using something like flash.system.Security.allowDomain(""~~"");
  • *

* * OPTIONAL VARS PROPERTIES
* The following special properties can be passed into the SWFLoader constructor via its vars * parameter which can be either a generic object or an SWFLoaderVars object:
*
    *
  • name : String - A name that is used to identify the SWFLoader instance. This name can be fed to the LoaderMax.getLoader() or LoaderMax.getContent() methods. This name is also applied to the Sprite that is created to hold the swf (The SWFLoader's content refers to this Sprite). Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like ""loader21"".
  • *
  • container : DisplayObjectContainer - A DisplayObjectContainer into which the content Sprite should be added immediately.
  • *
  • width : Number - Sets the ContentDisplay's width property (applied before rotation, scaleX, and scaleY).
  • *
  • height : Number - Sets the ContentDisplay's height property (applied before rotation, scaleX, and scaleY).
  • *
  • centerRegistration : Boolean - if true, the registration point will be placed in the center of the ContentDisplay Sprite which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center.
  • *
  • scaleMode : String - When a width and height are defined, the scaleMode controls how the loaded swf will be scaled to fit the area. The following values are recognized (you may use the com.greensock.layout.ScaleMode constants if you prefer): *
      *
    • ""stretch"" (the default) - The swf will fill the width/height exactly.
    • *
    • ""proportionalInside"" - The swf will be scaled proportionally to fit inside the area defined by the width/height
    • *
    • ""proportionalOutside"" - The swf will be scaled proportionally to completely fill the area, allowing portions of it to exceed the bounds defined by the width/height.
    • *
    • ""widthOnly"" - Only the width of the swf will be adjusted to fit.
    • *
    • ""heightOnly"" - Only the height of the swf will be adjusted to fit.
    • *
    • ""none"" - No scaling of the swf will occur.
    • *
  • *
  • hAlign : String - When a width and height are defined, the hAlign determines how the swf is horizontally aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered horizontally in the area
    • *
    • ""left"" - The swf will be aligned with the left side of the area
    • *
    • ""right"" - The swf will be aligned with the right side of the area
    • *
  • *
  • vAlign : String - When a width and height are defined, the vAlign determines how the swf is vertically aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered vertically in the area
    • *
    • ""top"" - The swf will be aligned with the top of the area
    • *
    • ""bottom"" - The swf will be aligned with the bottom of the area
    • *
  • *
  • crop : Boolean - When a width and height are defined, setting crop to true will cause the swf to be cropped within that area (by applying a scrollRect for maximum performance) based on its native size (not the bounding box of the swf's current contents). This is typically useful when the scaleMode is ""proportionalOutside"" or ""none"" or when the swf contains objects that are positioned off-stage. Any parts of the swf that exceed the dimensions defined by width and height are visually chopped off. Use the hAlign and vAlign special properties to control the vertical and horizontal alignment within the cropped area.
  • *
  • x : Number - Sets the ContentDisplay's x property (for positioning on the stage).
  • *
  • y : Number - Sets the ContentDisplay's y property (for positioning on the stage).
  • *
  • scaleX : Number - Sets the ContentDisplay's scaleX property.
  • *
  • scaleY : Number - Sets the ContentDisplay's scaleY property.
  • *
  • rotation : Number - Sets the ContentDisplay's rotation property.
  • *
  • alpha : Number - Sets the ContentDisplay's alpha property.
  • *
  • visible : Boolean - Sets the ContentDisplay's visible property.
  • *
  • blendMode : String - Sets the ContentDisplay's blendMode property.
  • *
  • autoPlay : Boolean - If autoPlay is true (the default), the swf will begin playing immediately when the INIT event fires. To prevent this behavior, set autoPlay to false which will also mute the swf until the SWFLoader completes.
  • *
  • bgColor : uint - When a width and height are defined, a rectangle will be drawn inside the ContentDisplay Sprite immediately in order to ease the development process. It is transparent by default, but you may define a bgAlpha if you prefer.
  • *
  • bgAlpha : Number - Controls the alpha of the rectangle that is drawn when a width and height are defined.
  • *
  • context : LoaderContext - To control things like the ApplicationDomain, SecurityDomain, and whether or not a policy file is checked, define a LoaderContext object. The default context is null when running locally and new LoaderContext(true, new ApplicationDomain(ApplicationDomain.currentDomain), SecurityDomain.currentDomain) when running remotely in order to avoid common security sandbox errors (see Adobe's LoaderContext documentation for details and precautions). Please make sure that if you load swfs from another domain that you have a crossdomain.xml file installed on that remote server that grants your swf access rights (see Adobe's docs for crossdomain.xml details). Again, if you want to impose security restrictions on the loaded swf, please define your own LoaderContext.
  • *
  • integrateProgress : Boolean - By default, a SWFLoader instance will automatically look for LoaderMax loaders in the swf when it initializes. Every loader found with a requireWithRoot parameter set to that swf's root will be integrated into the SWFLoader's overall progress. The SWFLoader's COMPLETE event won't fire until all such loaders are also complete. If you prefer NOT to integrate the subloading loaders into the SWFLoader's overall progress, set integrateProgress to false.
  • *
  • alternateURL : String - If you define an alternateURL, the loader will initially try to load from its original url and if it fails, it will automatically (and permanently) change the loader's url to the alternateURL and try again. Think of it as a fallback or backup url. It is perfectly acceptable to use the same alternateURL for multiple loaders (maybe a default image for various ImageLoaders for example).
  • *
  • noCache : Boolean - If noCache is true, a ""cacheBusterID"" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you getLoader() or getContent() by url and when you're running locally)
  • *
  • estimatedBytes : uint - Initially, the loader's bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the swf initializes and has been analyzed enough to determine the size of any nested loaders that were found inside the swf with their requireWithRoot set to that swf's root, it will adjust the bytesTotal accordingly. Setting estimatedBytes is optional, but it provides a way to avoid situations where the progress and bytesTotal values jump around as SWFLoader recognizes nested loaders in the swf and audits their size. The estimatedBytes value should include all nested loaders as well, so if your swf file itself is 2000 bytes and it has 3 nested ImageLoaders, each loading a 2000-byte image, your SWFLoader's estimatedBytes should be 8000. The more accurate the value, the more accurate the loaders' overall progress will be.
  • *
  • requireWithRoot : DisplayObject - LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this SWFLoader as part of its parent SWFLoader's progress, you must set the requireWithRoot property to your swf's root. For example, var loader:SWFLoader = new SWFLoader(""subload.swf"", {name:""subloadSWF"", requireWithRoot:this.root});
  • *
  • autoDispose : Boolean - When autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with LoaderMax.getLoader() or LoaderMax.getContent() - it is essentially destroyed but its content is not unloaded (you must call unload() or dispose(true) to unload its content). The default autoDispose value is false. * *

    ----EVENT HANDLER SHORTCUTS----
  • *
  • onOpen : Function - A handler function for LoaderEvent.OPEN events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onInit : Function - A handler function for LoaderEvent.INIT events which are called when the swf has streamed enough of its content to render the first frame and determine if there are any required LoaderMax-related loaders recognized. It also adds the swf to the ContentDisplay Sprite at this point. Make sure your onInit function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onProgress : Function - A handler function for LoaderEvent.PROGRESS events which are dispatched whenever the bytesLoaded changes. Make sure your onProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can use the LoaderEvent's target.progress to get the loader's progress value or use its target.bytesLoaded and target.bytesTotal.
  • *
  • onComplete : Function - A handler function for LoaderEvent.COMPLETE events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onCancel : Function - A handler function for LoaderEvent.CANCEL events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or cancel() was manually called. Make sure your onCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onError : Function - A handler function for LoaderEvent.ERROR events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the onFail special property. Make sure your onError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onFail : Function - A handler function for LoaderEvent.FAIL events which are dispatched whenever the loader fails and its status changes to LoaderStatus.FAILED. Make sure your onFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onIOError : Function - A handler function for LoaderEvent.IO_ERROR events which will also call the onError handler, so you can use that as more of a catch-all whereas onIOError is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onHTTPStatus : Function - A handler function for LoaderEvent.HTTP_STATUS events. Make sure your onHTTPStatus function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can determine the httpStatus code using the LoaderEvent's target.httpStatus (LoaderItems keep track of their httpStatus when possible, although certain environments prevent Flash from getting httpStatus information).
  • *
  • onSecurityError : Function - A handler function for LoaderEvent.SECURITY_ERROR events which onError handles as well, so you can use that as more of a catch-all whereas onSecurityError is specifically for SECURITY_ERROR events. Make sure your onSecurityError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onScriptAccessDenied : Function - A handler function for LoaderMax.SCRIPT_ACCESS_DENIED events which occur when the swf is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like BitmapData manipulation or integration of LoaderMax data inside the swf, etc. You can also check the scriptAccessDenied property after the swf has loaded. Make sure your function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildOpen : Function - A handler function for LoaderEvent.CHILD_OPEN events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) begins loading. Make sure your onChildOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildProgress : Function - A handler function for LoaderEvent.CHILD_PROGRESS events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) dispatches a PROGRESS event. To listen for changes in the SWFLoader's overall progress, use the onProgress special property instead. You can use the LoaderEvent's target.progress to get the child loader's progress value or use its target.bytesLoaded and target.bytesTotal. The LoaderEvent's currentTarget refers to the SWFLoader, so you can check its overall progress with the LoaderEvent's currentTarget.progress. Make sure your onChildProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildComplete : Function - A handler function for LoaderEvent.CHILD_COMPLETE events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildCancel : Function - A handler function for LoaderEvent.CHILD_CANCEL events which are dispatched each time loading is aborted on any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) due to either an error or because another loader was prioritized in the queue or because cancel() was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildFail : Function - A handler function for LoaderEvent.CHILD_FAIL events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) fails (and its status chances to LoaderStatus.FAILED). Make sure your onChildFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *

* * Note: Using a SWFLoaderVars instance * instead of a generic object to define your vars is a bit more verbose but provides * code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.

* * content data type: com.greensock.loading.display.ContentDisplay (a Sprite). * When the swf has finished loading, the rawContent will be added to the ContentDisplay * Sprite at index 0 using addChildAt(). rawContent refers to the loaded swf's root * unless unless script access is denied in which case it will be a flash.display.Loader (to avoid security errors).

* * @example Example AS3 code: import com.greensock.~~; import com.greensock.loading.~~; //create a SWFLoader that will add the content to the display list at position x:50, y:100 when it has loaded: var loader:SWFLoader = new SWFLoader(""swf/main.swf"", {name:""mainSWF"", container:this, x:50, y:100, onInit:initHandler, estimatedBytes:9500}); //begin loading loader.load(); function initHandler(event:LoaderEvent):void { //fade the swf in as soon as it inits TweenLite.from(event.target.content, 1, {alpha:0}); //get a MovieClip named ""phoneAnimation_mc"" that's on the root of the subloaded swf var mc:DisplayObject = loader.getSWFChild(""phoneAnimation_mc""); //find the ""com.greensock.TweenLite"" class that's inside the subloaded swf var tweenClass:Class = loader.getClass(""com.greensock.TweenLite""); } //Or you could put the SWFLoader into a LoaderMax. Create one first... var queue:LoaderMax = new LoaderMax({name:""mainQueue"", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); //append the SWFLoader and several other loaders queue.append( loader ); queue.append( new XMLLoader(""xml/doc.xml"", {name:""xmlDoc"", estimatedBytes:425}) ); queue.append( new ImageLoader(""img/photo1.jpg"", {name:""photo1"", estimatedBytes:3500}) ); //start loading queue.load(); function progressHandler(event:LoaderEvent):void { trace(""progress: "" + event.target.progress); } function completeHandler(event:LoaderEvent):void { trace(event.target + "" is complete!""); } function errorHandler(event:LoaderEvent):void { trace(""error occured with "" + event.target + "": "" + event.text); } * * Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. * * @see com.greensock.loading.data.SWFLoaderVars * * @author Jack Doyle, jack@greensock.com */ public class SWFLoader extends DisplayObjectLoader { /** @private **/ private static var _classActivated:Boolean = _activateClass(""SWFLoader"", SWFLoader, ""swf""); /** @private **/ protected var _queue:LoaderMax; /** @private When the INIT event is dispatched, we'll check to see if there's a runtime shared library like for TLF and we must do some backflips to accommodate it - _hasRSL will be toggled to true if we find one. **/ protected var _hasRSL:Boolean; /** @private **/ protected var _rslAddedCount:uint; /** @private In certain browsers, there's a bug in the Flash Player that incorrectly reports the Loader's bytesLoaded as never reaching bytesTotal even AFTER the Loader completes (only when gzip is enabled on the server). This helps us get around that bug. **/ protected var _loaderCompleted:Boolean; /** * Constructor * * @param urlOrRequest The url (String) or URLRequest from which the loader should get its content * @param vars An object containing optional configuration details. For example: new SWFLoader(""swf/main.swf"", {name:""main"", container:this, x:100, y:50, alpha:0, autoPlay:false, onComplete:completeHandler, onProgress:progressHandler}).

* * The following special properties can be passed into the constructor via the vars parameter * which can be either a generic object or an SWFLoaderVars object:
*
    *
  • name : String - A name that is used to identify the SWFLoader instance. This name can be fed to the LoaderMax.getLoader() or LoaderMax.getContent() methods. This name is also applied to the Sprite that is created to hold the swf (The SWFLoader's content refers to this Sprite). Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like ""loader21"".
  • *
  • container : DisplayObjectContainer - A DisplayObjectContainer into which the content Sprite should be added immediately.
  • *
  • width : Number - Sets the ContentDisplay's width property (applied before rotation, scaleX, and scaleY).
  • *
  • height : Number - Sets the ContentDisplay's height property (applied before rotation, scaleX, and scaleY).
  • *
  • centerRegistration : Boolean - if true, the registration point will be placed in the center of the ContentDisplay Sprite which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center.
  • *
  • scaleMode : String - When a width and height are defined, the scaleMode controls how the loaded swf will be scaled to fit the area. The following values are recognized (you may use the com.greensock.layout.ScaleMode constants if you prefer): *
      *
    • ""stretch"" (the default) - The swf will fill the width/height exactly.
    • *
    • ""proportionalInside"" - The swf will be scaled proportionally to fit inside the area defined by the width/height
    • *
    • ""proportionalOutside"" - The swf will be scaled proportionally to completely fill the area, allowing portions of it to exceed the bounds defined by the width/height.
    • *
    • ""widthOnly"" - Only the width of the swf will be adjusted to fit.
    • *
    • ""heightOnly"" - Only the height of the swf will be adjusted to fit.
    • *
    • ""none"" - No scaling of the swf will occur.
    • *
  • *
  • hAlign : String - When a width and height are defined, the hAlign determines how the swf is horizontally aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered horizontally in the area
    • *
    • ""left"" - The swf will be aligned with the left side of the area
    • *
    • ""right"" - The swf will be aligned with the right side of the area
    • *
  • *
  • vAlign : String - When a width and height are defined, the vAlign determines how the swf is vertically aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer): *
      *
    • ""center"" (the default) - The swf will be centered vertically in the area
    • *
    • ""top"" - The swf will be aligned with the top of the area
    • *
    • ""bottom"" - The swf will be aligned with the bottom of the area
    • *
  • *
  • crop : Boolean - When a width and height are defined, setting crop to true will cause the swf to be cropped within that area (by applying a scrollRect for maximum performance) based on its native size (not the bounding box of the swf's current contents). This is typically useful when the scaleMode is ""proportionalOutside"" or ""none"" or when the swf contains objects that are positioned off-stage. Any parts of the swf that exceed the dimensions defined by width and height are visually chopped off. Use the hAlign and vAlign special properties to control the vertical and horizontal alignment within the cropped area.
  • *
  • x : Number - Sets the ContentDisplay's x property (for positioning on the stage).
  • *
  • y : Number - Sets the ContentDisplay's y property (for positioning on the stage).
  • *
  • scaleX : Number - Sets the ContentDisplay's scaleX property.
  • *
  • scaleY : Number - Sets the ContentDisplay's scaleY property.
  • *
  • rotation : Number - Sets the ContentDisplay's rotation property.
  • *
  • alpha : Number - Sets the ContentDisplay's alpha property.
  • *
  • visible : Boolean - Sets the ContentDisplay's visible property.
  • *
  • blendMode : String - Sets the ContentDisplay's blendMode property.
  • *
  • autoPlay : Boolean - If autoPlay is true (the default), the swf will begin playing immediately when the INIT event fires. To prevent this behavior, set autoPlay to false which will also mute the swf until the SWFLoader completes.
  • *
  • bgColor : uint - When a width and height are defined, a rectangle will be drawn inside the ContentDisplay Sprite immediately in order to ease the development process. It is transparent by default, but you may define a bgAlpha if you prefer.
  • *
  • bgAlpha : Number - Controls the alpha of the rectangle that is drawn when a width and height are defined.
  • *
  • context : LoaderContext - To control things like the ApplicationDomain, SecurityDomain, and whether or not a policy file is checked, define a LoaderContext object. The default context is null when running locally and new LoaderContext(true, new ApplicationDomain(ApplicationDomain.currentDomain), SecurityDomain.currentDomain) when running remotely in order to avoid common security sandbox errors (see Adobe's LoaderContext documentation for details and precautions). Please make sure that if you load swfs from another domain that you have a crossdomain.xml file installed on that remote server that grants your swf access rights (see Adobe's docs for crossdomain.xml details). Again, if you want to impose security restrictions on the loaded swf, please define your own LoaderContext.
  • *
  • integrateProgress : Boolean - By default, a SWFLoader instance will automatically look for LoaderMax loaders in the swf when it initializes. Every loader found with a requireWithRoot parameter set to that swf's root will be integrated into the SWFLoader's overall progress. The SWFLoader's COMPLETE event won't fire until all such loaders are also complete. If you prefer NOT to integrate the subloading loaders into the SWFLoader's overall progress, set integrateProgress to false.
  • *
  • alternateURL : String - If you define an alternateURL, the loader will initially try to load from its original url and if it fails, it will automatically (and permanently) change the loader's url to the alternateURL and try again. Think of it as a fallback or backup url. It is perfectly acceptable to use the same alternateURL for multiple loaders (maybe a default image for various ImageLoaders for example).
  • *
  • noCache : Boolean - If noCache is true, a ""cacheBusterID"" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you getLoader() or getContent() by url and when you're running locally)
  • *
  • estimatedBytes : uint - Initially, the loader's bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the swf initializes and has been analyzed enough to determine the size of any nested loaders that were found inside the swf with their requireWithRoot set to that swf's root, it will adjust the bytesTotal accordingly. Setting estimatedBytes is optional, but it provides a way to avoid situations where the progress and bytesTotal values jump around as SWFLoader recognizes nested loaders in the swf and audits their size. The estimatedBytes value should include all nested loaders as well, so if your swf file itself is 2000 bytes and it has 3 nested ImageLoaders, each loading a 2000-byte image, your SWFLoader's estimatedBytes should be 8000. The more accurate the value, the more accurate the loaders' overall progress will be.
  • *
  • requireWithRoot : DisplayObject - LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this SWFLoader as part of its parent SWFLoader's progress, you must set the requireWithRoot property to your swf's root. For example, var loader:SWFLoader = new SWFLoader(""subload.swf"", {name:""subloadSWF"", requireWithRoot:this.root});
  • *
  • autoDispose : Boolean - When autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with LoaderMax.getLoader() or LoaderMax.getContent() - it is essentially destroyed but its content is not unloaded (you must call unload() or dispose(true) to unload its content). The default autoDispose value is false. * *

    ----EVENT HANDLER SHORTCUTS----
  • *
  • onOpen : Function - A handler function for LoaderEvent.OPEN events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onInit : Function - A handler function for LoaderEvent.INIT events which are called when the swf has streamed enough of its content to render the first frame and determine if there are any required LoaderMax-related loaders recognized. It also adds the swf to the ContentDisplay Sprite at this point. Make sure your onInit function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onProgress : Function - A handler function for LoaderEvent.PROGRESS events which are dispatched whenever the bytesLoaded changes. Make sure your onProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can use the LoaderEvent's target.progress to get the loader's progress value or use its target.bytesLoaded and target.bytesTotal.
  • *
  • onComplete : Function - A handler function for LoaderEvent.COMPLETE events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onCancel : Function - A handler function for LoaderEvent.CANCEL events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or cancel() was manually called. Make sure your onCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onError : Function - A handler function for LoaderEvent.ERROR events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the onFail special property. Make sure your onError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onFail : Function - A handler function for LoaderEvent.FAIL events which are dispatched whenever the loader fails and its status changes to LoaderStatus.FAILED. Make sure your onFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onIOError : Function - A handler function for LoaderEvent.IO_ERROR events which will also call the onError handler, so you can use that as more of a catch-all whereas onIOError is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onHTTPStatus : Function - A handler function for LoaderEvent.HTTP_STATUS events. Make sure your onHTTPStatus function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can determine the httpStatus code using the LoaderEvent's target.httpStatus (LoaderItems keep track of their httpStatus when possible, although certain environments prevent Flash from getting httpStatus information).
  • *
  • onSecurityError : Function - A handler function for LoaderEvent.SECURITY_ERROR events which onError handles as well, so you can use that as more of a catch-all whereas onSecurityError is specifically for SECURITY_ERROR events. Make sure your onSecurityError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onScriptAccessDenied : Function - A handler function for LoaderMax.SCRIPT_ACCESS_DENIED events which occur when the swf is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like BitmapData manipulation or integration of LoaderMax data inside the swf, etc. You can also check the scriptAccessDenied property after the swf has loaded. Make sure your function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildOpen : Function - A handler function for LoaderEvent.CHILD_OPEN events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) begins loading. Make sure your onChildOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildProgress : Function - A handler function for LoaderEvent.CHILD_PROGRESS events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) dispatches a PROGRESS event. To listen for changes in the SWFLoader's overall progress, use the onProgress special property instead. You can use the LoaderEvent's target.progress to get the child loader's progress value or use its target.bytesLoaded and target.bytesTotal. The LoaderEvent's currentTarget refers to the SWFLoader, so you can check its overall progress with the LoaderEvent's currentTarget.progress. Make sure your onChildProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildComplete : Function - A handler function for LoaderEvent.CHILD_COMPLETE events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildCancel : Function - A handler function for LoaderEvent.CHILD_CANCEL events which are dispatched each time loading is aborted on any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) due to either an error or because another loader was prioritized in the queue or because cancel() was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
  • onChildFail : Function - A handler function for LoaderEvent.CHILD_FAIL events which are dispatched each time any nested LoaderMax-related loaders (active ones that the SWFLoader found inside the subloading swf that had their requireWithRoot set to its root) fails (and its status chances to LoaderStatus.FAILED). Make sure your onChildFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • *
* @see com.greensock.loading.data.SWFLoaderVars */ public function SWFLoader(urlOrRequest:*, vars:Object=null) { super(urlOrRequest, vars); _preferEstimatedBytesInAudit = true; _type = ""SWFLoader""; } /** @private **/ override protected function _load():void { if (_stealthMode) { //it's already loading, so exit stealth mode (stealth mode is entered when the SWFLoader is canceled before the Loader has dispatched the INIT event - bugs in Flash cause gc problems if we try to close() or unload() a Loader between the time it starts loading and when INIT fires... _stealthMode = false; } else if (!_initted) { super._load(); } else if (_queue != null) { _changeQueueListeners(true); _queue.load(false); } } /** @private **/ override protected function _refreshLoader(unloadContent:Boolean=true):void { super._refreshLoader(unloadContent); _loaderCompleted = false; } /** @private **/ protected function _changeQueueListeners(add:Boolean):void { if (_queue != null) { var p:String; if (add && this.vars.integrateProgress != false) { _queue.addEventListener(LoaderEvent.COMPLETE, _completeHandler, false, 0, true); _queue.addEventListener(LoaderEvent.PROGRESS, _progressHandler, false, 0, true); _queue.addEventListener(LoaderEvent.FAIL, _failHandler, false, 0, true); for (p in _listenerTypes) { if (p != ""onProgress"" && p != ""onInit"") { _queue.addEventListener(_listenerTypes[p], _passThroughEvent, false, 0, true); } } } else { _queue.removeEventListener(LoaderEvent.COMPLETE, _completeHandler); _queue.removeEventListener(LoaderEvent.PROGRESS, _progressHandler); _queue.removeEventListener(LoaderEvent.FAIL, _failHandler); for (p in _listenerTypes) { if (p != ""onProgress"" && p != ""onInit"") { _queue.removeEventListener(_listenerTypes[p], _passThroughEvent); } } } } } /** @private scrubLevel: 0 = cancel, 1 = unload, 2 = dispose, 3 = flush **/ override protected function _dump(scrubLevel:int=0, newStatus:int=0, suppressEvents:Boolean=false):void { //Flash will refuse to properly unload it if the INIT event hasn't been dispatched! Technically we allow it to keep loading until _initHandler() is called where we'll unload it. if (_status == LoaderStatus.LOADING && !_initted) { _stealthMode = true; super._dump(scrubLevel, newStatus, suppressEvents); return; } if (_initted && !_scriptAccessDenied && scrubLevel != 2) { _stopMovieClips(_loader.content); if (_loader.content in _rootLookup) { _queue = LoaderMax(_rootLookup[_loader.content]); _changeQueueListeners(false); if (scrubLevel == 1) { _queue.cancel(); } else { if (scrubLevel == 1) { _queue.unload(); } _queue.dispose(); } } } if (_stealthMode) { try { _loader.close(); } catch (error:Error) { } } _stealthMode = _hasRSL = false; _cacheIsDirty = true; if (scrubLevel >= 1) { _queue = null; _initted = _loaderCompleted = false; super._dump(scrubLevel, newStatus, suppressEvents); } else { var content:* = _content; super._dump(scrubLevel, newStatus, suppressEvents); _content = content; //super._dump() will null ""_content"", but if the swf has loaded but not the _queue, we should keep the content so that if resume() is called, it just starts loading the queue. } } /** @private **/ protected function _stopMovieClips(obj:DisplayObject):void { var mc:MovieClip = obj as MovieClip; if (mc == null) { return; } mc.stop(); var i:int = mc.numChildren; while (--i > -1) { _stopMovieClips(mc.getChildAt(i)); } } /** @private **/ override protected function _determineScriptAccess():void { //don't test the BitmapData.draw() until the swf has fully loaded because it can incorrectly throw security errors in certain situations (like NetStreams that haven't started yet). try { var mc:DisplayObject = _loader.content; } catch (error:Error) { _scriptAccessDenied = true; dispatchEvent(new LoaderEvent(LoaderEvent.SCRIPT_ACCESS_DENIED, this, error.message)); return; } if (_loader.content is AVM1Movie) { _scriptAccessDenied = true; dispatchEvent(new LoaderEvent(LoaderEvent.SCRIPT_ACCESS_DENIED, this, ""AVM1Movie denies script access"")); } } /** @private **/ override protected function _calculateProgress():void { _cachedBytesLoaded = (_stealthMode) ? 0 : _loader.contentLoaderInfo.bytesLoaded; _cachedBytesTotal = _loader.contentLoaderInfo.bytesTotal; if (_cachedBytesTotal < _cachedBytesLoaded || _loaderCompleted) { //In Chrome when the file exceeds a certain size and gzip is enabled on the server, Adobe's Loader reports bytesTotal as 0!!! //and in Firefox, if gzip was enabled, on very small files the Loader's bytesLoaded would never quite reach the bytesTotal even after the COMPLETE event fired! _cachedBytesTotal = _cachedBytesLoaded; } if (this.vars.integrateProgress == false) { // do nothing } else if (_queue != null && (uint(this.vars.estimatedBytes) < _cachedBytesLoaded || _queue.auditedSize)) { //make sure that estimatedBytes is prioritized until the _queue has audited its size successfully! if (_queue.status <= LoaderStatus.COMPLETED) { _cachedBytesLoaded += _queue.bytesLoaded; _cachedBytesTotal += _queue.bytesTotal; } } else if (uint(this.vars.estimatedBytes) > _cachedBytesLoaded && (!_initted || (_queue != null && _queue.status <= LoaderStatus.COMPLETED && !_queue.auditedSize))) { _cachedBytesTotal = uint(this.vars.estimatedBytes); } if ((_hasRSL && _content == null) || (!_initted && _cachedBytesLoaded == _cachedBytesTotal)) { _cachedBytesLoaded = int(_cachedBytesLoaded * 0.99); //don't allow the progress to hit 1 yet } _cacheIsDirty = false; } /** @private **/ protected function _checkRequiredLoaders():void { if (_queue == null && this.vars.integrateProgress != false && !_scriptAccessDenied) { _queue = _rootLookup[_loader.content]; if (_queue != null) { _changeQueueListeners(true); _queue.load(false); _cacheIsDirty = true; } } } /** * Searches the loaded swf (and any of its subloaded swfs that were loaded using SWFLoader) for a particular * class by name. For example, if the swf contains a class named ""com.greensock.TweenLite"", you can get a * reference to that class like:

* * var tweenLite:Class = loader.getClass(""com.greensock.TweenLite"");
* //then you can create an instance of TweenLite like:
* var tween:Object = new tweenLite(mc, 1, {x:100});
* * @param className The full name of the class, like ""com.greensock.TweenLite"". * @return The class associated with the className */ public function getClass(className:String):Class { if (_content == null || _scriptAccessDenied) { return null; } var result:Object = _content.loaderInfo.applicationDomain.getDefinition(className); if (result != null) { return result as Class; } else if (_queue != null) { var loaders:Array = _queue.getChildren(true, true); var i:int = loaders.length; while (--i > -1) { if (loaders[i] is SWFLoader) { result = (loaders[i] as SWFLoader).getClass(className); if (result != null) { return result as Class; } } } } return null; } /** * Finds a DisplayObject that's on the root of the loaded SWF by name. For example, * you could put a MovieClip with an instance name of ""phoneAnimation_mc"" on the stage (along with * any other objects of course) and then when you load that swf you could use * loader.getSWFChild(""phoneAnimation_mc"") to get that MovieClip. It would be * similar to doing (loader.rawContent as DisplayObjectContainer).getChildByName(""phoneAnimation_mc"") * but in a more concise way that doesn't require checking to see if the rawContent is null. getSWFChild() * will return null if the content hasn't loaded yet or if scriptAccessDenied is true. * * @param name The name of the child DisplayObject that is located at the root of the swf. * @return The DisplayObject with the specified name. Returns null if the content hasn't loaded yet or if scriptAccessDenied is true. */ public function getSWFChild(name:String):DisplayObject { return (!_scriptAccessDenied && _content is DisplayObjectContainer) ? DisplayObjectContainer(_content).getChildByName(name) : null; } /** * @private * Finds a particular loader inside any active LoaderMax instances that were discovered in the subloaded swf * which had their requireWithRoot set to the swf's root. This is only useful in situations * where the swf contains other loaders that are required. * * @param nameOrURL The name or url associated with the loader that should be found. * @return The loader associated with the name or url. Returns null if none were found. */ public function getLoader(nameOrURL:String):* { return (_queue != null) ? _queue.getLoader(nameOrURL) : null; } /** * @private * Finds a particular loader's content from inside any active LoaderMax instances that were discovered in the * subloaded swf which had their requireWithRoot set to the swf's root. This is only useful * in situations where the swf contains other loaders that are required. * * @param nameOrURL The name or url associated with the loader whose content should be found. * @return The content associated with the name or url. Returns null if none was found. */ public function getContent(nameOrURL:String):* { if (nameOrURL == this.name || nameOrURL == _url) { return this.content; } var loader:LoaderCore = this.getLoader(nameOrURL); return (loader != null) ? loader.content : null; } /** @private **/ public function getChildren(includeNested:Boolean=false, omitLoaderMaxes:Boolean=false):Array { return (_queue != null) ? _queue.getChildren(includeNested, omitLoaderMaxes) : []; } //---- EVENT HANDLERS ------------------------------------------------------------------------------------ /** @private **/ override protected function _initHandler(event:Event):void { //if the SWFLoader was cancelled before _initHandler() was called, Flash will refuse to properly unload it, so we allow it to continue but check the status here and _dump() if necessary. if (_stealthMode) { _initted = true; _dump(1, _status, true); return; } //swfs with TLF use their own funky preloader system that causes problems, so we need to work around them here... _hasRSL = false; try { var tempContent:DisplayObject = _loader.content; var className:String = getQualifiedClassName(tempContent); if (className.substr(-13) == ""__Preloader__"") { var rslPreloader:Object = tempContent[""__rslPreloader""]; if (rslPreloader != null) { className = getQualifiedClassName(rslPreloader); if (className == ""fl.rsl::RSLPreloader"") { _hasRSL = true; _rslAddedCount = 0; tempContent.addEventListener(Event.ADDED, _rslAddedHandler); } } } } catch (error:Error) { } if (!_hasRSL) { _init(); } } /** @private **/ protected function _init():void { _determineScriptAccess(); if (!_scriptAccessDenied) { if (!_hasRSL) { _content = _loader.content; } if (_content != null) { if (this.vars.autoPlay == false && _content is MovieClip) { var st:SoundTransform = _content.soundTransform; st.volume = 0; //just make sure you can't hear any sounds as it's loading in the background. _content.soundTransform = st; _content.stop(); } _checkRequiredLoaders(); } } else { _content = _loader; } super._initHandler(null); } /** @private Works around bug - see http://kb2.adobe.com/cps/838/cpsid_83812.html **/ protected function _rslAddedHandler(event:Event):void { // check to ensure this was actually something added to the _loader.content if (event.target is DisplayObject && event.currentTarget is DisplayObjectContainer && event.target.parent == event.currentTarget) { _rslAddedCount++; } // the first thing added will be the loader animation swf - ignore that if (_rslAddedCount > 1) { event.currentTarget.removeEventListener(Event.ADDED, _rslAddedHandler); if (_status == LoaderStatus.LOADING) { _content = event.target; _init(); _calculateProgress(); dispatchEvent(new LoaderEvent(LoaderEvent.PROGRESS, this)); _completeHandler(null); } } } /** @private **/ override protected function _passThroughEvent(event:Event):void { if (event.target != _queue) { super._passThroughEvent(event); } } /** @private **/ override protected function _progressHandler(event:Event):void { if (_status == LoaderStatus.LOADING) { if (_queue == null && _initted) { _checkRequiredLoaders(); } if (_dispatchProgress) { var bl:uint = _cachedBytesLoaded; var bt:uint = _cachedBytesTotal; _calculateProgress(); if (_cachedBytesLoaded != _cachedBytesTotal && (bl != _cachedBytesLoaded || bt != _cachedBytesTotal)) { dispatchEvent(new LoaderEvent(LoaderEvent.PROGRESS, this)); } } else { _cacheIsDirty = true; } } } /** @private **/ override protected function _completeHandler(event:Event=null):void { _loaderCompleted = true; _checkRequiredLoaders(); _calculateProgress(); if (this.progress == 1) { if (!_scriptAccessDenied && this.vars.autoPlay == false && _content is MovieClip) { var st:SoundTransform = _content.soundTransform; st.volume = 1; _content.soundTransform = st; } _changeQueueListeners(false); super._determineScriptAccess(); //now do the BitmapData.draw() test. super._completeHandler(event); } } } }",16177,True,3347.163064126043,median "/** * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. * If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. * You may add additional accurate notices of copyright ownership. * * It is desirable to notify that Covered Software was ""Powered by AlternativaPlatform"" with link to http://www.alternativaplatform.com/ * */ package alternativa.engine3d.materials { import alternterrain.core.QuadTreePage; import alternativa.engine3d.alternativa3d; import alternativa.engine3d.core.Camera3D; import alternativa.engine3d.core.DrawUnit; import alternativa.engine3d.core.Light3D; import alternativa.engine3d.core.Object3D; import alternativa.engine3d.core.Renderer; import alternativa.engine3d.core.Transform3D; import alternativa.engine3d.core.VertexAttributes; import alternativa.engine3d.lights.DirectionalLight; import alternativa.engine3d.lights.OmniLight; import alternativa.engine3d.lights.SpotLight; import alternativa.engine3d.materials.compiler.Linker; import alternativa.engine3d.materials.compiler.Procedure; import alternativa.engine3d.materials.compiler.VariableType; import alternativa.engine3d.objects.Surface; import alternativa.engine3d.resources.BitmapTextureResource; import alternativa.engine3d.resources.Geometry; import alternativa.engine3d.resources.TextureResource; import alternterrain.core.QuadChunkCornerData; import alternterrain.materials.ILODTerrainMaterial; import flash.display.BitmapData; import avmplus.getQualifiedClassName; import flash.display3D.Context3D; import flash.display3D.Context3DBlendFactor; import flash.display3D.Context3DProgramType; import flash.display3D.Context3DVertexBufferFormat; import flash.display3D.VertexBuffer3D; import flash.utils.Dictionary; import flash.utils.getDefinitionByName; use namespace alternativa3d; /** * Same as StandardMaterial but supports fog and mist and forceRenderPriority! * * Material with diffuse, normal, opacity, specular maps and glossiness value. The material is able to draw skin * with the number of bones in surface no more than 41. To reduce the number of bones in surface can break * the skin for more surface with fewer bones. Use the method Skin.divide (). To be drawn with this material, * geometry should have UV coordinates vertex normals and tangent and binormal values​​. * * @see alternativa.engine3d.core.VertexAttributes#TEXCOORDS * @see alternativa.engine3d.core.VertexAttributes#NORMAL * @see alternativa.engine3d.core.VertexAttributes#TANGENT4 * @see alternativa.engine3d.objects.Skin#divide() */ public class StandardTerrainMaterial extends TextureMaterial implements ILODTerrainMaterial { private static const LIGHT_MAP_BIT:int = 1; private static const GLOSSINESS_MAP_BIT:int = 2; private static const SPECULAR_MAP_BIT:int = 4; private static const OPACITY_MAP_BIT:int = 8; private static const WATER_BIT:int = 16; private static const NORMAL_MAP_SPACE_OFFSET:int = 4; // shift value private static const ALPHA_TEST_OFFSET:int = 6; private static const OMNI_LIGHT_OFFSET:int = 8; private static const DIRECTIONAL_LIGHT_OFFSET:int = 11; private static const SPOT_LIGHT_OFFSET:int = 14; private static const SHADOW_OFFSET:int = 17; // TODO: remove double cash by transform procedure. It increase speed by 1% // private static const OBJECT_TYPE_BIT:int = 19; private static var caches:Dictionary = new Dictionary(true); private var cachedContext3D:Context3D; private var programsCache:Dictionary; private var groups:Vector.> = new Vector.>(); /** * @private */ public static const DISABLED:int = 0; /** * @private */ public static const SIMPLE:int = 1; /** * @private */ public static const ADVANCED:int = 2; /** * @private */ public static var fogMode:int = DISABLED; /** * @private */ public static var fogNear:Number = 1000; public static var fogFar:Number = 5000; /** * @private */ public static var fogMaxDensity:Number = 1; /** * @private */ alternativa3d static var fogColorR:Number = 0xC8/255; /** * @private */ alternativa3d static var fogColorG:Number = 0xA2/255; /** * @private */ alternativa3d static var fogColorB:Number = 0xC8 / 255; public static function set fogColor(val:uint):void { fogColorR = ((val & 0xFF0000) >> 16) / 255; fogColorG = ((val & 0xFF00) >> 8) / 255; fogColorB = ((val & 0xFF)) / 255; } private var _waterMode:int = 0; private var _useWaterMode:int = 0; public var waterLevel:Number = 0; /** * @private */ alternativa3d static var fogTexture:TextureResource; // inputs : position private static const _passVaryingsProcedure:Procedure = new Procedure([ ""#v0=vPosition"", ""#v1=vViewVector"", ""#c0=cCameraPosition"", // Pass the position ""mov v0, i0"", // Vector to Camera ""sub t0, c0, i0"", ""mov v1.xyz, t0.xyz"", ""mov v1.w, c0.w"" ]); // inputs : tangent, normal private static const _passTBNRightProcedure:Procedure = getPassTBNProcedure(true); private static const _passTBNLeftProcedure:Procedure = getPassTBNProcedure(false); private static function getPassTBNProcedure(right:Boolean):Procedure { var crsInSpace:String = (right) ? ""crs t1.xyz, i0, i1"" : ""crs t1.xyz, i1, i0""; return new Procedure([ ""#v0=vTangent"", ""#v1=vBinormal"", ""#v2=vNormal"", // Calculate binormal crsInSpace, ""mul t1.xyz, t1.xyz, i0.w"", // Транспонируем матрицу нормалей ""mov v0.xyzw, i1.xyxw"", ""mov v0.x, i0.x"", ""mov v0.y, t1.x"", ""mov v1.xyzw, i1.xyyw"", ""mov v1.x, i0.y"", ""mov v1.y, t1.y"", ""mov v2.xyzw, i1.xyzw"", ""mov v2.x, i0.z"", ""mov v2.y, t1.z"" ], ""passTBNProcedure""); } // outputs : light, highlight private static const _ambientLightProcedure:Procedure = new Procedure([ ""#c0=cSurface"", ""mov o0, i0"", ""mov o1, c0.xxxx"" ], ""ambientLightProcedure""); // Set o.w to glossiness private static const _setGlossinessFromConstantProcedure:Procedure = new Procedure([ ""#c0=cSurface"", ""mov o0.w, c0.y"" ], ""setGlossinessFromConstantProcedure""); // Set o.w to glossiness from texture private static const _setGlossinessFromTextureProcedure:Procedure = new Procedure([ ""#v0=vUV"", ""#c0=cSurface"", ""#s0=sGlossiness"", ""tex t0, v0, s0 <2d, repeat, linear, miplinear>"", ""mul o0.w, t0.x, c0.y"" ], ""setGlossinessFromTextureProcedure""); // outputs : normal, viewVector private static const _getNormalAndViewTangentProcedure:Procedure = new Procedure([ ""#v0=vTangent"", ""#v1=vBinormal"", ""#v2=vNormal"", ""#v3=vUV"", ""#v4=vViewVector"", ""#c0=cAmbientColor"", ""#s0=sBump"", // Extract normal from the texture ""tex t0, v3, s0 <2d,repeat,linear,miplinear>"", ""add t0, t0, t0"", ""sub t0.xyz, t0.xyz, c0.www"", // Transform the normal with TBN ""nrm t1.xyz, v0.xyz"", ""dp3 o0.x, t0.xyz, t1.xyz"", ""nrm t1.xyz, v1.xyz"", ""dp3 o0.y, t0.xyz, t1.xyz"", ""nrm t1.xyz, v2.xyz"", ""dp3 o0.z, t0.xyz, t1.xyz"", // Normalization ""nrm o0.xyz, o0.xyz"", // Returns normalized vector of view ""nrm o1.xyz, v4"" ], ""getNormalAndViewTangentProcedure""); // outputs : normal, viewVector private static const _getNormalAndViewObjectProcedure:Procedure = new Procedure([ ""#v3=vUV"", ""#v4=vViewVector"", ""#c0=cAmbientColor"", ""#s0=sBump"", // Extract normal from the texture ""tex t0, v3, s0 <2d,repeat,linear,miplinear>"", ""add t0, t0, t0"", ""sub t0.xyz, t0.xyz, c0.www"", // Normalization ""nrm o0.xyz, t0.xyz"", // Returns normalized vector of view ""nrm o1.xyz, v4"" ], ""getNormalAndViewObjectProcedure""); // Apply specular map color to a flare private static const _applySpecularProcedure:Procedure = new Procedure([ ""#v0=vUV"", ""#s0=sSpecular"", ""tex t0, v0, s0 <2d, repeat,linear,miplinear>"", ""mul o0.xyz, o0.xyz, t0.xyz"" ], ""applySpecularProcedure""); //Apply light and flare to diffuse // inputs : ""diffuse"", ""tTotalLight"", ""tTotalHighLight"" private static const _mulLightingProcedure:Procedure = new Procedure([ ""#c0=cSurface"", // c0.z - specularPower ""mul i0.xyz, i0.xyz, i1.xyz"", ""mul t1.xyz, i2.xyz, c0.z"", ""add i0.xyz, i0.xyz, t1.xyz"", ""mov o0, i0"" ], ""mulLightingProcedure""); // KIL water level fragment shader - waterMode = 1 private static const kilWaterLevel:Procedure = new Procedure([ ""#c0=cWater"", ""#v0=vPosition"", ""sub t0.z, v0.z, c0.z"", ""kil t0.z"" ], ""kilWaterLevel""); // MIST alpha blend area near water level (useful for gradient mist effect of terrain near water) // inputs : position private static const passSimpleFogConstProcedure:Procedure = new Procedure([ ""#v0=vZDistance"", ""#c0=cFogSpace"", ""dp4 t0.z, i0, c0"", ""mov v0, t0.zzzz"", ""sub v0.y, i0.w, t0.z"" ], ""passSimpleFogConst""); // inputs : color private static const outputWithSimpleFogProcedure:Procedure = new Procedure([ ""#v0=vZDistance"", ""#c0=cFogColor"", ""#c1=cFogRange"", // Restrict fog factor with the range ""min t0.xy, v0.xy, c1.xy"", ""max t0.xy, t0.xy, c1.zw"", ""mul i0.xyz, i0.xyz, t0.y"", ""mul t0.xyz, c0.xyz, t0.x"", ""add i0.xyz, i0.xyz, t0.xyz"", ""mov o0, i0"" ], ""outputWithSimpleFog""); private static const MIST_APPLY:Array = [ ""#c0=cFogColor"", ""#s0=sMist"", ""#v0=vUV"", ""tex t0, v0, s0 <2d, linear,repeat, miplinear>"", ""sub t0.y, c0.w, t0.y"", ""mul i0.xyz, i0.xyz, t0.y"", ""mul t0.xyz, c0.xyz, t0.x"", ""add i0.xyz, i0.xyz, t0.xyz"", ]; protected static const applyWithMistProcedure:Procedure = new Procedure( MIST_APPLY.concat() , ""applyWithMist""); protected static const outputWithMistProcedure:Procedure = new Procedure( MIST_APPLY.concat( ""mov o0, i0"" ) , ""outputWithMist""); // inputs : position, projected private static const postPassAdvancedFogConstProcedure:Procedure = new Procedure([ ""#v0=vZDistance"", ""#c0=cFogSpace"", ""dp4 t0.z, i0, c0"", ""mov v0, t0.zzzz"", ""sub v0.y, i0.w, t0.z"", // Screen x coordinate ""mov v0.zw, i1.xwxw"", ""mov o0, i1"" ], ""postPassAdvancedFogConst""); // inputs : color private static const outputWithAdvancedFogProcedure:Procedure = new Procedure([ ""#v0=vZDistance"", ""#c0=cFogConsts"", ""#c1=cFogRange"", ""#s0=sFogTexture"", // Restrict fog factor with the range ""min t0.xy, v0.xy, c1.xy"", ""max t0.xy, t0.xy, c1.zw"", ""mul i0.xyz, i0.xyz, t0.y"", // Calculate fog color ""mov t1.xyzw, c0.yyzw"", ""div t0.z, v0.z, v0.w"", ""mul t0.z, t0.z, c0.x"", ""add t1.x, t1.x, t0.z"", ""tex t1, t1, s0 <2d, repeat, linear, miplinear>"", ""mul t0.xyz, t1.xyz, t0.x"", ""add i0.xyz, i0.xyz, t0.xyz"", ""mov o0, i0"" ], ""outputWithAdvancedFog""); // Add lightmap value with light private static const _addLightMapProcedure:Procedure = new Procedure([ ""#v0=vUV1"", ""#s0=sLightMap"", ""tex t0, v0, s0 <2d,repeat,linear,miplinear>"", ""add t0, t0, t0"", ""add o0.xyz, i0.xyz, t0.xyz"" ], ""applyLightMapProcedure""); private static const _passLightMapUVProcedure:Procedure = new Procedure([ ""#a0=aUV1"", ""#v0=vUV1"", ""mov v0, a0"" ], ""passLightMapUVProcedure""); /** * @private */ alternativa3d static var fallbackTextureMaterial:TextureMaterial = new TextureMaterial(); /** * @private */ alternativa3d static var fallbackLightMapMaterial:LightMapMaterial = new LightMapMaterial(); /** * Normal map. */ public var normalMap:TextureResource; private var _normalMapSpace:int = NormalMapSpace.TANGENT_RIGHT_HANDED; /** * Type of the normal map. Should be defined by constants of NormalMapSpace class. * * @default NormalMapSpace.TANGENT_RIGHT_HANDED; * * @see NormalMapSpace */ public function get normalMapSpace():int { return _normalMapSpace; } /** * @private */ public function set normalMapSpace(value:int):void { if (value != NormalMapSpace.TANGENT_RIGHT_HANDED && value != NormalMapSpace.TANGENT_LEFT_HANDED && value != NormalMapSpace.OBJECT) { throw new ArgumentError(""Value must be a constant from the NormalMapSpace class""); } _normalMapSpace = value; } public function get waterMode():int { return _waterMode; } public function set waterMode(value:int):void { _waterMode = value; _useWaterMode = value; } /** * Specular map. */ public var specularMap:TextureResource; /** * Glossiness map. */ public var glossinessMap:TextureResource; /** * Light map. */ public var lightMap:TextureResource; /** * Number of the UV-channel for light map. */ public var lightMapChannel:uint = 0; /** * Glossiness. Multiplies with glossinessMap value. */ public var glossiness:Number = 100; /** * Brightness of a flare. Multiplies with specularMap value. */ public var specularPower:Number = 1; public var mistMap:TextureResource; // a fog of war texture public var forceRenderPriority:int = -1; /** * Creates a new StandardTerrainMaterial instance. * @param diffuseMap Diffuse map. * @param normalMap Normal map. * @param specularMap Specular map. * @param glossinessMap Glossiness map. * @param opacityMap Opacity map. */ public function StandardTerrainMaterial(diffuseMap:TextureResource = null, normalMap:TextureResource = null, specularMap:TextureResource = null, glossinessMap:TextureResource = null, opacityMap:TextureResource = null) { super(diffuseMap, opacityMap); this.normalMap = normalMap; this.specularMap = specularMap; this.glossinessMap = glossinessMap; } /** * @private */ override alternativa3d function fillResources(resources:Dictionary, resourceType:Class):void { super.fillResources(resources, resourceType); if (normalMap != null && A3DUtils.checkParent(getDefinitionByName(getQualifiedClassName(normalMap)) as Class, resourceType)) { resources[normalMap] = true; } if (mistMap != null && A3DUtils.checkParent(getDefinitionByName(getQualifiedClassName(mistMap)) as Class, resourceType)) { resources[mistMap] = true; } if (lightMap != null && A3DUtils.checkParent(getDefinitionByName(getQualifiedClassName(lightMap)) as Class, resourceType)) { resources[lightMap] = true; } if (glossinessMap != null && A3DUtils.checkParent(getDefinitionByName(getQualifiedClassName(glossinessMap)) as Class, resourceType)) { resources[glossinessMap] = true; } if (specularMap != null && A3DUtils.checkParent(getDefinitionByName(getQualifiedClassName(specularMap)) as Class, resourceType)) { resources[specularMap] = true; } } /** * @private */ alternativa3d function getPassUVProcedure():Procedure { return _passUVProcedure; } /** * @private */ alternativa3d function setPassUVProcedureConstants(destination:DrawUnit, vertexLinker:Linker):void { } // inputs: tNormal"", ""tViewVector"", ""shadow"", ""cAmbientColor"" // outputs : light, hightlight private function formDirectionalProcedure(procedure:Procedure, index:int, useShadow:Boolean):void { var source:Array = [ // Position - dirction vector of light ""#c0=c"" + index + ""Position"", ""#c1=c"" + index + ""Color"", // Calculate half-way vector ""add t0.xyz, i1.xyz, c0.xyz"", ""mov t0.w, c0.w"", ""nrm t0.xyz,t0.xyz"", // Calculate a flare ""dp3 t0.w, t0.xyz, i0.xyz"", ""pow t0.w, t0.w, o1.w"", // Calculate light ""dp3 t0.x, i0.xyz, c0.xyz"", ""sat t0.x, t0.x"" ]; if (useShadow) { source.push(""mul t0.xw, t0.xw, i2.x""); source.push(""mul t0.xyz, c1.xyz, t0.xxx""); source.push(""add o0.xyz, t0.xyz, i3.xyz""); source.push(""mul o1.xyz, c1.xyz, t0.www""); } else { // Apply calculated values source.push(""mul t0.xyz, c1.xyz, t0.xxxx""); source.push(""add o0, o0, t0.xyz""); source.push(""mul t0.xyz, c1.xyz, t0.w""); source.push(""add o1.xyz, o1.xyz, t0.xyz""); } procedure.compileFromArray(source); } private function formOmniProcedure(procedure:Procedure, index:int, useShadow:Boolean):void { // fragmentLinker.setInputParams(omniMulShadowProcedure, ""tNormal"", ""tViewVector"", ""tTotalLight"", ""cAmbientColor""); var source:Array = [ ""#c0=c"" + index + ""Position"", ""#c1=c"" + index + ""Color"", ""#c2=c"" + index + ""Radius"", ""#v0=vPosition"" ]; if (useShadow) { // Считаем вектор из точки к свету source.push(""sub t0, c0, v0""); // L = lightPos - PointPos source.push(""dp3 t0.w, t0.xyz, t0.xyz""); // lenSqr source.push(""nrm t0.xyz, t0.xyz""); // L = normalize(L) // Считаем half-way вектор source.push(""add t1.xyz, i1.xyz, t0.xyz""); source.push(""nrm t1.xyz, t1.xyz""); // Считаем блик source.push(""dp3 t1.w, t1.xyz, i0.xyz""); source.push(""pow t1.w, t1.w, o1.w""); // Считаем расстояние до источника света source.push(""sqt t1.x, t0.w""); // len = sqt(lensqr) // Считаем свет source.push(""dp3 t0.w, t0.xyz, i0.xyz""); // dot = dot(normal, L) // Считаем затухание source.push(""sub t0.x, t1.x, c2.z""); // len = len - atenuationBegin source.push(""div t0.y, t0.x, c2.y""); // att = len/radius source.push(""sub t0.x, c2.x, t0.y""); // att = 1 - len/radius source.push(""sat t0.xw, t0.xw""); // t = max(t, 0) // i3 - ambient // i2 - shadow-test source.push(""mul t0.xw, t0.xwww, i2.xxxx""); source.push(""mul t0.xyz, c1.xyz, t0.xxx""); // t = color*t source.push(""mul t1.xyz, t0.xyz, t1.w""); source.push(""add o1.xyz, o1.xyz, t1.xyz""); source.push(""mul t0.xyz, t0.xyz, t0.www""); source.push(""add o0.xyz, t0.xyz, i3.xyz""); } else { // Считаем вектор из точки к свету source.push(""sub t0, c0, v0""); // L = lightPos - PointPos source.push(""dp3 t0.w, t0.xyz, t0.xyz""); // lenSqr source.push(""nrm t0.xyz, t0.xyz""); // L = normalize(L) // Считаем half-way вектор source.push(""add t1.xyz, i1.xyz, t0.xyz""); source.push(""mov t1.w, c0.w""); source.push(""nrm t1.xyz, t1.xyz""); // Считаем блик source.push(""dp3 t1.w, t1.xyz, i0.xyz""); source.push(""pow t1.w, t1.w, o1.w""); //!!! // Считаем расстояние до источника света source.push(""sqt t1.x, t0.w""); // len = sqt(lensqr) // Считаем свет source.push(""dp3 t0.w, t0.xyz, i0.xyz""); // dot = dot(normal, L) // Считаем затухание source.push(""sub t0.x, t1.x, c2.z""); // len = len - atenuationBegin source.push(""div t0.y, t0.x, c2.y""); // att = len/radius source.push(""sub t0.x, c2.x, t0.y""); // att = 1 - len/radius source.push(""sat t0.xw, t0.xw""); // t = max(t, 0) // Перемножаем цвет источника с затуханием source.push(""mul t0.xyz, c1.xyz, t0.xxx""); // t = color*t source.push(""mul t1.xyz, t0.xyz, t1.w""); source.push(""add o1.xyz, o1.xyz, t1.xyz""); source.push(""mul t0.xyz, t0.xyz, t0.www""); source.push(""add o0.xyz, o0.xyz, t0.xyz""); } procedure.compileFromArray(source); } /** * @param object * @param materialKey * @param opacityMap * @param alphaTest 0:disabled 1:alpha-test 2:contours * @param lightsGroup * @param directionalLight * @param lightsLength */ private function getProgram(object:Object3D, programs:Array, camera:Camera3D, materialKey:int, opacityMap:TextureResource, alphaTest:int, lightsGroup:Vector., lightsLength:int, isFirstGroup:Boolean, shadowedLight:Light3D):StandardTerrainMaterialProgram { // 0 bit - lightmap // 1 bit - glossiness map // 2 bit - opacity map // 3 bit - specular map // 4-5 bits - normalMapSpace // 6-7 bits - alphaTest // 8-10 bits - OmniLight count // 11-13 bits - DirectionalLight count // 14-16 bits - SpotLight count // 17-18 bit - Shadow Type (PCF, SIMPLE, NONE) var key:uint = materialKey | (opacityMap != null ? OPACITY_MAP_BIT : 0) | (alphaTest << ALPHA_TEST_OFFSET); key |= _useWaterMode > 0 ? WATER_BIT : 0; var program:StandardTerrainMaterialProgram = programs[key]; if (program == null) { var vertexLinker:Linker = new Linker(Context3DProgramType.VERTEX); var fragmentLinker:Linker = new Linker(Context3DProgramType.FRAGMENT); var i:int; if (key & WATER_BIT) fragmentLinker.addProcedure(kilWaterLevel); // Merge program using lightsGroup // add property useShadow fragmentLinker.declareVariable(""tTotalLight""); fragmentLinker.declareVariable(""tTotalHighLight""); fragmentLinker.declareVariable(""tNormal""); if (isFirstGroup){ fragmentLinker.declareVariable(""cAmbientColor"", VariableType.CONSTANT); fragmentLinker.addProcedure(_ambientLightProcedure); fragmentLinker.setInputParams(_ambientLightProcedure, ""cAmbientColor""); fragmentLinker.setOutputParams(_ambientLightProcedure, ""tTotalLight"", ""tTotalHighLight""); if (lightMap != null) { vertexLinker.addProcedure(_passLightMapUVProcedure); fragmentLinker.addProcedure(_addLightMapProcedure); fragmentLinker.setInputParams(_addLightMapProcedure, ""tTotalLight""); fragmentLinker.setOutputParams(_addLightMapProcedure, ""tTotalLight""); } } else{ // сбросить tTotalLight tTotalHighLight fragmentLinker.declareVariable(""cAmbientColor"", VariableType.CONSTANT); fragmentLinker.addProcedure(_ambientLightProcedure); fragmentLinker.setInputParams(_ambientLightProcedure, ""cAmbientColor""); fragmentLinker.setOutputParams(_ambientLightProcedure, ""tTotalLight"", ""tTotalHighLight""); } var positionVar:String = ""aPosition""; var normalVar:String = ""aNormal""; var tangentVar:String = ""aTangent""; vertexLinker.declareVariable(positionVar, VariableType.ATTRIBUTE); vertexLinker.declareVariable(tangentVar, VariableType.ATTRIBUTE); vertexLinker.declareVariable(normalVar, VariableType.ATTRIBUTE); if (object.transformProcedure != null) { positionVar = appendPositionTransformProcedure(object.transformProcedure, vertexLinker); } vertexLinker.addProcedure(_projectProcedure); vertexLinker.setInputParams(_projectProcedure, positionVar); vertexLinker.addProcedure(getPassUVProcedure()); if (glossinessMap != null) { fragmentLinker.addProcedure(_setGlossinessFromTextureProcedure); fragmentLinker.setOutputParams(_setGlossinessFromTextureProcedure, ""tTotalHighLight""); } else { fragmentLinker.addProcedure(_setGlossinessFromConstantProcedure); fragmentLinker.setOutputParams(_setGlossinessFromConstantProcedure, ""tTotalHighLight""); } if (lightsLength > 0 || shadowedLight) { var procedure:Procedure; if (object.deltaTransformProcedure != null) { vertexLinker.declareVariable(""tTransformedNormal""); procedure = object.deltaTransformProcedure.newInstance(); vertexLinker.addProcedure(procedure); vertexLinker.setInputParams(procedure, normalVar); vertexLinker.setOutputParams(procedure, ""tTransformedNormal""); normalVar = ""tTransformedNormal""; vertexLinker.declareVariable(""tTransformedTangent""); procedure = object.deltaTransformProcedure.newInstance(); vertexLinker.addProcedure(procedure); vertexLinker.setInputParams(procedure, tangentVar); vertexLinker.setOutputParams(procedure, ""tTransformedTangent""); tangentVar = ""tTransformedTangent""; } vertexLinker.addProcedure(_passVaryingsProcedure); vertexLinker.setInputParams(_passVaryingsProcedure, positionVar); fragmentLinker.declareVariable(""tViewVector""); if (_normalMapSpace == NormalMapSpace.TANGENT_RIGHT_HANDED || _normalMapSpace == NormalMapSpace.TANGENT_LEFT_HANDED) { var nrmProcedure:Procedure = (_normalMapSpace == NormalMapSpace.TANGENT_RIGHT_HANDED) ? _passTBNRightProcedure : _passTBNLeftProcedure; vertexLinker.addProcedure(nrmProcedure); vertexLinker.setInputParams(nrmProcedure, tangentVar, normalVar); fragmentLinker.addProcedure(_getNormalAndViewTangentProcedure); fragmentLinker.setOutputParams(_getNormalAndViewTangentProcedure, ""tNormal"", ""tViewVector""); } else { fragmentLinker.addProcedure(_getNormalAndViewObjectProcedure); fragmentLinker.setOutputParams(_getNormalAndViewObjectProcedure, ""tNormal"", ""tViewVector""); } if (shadowedLight != null) { var shadowProc:Procedure; if (shadowedLight is DirectionalLight){ vertexLinker.addProcedure(shadowedLight.shadow.vertexShadowProcedure, positionVar); shadowProc = shadowedLight.shadow.fragmentShadowProcedure; fragmentLinker.addProcedure(shadowProc); fragmentLinker.setOutputParams(shadowProc, ""tTotalLight""); var dirMulShadowProcedure:Procedure = new Procedure(null, ""lightShadowDirectional""); formDirectionalProcedure(dirMulShadowProcedure, 0, true); fragmentLinker.addProcedure(dirMulShadowProcedure); fragmentLinker.setInputParams(dirMulShadowProcedure, ""tNormal"", ""tViewVector"", ""tTotalLight"", ""cAmbientColor""); fragmentLinker.setOutputParams(dirMulShadowProcedure, ""tTotalLight"", ""tTotalHighLight""); } if (shadowedLight is OmniLight){ vertexLinker.addProcedure(shadowedLight.shadow.vertexShadowProcedure, positionVar); shadowProc = shadowedLight.shadow.fragmentShadowProcedure; fragmentLinker.addProcedure(shadowProc); fragmentLinker.setOutputParams(shadowProc, ""tTotalLight""); var omniMulShadowProcedure:Procedure = new Procedure(null, ""lightShadowDirectional""); formOmniProcedure(omniMulShadowProcedure, 0, true); fragmentLinker.addProcedure(omniMulShadowProcedure); fragmentLinker.setInputParams(omniMulShadowProcedure, ""tNormal"", ""tViewVector"", ""tTotalLight"", ""cAmbientColor""); fragmentLinker.setOutputParams(omniMulShadowProcedure, ""tTotalLight"", ""tTotalHighLight""); } } for (i = 0; i < lightsLength; i++) { var light:Light3D = lightsGroup[i]; if (light == shadowedLight && (shadowedLight is DirectionalLight || shadowedLight is OmniLight)) continue; var lightFragmentProcedure:Procedure = new Procedure(); lightFragmentProcedure.name = ""light"" + i.toString(); if (light is DirectionalLight) { formDirectionalProcedure(lightFragmentProcedure, i, false); lightFragmentProcedure.name += ""Directional""; } else if (light is OmniLight) { formOmniProcedure(lightFragmentProcedure, i, false); lightFragmentProcedure.name += ""Omni""; } else if (light is SpotLight) { lightFragmentProcedure.compileFromArray([ ""#c0=c"" + i + ""Position"", ""#c1=c"" + i + ""Color"", ""#c2=c"" + i + ""Radius"", ""#c3=c"" + i + ""Axis"", ""#v0=vPosition"", // Calculate vector from the point to light ""sub t0, c0, v0"",// L = pos - lightPos ""dp3 t0.w, t0, t0"",// lenSqr ""nrm t0.xyz,t0.xyz"",// L = normalize(L) // Calculate half-way vector ""add t2.xyz, i1.xyz, t0.xyz"", ""nrm t2.xyz, t2.xyz"", //Calculate a flare ""dp3 t2.x, t2.xyz, i0.xyz"", ""pow t2.x, t2.x, o1.w"", ""dp3 t1.x, t0.xyz, c3.xyz"", //axisDirDot ""dp3 t0.x, t0, i0.xyz"",// dot = dot(normal, L) ""sqt t0.w, t0.w"",// len = sqt(lensqr) ""sub t0.w, t0.w, c2.y"",// len = len - atenuationBegin ""div t0.y, t0.w, c2.x"",// att = len/radius ""sub t0.w, c0.w, t0.y"",// att = 1 - len/radius ""sub t0.y, t1.x, c2.w"", ""div t0.y, t0.y, c2.z"", ""sat t0.xyw,t0.xyw"",// t = sat(t) ""mul t1.xyz,c1.xyz,t0.yyy"",// t = color*t ""mul t1.xyz,t1.xyz,t0.www"",// ""mul t2.xyz, t2.x, t1.xyz"", ""add o1.xyz, o1.xyz, t2.xyz"", ""mul t1.xyz, t1.xyz, t0.xxx"", ""add o0.xyz, o0.xyz, t1.xyz"" ]); lightFragmentProcedure.name += ""Spot""; } fragmentLinker.addProcedure(lightFragmentProcedure); fragmentLinker.setInputParams(lightFragmentProcedure, ""tNormal"", ""tViewVector""); fragmentLinker.setOutputParams(lightFragmentProcedure, ""tTotalLight"", ""tTotalHighLight""); } } var outputProcedure:Procedure; if (specularMap != null) { fragmentLinker.addProcedure(_applySpecularProcedure); fragmentLinker.setOutputParams(_applySpecularProcedure, ""tTotalHighLight""); outputProcedure = _applySpecularProcedure; } fragmentLinker.declareVariable(""tColor""); outputProcedure = opacityMap != null ? getDiffuseOpacityProcedure : getDiffuseProcedure; fragmentLinker.addProcedure(outputProcedure); fragmentLinker.setOutputParams(outputProcedure, ""tColor""); if (alphaTest > 0) { outputProcedure = alphaTest == 1 ? thresholdOpaqueAlphaProcedure : thresholdTransparentAlphaProcedure; fragmentLinker.addProcedure(outputProcedure, ""tColor""); fragmentLinker.setOutputParams(outputProcedure, ""tColor""); } fragmentLinker.addProcedure(_mulLightingProcedure, ""tColor"", ""tTotalLight"", ""tTotalHighLight""); if (mistMap != null) { fragmentLinker.addProcedure( fogMode !=0 ? applyWithMistProcedure : outputWithMistProcedure, ""tColor""); } ///* if (fogMode == SIMPLE || fogMode == ADVANCED || mistMap!=null ) { fragmentLinker.setOutputParams(_mulLightingProcedure, ""tColor""); } if (fogMode == SIMPLE) { vertexLinker.addProcedure(passSimpleFogConstProcedure); vertexLinker.setInputParams(passSimpleFogConstProcedure, positionVar); fragmentLinker.addProcedure(outputWithSimpleFogProcedure); fragmentLinker.setInputParams(outputWithSimpleFogProcedure, ""tColor""); outputProcedure = outputWithSimpleFogProcedure; } else if (fogMode == ADVANCED) { vertexLinker.declareVariable(""tProjected""); vertexLinker.setOutputParams(_projectProcedure, ""tProjected""); vertexLinker.addProcedure(postPassAdvancedFogConstProcedure); vertexLinker.setInputParams(postPassAdvancedFogConstProcedure, positionVar, ""tProjected""); fragmentLinker.addProcedure(outputWithAdvancedFogProcedure); fragmentLinker.setInputParams(outputWithAdvancedFogProcedure, ""tColor""); outputProcedure = outputWithAdvancedFogProcedure; } // */ fragmentLinker.varyings = vertexLinker.varyings; program = new StandardTerrainMaterialProgram(vertexLinker, fragmentLinker, (shadowedLight != null) ? 1 : lightsLength); program.upload(camera.context3D); programs[key] = program; } return program; } private function addDrawUnits(program:StandardTerrainMaterialProgram, camera:Camera3D, surface:Surface, geometry:Geometry, opacityMap:TextureResource, lights:Vector., lightsLength:int, isFirstGroup:Boolean, shadowedLight:Light3D, opaqueOption:Boolean, transparentOption:Boolean, objectRenderPriority:int):void { // Buffers var positionBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.POSITION); var uvBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.TEXCOORDS[0]); var normalsBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.NORMAL); var tangentsBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.TANGENT4); if (positionBuffer == null || uvBuffer == null) return; //if ((lightsLength > 0 || shadowedLight != null) && (normalsBuffer == null || tangentsBuffer == null)) return; var object:Object3D = surface.object; // Draw call var drawUnit:DrawUnit = camera.renderer.createDrawUnit(object, program.program, geometry._indexBuffer, surface.indexBegin, surface.numTriangles, program); // Streams drawUnit.setVertexBufferAt(program.aPosition, positionBuffer, geometry._attributesOffsets[VertexAttributes.POSITION], VertexAttributes.FORMATS[VertexAttributes.POSITION]); drawUnit.setVertexBufferAt(program.aUV, uvBuffer, geometry._attributesOffsets[VertexAttributes.TEXCOORDS[0]], VertexAttributes.FORMATS[VertexAttributes.TEXCOORDS[0]]); // Constants object.setTransformConstants(drawUnit, surface, program.vertexShader, camera); drawUnit.setProjectionConstants(camera, program.cProjMatrix, object.localToCameraTransform); // Set options for a surface. X should be 0. drawUnit.setFragmentConstantsFromNumbers(program.cSurface, 0, glossiness, specularPower, 1); drawUnit.setFragmentConstantsFromNumbers(program.cThresholdAlpha, alphaThreshold, 0, 0, alpha); if (_useWaterMode > 0) drawUnit.setFragmentConstantsFromNumbers(program.cWater, 0, 0, waterLevel, 1); var light:Light3D; var len:Number; var transform:Transform3D; var rScale:Number; var omni:OmniLight; var spot:SpotLight; var falloff:Number; var hotspot:Number; if (lightsLength > 0 || shadowedLight != null) { if (_normalMapSpace == NormalMapSpace.TANGENT_RIGHT_HANDED || _normalMapSpace == NormalMapSpace.TANGENT_LEFT_HANDED) { drawUnit.setVertexBufferAt(program.aNormal, normalsBuffer, geometry._attributesOffsets[VertexAttributes.NORMAL], VertexAttributes.FORMATS[VertexAttributes.NORMAL]); drawUnit.setVertexBufferAt(program.aTangent, tangentsBuffer, geometry._attributesOffsets[VertexAttributes.TANGENT4], VertexAttributes.FORMATS[VertexAttributes.TANGENT4]); } drawUnit.setTextureAt(program.sBump, normalMap._texture); var camTransform:Transform3D = object.cameraToLocalTransform; drawUnit.setVertexConstantsFromNumbers(program.cCameraPosition, camTransform.d, camTransform.h, camTransform.l); for (var i:int = 0; i < lightsLength; i++) { light = lights[i]; if (light is DirectionalLight) { transform = light.lightToObjectTransform; len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], -transform.c/len, -transform.g/len, -transform.k/len, 1); drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue); } else if (light is OmniLight) { omni = light as OmniLight; transform = light.lightToObjectTransform; rScale = Math.sqrt(transform.a*transform.a + transform.e*transform.e + transform.i*transform.i); rScale += Math.sqrt(transform.b*transform.b + transform.f*transform.f + transform.j*transform.j); rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); rScale /= 3; drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[i], 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale); drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue); } else if (light is SpotLight) { spot = light as SpotLight; transform = light.lightToObjectTransform; rScale = Math.sqrt(transform.a*transform.a + transform.e*transform.e + transform.i*transform.i); rScale += Math.sqrt(transform.b*transform.b + transform.f*transform.f + transform.j*transform.j); rScale += len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); rScale /= 3; falloff = Math.cos(spot.falloff*0.5); hotspot = Math.cos(spot.hotspot*0.5); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cAxis[i], -transform.c/len, -transform.g/len, -transform.k/len); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[i], spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff); drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue); } } } if (shadowedLight != null) { light = shadowedLight; if (light is DirectionalLight) { transform = light.lightToObjectTransform; len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], -transform.c/len, -transform.g/len, -transform.k/len, 1); drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue); } else if (light is OmniLight) { omni = light as OmniLight; transform = light.lightToObjectTransform; rScale = Math.sqrt(transform.a*transform.a + transform.e*transform.e + transform.i*transform.i); rScale += Math.sqrt(transform.b*transform.b + transform.f*transform.f + transform.j*transform.j); rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); rScale /= 3; drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[0], 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale); drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue); } else if (light is SpotLight) { spot = light as SpotLight; transform = light.lightToObjectTransform; rScale = Math.sqrt(transform.a*transform.a + transform.e*transform.e + transform.i*transform.i); rScale += Math.sqrt(transform.b*transform.b + transform.f*transform.f + transform.j*transform.j); rScale += len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); rScale /= 3; falloff = Math.cos(spot.falloff*0.5); hotspot = Math.cos(spot.hotspot*0.5); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cAxis[0], -transform.c/len, -transform.g/len, -transform.k/len); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[0], spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff); drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue); } } // Textures drawUnit.setTextureAt(program.sDiffuse, diffuseMap._texture); if (opacityMap != null) { drawUnit.setTextureAt(program.sOpacity, opacityMap._texture); } if (glossinessMap != null) { drawUnit.setTextureAt(program.sGlossiness, glossinessMap._texture); } if (specularMap != null) { drawUnit.setTextureAt(program.sSpecular, specularMap._texture); } if (isFirstGroup) { if (lightMap != null) { drawUnit.setVertexBufferAt(program.aUV1, geometry.getVertexBuffer(VertexAttributes.TEXCOORDS[lightMapChannel]), geometry._attributesOffsets[VertexAttributes.TEXCOORDS[lightMapChannel]], Context3DVertexBufferFormat.FLOAT_2); drawUnit.setFragmentConstantsFromNumbers(program.cAmbientColor, 0,0,0, 1); drawUnit.setTextureAt(program.sLightMap, lightMap._texture); } else { drawUnit.setFragmentConstantsFromVector(program.cAmbientColor, camera.ambient, 1); } } else{ drawUnit.setFragmentConstantsFromNumbers(program.cAmbientColor, 0,0,0, 1); } setPassUVProcedureConstants(drawUnit, program.vertexShader); if (shadowedLight != null && ((shadowedLight is DirectionalLight)||(shadowedLight is OmniLight))) { shadowedLight.shadow.setup(drawUnit, program.vertexShader, program.fragmentShader, surface); } // Inititalizing render properties if (opaqueOption) { // Use z-buffer within DrawCall, draws without blending if (isFirstGroup){ drawUnit.blendSource = Context3DBlendFactor.ONE; drawUnit.blendDestination = Context3DBlendFactor.ZERO; camera.renderer.addDrawUnit(drawUnit, objectRenderPriority >= 0 ? objectRenderPriority : Renderer.OPAQUE); } else{ drawUnit.blendSource = Context3DBlendFactor.ONE; drawUnit.blendDestination = Context3DBlendFactor.ONE; camera.renderer.addDrawUnit(drawUnit, objectRenderPriority >= 0 ? objectRenderPriority : Renderer.OPAQUE_OVERHEAD); } } if (transparentOption){ // Do not use z-buffer, draws with blending if (isFirstGroup){ drawUnit.blendSource = Context3DBlendFactor.SOURCE_ALPHA; drawUnit.blendDestination = Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA; } else{ drawUnit.blendSource = Context3DBlendFactor.SOURCE_ALPHA; drawUnit.blendDestination = Context3DBlendFactor.ONE; } camera.renderer.addDrawUnit(drawUnit, objectRenderPriority >= 0 ? objectRenderPriority : Renderer.TRANSPARENT_SORT); } ///* if (fogMode == SIMPLE || fogMode == ADVANCED) { var lm:Transform3D = object.localToCameraTransform; var dist:Number = fogFar - fogNear; drawUnit.setVertexConstantsFromNumbers(program.vertexShader.getVariableIndex(""cFogSpace""), lm.i/dist, lm.j/dist, lm.k/dist, (lm.l - fogNear)/dist); drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex(""cFogRange""), fogMaxDensity, 1, 0, 1 - fogMaxDensity); } if (fogMode == SIMPLE || mistMap != null) { drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex(""cFogColor""), fogColorR, fogColorG, fogColorB, 1); } if (mistMap != null) drawUnit.setTextureAt(program.fragmentShader.getVariableIndex(""sMist""), mistMap._texture); if (fogMode == ADVANCED) { if (fogTexture == null) { var bmd:BitmapData = new BitmapData(32, 1, false, 0xFF0000); for (i = 0; i < 32; i++) { bmd.setPixel(i, 0, ((i/32)*255) << 16); } fogTexture = new BitmapTextureResource(bmd); fogTexture.upload(camera.context3D); } var cLocal:Transform3D = camera.localToGlobalTransform; var halfW:Number = camera.view.width/2; var leftX:Number = -halfW*cLocal.a + camera.focalLength*cLocal.c; var leftY:Number = -halfW*cLocal.e + camera.focalLength*cLocal.g; var rightX:Number = halfW*cLocal.a + camera.focalLength*cLocal.c; var rightY:Number = halfW*cLocal.e + camera.focalLength*cLocal.g; // Finding UV var angle:Number = (Math.atan2(leftY, leftX) - Math.PI/2); if (angle < 0) angle += Math.PI*2; var dx:Number = rightX - leftX; var dy:Number = rightY - leftY; var lens:Number = Math.sqrt(dx*dx + dy*dy); leftX /= lens; leftY /= lens; rightX /= lens; rightY /= lens; var uScale:Number = Math.acos(leftX*rightX + leftY*rightY)/Math.PI/2; var uRight:Number = angle/Math.PI/2; drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex(""cFogConsts""), 0.5*uScale, 0.5 - uRight, 0); drawUnit.setTextureAt(program.fragmentShader.getVariableIndex(""sFogTexture""), fogTexture._texture); } //*/ } private static var lightGroup:Vector. = new Vector.(); private static var shadowGroup:Vector. = new Vector.(); /** * @private */ override alternativa3d function collectDraws(camera:Camera3D, surface:Surface, geometry:Geometry, lights:Vector., lightsLength:int, useShadow:Boolean, objectRenderPriority:int = -1):void { if (diffuseMap == null || normalMap == null || diffuseMap._texture == null || normalMap._texture == null) return; // Check if textures uploaded in to the context. if (opacityMap != null && opacityMap._texture == null || glossinessMap != null && glossinessMap._texture == null || specularMap != null && specularMap._texture == null || lightMap != null && lightMap._texture == null) return; objectRenderPriority = forceRenderPriority < 0 ? objectRenderPriority : forceRenderPriority; if (camera.context3DProperties.isConstrained) { // fallback to simpler material if (lightMap == null) { fallbackTextureMaterial.diffuseMap = diffuseMap; fallbackTextureMaterial.opacityMap = opacityMap; fallbackTextureMaterial.alphaThreshold = alphaThreshold; fallbackTextureMaterial.alpha = alpha; fallbackTextureMaterial.opaquePass = opaquePass; fallbackTextureMaterial.transparentPass = transparentPass; fallbackTextureMaterial.collectDraws(camera, surface, geometry, lights, lightsLength, useShadow, objectRenderPriority); } else { fallbackLightMapMaterial.diffuseMap = diffuseMap; fallbackLightMapMaterial.lightMap = lightMap; fallbackLightMapMaterial.lightMapChannel = lightMapChannel; fallbackLightMapMaterial.opacityMap = opacityMap; fallbackLightMapMaterial.alphaThreshold = alphaThreshold; fallbackLightMapMaterial.alpha = alpha; fallbackLightMapMaterial.opaquePass = opaquePass; fallbackLightMapMaterial.transparentPass = transparentPass; fallbackLightMapMaterial.collectDraws(camera, surface, geometry, lights, lightsLength, useShadow, objectRenderPriority); } return; } var object:Object3D = surface.object; // Buffers var positionBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.POSITION); var uvBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.TEXCOORDS[0]); var normalsBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.NORMAL); var tangentsBuffer:VertexBuffer3D = geometry.getVertexBuffer(VertexAttributes.TANGENT4); if (positionBuffer == null || uvBuffer == null) return; var i:int; var light:Light3D; if (lightsLength > 0 && (_normalMapSpace == NormalMapSpace.TANGENT_RIGHT_HANDED || _normalMapSpace == NormalMapSpace.TANGENT_LEFT_HANDED)) { if (normalsBuffer == null || tangentsBuffer == null) return; } // Refresh programs for this context. if (camera.context3D != cachedContext3D) { cachedContext3D = camera.context3D; programsCache = caches[cachedContext3D]; if (programsCache == null) { programsCache = new Dictionary(false); caches[cachedContext3D] = programsCache; } } var optionsPrograms:Array = programsCache[object.transformProcedure]; if (optionsPrograms == null) { optionsPrograms = []; programsCache[object.transformProcedure] = optionsPrograms; } // Form groups of lights var groupsCount:int = 0; var lightGroupLength:int = 0; var shadowGroupLength:int = 0; for (i = 0; i < lightsLength; i++) { light = lights[i]; if (light.shadow != null && useShadow) { shadowGroup[int(shadowGroupLength++)] = light; } else { if (lightGroupLength == 6) { groups[int(groupsCount++)] = lightGroup; lightGroup = new Vector.(); lightGroupLength = 0; } lightGroup[int(lightGroupLength++)] = light; } } if (lightGroupLength != 0) { groups[int(groupsCount++)] = lightGroup; } // Iterate groups var materialKey:int; var program:StandardTerrainMaterialProgram; if (groupsCount == 0 && shadowGroupLength == 0) { // There is only Ambient light on the scene // Form key materialKey = ((lightMap != null) ? LIGHT_MAP_BIT : 0) | ((glossinessMap != null) ? GLOSSINESS_MAP_BIT : 0) | ((specularMap != null) ? SPECULAR_MAP_BIT : 0); if (opaquePass && alphaThreshold <= alpha) { if (alphaThreshold > 0) { // Alpha test // use opacityMap if it is presented program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 1, null, 0, true, null); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, true, false, objectRenderPriority); } else { // do not use opacityMap at all program = getProgram(object, optionsPrograms, camera, materialKey, null, 0, null, 0, true, null); addDrawUnits(program, camera, surface, geometry, null, null, 0, true, null, true, false, objectRenderPriority); } } // Transparent pass if (transparentPass && alphaThreshold > 0 && alpha > 0) { // use opacityMap if it is presented if (alphaThreshold <= alpha && !opaquePass) { // Alpha threshold program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 2, null, 0, true, null); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, false, true, objectRenderPriority); } else { // There is no Alpha threshold or check z-buffer by previous pass program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 0, null, 0, true, null); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, false, true, objectRenderPriority); } } } else { var j:int; var isFirstGroup:Boolean = true; for (i = 0; i < groupsCount; i++) { lightGroup = groups[i]; lightGroupLength = lightGroup.length; // Group of lights without shadow // Form key materialKey = (isFirstGroup) ? ((lightMap != null) ? LIGHT_MAP_BIT : 0) : 0; materialKey |= (_normalMapSpace << NORMAL_MAP_SPACE_OFFSET) | ((glossinessMap != null) ? GLOSSINESS_MAP_BIT : 0) | ((specularMap != null) ? SPECULAR_MAP_BIT : 0); var omniLightCount:int = 0; var directionalLightCount:int = 0; var spotLightCount:int = 0; for (j = 0; j < lightGroupLength; j++) { light = lightGroup[j]; if (light is OmniLight) omniLightCount++; else if (light is DirectionalLight) directionalLightCount++; else if (light is SpotLight) spotLightCount++; } materialKey |= omniLightCount << OMNI_LIGHT_OFFSET; materialKey |= directionalLightCount << DIRECTIONAL_LIGHT_OFFSET; materialKey |= spotLightCount << SPOT_LIGHT_OFFSET; // Create program and drawUnit for group // Opaque pass if (opaquePass && alphaThreshold <= alpha) { if (alphaThreshold > 0) { // Alpha test // use opacityMap if it is presented program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 1, lightGroup, lightGroupLength, isFirstGroup, null); addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, true, false, objectRenderPriority); } else { // do not use opacityMap at all program = getProgram(object, optionsPrograms, camera, materialKey, null, 0, lightGroup, lightGroupLength, isFirstGroup, null); addDrawUnits(program, camera, surface, geometry, null, lightGroup, lightGroupLength, isFirstGroup, null, true, false, objectRenderPriority); } } // Transparent pass if (transparentPass && alphaThreshold > 0 && alpha > 0) { // use opacityMap if it is presented if (alphaThreshold <= alpha && !opaquePass) { // Alpha threshold program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 2, lightGroup, lightGroupLength, isFirstGroup, null); addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, false, true, objectRenderPriority); } else { // There is no Alpha threshold or check z-buffer by previous pass program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 0, lightGroup, lightGroupLength, isFirstGroup, null); addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, false, true, objectRenderPriority); } } isFirstGroup = false; lightGroup.length = 0; } if (shadowGroupLength > 0) { // Group of ligths with shadow // For each light we will create new drawUnit for (j = 0; j < shadowGroupLength; j++) { light = shadowGroup[j]; // Form key materialKey = (isFirstGroup) ? ((lightMap != null) ? LIGHT_MAP_BIT : 0) : 0; materialKey |= (_normalMapSpace << NORMAL_MAP_SPACE_OFFSET) | ((glossinessMap != null) ? GLOSSINESS_MAP_BIT : 0) | ((specularMap != null) ? SPECULAR_MAP_BIT : 0); materialKey |= light.shadow.type << SHADOW_OFFSET; if (light is OmniLight) materialKey |= 1 << OMNI_LIGHT_OFFSET; else if (light is DirectionalLight) materialKey |= 1 << DIRECTIONAL_LIGHT_OFFSET; else if (light is SpotLight) materialKey |= 1 << SPOT_LIGHT_OFFSET; // Для группы создаем программу и дроуюнит // Opaque pass if (opaquePass && alphaThreshold <= alpha) { if (alphaThreshold > 0) { // Alpha test // use opacityMap if it is presented program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 1, null, 0, isFirstGroup, light); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, true, false, objectRenderPriority); } else { // do not use opacityMap at all program = getProgram(object, optionsPrograms, camera, materialKey, null, 0, null, 0, isFirstGroup, light); addDrawUnits(program, camera, surface, geometry, null, null, 0, isFirstGroup, light, true, false, objectRenderPriority); } } // Transparent pass if (transparentPass && alphaThreshold > 0 && alpha > 0) { // use opacityMap if it is presented if (alphaThreshold <= alpha && !opaquePass) { // Alpha threshold program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 2, null, 0, isFirstGroup, light); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, false, true, objectRenderPriority); } else { // There is no Alpha threshold or check z-buffer by previous pass program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 0, null, 0, isFirstGroup, light); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, false, true, objectRenderPriority); } } isFirstGroup = false; } } shadowGroup.length = 0; } groups.length = 0; } /** * @inheritDoc */ override public function clone():Material { var res:StandardTerrainMaterial = new StandardTerrainMaterial(diffuseMap, normalMap, specularMap, glossinessMap, opacityMap); res.clonePropertiesFrom(this); return res; } /* INTERFACE alternterrain.materials.ILODTerrainMaterial */ public function visit(cd:QuadChunkCornerData, root:QuadTreePage, patchShift:int, lookupIndex:int):void { _useWaterMode = _waterMode > 0 ? cd.Square.MinY < waterLevel ? _waterMode : 0 : 0; } /** * @inheritDoc */ override protected function clonePropertiesFrom(source:Material):void { super.clonePropertiesFrom(source); var sMaterial:StandardTerrainMaterial = StandardTerrainMaterial(source); glossiness = sMaterial.glossiness; specularPower = sMaterial.specularPower; _normalMapSpace = sMaterial._normalMapSpace; lightMap = sMaterial.lightMap; lightMapChannel = sMaterial.lightMapChannel; } } } import alternativa.engine3d.materials.ShaderProgram; import alternativa.engine3d.materials.compiler.Linker; import flash.display3D.Context3D; class StandardTerrainMaterialProgram extends ShaderProgram { public var aPosition:int = -1; public var aUV:int = -1; public var aUV1:int = -1; public var aNormal:int = -1; public var aTangent:int = -1; public var cProjMatrix:int = -1; public var cCameraPosition:int = -1; public var cAmbientColor:int = -1; public var cSurface:int = -1; public var cThresholdAlpha:int = -1; public var sDiffuse:int = -1; public var sOpacity:int = -1; public var sBump:int = -1; public var sGlossiness:int = -1; public var sSpecular:int = -1; public var sLightMap:int = -1; public var cWater:int = -1; public var cPosition:Vector.; public var cRadius:Vector.; public var cAxis:Vector.; public var cColor:Vector.; public function StandardTerrainMaterialProgram(vertex:Linker, fragment:Linker, numLigths:int) { super(vertex, fragment); cPosition = new Vector.(numLigths); cRadius = new Vector.(numLigths); cAxis = new Vector.(numLigths); cColor = new Vector.(numLigths); } override public function upload(context3D:Context3D):void { super.upload(context3D); aPosition = vertexShader.findVariable(""aPosition""); aUV = vertexShader.findVariable(""aUV""); aUV1 = vertexShader.findVariable(""aUV1""); aNormal = vertexShader.findVariable(""aNormal""); aTangent = vertexShader.findVariable(""aTangent""); cProjMatrix = vertexShader.findVariable(""cProjMatrix""); cCameraPosition = vertexShader.findVariable(""cCameraPosition""); cAmbientColor = fragmentShader.findVariable(""cAmbientColor""); cSurface = fragmentShader.findVariable(""cSurface""); cThresholdAlpha = fragmentShader.findVariable(""cThresholdAlpha""); cWater = fragmentShader.findVariable(""cWater""); sDiffuse = fragmentShader.findVariable(""sDiffuse""); sOpacity = fragmentShader.findVariable(""sOpacity""); sBump = fragmentShader.findVariable(""sBump""); sGlossiness = fragmentShader.findVariable(""sGlossiness""); sSpecular = fragmentShader.findVariable(""sSpecular""); sLightMap = fragmentShader.findVariable(""sLightMap""); var count:int = cPosition.length; for (var i:int = 0; i < count; i++) { cPosition[i] = fragmentShader.findVariable(""c"" + i + ""Position""); cRadius[i] = fragmentShader.findVariable(""c"" + i + ""Radius""); cAxis[i] = fragmentShader.findVariable(""c"" + i + ""Axis""); cColor[i] = fragmentShader.findVariable(""c"" + i + ""Color""); } } } ",16317,True,2777.1941269890926,median "//////////////////////////////////////////////////////////////////////////////// // // ADOBE SYSTEMS INCORPORATED // Copyright 2003-2007 Adobe Systems Incorporated // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// package flexlib.baseClasses { import flash.display.DisplayObject; import flash.events.Event; import flash.events.FocusEvent; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.geom.Rectangle; import flash.ui.Keyboard; import flexlib.containers.accordionClasses.AccordionHeader; import mx.automation.IAutomationObject; import mx.controls.Button; import mx.core.ClassFactory; import mx.core.ComponentDescriptor; import mx.core.Container; import mx.core.ContainerCreationPolicy; import mx.core.EdgeMetrics; import mx.core.FlexVersion; import mx.core.IDataRenderer; import mx.core.IFactory; import mx.core.IInvalidating; import mx.core.INavigatorContent; import mx.core.IUIComponent; import mx.core.ScrollPolicy; import mx.core.UIComponent; import mx.core.mx_internal; import mx.effects.Effect; import mx.effects.Tween; import mx.events.ChildExistenceChangedEvent; import mx.events.FlexEvent; import mx.events.IndexChangedEvent; import mx.geom.RoundedRectangle; import mx.managers.HistoryManager; import mx.managers.IFocusManagerComponent; import mx.managers.IHistoryManagerClient; import mx.styles.CSSStyleDeclaration; import spark.components.NavigatorContent; use namespace mx_internal; [RequiresDataBinding(true)] //[IconFile(""Accordion.png"")] /** * Dispatched when the selected child container changes. * * @eventType mx.events.IndexChangedEvent.CHANGE * @helpid 3012 * @tiptext change event */ [Event(name=""change"", type=""mx.events.IndexChangedEvent"")] //-------------------------------------- // Styles //-------------------------------------- /** * Specifies the alpha transparency values used for the background fill of components. * You should set this to an Array of either two or four numbers. * Elements 0 and 1 specify the start and end values for * an alpha gradient. * If elements 2 and 3 exist, they are used instead of elements 0 and 1 * when the component is in a mouse-over state. * The global default value is [ 0.60, 0.40, 0.75, 0.65 ]. * Some components, such as the ApplicationControlBar container, * have a different default value. For the ApplicationControlBar container, * the default value is [ 0.0, 0.0 ]. */ [Style(name=""fillAlphas"", type=""Array"", arrayType=""Number"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Specifies the colors used to tint the background fill of the component. * You should set this to an Array of either two or four uint values * that specify RGB colors. * Elements 0 and 1 specify the start and end values for * a color gradient. * If elements 2 and 3 exist, they are used instead of elements 0 and 1 * when the component is in a mouse-over state. * For a flat-looking control, set the same color for elements 0 and 1 * and for elements 2 and 3, * The default value is * [ 0xFFFFFF, 0xCCCCCC, 0xFFFFFF, 0xEEEEEE ]. *

Some components, such as the ApplicationControlBar container, * have a different default value. For the ApplicationControlBar container, * the default value is [ 0xFFFFFF, 0xFFFFFF ].

*/ [Style(name=""fillColors"", type=""Array"", arrayType=""uint"", format=""Color"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Specifies the alpha transparency value of the focus skin. * * @default 0.4 */ [Style(name=""focusAlpha"", type=""Number"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Specifies which corners of the focus rectangle should be rounded. * This value is a space-separated String that can contain any * combination of ""tl"", ""tr"", ""bl"" * and ""br"". * For example, to specify that the right side corners should be rounded, * but the left side corners should be square, use ""tr br"". * The cornerRadius style property specifies * the radius of the rounded corners. * The default value depends on the component class; if not overridden for * the class, default value is ""tl tr bl br"". * */ [Style(name=""focusRoundedCorners"", type=""String"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Skin used to draw the focus rectangle. * * @default mx.skins.halo.HaloFocusRect */ [Style(name=""focusSkin"", type=""Class"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Thickness, in pixels, of the focus rectangle outline. * * @default 2 */ [Style(name=""focusThickness"", type=""Number"", format=""Length"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Name of the CSS style declaration that specifies styles for the accordion * headers (tabs). * *

You can use this class selector to set the values of all the style properties * of the AccordionHeader class, including fillAlphas, fillColors, * focusAlpha, focusRounderCorners, * focusSkin, focusThickness, and selectedFillColors.

*/ [Style(name=""headerStyleName"", type=""String"", inherit=""no"")] /** * Number of pixels between children in the horizontal direction. * The default value is 8. */ [Style(name=""horizontalGap"", type=""Number"", format=""Length"", inherit=""no"")] /** * Height of each accordion header, in pixels. * The default value is automatically calculated based on the font styles for * the header. */ [Style(name=""headerHeight"", type=""Number"", format=""Length"", inherit=""no"")] /** * Duration, in milliseconds, of the animation from one child to another. * The default value is 250. */ [Style(name=""openDuration"", type=""Number"", format=""Time"", inherit=""no"")] /** * Tweening function used by the animation from one child to another. */ [Style(name=""openEasingFunction"", type=""Function"", inherit=""no"")] /** * Number of pixels between the container's bottom border and its content area. * The default value is -1, so the bottom border of the last header * overlaps the Accordion container's bottom border. */ [Style(name=""paddingBottom"", type=""Number"", format=""Length"", inherit=""no"")] /** * Number of pixels between the container's top border and its content area. * The default value is -1, so the top border of the first header * overlaps the Accordion container's top border. */ [Style(name=""paddingTop"", type=""Number"", format=""Length"", inherit=""no"")] /** * The two colors used to tint the background of the component * when in its selected state. * Pass the same color for both values for ""flat"" looking control. * The default value is undefined, which means the colors * are derived from themeColor. */ [Style(name=""selectedFillColors"", type=""Array"", arrayType=""uint"", format=""Color"", inherit=""no"", deprecatedReplacement=""headerStyleName"", deprecatedSince=""3.0"")] /** * Color of header text when rolled over. * The default value is 0x2B333C. */ [Style(name=""textRollOverColor"", type=""uint"", format=""Color"", inherit=""yes"")] /** * Color of selected text. * The default value is 0x2B333C. */ [Style(name=""textSelectedColor"", type=""uint"", format=""Color"", inherit=""yes"")] /** * Number of pixels between children in the vertical direction. * The default value is -1, so the top and bottom borders * of adjacent headers overlap. */ [Style(name=""verticalGap"", type=""Number"", format=""Length"", inherit=""no"")] //-------------------------------------- // Excluded APIs //-------------------------------------- [Exclude(name=""autoLayout"", kind=""property"")] [Exclude(name=""clipContent"", kind=""property"")] [Exclude(name=""defaultButton"", kind=""property"")] [Exclude(name=""horizontalLineScrollSize"", kind=""property"")] [Exclude(name=""horizontalPageScrollSize"", kind=""property"")] [Exclude(name=""horizontalScrollBar"", kind=""property"")] [Exclude(name=""horizontalScrollPolicy"", kind=""property"")] [Exclude(name=""horizontalScrollPosition"", kind=""property"")] [Exclude(name=""maxHorizontalScrollPosition"", kind=""property"")] [Exclude(name=""maxVerticalScrollPosition"", kind=""property"")] [Exclude(name=""verticalLineScrollSize"", kind=""property"")] [Exclude(name=""verticalPageScrollSize"", kind=""property"")] [Exclude(name=""verticalScrollBar"", kind=""property"")] [Exclude(name=""verticalScrollPolicy"", kind=""property"")] [Exclude(name=""verticalScrollPosition"", kind=""property"")] [Exclude(name=""scroll"", kind=""event"")] /* [Exclude(name=""focusBlendMode"", kind=""style"")] [Exclude(name=""focusSkin"", kind=""style"")] [Exclude(name=""focusThickness"", kind=""style"")] */ [Exclude(name=""horizontalScrollBarStyleName"", kind=""style"")] [Exclude(name=""verticalScrollBarStyleName"", kind=""style"")] //-------------------------------------- // Other metadata //-------------------------------------- [DefaultBindingProperty(source=""selectedIndex"", destination=""selectedIndex"")] [DefaultTriggerEvent(""change"")] /** * AccordionBase is a copy/paste version of the original Accordion class in the Flex framework. * *

The only modifications made to this class were to change some properties and * methods from private to protected so we can override them in a subclass.

* *

An Accordion navigator container has a collection of child containers, * but only one of them at a time is visible. * It creates and manages navigator buttons (accordion headers), which you use * to navigate between the children. * There is one navigator button associated with each child container, * and each navigator button belongs to the Accordion container, not to the child. * When the user clicks a navigator button, the associated child container * is displayed. * The transition to the new child uses an animation to make it clear to * the user that one child is disappearing and a different one is appearing.

* *

The Accordion container does not extend the ViewStack container, * but it implements all the properties, methods, styles, and events * of the ViewStack container, such as selectedIndex * and selectedChild.

* *

An Accordion container has the following default sizing characteristics:

* * * * * * * * * * * * * * * * * * * * * *
CharacteristicDescription
Default sizeThe width and height of the currently active child.
Container resizing rulesAccordion containers are only sized once to fit the size of the first child container by default. * They do not resize when you navigate to other child containers by default. * To force Accordion containers to resize when you navigate to a different child container, * set the resizeToContent property to true.
Child sizing rulesChildren are sized to their default size. The child is clipped if it is larger than the Accordion container. * If the child is smaller than the Accordion container, it is aligned to the upper-left corner of the * Accordion container.
Default padding-1 pixel for the top, bottom, left, and right values.
* * @mxml * *

The <mx:Accordion> tag inherits all of the * tag attributes of its superclass, with the exception of scrolling-related * attributes, and adds the following tag attributes:

* *
   *  <mx:Accordion
   *    Properties
   *    headerRenderer=""IFactory""
   *    historyManagementEnabled=""true|false""
   *    resizeToContent=""false|true""
   *    selectedIndex=""undefined""
   *
   *    Styles
   *    headerHeight=""depends on header font styles""
   *    headerStyleName=""No default""
   *    horizontalGap=""8""
   *    openDuration=""250""
   *    openEasingFunction=""undefined""
   *    paddingBottom=""-1""
   *    paddingTop=""-1""
   *    textRollOverColor=""0xB333C""
   *    textSelectedColor=""0xB333C""
   *    verticalGap=""-1""
   *
   *    Events
   *    change=""No default""
   *    >
   *      ...
   *      child tags
   *      ...
   *  </mx:Accordion>
   *  
* * * * @see mx.containers.accordionClasses.AccordionHeader * * @tiptext Accordion allows for navigation between different child views * @helpid 3013 */ public class AccordionBase extends Container implements IHistoryManagerClient, IFocusManagerComponent { //include ""../core/Version.as""; //-------------------------------------------------------------------------- // // Class constants // //-------------------------------------------------------------------------- /** * @private * Base for all header names (_header0 - _headerN). */ private static const HEADER_NAME_BASE:String = ""_header""; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. */ public function AccordionBase() { super(); headerRenderer = new ClassFactory(AccordionHeader); // Most views can't take focus, but an accordion can. // However, it draws its own focus indicator on the // header for the currently selected child view. // Container() has set tabEnabled false, so we // have to set it back to true. tabEnabled = true; // Accordion always clips content, it just handles it by itself super.clipContent = false; addEventListener(ChildExistenceChangedEvent.CHILD_ADD, childAddHandler); addEventListener(ChildExistenceChangedEvent.CHILD_REMOVE, childRemoveHandler); showInAutomationHierarchy = true; } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * @private * Is the accordian currently sliding between views? */ protected var bSliding:Boolean = false; /** * @private */ private var initialSelectedIndex:int = -1; /** * @private * If true, call HistoryManager.save() when setting currentIndex. */ private var bSaveState:Boolean = false; /** * @private */ private var bInLoadState:Boolean = false; /** * @private */ private var firstTime:Boolean = true; /** * @private */ protected var showFocusIndicator:Boolean = false; /** * @private * Cached tween properties to speed up tweening calculations. */ protected var tweenViewMetrics:EdgeMetrics; protected var tweenContentWidth:Number; protected var tweenContentHeight:Number; protected var tweenOldSelectedIndex:int; protected var tweenNewSelectedIndex:int; protected var tween:Tween; /** * @private * We'll measure ourselves once and then store the results here * for the lifetime of the ViewStack. */ protected var accMinWidth:Number; protected var accMinHeight:Number; protected var accPreferredWidth:Number; protected var accPreferredHeight:Number; /** * @private * When a child is added or removed, this flag is set true * and it causes a re-measure. */ private var childAddedOrRemoved:Boolean = false; /** * @private * Remember which child has an overlay mask, if any. */ private var overlayChild:IUIComponent; /** * @private * Keep track of the overlay's targetArea */ private var overlayTargetArea:RoundedRectangle; /** * @private */ protected var layoutStyleChanged:Boolean = false; /** * @private */ protected var currentDissolveEffect:Effect; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // autoLayout //---------------------------------- // Don't allow user to set autoLayout because // there are problems if deferred instantiation // runs at the same time as an effect. (Bug 79174) [Inspectable(environment=""none"")] /** * @private */ override public function get autoLayout():Boolean { return true; } /** * @private */ override public function set autoLayout(value:Boolean):void { } //---------------------------------- // baselinePosition //---------------------------------- /** * @private * The baselinePosition of an Accordion is calculated * for the label of the first header. * If there are no children, a child is temporarily added * to do the computation. */ override public function get baselinePosition():Number { if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0) return super.baselinePosition; if (!validateBaselinePosition()) return NaN; var isEmpty:Boolean = numChildren == 0; if (isEmpty) { var child0 : NavigatorContent = new NavigatorContent(); addChild(child0); validateNow(); } var header0:Button = getHeaderAt(0); var result:Number = header0.y + header0.baselinePosition; if (isEmpty) { removeChildAt(0); validateNow(); } return result; } //---------------------------------- // clipContent //---------------------------------- // We still need to ensure the clip mask is *never* created for an // Accordion. [Inspectable(environment=""none"")] /** * @private */ override public function get clipContent():Boolean { return true; // Accordion does clip, it just does it itself } /** * @private */ override public function set clipContent(value:Boolean):void { } //---------------------------------- // horizontalScrollPolicy //---------------------------------- [Inspectable(environment=""none"")] /** * @private */ override public function get horizontalScrollPolicy():String { return ScrollPolicy.OFF; } /** * @private */ override public function set horizontalScrollPolicy(value:String):void { } //---------------------------------- // verticalScrollPolicy //---------------------------------- [Inspectable(environment=""none"")] /** * @private */ override public function get verticalScrollPolicy():String { return ScrollPolicy.OFF; } /** * @private */ override public function set verticalScrollPolicy(value:String):void { } //-------------------------------------------------------------------------- // // Public properties // //-------------------------------------------------------------------------- /** * @private */ private var _focusedIndex:int = -1; /** * @private */ mx_internal function get focusedIndex():int { return _focusedIndex; } //---------------------------------- // contentHeight //---------------------------------- /** * The height of the area, in pixels, in which content is displayed. * You can override this getter if your content * does not occupy the entire area of the container. */ protected function get contentHeight():Number { // Start with the height of the entire accordion. var contentHeight:Number = unscaledHeight; // Subtract the heights of the top and bottom borders. var vm:EdgeMetrics = viewMetricsAndPadding; contentHeight -= vm.top + vm.bottom; // Subtract the header heights. var verticalGap:Number = getStyle(""verticalGap""); var n:int = numChildren; for (var i:int = 0; i < n; i++) { contentHeight -= getHeaderAt(i).height; if (i > 0) contentHeight -= verticalGap; } return contentHeight; } //---------------------------------- // contentWidth //---------------------------------- /** * The width of the area, in pixels, in which content is displayed. * You can override this getter if your content * does not occupy the entire area of the container. */ protected function get contentWidth():Number { // Start with the width of the entire accordion. var contentWidth:Number = unscaledWidth; // Subtract the widths of the left and right borders. var vm:EdgeMetrics = viewMetricsAndPadding; contentWidth -= vm.left + vm.right; contentWidth -= getStyle(""paddingLeft"") + getStyle(""paddingRight""); return contentWidth; } //---------------------------------- // headerRenderer //---------------------------------- /** * @private * Storage for the headerRenderer property. */ private var _headerRenderer:IFactory; [Bindable(""headerRendererChanged"")] /** * A factory used to create the navigation buttons for each child. * The default value is a factory which creates a * mx.containers.accordionClasses.AccordionHeader. The * created object must be a subclass of Button and implement the * mx.core.IDataRenderer interface. The data * property is set to the content associated with the header. * * @see mx.containers.accordionClasses.AccordionHeader */ public function get headerRenderer():IFactory { return _headerRenderer; } /** * @private */ public function set headerRenderer(value:IFactory):void { _headerRenderer = value; dispatchEvent(new Event(""headerRendererChanged"")); } //---------------------------------- // historyManagementEnabled //---------------------------------- /** * @private * Storage for historyManagementEnabled property. */ private var _historyManagementEnabled:Boolean = true; /** * @private */ private var historyManagementEnabledChanged:Boolean = false; [Inspectable(defaultValue=""true"")] /** * If set to true, this property enables history management * within this Accordion container. * As the user navigates from one child to another, * the browser remembers which children were visited. * The user can then click the browser's Back and Forward buttons * to move through this navigation history. * * @default true * * @see mx.managers.HistoryManager */ public function get historyManagementEnabled():Boolean { return _historyManagementEnabled; } /** * @private */ public function set historyManagementEnabled(value:Boolean):void { if (value != _historyManagementEnabled) { _historyManagementEnabled = value; historyManagementEnabledChanged = true; invalidateProperties(); } } //---------------------------------- // resizeToContent //---------------------------------- /** * @private * Storage for the resizeToContent property. */ protected var _resizeToContent:Boolean = false; [Inspectable(defaultValue=""false"")] /** * If set to true, this Accordion automatically resizes to * the size of its current child. * * @default false */ public function get resizeToContent():Boolean { return _resizeToContent; } /** * @private */ public function set resizeToContent(value:Boolean):void { if (value != _resizeToContent) { _resizeToContent = value; if (value) invalidateSize(); } } //---------------------------------- // selectedChild //---------------------------------- [Bindable(""valueCommit"")] /** * A reference to the currently visible child container. * The default value is a reference to the first child. * If there are no children, this property is null. * *

Note: You can only set this property in an ActionScript statement, * not in MXML.

* * @tiptext Specifies the child view that is currently displayed * @helpid 3401 */ public function get selectedChild() : INavigatorContent { if (selectedIndex == -1) return null; return INavigatorContent( getChildAt( selectedIndex ) ); } /** * @private */ public function set selectedChild( value : INavigatorContent ):void { var newIndex:int = getChildIndex(DisplayObject(value)); if (newIndex >= 0 && newIndex < numChildren) selectedIndex = newIndex; } //---------------------------------- // selectedIndex //---------------------------------- /** * @private * Storage for the selectedIndex and selectedChild properties. */ private var _selectedIndex:int = -1; /** * @private */ private var proposedSelectedIndex:int = -1; [Bindable(""valueCommit"")] [Inspectable(category=""General"", defaultValue=""0"")] /** * The zero-based index of the currently visible child container. * Child indexes are in the range 0, 1, 2, ..., n - 1, where n is the number * of children. * The default value is 0, corresponding to the first child. * If there are no children, this property is -1. * * @default 0 * * @tiptext Specifies the index of the child view that is currently displayed * @helpid 3402 */ public function get selectedIndex():int { if (proposedSelectedIndex != -1) return proposedSelectedIndex; return _selectedIndex; } /** * @private */ public function set selectedIndex(value:int):void { // Bail if new index isn't a number. if (value == -1) return; // Bail if the index isn't changing. if (value == _selectedIndex) return; // Propose the specified value as the new value for selectedIndex. // It gets applied later when commitProperties() calls commitSelectedIndex(). // The proposed value can be ""out of range"", because the children // may not have been created yet, so the range check is handled // in commitSelectedIndex(), not here. Other calls to this setter // can change the proposed index before it is committed. Also, // childAddHandler() proposes a value of 0 when it creates the first // child, if no value has yet been proposed. proposedSelectedIndex = value; invalidateProperties(); // Set a flag which will cause the History Manager to save state // the next time measure() is called. if (historyManagementEnabled && _selectedIndex != -1 && !bInLoadState) bSaveState = true; dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private */ override public function createComponentsFromDescriptors( recurse:Boolean=true):void { // The easiest way to handle the ContainerCreationPolicy.ALL policy is to let // Container's implementation of createComponents handle it. if (actualCreationPolicy == ContainerCreationPolicy.ALL) { super.createComponentsFromDescriptors(); return; } // If the policy is ContainerCreationPolicy.AUTO, Accordion instantiates its children // immediately, but not any grandchildren. The children of // the selected child will get created in instantiateSelectedChild(). // Why not create the grandchildren of the selected child by calling // createComponentFromDescriptor(childDescriptors[i], i == selectedIndex); // in the loop below? Because one of this Accordion's childDescriptors // may be for a Repeater, in which case the following loop over the // childDescriptors is not the same as a loop over the children. // In particular, selectedIndex is supposed to specify the nth // child, not the nth childDescriptor, and the 2nd parameter of // createComponentFromDescriptor() should make the recursion happen // on the nth child, not the nth childDescriptor. var numChildrenBefore:int = numChildren; if (childDescriptors) { var n:int = childDescriptors.length; for (var i:int = 0; i < n; i++) { var descriptor:ComponentDescriptor = ComponentDescriptor(childDescriptors[i]); createComponentFromDescriptor(descriptor, false); } } numChildrenCreated = numChildren - numChildrenBefore; processedDescriptors = true; } /** * @private */ override public function setChildIndex(child:DisplayObject, newIndex:int):void { var oldIndex:int = getChildIndex(child); // Check boundary conditions first if (oldIndex == -1 || newIndex < 0) return; var nChildren:int = numChildren; if (newIndex >= nChildren) newIndex = nChildren - 1; // Next, check for no move if (newIndex == oldIndex) return; // De-select the old selected index header var oldSelectedHeader:Button = getHeaderAt(selectedIndex); if (oldSelectedHeader) { oldSelectedHeader.selected = false; drawHeaderFocus(_focusedIndex, false); } // Adjust the depths and _childN references of the affected children. super.setChildIndex(child, newIndex); // Shuffle the headers shuffleHeaders(oldIndex, newIndex); // Select the new selected index header var newSelectedHeader:Button = getHeaderAt(selectedIndex); if (newSelectedHeader) { newSelectedHeader.selected = true; drawHeaderFocus(_focusedIndex, showFocusIndicator); } // Make sure the new selected child is instantiated instantiateChild(selectedChild); } /** * @private */ private function shuffleHeaders(oldIndex:int, newIndex:int):void { var i:int; // Adjust the _headerN references of the affected headers. // Note: Algorithm is the same as Container.setChildIndex(). var header:Button = getHeaderAt(oldIndex); if (newIndex < oldIndex) { for (i = oldIndex; i > newIndex; i--) { getHeaderAt(i - 1).name = HEADER_NAME_BASE + i; } } else { for (i = oldIndex; i < newIndex; i++) { getHeaderAt(i + 1).name = HEADER_NAME_BASE + i; } } header.name = HEADER_NAME_BASE + newIndex; } /** * @private */ override protected function commitProperties():void { super.commitProperties(); if (historyManagementEnabledChanged) { if (historyManagementEnabled) HistoryManager.register(this); else HistoryManager.unregister(this); historyManagementEnabledChanged = false; } commitSelectedIndex(); if (firstTime) { firstTime = false; // Add ""addedToStage"" and ""removedFromStage"" listeners so we can // register/un-register from the history manager when this component // is added or removed from the display list. addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler, false, 0, true); addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler, false, 0, true); } } /** * @private */ override protected function measure():void { super.measure(); /* measure() gets implemented by a subclass, either HAccordion or VAccordion */ /** var minWidth:Number = 0; var minHeight:Number = 0; var preferredWidth:Number = 0; var preferredHeight:Number = 0; var paddingLeft:Number = getStyle(""paddingLeft""); var paddingRight:Number = getStyle(""paddingRight""); var headerHeight:Number = getHeaderHeight(); // In general, we only measure once and thereafter use cached values. // There are three exceptions: when resizeToContent is true, // when a layout style like headerHeight changes, // and when a child is added or removed. // // We need to copy the cached values into the measured fields // again to handle the case where scaleX or scaleY is not 1.0. // When the Accordion is zoomed, code in UIComponent.measureSizes // scales the measuredWidth/Height values every time that // measureSizes is called. (bug 100749) if (accPreferredWidth && !_resizeToContent && !layoutStyleChanged && !childAddedOrRemoved) { measuredMinWidth = accMinWidth; measuredMinHeight = accMinHeight; measuredWidth = accPreferredWidth; measuredHeight = accPreferredHeight; return; } layoutStyleChanged = false; childAddedOrRemoved = false; var n:int = numChildren; for (var i:int = 0; i < n; i++) { var button:Button = getHeaderAt(i); var child:IUIComponent = IUIComponent(getChildAt(i)); minWidth = Math.max(minWidth, button.minWidth); minHeight += headerHeight; preferredWidth = Math.max(preferredWidth, minWidth); preferredHeight += headerHeight; // The headers preferredWidth is messing up the accordion measurement. This may not // be needed anyway because we're still using the headers minWidth to determine our overall // minWidth. if (i == selectedIndex) { preferredWidth = Math.max(preferredWidth, child.getExplicitOrMeasuredWidth()); preferredHeight += child.getExplicitOrMeasuredHeight(); minWidth = Math.max(minWidth, child.minWidth); minHeight += child.minHeight; } } // Add space for borders and margins var vm:EdgeMetrics = viewMetricsAndPadding; var widthPadding:Number = vm.left + vm.right; var heightPadding:Number = vm.top + vm.bottom; // Need to adjust the widthPadding if paddingLeft and paddingRight are negative numbers // (see explanation in updateDisplayList()) if (paddingLeft < 0) widthPadding -= paddingLeft; if (paddingRight < 0) widthPadding -= paddingRight; minWidth += widthPadding; preferredWidth += widthPadding; minHeight += heightPadding; preferredHeight += heightPadding; measuredMinWidth = minWidth; measuredMinHeight = minHeight; measuredWidth = preferredWidth; measuredHeight = preferredHeight; // If we're called before instantiateSelectedChild, then bail. // We'll be called again later (instantiateSelectedChild calls // invalidateSize), and we don't want to load values into the // cache until we're fully initialized. (bug 102639) // This check was moved from the beginning of this function to // here to fix bugs 103665/104213. if (selectedChild && Container(selectedChild).numChildrenCreated == -1) return; // Don't remember sizes if we don't have any children if (numChildren == 0) return; accMinWidth = minWidth; accMinHeight = minHeight; accPreferredWidth = preferredWidth; accPreferredHeight = preferredHeight; **/ } /** * @private * Arranges the layout of the accordion contents. * * @tiptext Arranges the layout of the Accordion's contents * @helpid 3017 */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); /* updateDisplayList() gets implemented by a subclass, either HAccordion or VAccordion */ /** // Don't do layout if we're tweening because the tweening // code is handling it. if (tween) return; // Measure the border. var bm:EdgeMetrics = borderMetrics; var paddingLeft:Number = getStyle(""paddingLeft""); var paddingRight:Number = getStyle(""paddingRight""); var paddingTop:Number = getStyle(""paddingTop""); var verticalGap:Number = getStyle(""verticalGap""); // Determine the width and height of the content area. var localContentWidth:Number = calcContentWidth(); var localContentHeight:Number = calcContentHeight(); // Arrange the headers, the content clips, // based on selectedIndex. var x:Number = bm.left + paddingLeft; var y:Number = bm.top + paddingTop; // Adjustments. These are required since the default halo // appearance has verticalGap and all margins set to -1 // so the edges of the headers overlap each other and the // border of the accordion. These overlaps cause problems with // the content area clipping, so we adjust for them here. var contentX:Number = x; var adjContentWidth:Number = localContentWidth; var headerHeight:Number = getHeaderHeight(); if (paddingLeft < 0) { contentX -= paddingLeft; adjContentWidth += paddingLeft; } if (paddingRight < 0) adjContentWidth += paddingRight; var n:int = numChildren; for (var i:int = 0; i < n; i++) { var header:Button = getHeaderAt(i); var content:IUIComponent = IUIComponent(getChildAt(i)); header.move(x, y); header.setActualSize(localContentWidth, headerHeight); y += headerHeight; if (i == selectedIndex) { content.move(contentX, y); content.visible = true; var contentW:Number = adjContentWidth; var contentH:Number = localContentHeight; if (!isNaN(content.percentWidth)) { if (contentW > content.maxWidth) contentW = content.maxWidth; } else { if (contentW > content.getExplicitOrMeasuredWidth()) contentW = content.getExplicitOrMeasuredWidth(); } if (!isNaN(content.percentHeight)) { if (contentH > content.maxHeight) contentH = content.maxHeight; } else { if (contentH > content.getExplicitOrMeasuredHeight()) contentH = content.getExplicitOrMeasuredHeight(); } if (content.width != contentW || content.height != contentH) { content.setActualSize(contentW, contentH); } y += localContentHeight; } else { content.move(contentX, i < selectedIndex ? y : y - localContentHeight); content.visible = false; } y += verticalGap; } // Make sure blocker is in front if (blocker) rawChildren.setChildIndex(blocker, numChildren - 1); // refresh the focus rect, the dimensions might have changed. drawHeaderFocus(_focusedIndex, showFocusIndicator); */ } /** * @private */ override mx_internal function setActualCreationPolicies(policy:String):void { super.setActualCreationPolicies(policy); // If the creation policy is switched to ContainerCreationPolicy.ALL and our createComponents // function has already been called (we've created our children but not // all our grandchildren), then create all our grandchildren now (bug 99160). if (policy == ContainerCreationPolicy.ALL && numChildren > 0) { var n:int = numChildren; for (var i:int = 0; i < n; i++) { INavigatorContent(getChildAt(i)).createDeferredContent(); } } } /** * @private */ override protected function focusInHandler(event:FocusEvent):void { super.focusInHandler(event); showFocusIndicator = focusManager.showFocusIndicator; // When the accordion has focus, the Focus Manager // should not treat the Enter key as a click on // the default pushbutton. if (event.target == this) focusManager.defaultButtonEnabled = false; } /** * @private */ override protected function focusOutHandler(event:FocusEvent):void { super.focusOutHandler(event); showFocusIndicator = false; if (focusManager && event.target == this) focusManager.defaultButtonEnabled = true; } /** * @private */ override public function drawFocus(isFocused:Boolean):void { drawHeaderFocus(_focusedIndex, isFocused); } /** * @private */ override public function styleChanged(styleProp:String):void { super.styleChanged(styleProp); if (!styleProp || styleProp == ""headerStyleName"" || styleProp == ""styleName"") { var headerStyleName:Object = getStyle(""headerStyleName""); var header:Button; if (headerStyleName) { if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0) { var headerStyleDecl:CSSStyleDeclaration = styleManager.getStyleDeclaration(""."" + headerStyleName); if (headerStyleDecl) { // Need to reset the header style declaration and // regenerate their style cache for (var i:int = 0; i < numChildren; i++) { header = getHeaderAt(i); if (header) { header.styleDeclaration = headerStyleDecl; header.regenerateStyleCache(true); header.styleChanged(null); } } } } else { for (var j:int = 0; j < numChildren; j++) { header = getHeaderAt(j); if (header) { header.styleName = headerStyleName; } } } } } else if (styleManager.isSizeInvalidatingStyle(styleProp)) { layoutStyleChanged = true; } } /** * @private * When asked to create an overlay mask, create it on the selected child * instead. That way, the chrome around the edge of the Accordion (e.g. the * header buttons) is not occluded by the overlay mask (bug 99029). */ override mx_internal function addOverlay(color:uint, targetArea:RoundedRectangle=null):void { // As we're switching the currently-selected child, don't // allow two children to both have an overlay at the same time. // This is done because it makes accounting a headache. If there's // a legitimate reason why two children both need overlays, this // restriction could be relaxed. if (overlayChild) removeOverlay(); // Remember which child has an overlay, so that we don't inadvertently // create an overlay on one child and later try to remove the overlay // of another child. (bug 100731) overlayChild = selectedChild as IUIComponent; if (!overlayChild) return; /*FLEX_TARGET_VERSION::flex4 {*/ effectOverlayColor = color; /* } FLEX_TARGET_VERSION::flex3 { overlayColor = color; }*/ overlayTargetArea = targetArea; if ( selectedChild && selectedChild.deferredContentCreated == false ) // No children have been created { // Wait for the childrenCreated event before creating the overlay selectedChild.addEventListener(FlexEvent.INITIALIZE, initializeHandler); } else // Children already exist { initializeHandler(null); } } /** * @private * Called when we are running a Dissolve effect * and the initialize event has been dispatched * or the children already exist */ private function initializeHandler(event:FlexEvent):void { /*FLEX_TARGET_VERSION::flex4 {*/ UIComponent(overlayChild).addOverlay(effectOverlayColor, overlayTargetArea); /*} FLEX_TARGET_VERSION::flex3 { UIComponent(overlayChild).addOverlay(overlayColor, overlayTargetArea); }*/ } /** * @private * Handle key down events */ override mx_internal function removeOverlay():void { if (overlayChild) { UIComponent(overlayChild).removeOverlay(); overlayChild = null; } } // ------------------------------------------------------------------------- // StateInterface // ------------------------------------------------------------------------- /** * @copy mx.managers.IHistoryManagerClient#saveState() */ public function saveState():Object { var index:int = _selectedIndex == -1 ? 0 : _selectedIndex; return {selectedIndex: index}; } /** * @copy mx.managers.IHistoryManagerClient#loadState() */ public function loadState(state:Object):void { var newIndex:int = state ? int(state.selectedIndex) : 0; if (newIndex == -1) newIndex = initialSelectedIndex; if (newIndex == -1) newIndex = 0; if (newIndex != _selectedIndex) { // When loading a new state, we don't want to // save our current state in the history stack. bInLoadState = true; selectedIndex = newIndex; bInLoadState = false; } } //-------------------------------------------------------------------------- // // Public methods // //-------------------------------------------------------------------------- /** * Returns a reference to the navigator button for a child container. * * @param index Zero-based index of the child. * * @return Button object representing the navigator button. */ public function getHeaderAt(index:int):Button { return Button(rawChildren.getChildByName(HEADER_NAME_BASE + index)); } /** * @private * Returns the height of the header control. All header controls are the same * height. */ protected function getHeaderHeight():Number { var headerHeight:Number = getStyle(""headerHeight""); if (isNaN(headerHeight)) { headerHeight = 0; if (numChildren > 0) headerHeight = getHeaderAt(0).measuredHeight; } return headerHeight; } /** * @private * Returns the width of the header control. All header controls are the same * width. */ protected function getHeaderWidth():Number { var headerWidth:Number = getStyle(""headerWidth""); if (isNaN(headerWidth)) { headerWidth = 0; if (numChildren > 0) headerWidth = getHeaderAt(0).measuredHeight; } return headerWidth; } //-------------------------------------------------------------------------- // // Private methods // //-------------------------------------------------------------------------- /** * @private * Utility method to create the segment header */ private function createHeader(content:DisplayObject, i:int):void { // Before creating the header, un-select the currently selected // header. We will be selecting the correct header below. if (selectedIndex != -1 && getHeaderAt(selectedIndex)) getHeaderAt(selectedIndex).selected = false; // Create the header. // Notes: // 1) An accordion maintains a reference to // the header for its Nth child as _headerN. These references are // juggled when children and their headers are re-indexed or // removed, to ensure that _headerN is always a reference the // header for the Nth child. // 2) Always create the header with the index of the last item. // If needed, the headers will be shuffled below. var header:Button = Button(headerRenderer.newInstance()); header.name = HEADER_NAME_BASE + (numChildren - 1); if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0) { header.styleName = this; } var headerStyleName:String = getStyle(""headerStyleName""); if (headerStyleName) { if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0) { var headerStyleDecl:CSSStyleDeclaration = styleManager. getStyleDeclaration(""."" + headerStyleName); if (headerStyleDecl) header.styleDeclaration = headerStyleDecl; } else { header.styleName = headerStyleName; } } header.addEventListener(MouseEvent.CLICK, headerClickHandler); IDataRenderer(header).data = content; if (content is INavigatorContent) { var contentContainer:INavigatorContent = INavigatorContent(content); header.label = contentContainer.label; if (contentContainer.icon) header.setStyle(""icon"", contentContainer.icon); // If the child has a toolTip, transfer it to the header. var toolTip:String = contentContainer.toolTip; if (toolTip && toolTip != """") { header.toolTip = toolTip; contentContainer.toolTip = null; } } rawChildren.addChild(header); // If the newly added child isn't at the end of our child list, shuffle // the headers accordingly. if (i != numChildren - 1) shuffleHeaders(numChildren - 1, i); // Make sure the correct header is selected if (selectedIndex != -1 && getHeaderAt(selectedIndex)) getHeaderAt(selectedIndex).selected = true; } /** * @private */ protected function calcContentWidth():Number { // Start with the width of the entire accordion. var contentWidth:Number = unscaledWidth; // Subtract the widths of the left and right borders. var vm:EdgeMetrics = viewMetricsAndPadding; contentWidth -= vm.left + vm.right; return contentWidth; } /** * @private */ protected function calcContentHeight():Number { // Start with the height of the entire accordion. var contentHeight:Number = unscaledHeight; // Subtract the heights of the top and bottom borders. var vm:EdgeMetrics = viewMetricsAndPadding; contentHeight -= vm.top + vm.bottom; // Subtract the header heights. var verticalGap:Number = getStyle(""verticalGap""); var headerHeight:Number = getHeaderHeight(); var n:int = numChildren; for (var i:int = 0; i < n; i++) { contentHeight -= headerHeight; if (i > 0) contentHeight -= verticalGap; } return contentHeight; } /** * @private */ protected function drawHeaderFocus(headerIndex:int, isFocused:Boolean):void { if (headerIndex != -1) getHeaderAt(headerIndex).drawFocus(isFocused); } /** * @private */ private function headerClickHandler(event:Event):void { var header:Button = Button(event.currentTarget); var oldIndex:int = selectedIndex; // content is placed onto the button so we have to access it via [] selectedChild = INavigatorContent(IDataRenderer(header).data); var newIndex:int = selectedIndex; if (oldIndex != newIndex) dispatchChangeEvent(oldIndex, newIndex, event); } /** * @private */ private function commitSelectedIndex():void { if (proposedSelectedIndex == -1) return; var newIndex:int = proposedSelectedIndex; proposedSelectedIndex = -1; // The selectedIndex must be undefined if there are no children, // even if a selectedIndex has been proposed. if (numChildren == 0) { _selectedIndex = -1; return; } // Ensure that the new index is in bounds. if (newIndex < 0) newIndex = 0; else if (newIndex > numChildren - 1) newIndex = numChildren - 1; // Remember the old index. var oldIndex:int = _selectedIndex; // Bail if the index isn't changing. if (newIndex == oldIndex) return; // If we are currently playing a Dissolve effect, end it and restart it again currentDissolveEffect = null; if (isEffectStarted) { var dissolveInstanceClass:Class = Class(systemManager.getDefinitionByName(""mx.effects.effectClasses.DissolveInstance"")); for (var i:int = 0; i < _effectsStarted.length; i++) { // Avoid referencing the DissolveInstance class directly, so that // we don't create an unwanted linker dependency. if (dissolveInstanceClass && _effectsStarted[i] is dissolveInstanceClass) { // If we find the dissolve, save a pointer to the parent effect and end the instance currentDissolveEffect = _effectsStarted[i].effect; _effectsStarted[i].end(); break; } } } // Unfocus the old header. if (_focusedIndex != newIndex) drawHeaderFocus(_focusedIndex, false); // Deselect the old header. if (oldIndex != -1) getHeaderAt(oldIndex).selected = false; // Commit the new index. _selectedIndex = newIndex; // Remember our initial selected index so we can // restore to our default state when the history // manager requests it. if (initialSelectedIndex == -1) initialSelectedIndex = _selectedIndex; // Select the new header. getHeaderAt(newIndex).selected = true; if (_focusedIndex != newIndex) { // Focus the new header. _focusedIndex = newIndex; drawHeaderFocus(_focusedIndex, showFocusIndicator); } if (bSaveState) { HistoryManager.save(); bSaveState = false; } if (getStyle(""openDuration"") == 0 || oldIndex == -1) { // Need to set the new index to be visible here // in order for effects to work. UIComponent(getChildAt(newIndex)).setVisible(true); // Now that the effects have been triggered, we can hide the // current view until it is properly sized and positioned below. UIComponent(getChildAt(newIndex)).setVisible(false, true); if (oldIndex != -1) INavigatorContent(getChildAt(oldIndex)).setVisible(false); instantiateChild(selectedChild); } else { if (tween) tween.endTween(); startTween(oldIndex, newIndex); } } /** * @private */ protected function instantiateChild( child : INavigatorContent ):void { // fix for bug#137430 // when the selectedChild index is -1 (invalid value due to any reason) // selectedContainer will not be valid. Before we proceed // we need to make sure of its validity. if (!child) return; // Performance optimization: don't call createComponents if we know // that createComponents has already been called. /*if (child && child.numChildrenCreated == -1) child.createComponentsFromDescriptors();*/ if ( child && child.deferredContentCreated == false ) child.createDeferredContent(); // Do the initial measurement/layout pass for the newly-instantiated // descendants. invalidateSize(); invalidateDisplayList(); if (child is IInvalidating) IInvalidating(child).invalidateSize(); } /** * @private */ private function dispatchChangeEvent(oldIndex:int, newIndex:int, cause:Event=null):void { var indexChangeEvent:IndexChangedEvent = new IndexChangedEvent(IndexChangedEvent.CHANGE); indexChangeEvent.oldIndex = oldIndex; indexChangeEvent.newIndex = newIndex; indexChangeEvent.relatedObject = getChildAt(newIndex); indexChangeEvent.triggerEvent = cause; dispatchEvent(indexChangeEvent); } /** * @private */ protected function startTween(oldSelectedIndex:int, newSelectedIndex:int):void { bSliding = true; // To improve the animation performance, we set up some invariants // used in onTweenUpdate. (Some of these, like contentHeight, are // too slow to recalculate at every tween step.) tweenViewMetrics = viewMetricsAndPadding; tweenContentWidth = calcContentWidth(); tweenContentHeight = calcContentHeight(); tweenOldSelectedIndex = oldSelectedIndex; tweenNewSelectedIndex = newSelectedIndex; // A single instance of Tween drives the animation. var openDuration:Number = getStyle(""openDuration""); tween = new Tween(this, 0, tweenContentHeight, openDuration); var easingFunction:Function = getStyle(""openEasingFunction"") as Function; if (easingFunction != null) tween.easingFunction = easingFunction; // Ideally, all tweening should be managed by the EffectManager. Since // this tween isn't managed by the EffectManager, we need this alternate // mechanism to tell the EffectManager that we're tweening. Otherwise, the // EffectManager might try to play another effect that animates the same // properties. if (oldSelectedIndex != -1) INavigatorContent(getChildAt(oldSelectedIndex)).tweeningProperties = [""x"", ""y"", ""width"", ""height""]; INavigatorContent(getChildAt(newSelectedIndex)).tweeningProperties = [""x"", ""y"", ""width"", ""height""]; // If the content of the new child hasn't been created yet, set the new child // to the content width/height. This way any background color will show up // properly during the animation. var newSelectedChild:INavigatorContent = INavigatorContent(getChildAt(newSelectedIndex)); if ( UIComponent( newSelectedChild ).numChildren == 0) { var paddingLeft:Number = getStyle(""paddingLeft""); var contentX:Number = borderMetrics.left + (paddingLeft > 0 ? paddingLeft : 0); newSelectedChild.move(contentX, newSelectedChild.y); newSelectedChild.setActualSize(tweenContentWidth, tweenContentHeight); } UIComponent.suspendBackgroundProcessing(); } /** * @private */ mx_internal function onTweenUpdate(value:Number):void { // Fetch the tween invariants we set up in startTween. var vm:EdgeMetrics = tweenViewMetrics; var contentWidth:Number = tweenContentWidth; var contentHeight:Number = tweenContentHeight; var oldSelectedIndex:int = tweenOldSelectedIndex; var newSelectedIndex:int = tweenNewSelectedIndex; // The tweened value is the height of the new content area, which varies // from 0 to the contentHeight. As the new content area grows, the // old content area shrinks. var newContentHeight:Number = value; var oldContentHeight:Number = contentHeight - value; // These offsets for the Y position of the content clips make the content // clips appear to be pushed up and pulled down. var oldOffset:Number = oldSelectedIndex < newSelectedIndex ? -newContentHeight : newContentHeight; var newOffset:Number = newSelectedIndex > oldSelectedIndex ? oldContentHeight : -oldContentHeight; // Loop over all the headers to arrange them vertically. // The loop is intentionally over ALL the headers, not just the ones that // need to move; this makes the animation look equally smooth // regardless of how many headers are moving. // We also reposition the two visible content clips. var y:Number = vm.top; var verticalGap:Number = getStyle(""verticalGap""); var n:int = numChildren; for (var i:int = 0; i < n; i++) { var header:Button = getHeaderAt(i); var content:INavigatorContent = INavigatorContent(getChildAt(i)); header.$y = y; y += header.height; if (i == oldSelectedIndex) { content.cacheAsBitmap = true; content.scrollRect = new Rectangle(0, -oldOffset, contentWidth, contentHeight); content.visible = true; y += oldContentHeight; } else if (i == newSelectedIndex) { content.cacheAsBitmap = true; content.scrollRect = new Rectangle(0, -newOffset, contentWidth, contentHeight); content.visible = true; y += newContentHeight; } y += verticalGap; } } /** * @private */ mx_internal function onTweenEnd(value:Number):void { bSliding = false; var oldSelectedIndex:int = tweenOldSelectedIndex; var vm:EdgeMetrics = tweenViewMetrics; var verticalGap:Number = getStyle(""verticalGap""); var headerHeight:Number = getHeaderHeight(); var localContentWidth:Number = calcContentWidth(); var localContentHeight:Number = calcContentHeight(); var y:Number = vm.top; var content:INavigatorContent; var n:int = numChildren; for (var i:int = 0; i < n; i++) { var header:Button = getHeaderAt(i); header.$y = y; y += headerHeight; if (i == selectedIndex) { content = INavigatorContent(getChildAt(i)); content.cacheAsBitmap = false; content.scrollRect = null; content.visible = true; y += localContentHeight; } y += verticalGap; } if (oldSelectedIndex != -1) { content = INavigatorContent(getChildAt(oldSelectedIndex)); content.cacheAsBitmap = false; content.scrollRect = null; content.visible = false; content.tweeningProperties = null; } // Delete the temporary tween invariants we set up in startTween. tweenViewMetrics = null; tweenContentWidth = NaN; tweenContentHeight = NaN; tweenOldSelectedIndex = 0; tweenNewSelectedIndex = 0; tween = null; UIComponent.resumeBackgroundProcessing(); INavigatorContent(getChildAt(selectedIndex)).tweeningProperties = null; // If we interrupted a Dissolve effect, restart it here if (currentDissolveEffect) { if (currentDissolveEffect.target != null) { currentDissolveEffect.play(); } else { currentDissolveEffect.play([this]); } } // Let the screen render the last frame of the animation before // we begin instantiating the new child. callLater(instantiateChild, [selectedChild]); } //-------------------------------------------------------------------------- // // Overridden event handlers // //-------------------------------------------------------------------------- /** * @private * Handles ""keyDown"" event. */ override protected function keyDownHandler(event:KeyboardEvent):void { // Only listen for events that have come from the accordion itself. if (event.target != this) return; var prevValue:int = selectedIndex; switch (event.keyCode) { case Keyboard.PAGE_DOWN: { drawHeaderFocus(_focusedIndex, false); _focusedIndex = selectedIndex = (selectedIndex < numChildren - 1 ? selectedIndex + 1 : 0); drawHeaderFocus(_focusedIndex, true); event.stopPropagation(); dispatchChangeEvent(prevValue, selectedIndex, event); break; } case Keyboard.PAGE_UP: { drawHeaderFocus(_focusedIndex, false); _focusedIndex = selectedIndex = (selectedIndex > 0 ? selectedIndex - 1 : numChildren - 1); drawHeaderFocus(_focusedIndex, true); event.stopPropagation(); dispatchChangeEvent(prevValue, selectedIndex, event); break; } case Keyboard.HOME: { drawHeaderFocus(_focusedIndex, false); _focusedIndex = selectedIndex = 0; drawHeaderFocus(_focusedIndex, true); event.stopPropagation(); dispatchChangeEvent(prevValue, selectedIndex, event); break; } case Keyboard.END: { drawHeaderFocus(_focusedIndex, false); _focusedIndex = selectedIndex = numChildren - 1; drawHeaderFocus(_focusedIndex, true); event.stopPropagation(); dispatchChangeEvent(prevValue, selectedIndex, event); break; } case Keyboard.DOWN: case Keyboard.RIGHT: { drawHeaderFocus(_focusedIndex, false); _focusedIndex = (_focusedIndex < numChildren - 1 ? _focusedIndex + 1 : 0); drawHeaderFocus(_focusedIndex, true); event.stopPropagation(); break; } case Keyboard.UP: case Keyboard.LEFT: { drawHeaderFocus(_focusedIndex, false); _focusedIndex = (_focusedIndex > 0 ? _focusedIndex - 1 : numChildren - 1); drawHeaderFocus(_focusedIndex, true); event.stopPropagation(); break; } case Keyboard.SPACE: case Keyboard.ENTER: { event.stopPropagation(); if (_focusedIndex != selectedIndex) { selectedIndex = _focusedIndex; dispatchChangeEvent(prevValue, selectedIndex, event); } break; } } } //-------------------------------------------------------------------------- // // Event handlers // //-------------------------------------------------------------------------- /** * @private * Handles ""addedToStage"" event */ private function addedToStageHandler(event:Event):void { if (historyManagementEnabled) HistoryManager.register(this); } /** * @private * Handles ""removedFromStage"" event */ private function removedFromStageHandler(event:Event):void { HistoryManager.unregister(this); } /** * @private */ private function childAddHandler(event:ChildExistenceChangedEvent):void { childAddedOrRemoved = true; var child:DisplayObject = event.relatedObject; // Accordion creates all of its children initially invisible. // They are made as they become the selected child. child.visible = false; // Create the header associated with this child. createHeader(child, getChildIndex(child)); // If the child's label or icon changes, Accordion needs to know so that // the header label can be updated. This event is handled by // labelChanged(). // note: weak listeners child.addEventListener(""labelChanged"", labelChangedHandler, false, 0, true); child.addEventListener(""iconChanged"", iconChangedHandler, false, 0, true); // If we just created the first child and no selected index has // been proposed, then propose this child to be selected. if (numChildren == 1 && proposedSelectedIndex == -1) { selectedIndex = 0; // Select the new header. var newHeader:Button = getHeaderAt(0); newHeader.selected = true; // Focus the new header. _focusedIndex = 0; drawHeaderFocus(_focusedIndex, showFocusIndicator); } if (child as IAutomationObject) { IAutomationObject(child).showInAutomationHierarchy = true; } } /** * @private */ private function childRemoveHandler(event:ChildExistenceChangedEvent):void { childAddedOrRemoved = true; if (numChildren == 0) return; var child:DisplayObject = event.relatedObject; var oldIndex:int = selectedIndex; var newIndex:int; var index:int = getChildIndex(child); // Remove Event Listeners, in case children are referenced elsewhere. child.removeEventListener(""labelChanged"", labelChangedHandler); child.removeEventListener(""iconChanged"", iconChangedHandler); var nChildren:int = numChildren - 1; // number of children remaining after child has been removed rawChildren.removeChild(getHeaderAt(index)); // Shuffle all higher numbered headers down. for (var i:int = index; i < nChildren; i++) { getHeaderAt(i + 1).name = HEADER_NAME_BASE + i; } // If we just deleted the only child, the accordion is now empty, // and no child is now selected. if (nChildren == 0) { // There's no need to go through all of commitSelectedIndex(), // and it wouldn't do the right thing, anyway, because // it bails immediately if numChildren is 0. newIndex = _focusedIndex = -1; } else if (index > selectedIndex) { return; } // If we deleted a child before the selected child, the // index of that selected child is now 1 less than it was, // but the selected child itself hasn't changed. else if (index < selectedIndex) { newIndex = oldIndex - 1; } // Now handle the case that we deleted the selected child // and there is another child that we must select. else if (index == selectedIndex) { // If it was the last child, select the previous one. // Otherwise, select the next one. This next child now // has the same index as the one we just deleted, if (index == nChildren) { newIndex = oldIndex - 1; // if something's selected, instantiate it if (newIndex != -1) instantiateChild(INavigatorContent(getChildAt(newIndex))); } else { newIndex = oldIndex; // can't do selectedChild because we need to actually do // newIndex + 1 because currently that's what the index // of the child is (SDK-12622) since this one isn't // actually removed from the display list yet instantiateChild(INavigatorContent(getChildAt(newIndex + 1))); } // Select the new selected index header. var newHeader:Button = getHeaderAt(newIndex); newHeader.selected = true; } if (_focusedIndex > index) { _focusedIndex--; drawHeaderFocus(_focusedIndex, showFocusIndicator); } else if (_focusedIndex == index) { if (index == nChildren) _focusedIndex--; drawHeaderFocus(_focusedIndex, showFocusIndicator); } _selectedIndex = newIndex; dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } /** * @private * Handles ""labelChanged"" event. */ private function labelChangedHandler(event:Event):void { var child:DisplayObject = DisplayObject(event.target); var childIndex:int = getChildIndex(child); var header:Button = getHeaderAt(childIndex); header.label = INavigatorContent(event.target).label; } /** * @private * Handles ""iconChanged"" event. */ private function iconChangedHandler(event:Event):void { var child:DisplayObject = DisplayObject(event.target); var childIndex:int = getChildIndex(child); var header:Button = getHeaderAt(childIndex); header.setStyle(""icon"", INavigatorContent(event.target).icon); //header.icon = Container(event.target).icon; } } } ",16239,True,2927.5405116142438,median "package swag.core { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.Loader; import flash.display.PixelSnapping; import flash.events.Event; import flash.geom.Matrix; import flash.geom.Point; import flash.utils.ByteArray; import flash.utils.describeType; import flash.utils.getDefinitionByName; import flash.xml.XMLDocument; import flash.xml.XMLNode; import swag.core.SwagDispatcher; import swag.interfaces.core.ISwagDataTools; /** * The SwagDataTools class contains a variety of static methods and properties to assist with a variety * of data modification and verification tasks. For the most part, methods and properties can be accessed directly * without first creating an instance of the SwagDataTools class. * * @author Patrick Bay * * The MIT License (MIT) * * Copyright (c) 2014 Patrick Bay * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the ""Software""), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public final class SwagDataTools extends SwagDispatcher implements ISwagDataTools { /** * Contains the range of all numeric ASCII characters that can be used with various string operations. */ public static const NUMBERS_RANGE:String=""0123456789""; /** * Contains the range of all lowercase ASCII characters that can be used with various string operations. */ public static const LOWERCASE_RANGE:String=""abcdefghijklmnopqrstuvwxyz""; /** * Contains the range of all uppercase ASCII characters that can be used with various string operations. */ public static const UPPERCASE_RANGE:String=""ABCDEFGHIJKLMNOPQRSTUVWXYZ""; /** * Contains the range of all puncuation ASCII characters that can be used with various string operations. */ public static const PUNCTUATION_RANGE:String=""~`!@#$%^&*()+-={}[]|:\\"";'<>,.?""; /** * Contains the range of all separator ASCII characters (space, hyphen, underscore, back slash, forward slash), * that can be used with various string operations. */ public static const SEPARATOR_RANGE:String="" -_\\\\/\\n\\r\\t""; /** * Contains the range of all white space ASCII characters (spaces, tabs, newlines, carriage returns), * that can be used with various string operations. */ public static const WHITESPACE_RANGE:String="" \\n\\r\\t""+String.fromCharCode(13)+String.fromCharCode(10)+String.fromCharCode(9); /** * * Verifies the supplied property against the supplied type. * * @param property The property (variable, object, reference, etc.), to check. * @param type The type to check against. If this is an object reference, it is used directly. If this is a string, * a getDefinitionByType call is made to attempt to retrieve the object type first. * @param canBeNull If true, the evaluation will still return true even if the * supplied property is null. If false, the property must contain a value (i.e. be non-null). * * @return true if the supplied property parameter matches the supplied type * parameter, or false if the type doesn't match, or the property is null and canBeNull * is false. * */ public static function isType(property:*=null, type:*=null, canBeNull:Boolean=false):Boolean { if ((property==null) && (canBeNull==false)) { return (false) }//if if ((type==null) && (property==null)) { return (true); }//if if (type==String) { try { var typeClass:Class=getDefinitionByName(type) as Class; if (property==typeClass) { return (true); }//if } catch (e:ReferenceError) { return (false); }//catch } else { if (property==type) { return (true); }//if }//else return (false); }//isType /** * Verifies that the supplied property has data -- is not undefined and not null. * * @param args The property to check. * * @return True if the supplied property is not undefined and not null, otherwise * false is returned. * */ public static function hasData(... args):Boolean { try { if (args[0]==undefined) { return (false); }//if if (args[0]==null) { return (false); }//if } catch (e:*) { return (false); }//catch return (true); }//hasData /** * Verifies that the supplied parameter is one of the valid ActionScript 3 XML objects, or a string that can be converted to a valid XML * object. * * @param args The first parameter is the argument to validate as either XML, XMLList, XMLDocument, * XMLNode, or a string with valid XML data if the optional second parameter is true (default is false). * * @return True if the supplied argument is a valid XML, XMLList, XMLDocument, or * XMLNode object, or if it's a string that can be converted used as a valid XML object (if the second parameter is true). * False is returned when none of these conditions are met. * */ public static function isXML(... args):Boolean { try { if (args == null) { return (false); }//if if (args[0] == undefined) { return (false); }//if } catch (e:*) { return (false); }//catch if ((args[0]==String) && (args[1]==true)){ var localString:String=new String(args[0]); try { var testXML:XML=new XML(localString); return (true); } catch (e:TypeError) { return (false); }//catch }//if if ((args[0] is XML) || (args[0] is XMLList) || (args[0] is XMLDocument) || (args[0] is XMLNode)) { return (true); }//if return (false); }//isXML /** * * Scans sourceString for occurances of searchString and returns true if found. *

Optionally, a case-insensitive search may be performed between the two strings.

* * @param sourceString The string, or strings, to search through. If this parameter is a string, it is used as is. If the parameter is an * array, the contents of the array are analyzed one by one wherever possible. If the parameter is of a type that can be converted to a string * (XML, for example), a conversion will be attempted. * @param searchString The string to find within sourceString. * @param caseSensitive If true, a case-insensitive search is performed, otherwise the strings must match exactly. * * @return True if the searchString could be found within the sourceString. False is returned if * sourceString or searchString are null, or are of a type that can't be analyzed. * */ public static function stringContains(sourceString:*, searchString:String, caseSensitive:Boolean=true):Boolean { if ((sourceString==null) || (searchString==null)) { return (false); }//if if (sourceString is String) { var localSourceString:String=new String(sourceString); var localSearchString:String=new String(searchString); if (!caseSensitive) { localSourceString=localSourceString.toLowerCase(); localSearchString=localSearchString.toLowerCase(); }//if if (localSourceString.indexOf(localSearchString)>-1) { return (true); } else { return (false); }//else } else if (sourceString is Array) { localSearchString=new String(searchString); if (!caseSensitive) { localSearchString=localSearchString.toLowerCase(); }//if for (var count:uint=0; count-1) { return (true); } else { return (false); }//else }//for } else if ((sourceString==XML) || (sourceString==XMLNode)) { localSourceString=new String(sourceString.toString()); localSearchString=new String(searchString); if (!caseSensitive) { localSourceString=localSourceString.toLowerCase(); localSearchString=localSearchString.toLowerCase(); }//if if (localSourceString.indexOf(localSearchString)>-1) { return (true); } else { return (false); }//else } else { return (false); }//else return (false); }//stringContains /** * Returns the final character found in a specified input string. * * @param inputString The input string to examine. * @param exclusions A collection of excluded characters (all of these characters are ignored during the search). * * @return The final character of inputString that does not appear in any specified exclusions. * * @example * var myStr:String=""Hello there!""; * trace (getFinalChar(myStr, ""!"")); * //Final character in string is ""e"" since ""!"" is in the excluded character set. */ public static function getFinalChar(inputString:String, exclusions:* = null):String { if (inputString == null) { return (null); }//if if (inputString.length==0) { return (null); }//if var exclusionsStr:String = new String(); if (exclusions is Array) { exclusionsStr = exclusions.join(""""); }//if if (exclusions is String) { exclusionsStr = exclusions; }//if for (var count:int = inputString.length; count >= 0; count--) { var currentChar:String = inputString.substr(count, 1); if (exclusionsStr.indexOf(currentChar) < 0) { return (currentChar); }//if }//for return (null); }//getFinalChar /** * Strips the leading characters from an input string and returns the newly reformatted string. As soon as a non-stripped * character is encountered, the remainder of the string is left intact. * * @param inputString The string from which to strip the leading characters. The contents of this parameter are copied * so the original data is not affected. * @param stripChars The character or characters to strip from inputString. Multiple characters may be included * as a string or, alternately, this parameter may be an array of strings. * * @return A newly created copy of inputString with all the specified characters stripped out. * * @example The following example strips all punctuation from the beginning of the given input string: * * var sourceString:String = ""$-=This should not have puncutation at the beginning.""; * var strippedString:String = SwagDataTools.stripLeadingChars(sourceString, SwagDataTools.PUNCTUATION_RANGE); * trace (strippedString); //""This should not have puncutation at the beginning."" * * */ public static function stripLeadingChars(inputString:String, stripChars:*="" ""):String { if (inputString==null) { return(new String()); }//if if ((inputString=="""") || (inputString.length==0)) { return(new String()); }//if if (stripChars==null) { return (inputString); }//if var localStripChars:String=new String(); if (stripChars==Array) { for (var count:uint=0; countinputString. Multiple characters may be included * as a string or, alternately, this parameter may be an array of strings. * * @return A newly created copy of inputString with all the specified characters stripped out. * * @example The following example strips all lowercase letters and separators from the end of the given input string: * * var sourceString:String = ""IF YOU'RE NOT SHOUTING you will not be heard""; * var strippedString:String = SwagDataTools.stripTrailingChars(sourceString, SwagDataTools.LOWERCASE_RANGE + SwagDataTools.SEPARATOR_RANGE); * trace (strippedString); //""IF YOU'RE NOT SHOUTING"" * * */ public static function stripTrailingChars(inputString:String, stripChars:*="" ""):String { if (inputString==null) { return(new String()); }//if if ((inputString=="""") || (inputString.length==0)) { return(new String()); }//if if (stripChars==null) { return (inputString); }//if var localStripChars:String=new String(); if (stripChars==Array) { for (var count:uint=0; count=0; charCount--) { var currentChar:String=localInputString.charAt(charCount); if ((localStripChars.indexOf(currentChar)<0) || (trailStripped)) { returnString=currentChar+returnString; trailStripped=true; }//if }//for return (returnString); }//stripTrailingChars /** * Strips the outside (leading and trailing) characters from an input string and returns the newly reformatted string. As soon as a * non-stripped character is encountered from both directions, the remaining middle of the string is left intact. * * @param inputString The string from which to strip the outside characters. The contents of this parameter are copied * so the original data is not affected. * @param stripChars The character or characters to strip from inputString. Multiple characters may be included * as a string or, alternately, this parameter may be an array of strings. * * @return A newly created copy of inputString with all the specified characters stripped out. * * @example The following example strips all punctuation and separators from the beginning and end of the given input string: * * var sourceString:String = ""*** No extra stuff here! ***""; * var strippedString:String = SwagDataTools.stripOutsideChars(sourceString, SwagDataTools.PUNCTUATION_RANGE + SwagDataTools.SEPARATOR_RANGE); * trace (strippedString); //""No extra stuff here"" * * */ public static function stripOutsideChars(inputString:String, stripChars:*):String { var returnString:String=new String(); returnString=stripLeadingChars(inputString, stripChars); returnString=stripTrailingChars(returnString, stripChars); return (returnString); }//stripOutsideChars /** * Strips all of the specified characters from an input string and returns the newly reformatted string. * *

This method affects the whole string unlike the stripLeadingChars, stripTrailingChars, and * stripOutsideChars methods.

* * @param inputString The string from which to strip the characters. The contents of this parameter are copied * so the original data is not affected. * @param stripChars The character or characters to strip from inputString. Multiple characters may be included * as a string or, alternately, this parameter may be an array of strings. * * @return A newly created copy of inputString with all the specified characters stripped out. * * @example The following example strips the uppercase letters from the input string: * * var sourceString:String = ""EeVvEeRrYy OoTtHhEeRr LlEeTtTtEeRr IiSs OoKkAaYy""; * var strippedString:String = SwagDataTools.stripChars(sourceString, SwagDataTools.UPPERCASE_RANGE); * trace (strippedString); //""every other letter is okay"" * * */ public static function stripChars(inputString:String, stripChars:*="" ""):String { if (inputString==null) { return(new String()); }//if if ((inputString=="""") || (inputString.length==0)) { return(new String()); }//if if (stripChars==null) { return (inputString); }//if var localStripChars:String=new String(); if (stripChars is Array) { for (var count:uint=0; count=0; charCount--) { var currentChar:String=localInputString.charAt(charCount); if (localStripChars.indexOf(currentChar)<0) { returnString=currentChar+returnString; }//if }//for return (returnString); }//stripChars /** * Replaces all occurances of a specified string within a string with another string. * * @param sourceString The string within which to perform the replacement. The contents of the string are copied so that * the original string is not affected. * @param insertString The string to replace within sourceString. * @param patternString The pattern to replace with insertString within the sourceString. * * @return A copy of the sourceString with any occurances of patternString replaced with * insertString. * * @example The following example replaces all occurances of ""%name%"" with ""Bob"". * * * var sourceString:String = ""%name% is an excellent developer, and %name% is also a friend.""; * var resultString:String = SwagDataTools.replaceString(sourceString, ""Bob"", ""%name%""); * trace (resultString); //""Bob is an excellent developer, and Bob is also a friend."" * * */ public static function replaceString(sourceString:String, insertString:String, patternString:String):String { var localSourceString:String=new String(sourceString); var replaceSplit:Array=localSourceString.split(patternString); var returnString:String=replaceSplit.join(insertString); return (returnString); }//replaceString /** * Returns a substring of a string up to, and optionally inluding, a specific matching string. *

This method is similar to the String.slice, String.substr, or String.substring * methods except that it uses character matching instead of index values to denote the selected string.

* * @param sourceString The string from which to extract the substring. This value is copied by the method so the original * string will remain unaffacted. * @param patternString The pattern string to find within the sourceString. All the characters in sourceString * up to and (optionally), including patternString will be returned. * @param includePattern If true, the pattern string will be included in the returned string, otherwise only the * characters up to the patternString will be returned. * @param caseSensitive If true, the pattern and source strings are evaluated as is (case-sensitive). If false, * a non-case-sensitive comparison is done. * * @return The substring copy of sourceString up to and (optionally) including the patternString. If the * pattern can't be found, or it's empty (null or """"), an empty string is returned. If the method * encounters any other problem, a null value is returned. * * @see #getStringAfter() * */ public static function getStringBefore(sourceString:String, patternString:String, includePattern:Boolean=false, caseSensitive:Boolean=false):String { if (sourceString==null) { return (null); }//if var localSourceString:String=new String(sourceString); if ((patternString==null) || (patternString=="""") || (sourceString=="""")) { return (localSourceString); }//if var localLCSourceString:String=localSourceString.toLowerCase(); var localPatternString:String=new String(patternString); var localLCPatternString:String=localPatternString.toLowerCase(); var returnString:String=new String();; if (caseSensitive==true) { var patternIndex:int=localSourceString.indexOf(localPatternString); } else { patternIndex=localLCSourceString.indexOf(localLCPatternString); }//else if (patternIndex>0) { if (includePattern) { patternIndex+=localPatternString.length; returnString=localSourceString.substr(0, patternIndex); } else { returnString=localSourceString.substr(0, patternIndex); }//else return (returnString); } else { return (returnString); }//else return (returnString); }//getStringBefore /** * Returns a substring of a string after, and optionally inluding, a specific matching string. *

This method mimics the functionality of the getStringBefore method but returns the end of the string * up to and (optionally) including the pattern string instead of the beginning.

* * @param sourceString The string from which to extract the substring. This value is copied by the method so the original * string will remain unaffacted. * @param patternString The pattern string to find within the sourceString. All the characters in sourceString * after and (optionally), including patternString will be returned. * @param includePattern If true, the pattern string will be included in the returned string, otherwise only the * characters after the patternString will be returned. * @param caseSensitive If true, the pattern and source strings are evaluated as is (case-sensitive). If false, * a non-case-sensitive comparison is done. * * @return The substring copy of sourceString after and (optionally) including the patternString. If the * pattern can't be found, or it's empty (null or """"), an empty string is returned. If the method encounters any other problem, * a null value is returned. * */ public static function getStringAfter(sourceString:String, patternString:String, includePattern:Boolean=false, caseSensitive:Boolean=false):String { if (sourceString==null) { return (null); }//if var localSourceString:String=new String(sourceString); if ((patternString==null) || (patternString=="""") || (sourceString=="""")) { return (localSourceString); }//if var localLCSourceString:String=localSourceString.toLowerCase(); var localPatternString:String=new String(patternString); var localLCPatternString:String=localPatternString.toLowerCase(); var returnString:String=new String();; if (caseSensitive==true) { var patternIndex:int=localSourceString.lastIndexOf(localPatternString); } else { patternIndex=localLCSourceString.lastIndexOf(localLCPatternString); }//else patternIndex+=1; if (patternIndex>0) { if (includePattern) { patternIndex-=localPatternString.length; returnString=localSourceString.substr(patternIndex); } else { returnString=localSourceString.substr(patternIndex); }//else return (returnString); } else { return (returnString); }//else return (returnString); }//getStringAfter /** * Parses / splits a string containing software version information (for example, ""3.2.1 b""), into native (numeric / boolean) values. * *

The format of a typical version string is: majorVersion.minorVersion.buildNumber.internalBuildNumber a / b, where * ""a"" signifies an alpha version, and ""b"" is a beta version. If both ""a"" and ""b"" appear in the version information, it's considered * to represent an alpha version.

* * @param versionString The version string to parse. Currently, four levels of revision are supported (i.e. four * separators), as well as optional ""b"" or ""a"" on the end to denote beta or alpha versions. * @param separator The separator character between the version numbers (for example, "".""). * * @return An object containing the following properties: *
    *
  • major (int) - The parsed major value from the version string.
  • *
  • minor (int) - The parsed minor value from the version string.
  • *
  • build (int) - The parsed build value from the version string.
  • *
  • internalBuild (int) - The parsed internal build value from the version string.
  • *
  • alpha (Boolean) - The parsed alpha notation setting from the version string.
  • *
  • beta (Boolean) - The parsed beta notation setting from the version string (if alpha * is true, beta will always be false).
  • *
* Any numeric version values omitted will be returned as -1, and boolean values as false. * * @see flash.system.Capabilities#version */ public static function parseVersionString(versionString:String, separator:String="".""):Object { var returnObject:Object=new Object(); returnObject.major=new int(-1); returnObject.minor=new int(-1); returnObject.build=new int(-1); returnObject.internalBuild=new int(-1); returnObject.alpha=new Boolean(); returnObject.alpha=false; returnObject.beta=new Boolean(); returnObject.beta=false; if (versionString==null) { return (returnObject); }//if var localVersionString:String=new String(versionString); localVersionString=stripOutsideChars(localVersionString, "" ""); if ((localVersionString=="""") || ((localVersionString.length==0))) { return (returnObject); }//if var versionParts:Array=localVersionString.split(separator); if (hasData(versionParts[0])) { var partString:String=stripChars(versionParts[0], SwagDataTools.LOWERCASE_RANGE+SwagDataTools.UPPERCASE_RANGE); returnObject.major=int(partString); }//if if (hasData(versionParts[1])) { partString=stripChars(versionParts[1], SwagDataTools.LOWERCASE_RANGE+SwagDataTools.UPPERCASE_RANGE); returnObject.minor=int(partString); }//if if (hasData(versionParts[2])) { partString=stripChars(versionParts[2], SwagDataTools.LOWERCASE_RANGE+SwagDataTools.UPPERCASE_RANGE); returnObject.build=int(partString); }//if if (hasData(versionParts[3])) { var finalPart:String=new String(versionParts[3] as String); var stripCharacters:String=SwagDataTools.LOWERCASE_RANGE+SwagDataTools.UPPERCASE_RANGE +SwagDataTools.PUNCTUATION_RANGE+SwagDataTools.SEPARATOR_RANGE; returnObject.internalBuild=int(stripChars(finalPart, stripCharacters)); }//if if (stringContains(localVersionString, ""a"", false)) { returnObject.alpha=true; } else if (stringContains(localVersionString, ""b"", false)) { returnObject.beta=true; }//else if return (returnObject); }//parseVersionString /** * Converts a value in radians to its corresponding value in degrees. * * @param radians The radians value to convert to degrees. * * @return The degree equivalent of the input radians value. * */ public static function toDegrees(radians:Number):Number { var returnDegs:Number=radians*(180/Math.PI); return (returnDegs); }//toDegrees /** * Converts a value in degrees to its corresponding value in radians. * * @param degrees The degrees value to convert to radians. * * @return The radians equivalent of the input degrees value. * */ public static function toRadians(degrees:Number):Number { var returnRads:Number=degrees*(Math.PI/180); return (returnRads); }//toRadians /** * Returns the angle, in radians, between two planar line segments. * * @param line1 An object containing numeric properties x1, y1, and x2, y2 which define the first line segment. * @param line2 An object containing numeric properties x1, y1, and x2, y2 which define the second line segment. * * @return The angle between the two line segments, in degrees. * */ public static function getAngle(line1:Object=null, line2:Object=null):Number { if ((line1==null) || (line2==null)) { return (0); }//if if (!hasData(line1.x1)) { line1.x1=0; }//if if (!hasData(line1.x2)) { line1.x2=0; }//if if (!hasData(line1.y1)) { line1.y1=0; }//if if (!hasData(line1.y2)) { line1.y2=0; }//if if (!hasData(line2.x1)) { line2.x1=0; }//if if (!hasData(line2.x2)) { line2.x2=0; }//if if (!hasData(line2.y1)) { line2.y1=0; }//if if (!hasData(line2.y2)) { line2.y2=0; }//if //Adjust to 0,0 line1.x2-=line1.x1; line1.y2-=line1.y1; line2.x2-=line2.x1; line2.y2-=line2.y1; var angle1:Number = Math.atan2(line1.y2, line1.x2); var angle2:Number = Math.atan2(line2.y2, line2.x2); var returnAngle:Number = Math.abs(180*(angle1 - angle2)/Math.PI); return (returnAngle); }//getAngle /** * Returns a point on an elipse with x and y radii at a specified angle. The elipse * is assumed to have an origin at coordinates 0,0, and the angle (in degrees) begins at * the right-hand edge of the elipse as in standard geometry. If both the x and y radii are * the same, a circlular coordinate is returned. * * @param xRadius The x, or horizontal radius of the elipse. * @param yRadius The y, or vertical radius of the elipse. * @param angle The angle of the point, in degrees. * * @return A point on the specified elipse at the specified angle. Unless this point is offset to * a new x,y location, the returned Point object's length property can * be used to determing the distance, in pixels, from the elipse's origin to the point. * */ public static function getElipseCoords(xRadius:Number, yRadius:Number, angle:Number):Point { var returnPoint:Point=new Point(); var radianAngle:Number=toRadians(angle); returnPoint.x=xRadius*Math.cos(radianAngle); returnPoint.y=yRadius*Math.sin(radianAngle); return (returnPoint); }//getElipseCoords /** * Converts the to its hexadecimal representation as a string. *

For example, the input string ""Hello"" is represented by its hexadecimal values: 48+65+6C+6C+6F to produce the output * string ""48656C6C6F"". If the input parameter is a Number, its value (usually 32 bits) will be converted to its hexadecimal * string representation.

*

Note that the returned string has no standard hexadecimal notation such as ""#"" or ""0x"".

* * @param input The string to convert to its hexadecimal representation. Each character in the string will be converted to its * two-digit hexadecimal value. The input string is copied and so the original value won't be affected. * * @return The hexadecimal string representation of the input string. Any character for which the hexadecimal * value is less than 10 will have a 0 prepended. In this way the length of the returned string will always be double that * of the input string. If the input parameter is invalid, an empty string is returned. * * @see #toHexValue() * @see #fromHexString * * @internal Conversion from negative numeric values not working correctly! * */ public static function toHexString(input:*):String { if (isType(input, String, false)) { var localString:String=new String(); localString=String(input); var outStr:String=new String(); var tempStr:String=new String(); var currentChar:Number=new Number(); for (var count:uint=0;countinput string to. If this is a String, it's assumed to * be a string of hexadecimal values with each 2-digit value representing the ordinal number of an ASCII character. For * example, the input string ""48656C6C6F"" would be converted to ""Hello"". If this is a numeric type * (Number, int, or uint), the input string will be converted to the native numeric value * matching that type. If it's a ByteArray type, the whole hexadecimal string will be converted to native binary * data (uint) in a new ByteArra object. * * @return The plain text or native numeric value of the hexadecimal input string, or null if there was a problem converting it. * * @see #toHexString() */ public static function fromHexString(input:String, returnType:Class):* { if (returnType==Number) { var returnNum:Number=new Number(); returnNum=Number('0x'+input); return (returnNum); } else if (returnType==int) { var returnInt:int=new int(); returnInt=int('0x'+input); return (returnInt); } else if (returnType==uint) { var returnUInt:uint=new uint(); returnUInt=uint('0x'+input); return (returnUInt); } else if (returnType==ByteArray) { var realString:String=new String(); realString=String(input); var returnArray:ByteArray=new ByteArray(); var tempStr:String=new String(); for (var count:Number=0;countinputNumber. Note that if using a * bits value that is less than the number of bits found in the inputNumber * (typically 32 or 64), the resulting binary value won't be equal to the original decimal value since * some of the information is necessarily lost. * * @return The binary representation of the input number, accurate to the number of bits specified. * * @see fromBinaryString() * */ public static function toBinaryString(inputNumber:*, bits:uint=32):String { if (((inputNumber is uint) || (inputNumber is int) || (inputNumber is Number))==false) { return (new String()); }//if if (bits==0) { return (new String()); }//if var returnString:String=new String(); var currentDigit:String; for (var count:uint=0; count>> count); returnString=currentDigit+returnString; }//for return (returnString); }//toBinaryString /** * Converts the input binary string sequence to a native numeric type. * * @param inputString The string to convert to a native numeric type. * @param returnType The numeric type to convert the inputString to. Valid types are * Number, uint, and int. * * @return The numeric value represented by the binary inputString, of the type specified * by returnType. If the returnType specified is not a valid numeric type, * or the inputString contains invalid digits (not 0 or 1), null is returned. * * @see toBinaryString() * */ public static function fromBinaryString(inputString:String, returnType:Class):* { if ((returnType!=Number) && (returnType!=uint) && (returnType!=int)) { return (null); }//else var returnValue:*; var localInputString:String=new String(inputString); localInputString=stripOutsideChars(localInputString, SwagDataTools.SEPARATOR_RANGE); if ((localInputString=="""") || (localInputString.length==0)) { returnValue=0; return (returnValue); }//if for (var count:int=0; countNumber, int, or uint), from which to retrieve the * specified bit value. * @param bitPos The bit position to retrieve from within the input value. This number ranges from 1 to 32 (the highest * bit position currently supported by Flash). This parameter is 1-based so that 1 is the lowest (LSB) bit and 32 is the * highest (MSB) bit. * * @return True denotes that the bit at the specified position is on, or 1, and false denotes that it's off, or 0. * An undefined value is returned if the associated bit or input number are invalid. * * @see #setBit() * */ public static function getBit(input:*=null, bitPos:uint=0):Boolean { if ((!(input is Number)) && (!(input is int)) && (!(input is uint))) { return (undefined); }//if if ((bitPos<1) || (bitPos>32)) { return (undefined); }//if var returnBool:Boolean=new Boolean(); returnBool=Boolean ((input & (1 << (bitPos-1))) >> (bitPos-1)); return (returnBool); }//getBit /** * Sets the bit at the specified position in the input number to the specified value. * * @param input The numeric value (Number, int, or uint), within which * to manipulate the specified bit value. * @param bitPos The bit position to set from within the input value. This number ranges from 1 to 32 (the highest * bit position currently supported by Flash). This parameter is 1-based so that 1 is the lowest (LSB) bit and 32 is the * highest (MSB) bit. * @param setValue The value to assign to the specified bit, with true representing 1, or on, and false * representing 0, or off. * * @return The input value with the specified bit manipulated to the specified value. If the input * value was an object reference, the original object will be updated as well. * * @see #getBit() * */ public static function setBit(input:*=null, bitPos:uint=0, setValue:Boolean=false):* { if ((!(input is Number)) && (!(input is int)) && (!(input is uint))) { return (undefined); }//if if ((bitPos<1) || (bitPos>32)) { return (undefined); }//if if (setValue==true) { input=input | (1 << (bitPos-1)); } else { var tempVal:uint=1; tempVal=~(tempVal << (bitPos-1)); input=input & tempVal; }//else return (input); }//setBit /** * Converts an input value to a boolean value. Typical input values can include strings such * as ""true"", ""false"", ""yes"", ""no"", ""on"", ""off"", ""1"", ""0"", etc., and numbers such as 1 and 0. * * @param input The input value to attempt to convert to a valid boolean value. * @param defaultValue The default boolean value to return if the input parameter can't be converted. * * @return A valid boolean value based on the input, or the default value if conversion can't be completed. * */ public static function toBoolean(input:*, defaultValue:Boolean=false):Boolean { if (input==null) { return (defaultValue); }//if if ((input is XML) || (input is XMLList)) { input=new String(input.toString()); }//if if (input is String) { var inputString:String=new String(input); inputString=inputString.toLowerCase(); inputString=stripOutsideChars(inputString, SEPARATOR_RANGE); switch (inputString) { case ""true"" : return (true); break; case ""t"" : return (true); break; case ""yes"" : return (true); break; case ""y"" : return (true); break; case ""on"" : return (true); break; case ""active"" : return (true); break; case ""set"" : return (true); break; case ""1"" : return (true); break; case ""false"" : return (false); break; case ""f"" : return (false); break; case ""no"" : return (false); break; case ""n"" : return (false); break; case ""off"" : return (false); break; case ""inactive"" : return (true); break; case ""unset"" : return (true); break; case ""0"" : return (false); break; default : return (defaultValue); break; }//switch }//if if ((input is Number) || (input is uint) || (input is int)) { if (input==1) { return (true); } else { return (false); }//else }//if return (defaultValue); }//toBoolean /** * Sizes a target DisplayObject while maintaining the aspect ratio. The resulting image will be * sized according to the largest of the width and height parameters. * * @param target The DisplayObject to size while maintaining the aspect ratio. * @param targetWidth The desired width of the target object. This value is used if it's larger than the target height. * @param targetHeight The desired height of the target object. This value is used if it's larger than the target width. * @param scaleBitmap If the target parameter is a Bitmap, setting this value will force a * transform to be applied to the resulting Bitmap object. * * @return The target object, of the same type as the target parameter sized to either the largest width * or height specified while maintaining the aspect ratio. * */ public static function sizeWithAspectRatio(target:DisplayObject, targetWidth:Number, targetHeight:Number, scaleBitmap:Boolean=false):DisplayObject { if (target==null) { return (null); }//if if (target.width>target.height) { var multiplier:Number=targetWidth/target.width; if ((scaleBitmap) && (target is Bitmap)) { var matrix:Matrix = new Matrix(); matrix.scale(multiplier, multiplier); var smallBMD:BitmapData = new BitmapData(Bitmap(target).bitmapData.width*multiplier, Bitmap(target).bitmapData.height*multiplier, true, 0x000000); smallBMD.draw(Bitmap(target).bitmapData, matrix, null, null, null, true); var sizedBitmap:Bitmap = new Bitmap(smallBMD, PixelSnapping.NEVER, true); return (sizedBitmap); } else { target.width=targetWidth; target.height*=multiplier; }//else } else { multiplier=targetHeight/target.height; if ((scaleBitmap) && (target is Bitmap)) { matrix = new Matrix(); matrix.scale(multiplier, multiplier); smallBMD = new BitmapData(Bitmap(target).bitmapData.width*multiplier, Bitmap(target).bitmapData.height*multiplier, true, 0x000000); smallBMD.draw(Bitmap(target).bitmapData, matrix, null, null, null, true); sizedBitmap = new Bitmap(smallBMD, PixelSnapping.NEVER, true); return (sizedBitmap); } else { target.height=targetHeight; target.width*=multiplier; }//else }//else return (target); }//sizeWithAspectRatio /** * Creates a bitmap from a linked BitmapData object in the library. * * @param bitmapClass The fully qualified name of the library item to create. The item must * be of type BitmapData, otherwise this method will fail. * * @return The newly created Bitmap object created from the library bitmap data, * or null if it couldn't be created. */ public static function createBitmap(bitmapClass:String):Bitmap { try { var classRef:Class=getDefinitionByName(bitmapClass) as Class; var bmpData:BitmapData=new classRef(); var returnBitmap:Bitmap=new Bitmap(bmpData); return (returnBitmap); } catch (e:*) { return (null); }//catch return (null); }//createBitmap /** * Converts a ByteArray object to a native Flash display object. This may be * a Bitmap, Sprite, or MovieClip object depending on the data supplied. * * @param bytes The ByteArray object to be converted to a display object. * @param onLoadComplete The function to invoke when the load operation completes. This function * must be an event listener for an Event.INIT event. Target the event object's * .target.content property for the returned display object. * * @return A Bitmap, Sprite, or MovieClip object. * */ public static function byteArrayToDisplayObject(bytes:ByteArray, onLoadComplete:Function):DisplayObject { var objectLoader:Loader=new Loader(); objectLoader.contentLoaderInfo.addEventListener(Event.INIT, onLoadComplete); objectLoader.loadBytes(bytes); return (objectLoader.content); }//byteArrayToDisplayObject /** * Decodes a string containing HTML entitities, including those that are not directly supported with ActionScript's * unescape method. *

NOTE: As per the W3C specification, HTML entitities are case-sensitive.

* * @param inString The string containing the HTML entitities to translate to plain text. A copy of this * string is made so that the original paramater data is not affected. * * @return The processed copy of the inString parameter with all of the HTML entities translated to plain text. * */ public static function HTMLDecode(inString:String):String { var localString:String=new String(); localString=String(inString); //Typographical / markup / grammatical marks localString=replaceString(localString, String.fromCharCode(34), """""); localString=replaceString(localString, String.fromCharCode(39), ""'""); localString=replaceString(localString, String.fromCharCode(60), ""<""); localString=replaceString(localString, String.fromCharCode(62), "">""); localString=replaceString(localString, String.fromCharCode(160), "" ""); localString=replaceString(localString, String.fromCharCode(38), ""&""); localString=replaceString(localString, String.fromCharCode(166), ""¦""); localString=replaceString(localString, String.fromCharCode(8211), ""–""); localString=replaceString(localString, String.fromCharCode(8212), ""—""); localString=replaceString(localString, String.fromCharCode(171), ""«""); localString=replaceString(localString, String.fromCharCode(187), ""»""); localString=replaceString(localString, String.fromCharCode(171), ""‹""); localString=replaceString(localString, String.fromCharCode(187), ""›""); localString=replaceString(localString, String.fromCharCode(167), ""§""); localString=replaceString(localString, String.fromCharCode(182), ""¶""); localString=replaceString(localString, String.fromCharCode(8224), ""†""); localString=replaceString(localString, String.fromCharCode(8225), ""‡""); localString=replaceString(localString, String.fromCharCode(8226), ""•""); localString=replaceString(localString, String.fromCharCode(183), ""·""); localString=replaceString(localString, String.fromCharCode(191), ""¿""); localString=replaceString(localString, String.fromCharCode(161), ""¡""); //Intellectual property marks localString=replaceString(localString, String.fromCharCode(169), ""©""); localString=replaceString(localString, String.fromCharCode(169), ""©right;""); localString=replaceString(localString, String.fromCharCode(174), ""®""); localString=replaceString(localString, String.fromCharCode(174), ""®istered;""); localString=replaceString(localString, String.fromCharCode(8482), ""™""); localString=replaceString(localString, String.fromCharCode(8482), ""&trademark;""); //Mathematical marks localString=replaceString(localString, String.fromCharCode(177), ""±""); localString=replaceString(localString, String.fromCharCode(8722), ""−""); localString=replaceString(localString, String.fromCharCode(8721), ""∑""); localString=replaceString(localString, String.fromCharCode(215), ""×""); localString=replaceString(localString, String.fromCharCode(247), ""÷""); localString=replaceString(localString, String.fromCharCode(189), ""½""); localString=replaceString(localString, String.fromCharCode(188), ""¼""); localString=replaceString(localString, String.fromCharCode(190), ""¾""); localString=replaceString(localString, String.fromCharCode(8734), ""∞""); localString=replaceString(localString, String.fromCharCode(8776), ""≈""); localString=replaceString(localString, String.fromCharCode(8804), ""≤""); localString=replaceString(localString, String.fromCharCode(8805), ""≥""); localString=replaceString(localString, String.fromCharCode(8800), ""≠""); localString=replaceString(localString, String.fromCharCode(8801), ""≡""); localString=replaceString(localString, String.fromCharCode(8747), ""∫""); localString=replaceString(localString, String.fromCharCode(8730), ""√""); localString=replaceString(localString, String.fromCharCode(185), ""¹""); localString=replaceString(localString, String.fromCharCode(178), ""²""); localString=replaceString(localString, String.fromCharCode(179), ""³""); localString=replaceString(localString, String.fromCharCode(188), ""µ""); localString=replaceString(localString, String.fromCharCode(176), ""°""); localString=replaceString(localString, String.fromCharCode(8240), ""‰""); localString=replaceString(localString, String.fromCharCode(8242), ""′""); localString=replaceString(localString, String.fromCharCode(8243), ""″""); localString=replaceString(localString, String.fromCharCode(913), ""Α""); localString=replaceString(localString, String.fromCharCode(945), ""α""); localString=replaceString(localString, String.fromCharCode(914), ""Β""); localString=replaceString(localString, String.fromCharCode(946), ""β""); localString=replaceString(localString, String.fromCharCode(916), ""Δ""); localString=replaceString(localString, String.fromCharCode(948), ""δ""); localString=replaceString(localString, String.fromCharCode(928), ""Π""); localString=replaceString(localString, String.fromCharCode(960), ""π""); localString=replaceString(localString, String.fromCharCode(937), ""Ω""); localString=replaceString(localString, String.fromCharCode(969), ""ω""); //Currency symbols localString=replaceString(localString, String.fromCharCode(162), ""¢""); localString=replaceString(localString, String.fromCharCode(163), ""£""); localString=replaceString(localString, String.fromCharCode(165), ""¥""); localString=replaceString(localString, String.fromCharCode(8364), ""€""); localString=replaceString(localString, String.fromCharCode(164), ""¤""); //One more pass to decode numeric HTML entities localString=unescape (localString); return (localString); }//urlDecode /** * Retrieves an ordered list (Array), of the parameters for the specified method. *

The returned list will be an array of classes / types that can be used to determine what data type(s) * the supplied method supports.

* * @param method The method for which to retrieve the list of parameters. * @param container The containing object in which the method resides. Without this reference it's * not possible to determine the specific method properties (this call will fail). * * @return An ordered Array of classes / types, in the order in which they appear, of the specified * method, or null if there was a problem retrieving this information. For a method with no parameters, * an empty Array object is returned. If the container property is null or * doesn't contain the referenced method, null is returned. If a parameter is a wildcard (*), * a null value is stored at the associated index location within the returned array. The ... rest * notation is not considered a parameter since, technically, the method does not expect any data and no type is declared. *

Note: Unlike the index values returned by the describeType method, the returned parameter list * is 0-indexed (i.e. always 1 less than in the XML description).

* */ public static function getMethodParameters(method:Function, container:*):Array { if (method==null) { return (null); }//if if (container==null) { return (null); }//if var returnArray:Array=new Array(); var containerInfo:XML=describeType(container) as XML; if (SwagDataTools.hasData(containerInfo.method)==false) { return (null); }//if var methods:XMLList=containerInfo.method as XMLList; for (var count:uint=0; countThis can be used, for example, to determine if a specific event type belongs to * an event object.

* * @param targetObject The object to inspect for the constant. * @param constantName The name of the constant to attempt to find. * * @return True if the specified constant exists within the targetObject, * false otherwise. * */ public static function hasDeclaredConstant(targetObject:*=null, constantName:String=null):Boolean { if ((targetObject==null) || (constantName==null) || (constantName=="""")) { return (false); }//if var objectInfo:XML=describeType(targetObject) as XML; if (!SwagDataTools.hasData(objectInfo.constant)) { return (false); }//if var constantNodes:XMLList=objectInfo.constant as XMLList; for (var count:uint=0; count[a-zA-Z]+) : \\/\\/ (?P[^:\\/]*) (:(?P\\d+))? ((?P[^?]*))? ((?P.*))? /x; var results:Array = reg.exec(urlValue); var returnObj:Object=new Object(); returnObj.protocol = results.protocol; returnObj.domain = results.host; returnObj.port = results.port; returnObj.path = results.path; returnObj.file = String(returnObj.path).substr(String(returnObj.path).lastIndexOf(""/"")+1); returnObj.path=String(returnObj.path).split(returnObj.file).join(""""); var paramsStr:String = results.parameters; if(paramsStr!="""") { returnObj.parameters = new Object(); if(paramsStr.charAt(0) == ""?"") { paramsStr = paramsStr.substring(1); }//if var params:Array = paramsStr.split(""&""); for each(var paramStr:String in params) { var param:Array = paramStr.split(""=""); returnObj.parameters[param[0]] = param[1]; }//for }//if return (returnObj); }//getURLParts }//SwagDataTools class }//package",16132,True,2699.3877302165583,median "* Copyright 2019,2020 IBM Corp. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. class ZCL_IBMC_SERVICE definition public inheriting from ZCL_IBMC_SERVICE_ARCH create public . public section. types DATA_REFERENCE type ref to DATA . types: FIELDNAME(30) type c . types BOOLEAN type ZIF_IBMC_SERVICE_ARCH~BOOLEAN . types CHAR type ZIF_IBMC_SERVICE_ARCH~CHAR . types DATE type STRING . types TIME type STRING . types INTEGER type I . types SHORT type INT2 . types LONG type INT8 . types FLOAT type F . types DOUBLE type F . types NUMBER type F . types FILE type XSTRING . types BINARY type XSTRING . types JSONOBJECT type ref to DATA . types MAP type ref to DATA . types: ""!

DateTime type, format 2018-10-23T15:18:18.914xxxZ

DATETIME(27) type c . types TT_STRING type ZIF_IBMC_SERVICE_ARCH~TT_STRING . types: TT_BOOLEAN type standard table of ZIF_IBMC_SERVICE_ARCH~BOOLEAN with non-unique default key . types: TT_CHAR type standard table of ZIF_IBMC_SERVICE_ARCH~CHAR with non-unique default key . types: TT_INTEGER type standard table of INTEGER with non-unique default key . types: TT_SHORT type standard table of SHORT with non-unique default key . types: TT_LONG type standard table of LONG with non-unique default key . types: TT_FLOAT type standard table of FLOAT with non-unique default key . types: TT_DOUBLE type standard table of DOUBLE with non-unique default key . types: TT_NUMBER type standard table of NUMBER with non-unique default key . types: TT_FILE type standard table of FILE with non-unique default key . types: begin of TS_MAP_FILE, KEY type STRING, DATA type FILE, end of TS_MAP_FILE . types: TT_MAP_FILE type standard table of TS_MAP_FILE with non-unique default key . types: begin of TS_FILE_WITH_METADATA, FILENAME type string, CONTENT_TYPE type string, DATA type xstring, end of TS_FILE_WITH_METADATA . types: TT_FILE_WITH_METADATA type standard table of TS_FILE_WITH_METADATA with non-unique default key . types TS_FORM_PART type ZIF_IBMC_SERVICE_ARCH~TS_FORM_PART . types TT_FORM_PART type ZIF_IBMC_SERVICE_ARCH~TT_FORM_PART . constants C_BOOLEAN_FALSE type BOOLEAN value SPACE ##NO_TEXT. constants C_BOOLEAN_TRUE type BOOLEAN value 'X' ##NO_TEXT. constants C_TRIBOOL_FALSE type BOOLEAN value '-' ##NO_TEXT. constants C_DEFAULT type STRING value 'DEFAULT' ##NO_TEXT. constants C_SUBRC_UNKNOWN type SY-SUBRC value 999999 ##NO_TEXT. constants C_MSGID type SY-MSGID value 'ZIBMC' ##NO_TEXT. constants C_I_ZERO type I value -2147481648 ##NO_TEXT. constants C_I8_ZERO type INT8 value -9223372036854775608 ##NO_TEXT. constants C_F_ZERO type F value '-2147481.648' ##NO_TEXT. constants C_BLANK type STRING value '&#§§#&__%$X' ##NO_TEXT. constants: begin of C_DATATYPE, string type char value 'g', struct type char value 'v', end of C_DATATYPE . data P_REQUEST_PROP_DEFAULT type TS_REQUEST_PROP . data P_DEBUG_MODE type CHAR value SPACE ##NO_TEXT. data P_VERSION type STRING . ""!

Raises an exception.

""! ""! @parameter I_MSGNO | Message number. ""! @parameter I_MSGV1 | Substitution for 1st placeholder in message. ""! @parameter I_MSGV2 | Substitution for 2nd placeholder in message. ""! @parameter I_MSGV3 | Substitution for 3rd placeholder in message. ""! @parameter I_MSGV4 | Substitution for 4th placeholder in message. ""! @parameter I_TEXT | Message text; specify if message number is not specified. ""! @parameter I_SUBRC | Return code being returned. ""! @parameter I_PREVIOUS | Exception that has been captured before. ""! @parameter I_HTTP_STATUS | HTTP status code if exception is triggered by HTTP error ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised. ""! class-methods RAISE_EXCEPTION importing !I_MSGNO type SY-MSGNO optional !I_MSGV1 type STRING optional !I_MSGV2 type STRING optional !I_MSGV3 type STRING optional !I_MSGV4 type STRING optional !I_TEXT type STRING optional !I_SUBRC type SY-SUBRC default C_SUBRC_UNKNOWN !I_PREVIOUS type ref to CX_ROOT optional !I_HTTP_STATUS type TS_HTTP_STATUS optional raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Returns field type and length of a given parameter.

""! ""! @parameter I_FIELD | Field of type that is supposed to be determined. ""! @parameter E_TECHNICAL_TYPE | Technical type (= base type) of I_FIELD. ""! @parameter E_RELATIVE_TYPE | Relative type (= data type) of I_FIELD. ""! @parameter E_LENGTH | Length of type of I_FIELD. ""! class-methods GET_FIELD_TYPE importing !I_FIELD type ANY exporting !E_TECHNICAL_TYPE type ZIF_IBMC_SERVICE_ARCH~CHAR !E_RELATIVE_TYPE type STRING !E_LENGTH type I . ""!

Returns component names of a given structure.

""! ""! @parameter I_STRUCTURE | Structure with components. ""! @parameter E_COMPONENTS | Internal table of component names. ""! class-methods GET_COMPONENTS importing !I_STRUCTURE type ANY exporting value(E_COMPONENTS) type ZIF_IBMC_SERVICE_ARCH~TT_STRING . ""!

Parses a JSON string into an ABAP structure.

""! ""! @parameter I_JSON | JSON string. ""! @parameter I_DICTIONARY | Dictionary for mapping of identifier names. ""! @parameter C_ABAP | ABAP structure to be filled ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! class-methods PARSE_JSON importing !I_JSON type STRING !I_DICTIONARY type ANY optional changing value(C_ABAP) type ANY raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Method for internal use.

""! methods GET_REQUEST_PROP importing !I_AUTH_METHOD type STRING default C_DEFAULT returning value(E_REQUEST_PROP) type TS_REQUEST_PROP . ""!

Returns data type of a given parameter.

""! ""! @parameter I_FIELD | Field of type that is supposed to be determined. ""! @parameter E_DATATYPE | Technical type (= base type) of I_FIELD. ""! class-methods GET_DATATYPE importing !I_FIELD type ANY returning value(E_DATATYPE) type ZIF_IBMC_SERVICE_ARCH~CHAR . ""!

Unescape unicode codepoints to characters in a string

, ""! e.g. '\\u0041 b \\u0063' -> 'A b c' ""! ""! @parameter I_IN | String with unicode codepoints. ""! @parameter E_OUT | Unescaped string. ""! class-methods UNESCAPE_UNICODE importing !I_IN type STRING returning value(E_OUT) type STRING . ""!

Returns the file extension for a mime type

, ""! e.g. 'text/plain' -> 'txt' ""! ""! @parameter I_MIME_TYPE | MIME type. ""! @parameter E_EXTENSION | File extension (without leading dot). ""! class-methods GET_FILE_EXTENSION importing value(I_MIME_TYPE) type STRING returning value(E_EXTENSION) type STRING . ""!

Moves a referenced data structure to an ABAP structure.

""! ""! @parameter I_DATA_REFERENCE | Reference to data object. ""! @parameter E_ABAP | ABAP structure to be filled. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! class-methods MOVE_DATA_REFERENCE_TO_ABAP importing !I_DATA_REFERENCE type DATA_REFERENCE exporting value(E_ABAP) type ANY raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Method for internal use.

""! class-methods ADD_QUERY_PARAMETER importing !I_PARAMETER type STRING !I_VALUE type STRING !I_IS_BOOLEAN type BOOLEAN default C_BOOLEAN_FALSE changing !C_URL type TS_URL . ""!

Method for internal use.

""! class-methods ADD_HEADER_PARAMETER importing !I_PARAMETER type STRING !I_VALUE type STRING !I_IS_BOOLEAN type BOOLEAN default C_BOOLEAN_FALSE changing !C_HEADERS type ZIF_IBMC_SERVICE_ARCH~TS_REQUEST_PROP-HEADERS . ""!

Method for internal use.

""! class-methods GET_FULL_URL importing !I_URL type TS_URL returning value(E_URL) type STRING . ""!

Returns the service name.

""! ""! @parameter E_APPNAME | Name of the service. ""! methods GET_APPNAME returning value(E_APPNAME) type STRING . ""!

Method for internal use.

""! class-methods NORMALIZE_URL changing !C_URL type TS_URL . ""!

Extracts a JSON string from an ABAP structure.

""! ""! @parameter I_NAME | Name of component to be extracted. ""! @parameter I_VALUE | ABAP structure to be converted to JSON string. ""! @parameter I_DICTIONARY | Dictionary to be used for mapping ABAP identifiers to JSON keys. ""! @parameter I_REQUIRED_FIELDS | ""! Dictionary of required fields.
""! If a field is required, an initial value appears as initial value in JSON structure. ""! Otherwise it is omitted in JSON string. ""! @parameter I_LOWER_CASE | If set to C_BOOLEAN_TRUE all keys in JSON string will be lower case. ""! @parameter E_JSON | JSON string. ""! class-methods ABAP_TO_JSON importing !I_NAME type STRING optional !I_VALUE type ANY !I_DICTIONARY type ANY optional !I_REQUIRED_FIELDS type ANY optional !I_LOWER_CASE type BOOLEAN default C_BOOLEAN_TRUE returning value(E_JSON) type STRING . ""!

Throws an exception, if HTTP response indicates an error.

""! ""! @parameter I_RESPONSE | HTTP response to be checked. ""! @parameter I_URL | URL that the request has been sent to. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! methods CHECK_HTTP_RESPONSE importing !I_RESPONSE type TO_REST_RESPONSE optional !I_URL type TS_URL optional raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Class constructor.

""! ""! @parameter I_URL | URL of the service. ""! @parameter I_HOST | Host of the service. I_URL and I_HOST can be used synonymously. ""! @parameter I_PROXY_HOST | Proxy server, not applicable on SAP Cloud Platform. ""! @parameter I_PROXY_PORT | Proxy server port, not applicable on SAP Cloud Platform. ""! @parameter I_USERNAME | User name to authenticate on service. ""! @parameter I_PASSWORD | User password to authenticate on service. ""! @parameter I_APIKEY | API key password to authenticate on service. ""! @parameter I_ACCESS_TOKEN | Access token to authenticate on service. ""! @parameter I_SSL_ID | ID of PSE, not applicable on SAP Cloud Platform. ""! @parameter I_DEBUG_MODE | not used. ""! methods CONSTRUCTOR importing !I_URL type STRING optional !I_HOST type STRING optional !I_PROXY_HOST type STRING optional !I_PROXY_PORT type STRING optional !I_USERNAME type STRING optional !I_PASSWORD type STRING optional !I_APIKEY type STRING optional !I_ACCESS_TOKEN type TS_ACCESS_TOKEN optional !I_SSL_ID type ZIF_IBMC_SERVICE_ARCH~TY_SSL_ID optional !I_DEBUG_MODE type CHAR default SPACE . ""!

Method for internal use.

""! methods GET_REST_CLIENT importing !I_REQUEST_PROP type TS_REQUEST_PROP returning value(E_CLIENT) type TS_CLIENT raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Method for internal use.

""! methods GET_ACCESS_TOKEN importing !I_REQUEST_PROP type TS_REQUEST_PROP optional returning value(E_ACCESS_TOKEN) type TS_ACCESS_TOKEN raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Sends a HTTP DELETE request.

""! ""! @parameter I_REQUEST_PROP | Request properties. ""! @parameter E_RESPONSE | Response returned by service. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! methods HTTP_DELETE importing !I_REQUEST_PROP type TS_REQUEST_PROP returning value(E_RESPONSE) type TO_REST_RESPONSE raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Sets an access token explicitly.

""! ""! @parameter I_ACCESS_TOKEN | Access token. ""! methods SET_ACCESS_TOKEN importing !I_ACCESS_TOKEN type TS_ACCESS_TOKEN . ""!

Sends a HTTP GET request.

""! ""! @parameter I_REQUEST_PROP | Request properties. ""! @parameter E_RESPONSE | Response returned by service. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! methods HTTP_GET importing !I_REQUEST_PROP type TS_REQUEST_PROP returning value(E_RESPONSE) type TO_REST_RESPONSE raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Sends a HTTP POST request.

""! ""! @parameter I_REQUEST_PROP | Request properties. ""! @parameter E_RESPONSE | Response returned by service. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! methods HTTP_POST importing !I_REQUEST_PROP type TS_REQUEST_PROP returning value(E_RESPONSE) type TO_REST_RESPONSE raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Sends a HTTP POST request with multipart body.

""! ""! @parameter I_REQUEST_PROP | Request properties. ""! @parameter IT_FORM_PART | Internal table of form parts in request body. ""! @parameter E_RESPONSE | Response returned by service. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! methods HTTP_POST_MULTIPART importing !I_REQUEST_PROP type TS_REQUEST_PROP !IT_FORM_PART type TT_FORM_PART returning value(E_RESPONSE) type TO_REST_RESPONSE raising ZCX_IBMC_SERVICE_EXCEPTION . ""!

Sends a HTTP PUT request.

""! ""! @parameter I_REQUEST_PROP | Request properties. ""! @parameter E_RESPONSE | Response returned by service. ""! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. ""! methods HTTP_PUT importing !I_REQUEST_PROP type TS_REQUEST_PROP returning value(E_RESPONSE) type TO_REST_RESPONSE raising ZCX_IBMC_SERVICE_EXCEPTION . protected section. ""!

Method for internal use.

methods ADJUST_REQUEST_PROP changing !C_REQUEST_PROP type TS_REQUEST_PROP . ""!

Method for internal use.

class-methods MERGE_STRUCTURE importing !I_ALTERNATIVE type ANY changing !C_BASE type ANY . ""!

Method for internal use.

methods SET_DEFAULT_QUERY_PARAMETERS changing !C_URL type TS_URL . ""!

Method for internal use.

methods SET_URI_AND_AUTHORIZATION importing !I_CLIENT type TS_CLIENT !I_REQUEST_PROP type TS_REQUEST_PROP returning value(E_URI) type STRING raising ZCX_IBMC_SERVICE_EXCEPTION . private section. ENDCLASS. CLASS ZCL_IBMC_SERVICE IMPLEMENTATION. method abap_to_json. data: lv_json type string, lv_json_comp type string, lv_json_num(24) type c, lv_sep(1) type c, lv_name type string, lv_name_uc type string, lv_type type char, lt_compname type tt_string, lv_name_in_dict type boolean, lv_relative_type type string, lv_pattern type string, lv_str type string. field-symbols: type any, type string, type any, type i, type int8, type f, type any table, type string, type string. get_field_type( exporting i_field = i_value importing e_technical_type = lv_type e_relative_type = lv_relative_type ). if lv_type eq zif_ibmc_service_arch~c_datatype-dataref or lv_type eq zif_ibmc_service_arch~c_datatype-objectref. if i_value is initial. return. endif. assign i_value->* to . get_field_type( exporting i_field = importing e_technical_type = lv_type e_relative_type = lv_relative_type ). else. assign i_value to . endif. if lv_type ne zif_ibmc_service_arch~c_datatype-struct and lv_type ne zif_ibmc_service_arch~c_datatype-struct_deep and lv_type ne zif_ibmc_service_arch~c_datatype-itab. "" simple type if lv_type eq 'C' or lv_type eq 'N' or lv_type eq 'g'. lv_str = . if lv_str eq c_blank. "" parameter is blank, not initial (i.e. null) lv_str = ''. else. replace all occurrences of '""' in lv_str with '\\""'. replace all occurrences of cl_abap_char_utilities=>cr_lf in lv_str with '\\n'. replace all occurrences of cl_abap_char_utilities=>newline in lv_str with '\\n'. endif. "" quote value unless it is a boolean if lv_relative_type eq 'BOOLEAN'. if lv_str eq c_boolean_true. lv_json = `true`. elseif lv_str eq c_boolean_false. lv_json = `false`. else. lv_json = lv_str. endif. else. lv_json = `""` && lv_str && `""`. endif. else. do 1 times. "" to allow exit command "" special handling for optional parameters explicitly set to initial if lv_type eq 'I'. assign to . if = c_i_zero. lv_json_num = '0'. exit. endif. elseif lv_type eq '8'. assign to . if = c_i8_zero. lv_json_num = '0'. exit. endif. elseif lv_type eq 'F'. assign to . if = c_f_zero. lv_json_num = '0'. exit. endif. endif. lv_json_num = conv #( ). condense lv_json_num no-gaps. enddo. lv_json = lv_json_num. endif. elseif lv_type eq zif_ibmc_service_arch~c_datatype-struct or lv_type eq zif_ibmc_service_arch~c_datatype-struct_deep. "" structure get_components( exporting i_structure = importing e_components = lt_compname ). clear lv_sep. lv_json = lv_json && `{`. loop at lt_compname assigning . assign component of structure to . if sy-subrc <> 0. continue. endif. "" do not add property if not required and corresponding abap field is initial if is initial and not i_required_fields is initial. assign component lv_relative_type of structure i_required_fields to . if sy-subrc <> 0. continue. endif. lv_pattern = `*|` && && `|*`. if not cp lv_pattern. continue. endif. endif. lv_name = . "" check if key name exists in abap names dictionary lv_name_in_dict = c_boolean_false. try. assign component lv_name of structure i_dictionary to . if sy-subrc = 0. lv_name = . lv_name_in_dict = c_boolean_true. endif. catch cx_sy_assign_cast_illegal_cast cx_sy_assign_cast_unknown_type cx_sy_assign_out_of_range. endtry. if lv_name_in_dict eq c_boolean_false and i_lower_case eq c_boolean_true. "" convert name to lower case translate lv_name to lower case. endif. "" add property (recursively) lv_json_comp = abap_to_json( i_name = lv_name i_value = i_lower_case = i_lower_case i_dictionary = i_dictionary i_required_fields = i_required_fields ). lv_json = lv_json && lv_sep && lv_json_comp. lv_sep = ','. endloop. lv_json = lv_json && `}`. elseif lv_type eq zif_ibmc_service_arch~c_datatype-itab. "" internal table lv_json = lv_json && `[`. clear lv_sep. assign to . loop at assigning . lv_json_comp = abap_to_json( i_value = i_lower_case = i_lower_case i_dictionary = i_dictionary i_required_fields = i_required_fields ). lv_json = lv_json && lv_sep && lv_json_comp. lv_sep = ','. endloop. lv_json = lv_json && `]`. endif. if not i_name is initial. lv_name_in_dict = c_boolean_false. lv_name = i_name. if not i_dictionary is initial. assign component i_name of structure i_dictionary to . if sy-subrc = 0. lv_name = . lv_name_in_dict = c_boolean_true. endif. endif. if lv_name_in_dict eq c_boolean_false and i_lower_case eq c_boolean_true. "" convert name to lower case translate lv_name to lower case. endif. e_json = `""` && lv_name && `"": ` && lv_json. else. e_json = lv_json. endif. endmethod. method add_header_parameter. data: ls_header type line of zif_ibmc_service_arch~ts_request_prop-headers, lv_value type string. if i_is_boolean eq c_boolean_true. if i_value eq c_boolean_true. lv_value = 'true'. else. lv_value = 'false'. endif. else. lv_value = i_value. endif. condense lv_value. "" remove trailing spaces ls_header-name = i_parameter. ls_header-value = lv_value. append ls_header to c_headers. endmethod. method add_query_parameter. data: lv_param type string. if i_is_boolean eq c_boolean_true. if i_value eq c_boolean_true. lv_param = 'true'. else. lv_param = 'false'. endif. else. lv_param = i_value. endif. condense lv_param. "" remove trailing spaces lv_param = i_parameter && `=` && lv_param. if c_url-querystring is initial. c_url-querystring = lv_param. else. c_url-querystring = c_url-querystring && `&` && lv_param. endif. endmethod. method adjust_request_prop. data: ls_request_prop_openapi type ts_request_prop. merge_structure( exporting i_alternative = p_request_prop_default changing c_base = c_request_prop ). "" Separate protocol, host and path in url normalize_url( changing c_url = c_request_prop-url ). "" Set defaults for some unspecified properties if c_request_prop-url-protocol is initial. c_request_prop-url-protocol = 'http' ##NO_TEXT. endif. if c_request_prop-auth_headername is initial. c_request_prop-auth_headername = 'Authorization' ##NO_TEXT. endif. "" Allow basic authentication with apikey if c_request_prop-auth_basic eq c_boolean_true. if c_request_prop-username is initial and c_request_prop-password is initial and not c_request_prop-apikey is initial. c_request_prop-username = 'apikey' ##NO_TEXT. c_request_prop-password = c_request_prop-apikey. endif. endif. "" Correct authentication location if ( c_request_prop-auth_basic ne c_boolean_false or c_request_prop-auth_oauth ne c_boolean_false or c_request_prop-auth_apikey ne c_boolean_false ) and not ( c_request_prop-auth_header eq c_boolean_true or c_request_prop-auth_query eq c_boolean_true or c_request_prop-auth_body eq c_boolean_true ). c_request_prop-auth_header = c_boolean_true. endif. endmethod. method check_http_response. data: lv_http_status type ts_http_status, lv_full_url type string, ls_url type ts_url, lv_strlen type i, lv_code type string, lo_service_exception type ref to zcx_ibmc_service_exception. lv_http_status = get_http_status( i_rest_response = i_response ). lv_code = lv_http_status-code. shift lv_code left deleting leading space. if lv_code ne '200' and "" ok lv_code ne '201' and "" ok with response lv_code ne '202' and "" Accepted (asynchronous function call) lv_code ne '204'. "" Deleted ls_url = i_url. merge_structure( exporting i_alternative = p_request_prop_default-url changing c_base = ls_url ). lv_full_url = get_full_url( ls_url ). try. raise_exception( i_msgno = '003' "" HTTP Status: &1 (&2) i_msgv1 = lv_code i_msgv2 = lv_http_status-reason i_msgv3 = lv_full_url i_http_status = lv_http_status ). catch zcx_ibmc_service_exception into lo_service_exception. lo_service_exception->p_msg_json = lv_http_status-json. endtry. raise exception lo_service_exception. endif. endmethod. method constructor. data: lv_host type string. super->constructor( ). "" use i_url and i_host synonymously if not i_url is initial. lv_host = i_url. else. lv_host = i_host. endif. p_request_prop_default-url-host = lv_host. p_request_prop_default-username = i_username. p_request_prop_default-password = i_password. p_request_prop_default-apikey = i_apikey. p_request_prop_default-access_token = i_access_token. p_debug_mode = i_debug_mode. normalize_url( changing c_url = p_request_prop_default-url ). if not i_proxy_host is supplied. get_default_proxy( exporting i_url = p_request_prop_default-url importing e_proxy_host = p_request_prop_default-proxy_host e_proxy_port = p_request_prop_default-proxy_port ). else. p_request_prop_default-proxy_host = i_proxy_host. if not i_proxy_port is initial. p_request_prop_default-proxy_port = i_proxy_port. else. p_request_prop_default-proxy_port = '8080'. endif. endif. endmethod. method get_access_token. e_access_token = p_request_prop_default-access_token. endmethod. method get_appname. endmethod. method get_components. data: lo_abap_struc type ref to cl_abap_structdescr, lt_comp type cl_abap_structdescr=>component_table. field-symbols: type line of cl_abap_structdescr=>component_table. lo_abap_struc ?= cl_abap_structdescr=>describe_by_data( i_structure ). lt_comp = lo_abap_struc->get_components( ). clear e_components[]. loop at lt_comp assigning . append -name to e_components. endloop. endmethod. method get_datatype. get_field_type( exporting i_field = i_field importing e_technical_type = e_datatype ). endmethod. method get_field_type. data: lo_abap_type type ref to cl_abap_typedescr, lo_typedescr type ref to cl_abap_typedescr. call method cl_abap_typedescr=>describe_by_data exporting p_data = i_field receiving p_descr_ref = lo_typedescr. e_technical_type = lo_typedescr->type_kind. if e_relative_type is requested. if e_technical_type eq zif_ibmc_service_arch~c_datatype-objectref. data lo_refdescr type ref to cl_abap_refdescr. lo_refdescr ?= cl_abap_typedescr=>describe_by_data( i_field ). lo_abap_type ?= lo_refdescr->get_referenced_type( ). else. lo_abap_type = cl_abap_typedescr=>describe_by_data( i_field ). endif. e_relative_type = lo_abap_type->get_relative_name( ). endif. if e_length is requested. if e_technical_type eq zif_ibmc_service_arch~c_datatype-c or e_technical_type eq zif_ibmc_service_arch~c_datatype-n. e_length = lo_typedescr->length. else. e_length = 0. endif. endif. endmethod. method get_file_extension. data: lv_mime_type type string, lv_ext type string, lv_len type i. translate i_mime_type to lower case. case i_mime_type. when 'text/plain'. e_extension = 'txt'. when 'image/jpeg'. e_extension = 'jpg'. when 'application/octet-stream'. e_extension = 'bin'. when others. e_extension = 'dat'. find regex '([^/]*)$' in i_mime_type submatches lv_ext. if sy-subrc = 0. lv_len = strlen( lv_ext ). if lv_len >= 2 and lv_len <= 4. e_extension = lv_ext. endif. endif. endcase. endmethod. method get_full_url. data: lv_url type string. if not i_url-host cp 'http*'. if i_url-protocol is initial. lv_url = 'http://'. else. lv_url = i_url-protocol && `://`. endif. endif. lv_url = lv_url && i_url-host && i_url-path_base && i_url-path. if not i_url-querystring is initial. lv_url = lv_url && `?` && i_url-querystring. endif. e_url = lv_url. endmethod. method get_request_prop. e_request_prop-url-protocol = 'http'. e_request_prop-auth_headername = ''. e_request_prop-auth_basic = c_boolean_false. e_request_prop-auth_oauth = c_boolean_false. e_request_prop-auth_apikey = c_boolean_false. e_request_prop-auth_query = c_boolean_false. e_request_prop-auth_header = c_boolean_false. endmethod. method get_rest_client. data: ls_header type ts_header, ls_request_prop type ts_request_prop, lv_url type string. ls_request_prop = i_request_prop. adjust_request_prop( changing c_request_prop = ls_request_prop ). "" create http client instance lv_url = ls_request_prop-url-protocol && `://` && ls_request_prop-url-host. create_client_by_url( exporting i_url = lv_url i_request_prop = ls_request_prop importing e_client = e_client ). "" set URI and authorization lv_url = set_uri_and_authorization( i_client = e_client i_request_prop = ls_request_prop ). "" set request uri set_request_uri( i_client = e_client i_uri = lv_url ). "" set 'Content-Type' header if not i_request_prop-header_content_type is initial. set_request_header( i_client = e_client i_name = zif_ibmc_service_arch~c_header_content_type i_value = ls_request_prop-header_content_type ). endif. "" set 'Accept' header if not i_request_prop-header_accept is initial. set_request_header( i_client = e_client i_name = zif_ibmc_service_arch~c_header_accept i_value = ls_request_prop-header_accept ). endif. "" set additional headers if not ls_request_prop-headers is initial. loop at ls_request_prop-headers into ls_header. set_request_header( i_client = e_client i_name = ls_header-name i_value = ls_header-value ). endloop. endif. endmethod. method http_delete. data: lo_client type ts_client. "" create REST client lo_client = get_rest_client( i_request_prop = i_request_prop ). "" execute DELETE request e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_delete ). "" check response check_http_response( i_response = e_response i_url = i_request_prop-url ). endmethod. method http_get. data: lo_client type ts_client. "" create REST client lo_client = get_rest_client( i_request_prop = i_request_prop ). "" execute GET request e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_get ). "" check response check_http_response( i_response = e_response i_url = i_request_prop-url ). endmethod. method http_post. data: lo_client type ts_client. "" create REST client lo_client = get_rest_client( i_request_prop = i_request_prop ). "" set request body if not i_request_prop-body is initial. set_request_body_cdata( i_client = lo_client i_data = i_request_prop-body ). endif. if not i_request_prop-body_bin is initial. set_request_body_xdata( i_client = lo_client i_data = i_request_prop-body_bin ). endif. "" error: querystring of a POST request is not sent to server if the request body is empty "" workaround: set an empty json object for request body if i_request_prop-body is initial and i_request_prop-body_bin is initial. set_request_body_cdata( i_client = lo_client i_data = `{}` ). set_request_header( i_client = lo_client i_name = zif_ibmc_service_arch~c_header_content_type i_value = zif_ibmc_service_arch~c_mediatype-appl_json ). endif. "" execute POST request e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_post ). "" check response check_http_response( i_response = e_response i_url = i_request_prop-url ). endmethod. method HTTP_POST_MULTIPART. data: lo_client type ts_client. "" create REST client lo_client = get_rest_client( i_request_prop = i_request_prop ). "" set request body (multipart) add_form_part( i_client = lo_client it_form_part = it_form_part ). "" execute POST request e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_post ). "" check response check_http_response( i_response = e_response i_url = i_request_prop-url ). endmethod. method http_put. data: lo_client type ts_client. "" create REST client lo_client = get_rest_client( i_request_prop = i_request_prop ). "" set request body if not i_request_prop-body is initial. set_request_body_cdata( i_client = lo_client i_data = i_request_prop-body ). endif. if not i_request_prop-body_bin is initial. set_request_body_xdata( i_client = lo_client i_data = i_request_prop-body_bin ). endif. "" execute PUT request e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_put ). "" check response check_http_response( i_response = e_response i_url = i_request_prop-url ). endmethod. method merge_structure. data: lv_type type char, lt_compname type tt_string. field-symbols: type any, type any, type standard table, type standard table, type string. get_components( exporting i_structure = c_base importing e_components = lt_compname ). loop at lt_compname assigning . assign component of structure c_base to . check sy-subrc = 0. get_field_type( exporting i_field = importing e_technical_type = lv_type ). if lv_type eq zif_ibmc_service_arch~c_datatype-struct or lv_type eq zif_ibmc_service_arch~c_datatype-struct_deep. assign component of structure i_alternative to . check sy-subrc = 0. merge_structure( exporting i_alternative = changing c_base = ). else. if is initial. if lv_type eq zif_ibmc_service_arch~c_datatype-itab. assign component of structure c_base to . check sy-subrc = 0. assign component of structure i_alternative to . check sy-subrc = 0. if not is initial. append lines of to . endif. else. assign component of structure i_alternative to . check sy-subrc = 0. = . endif. endif. endif. endloop. endmethod. method move_data_reference_to_abap. data: lt_compname type tt_string, lv_compname type string, lv_index type i, lv_rowno type i, begin of ls_stack, name type string, ref type ref to data, struct type ref to data, type type char, end of ls_stack, ls_stack_new like ls_stack, lt_stack like standard table of ls_stack, lr_ref type ref to data. field-symbols: type data, type standard table, type standard table, type any, type any, type any, type any, type ref to data, type any. clear ls_stack-name. ls_stack-ref = i_data_reference. ls_stack-struct = ref #( e_abap ). get_field_type( exporting i_field = e_abap importing e_technical_type = ls_stack-type ). append ls_stack to lt_stack. do. lv_index = lines( lt_stack ). if lv_index <= 0. exit. endif. read table lt_stack into ls_stack index lv_index. if ls_stack-type eq 'u' or ls_stack-type eq 'v'. "" structure assign ls_stack-struct->* to . assign ls_stack-ref->* to . get_components( exporting i_structure = importing e_components = lt_compname ). loop at lt_compname into lv_compname. assign component lv_compname of structure to . ls_stack_new-name = lv_compname. ls_stack_new-struct = ref #( ). assign component lv_compname of structure to . if sy-subrc = 0. ls_stack_new-ref = . get_field_type( exporting i_field = importing e_technical_type = ls_stack_new-type ). append ls_stack_new to lt_stack. endif. endloop. else. if ls_stack-type eq 'h'. "" internal table assign ls_stack-struct->* to . assign ls_stack-ref->* to . loop at assigning . ls_stack_new-ref = . create data ls_stack_new-struct like line of . assign ls_stack_new-struct->* to . append to . "" append copies data lv_rowno = lines( ). read table assigning index lv_rowno. "" -> re-read row for reference ls_stack_new-struct = ref #( ). get_field_type( exporting i_field = importing e_technical_type = ls_stack_new-type ). clear ls_stack_new-name. append ls_stack_new to lt_stack. endloop. else. assign ls_stack-struct->* to . if ls_stack-type eq 'l' or ls_stack-type eq 'r'. "" reference = ls_stack-ref. else. "" simple type assign ls_stack-ref->* to . = . endif. endif. endif. delete lt_stack index lv_index. enddo. endmethod. method normalize_url. check not c_url is initial. data(lv_protocol) = c_url-protocol. if not lv_protocol is initial and lv_protocol np '*://'. lv_protocol = lv_protocol && '://'. endif. data(lv_host) = c_url-host. if c_url-host cp 'http:*' or c_url-host cp 'https:*'. clear lv_protocol. endif. shift lv_host right deleting trailing '/'. if not c_url-path_base is initial. shift c_url-path_base left deleting leading '/'. lv_host = lv_host && '/' && c_url-path_base. shift lv_host right deleting trailing '/'. endif. shift lv_host left deleting leading space. data(lv_path) = c_url-path. if not lv_path is initial. if lv_path np '/*'. lv_path = '/' && lv_path. endif. endif. data(lv_url_full) = lv_protocol && lv_host && lv_path. shift lv_url_full right deleting trailing '/'. shift lv_url_full left deleting leading space. clear: c_url-protocol, c_url-host, c_url-path_base, c_url-path. "" do not clear other components find regex '^(http.?:\\/\\/)?([^\\/]*)(.*)$' in lv_url_full submatches c_url-protocol c_url-host c_url-path. shift c_url-protocol right deleting trailing '/'. shift c_url-protocol right deleting trailing ':'. shift c_url-protocol left deleting leading space. "" split path into base_path and path if not lv_host is initial. find lv_host in lv_url_full match offset data(lv_offset) match length data(lv_length). if sy-subrc = 0. data(lv_strlen_url) = strlen( lv_url_full ). data(lv_strlen_path) = strlen( c_url-path ). data(lv_splitpoint) = lv_strlen_path - ( lv_strlen_url - lv_offset - lv_length ). c_url-path_base = c_url-path+0(lv_splitpoint). c_url-path = c_url-path+lv_splitpoint. endif. endif. return. endmethod. method PARSE_JSON. data: lv_json type string, lt_dictionary type zif_ibmc_service_arch~tt_string, lv_dictionary type string, lv_orgname type string, lv_abapname type string, lv_regex type string, lo_json type ref to /ui2/cl_json, lv_msg type string, lr_exception type ref to cx_sy_move_cast_error. field-symbols: type string. if not i_json is initial. lv_json = i_json. if i_dictionary is supplied. get_components( exporting i_structure = i_dictionary importing e_components = lt_dictionary ). loop at lt_dictionary into lv_dictionary. assign component lv_dictionary of structure i_dictionary to . lv_orgname = . translate lv_orgname to upper case. if lv_dictionary ne lv_orgname. lv_regex = `""` && && `""\\s*:`. lv_abapname = `""` && lv_dictionary && `"":`. replace all occurrences of regex lv_regex in lv_json with lv_abapname. endif. endloop. endif. "" copy code to execute /ui2/cl_json=>deserialize( exporting json = lv_json changing data = c_abap ) and catch exception create object lo_json. try. lo_json->deserialize_int( exporting json = lv_json changing data = c_abap ). catch cx_sy_move_cast_error into lr_exception. zcl_ibmc_service=>raise_exception( exporting i_msgno = 20 ). endtry. endif. endmethod. method raise_exception. data: ls_msg like if_t100_message=>t100key, lv_charval(11) type c, lo_service_exception type ref to zcx_ibmc_service_exception. ls_msg-msgid = c_msgid. if not i_msgno is initial. ls_msg-msgno = i_msgno. ls_msg-attr1 = i_msgv1. ls_msg-attr2 = i_msgv2. ls_msg-attr3 = i_msgv3. ls_msg-attr4 = i_msgv4. else. if not i_text is initial. if i_subrc <> c_subrc_unknown. lv_charval = conv #( i_subrc ). ls_msg-attr2 = lv_charval. ls_msg-msgno = '001'. "" &1: return code &2 else. ls_msg-msgno = '000'. "" &1 endif. ls_msg-attr1 = i_text. else. ls_msg-msgno = '002'. "" An exception has occurred, reason code &1. lv_charval = conv #( i_subrc ). ls_msg-attr1 = lv_charval. endif. endif. if ls_msg-attr4 is initial and not i_http_status-json is initial. data: begin of ls_error, error type string, description type string, end of ls_error. parse_json( exporting i_json = i_http_status-json changing c_abap = ls_error ). if not ls_error-error is initial. ls_msg-attr4 = unescape_unicode( ls_error-error ). elseif not ls_error-description is initial. ls_msg-attr4 = unescape_unicode( ls_error-description ). else. ls_msg-attr4 = unescape_unicode( i_http_status-json ). endif. endif. raise exception type zcx_ibmc_service_exception message id c_msgid type 'E' number ls_msg-msgno with ls_msg-attr1 ls_msg-attr2 ls_msg-attr3 ls_msg-attr4. endmethod. method set_access_token. p_request_prop_default-access_token = i_access_token. if p_request_prop_default-access_token-token_type is initial. p_request_prop_default-access_token-token_type = 'Bearer'. endif. if p_request_prop_default-access_token-expires_ts = 0. p_request_prop_default-access_token-expires_ts = '99991231235959' ##LITERAL. "" avoid token being refreshed by sdk endif. endmethod. method set_default_query_parameters. if not p_version is initial. add_query_parameter( exporting i_parameter = `version` i_value = p_version changing c_url = c_url ). endif. endmethod. method set_uri_and_authorization. data: ls_url type ts_url, lv_url type string. ls_url = i_request_prop-url. "" OAuth authorization if i_request_prop-auth_oauth eq c_boolean_true. "" = not ( c_boolean_false or c_tribool_false ) data: ls_access_token type ts_access_token, lv_full_token type string. ls_access_token = get_access_token( i_request_prop = i_request_prop ). if not ls_access_token-token_type is initial. concatenate ls_access_token-token_type ls_access_token-access_token into lv_full_token separated by space. else. lv_full_token = ls_access_token-access_token. endif. if i_request_prop-auth_header eq c_boolean_true. set_request_header( i_client = i_client i_name = i_request_prop-auth_headername i_value = lv_full_token ). endif. "" Basic authentication elseif i_request_prop-auth_basic eq c_boolean_true or i_request_prop-auth_apikey eq c_boolean_true. data: lv_username type string, lv_password type string. if i_request_prop-auth_apikey eq c_boolean_true. lv_username = 'apikey' ##NO_TEXT. lv_password = i_request_prop-apikey. else. lv_username = i_request_prop-username. lv_password = i_request_prop-password. endif. if i_request_prop-auth_header eq c_boolean_true. set_authentication_basic( i_client = i_client i_username = lv_username i_password = lv_password ). elseif i_request_prop-auth_query eq c_boolean_true. if i_request_prop-auth_apikey eq c_boolean_true. add_query_parameter( exporting i_parameter = 'apiKey' ##NO_TEXT i_value = lv_password changing c_url = ls_url ). else. add_query_parameter( exporting i_parameter = 'username' ##NO_TEXT i_value = lv_username changing c_url = ls_url ). add_query_parameter( exporting i_parameter = 'password' ##NO_TEXT i_value = lv_password changing c_url = ls_url ). endif. elseif i_request_prop-auth_body eq c_boolean_true. data: lv_body type string. if i_request_prop-auth_apikey eq c_boolean_true. lv_body = `{ ""userid"": ""apikey"", ""password"": ""` && i_request_prop-apikey && `"" }` ##NO_TEXT. else. lv_body = `{ ""userid"": ""` && i_request_prop-username && `"", ""password"": ""` && i_request_prop-password && `"" }` ##NO_TEXT. endif. set_request_body_cdata( i_client = i_client i_data = lv_body ). set_request_header( i_client = i_client i_name = zif_ibmc_service_arch~c_header_content_type i_value = zif_ibmc_service_arch~c_mediatype-appl_json ). endif. endif. e_uri = get_full_url( ls_url ). endmethod. method unescape_unicode. data: lv_match type string, lv_cp_str type string, lv_cp_hex(4) type x, lv_ucchar(1) type c. field-symbols: like lv_ucchar. e_out = i_in. do. find regex '(\\\\u[A-Fa-f0-9]{4})' in e_out ignoring case submatches lv_match ##NO_TEXT. if sy-subrc <> 0. exit. endif. lv_cp_str = lv_match+2. translate lv_cp_str to upper case. lv_cp_hex = lv_cp_str. assign lv_cp_hex to CASTING. lv_ucchar = . replace all occurrences of lv_match in e_out with lv_ucchar. enddo. endmethod. ENDCLASS. ",12532,False,2094.6725046496053,median "-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada.Exceptions; with SAL.Gen_Bounded_Definite_Queues; with WisiToken.Parse.LR.McKenzie_Recover.Parse; with WisiToken.Parse.LR.Parser; package body WisiToken.Parse.LR.McKenzie_Recover.Explore is procedure Do_Shift (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; State : in State_Index; ID : in Token_ID; Cost_Delta : in Integer; Strategy : in Strategies) is use Config_Op_Arrays; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Op : constant Config_Op := (Insert, ID, Config.Current_Shared_Token, State, Config.Stack.Depth); begin Config.Strategy_Counts (Strategy) := Config.Strategy_Counts (Strategy) + 1; if Is_Full (Config.Ops) then Super.Config_Full (""do_shift ops"", Parser_Index); raise Bad_Config; else Append (Config.Ops, Op); end if; if Cost_Delta = 0 then Config.Cost := Config.Cost + McKenzie_Param.Insert (ID); else -- Cost_Delta /= 0 comes from Insert_Minimal_Complete_Actions. That -- doesn't mean it is better than any other solution, so don't let -- cost be 0. -- -- We don't just eliminate all cost for Minimal_Complete_Actions; -- that leads to using it far too much at the expense of better -- solutions. Config.Cost := Integer'Max (1, Config.Cost + McKenzie_Param.Insert (ID) + Cost_Delta); end if; Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); if Config.Stack.Is_Full then Super.Config_Full (""do_shift stack"", Parser_Index); raise Bad_Config; else Config.Stack.Push ((State, Syntax_Trees.Invalid_Node_Index, (ID, Virtual => True, others => <>))); end if; if Trace_McKenzie > Detail then Base.Put ((if Label'Length > 0 then Label & "": "" else """") & ""insert "" & Image (ID, Super.Trace.Descriptor.all), Super, Shared, Parser_Index, Config); end if; Local_Config_Heap.Add (Config); end Do_Shift; procedure Do_Reduce_1 (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; Action : in Reduce_Action_Rec; Do_Language_Fixes : in Boolean := True) is use all type Semantic_Checks.Check_Status_Label; use all type WisiToken.Parse.LR.Parser.Language_Fixes_Access; Prev_State : constant Unknown_State_Index := Config.Stack.Peek.State; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Table : Parse_Table renames Shared.Table.all; Nonterm : Recover_Token; New_State : Unknown_State_Index; begin Config.Check_Status := Parse.Reduce_Stack (Shared, Config.Stack, Action, Nonterm, Default_Virtual => True); case Config.Check_Status.Label is when Ok => null; when Semantic_Checks.Error => Config.Error_Token := Nonterm; Config.Check_Token_Count := Action.Token_Count; if Do_Language_Fixes then if Shared.Language_Fixes /= null then Shared.Language_Fixes (Super.Trace.all, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap, Config); end if; end if; -- Finish the reduce; ignore the check fail. if Config.Stack.Depth < SAL.Base_Peek_Type (Config.Check_Token_Count) then raise SAL.Programmer_Error; else Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count)); end if; Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => Ok); end case; if Config.Stack.Depth = 0 or else Config.Stack.Peek.State = Unknown_State then raise Bad_Config; end if; New_State := Goto_For (Table, Config.Stack.Peek.State, Action.Production.LHS); if New_State = Unknown_State then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & "": Do_Reduce_1: unknown_State "" & Config.Stack.Peek.State'Image & "" "" & Image (Action.Production.LHS, Descriptor)); end if; raise Bad_Config; end if; Config.Stack.Push ((New_State, Syntax_Trees.Invalid_Node_Index, Nonterm)); if Trace_McKenzie > Extra and Label'Length > 0 then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & "": state"" & State_Index'Image (Prev_State) & "" reduce"" & Ada.Containers.Count_Type'Image (Action.Token_Count) & "" to "" & Image (Action.Production.LHS, Descriptor) & "", goto"" & State_Index'Image (New_State) & "" via"" & State_Index'Image (Config.Stack.Peek (2).State)); end if; end Do_Reduce_1; procedure Do_Reduce_2 (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; Inserted_ID : in Token_ID; Cost_Delta : in Integer; Strategy : in Strategies) is -- Perform reduce actions until shift Inserted_ID; if all succeed, -- add the final configuration to the heap, return True. If a conflict is -- encountered, process the other action the same way. If a semantic -- check fails, enqueue possible solutions. For parse table error -- actions, or exception Bad_Config, return False. Orig_Config : Configuration; Table : Parse_Table renames Shared.Table.all; Next_Action : Parse_Action_Node_Ptr := Action_For (Table, Config.Stack.Peek.State, Inserted_ID); begin if Next_Action.Next /= null then Orig_Config := Config; end if; case Next_Action.Item.Verb is when Shift => Do_Shift (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item.State, Inserted_ID, Cost_Delta, Strategy); when Reduce => Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item); Do_Reduce_2 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Inserted_ID, Cost_Delta, Strategy); when Accept_It => raise SAL.Programmer_Error with ""found test case for Do_Reduce Accept_It""; when Error => null; end case; loop exit when Next_Action.Next = null; -- There is a conflict; create a new config to shift or reduce. declare New_Config : Configuration := Orig_Config; Action : Parse_Action_Rec renames Next_Action.Next.Item; begin case Action.Verb is when Shift => Do_Shift (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, Inserted_ID, Cost_Delta, Strategy); when Reduce => Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action); Do_Reduce_2 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Inserted_ID, Cost_Delta, Strategy); when Accept_It => raise SAL.Programmer_Error with ""found test case for Do_Reduce Accept_It conflict""; when Error => null; end case; end; Next_Action := Next_Action.Next; end loop; exception when Bad_Config => if Debug_Mode then raise; end if; end Do_Reduce_2; function Fast_Forward (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration) return Non_Success_Status is -- Apply the ops in Config; they were inserted by some fix. -- Return Abandon if Config should be abandoned, otherwise Continue. -- Leaves Config.Error_Token, Config.Check_Status set. -- -- If there are conflicts, all are parsed; if more than one succeed, -- all are enqueued in Local_Config_Heap, and this returns Abandon. use Parse.Parse_Item_Arrays; use Config_Op_Arrays; use all type Ada.Containers.Count_Type; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Dummy : Boolean := Parse.Parse (Super, Shared, Parser_Index, Parse_Items, Config, Shared_Token_Goal => Invalid_Token_Index, All_Conflicts => True, Trace_Prefix => ""fast_forward""); begin -- This solution is from Language_Fixes; any cost increase is done there. if Length (Parse_Items) = 1 then declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then -- Item.Config.Error_Token.ID, Check_Status are correct. Config := Item.Config; if Is_Full (Config.Ops) then Super.Config_Full (""fast_forward 1"", Parser_Index); return Abandon; else Append (Config.Ops, (Fast_Forward, Config.Current_Shared_Token)); end if; Config.Minimal_Complete_State := None; Config.Matching_Begin_Done := False; return Continue; else return Abandon; end if; end; else for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then if Is_Full (Config.Ops) then Super.Config_Full (""fast_forward 2"", Parser_Index); return Abandon; else Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token)); end if; Item.Config.Minimal_Complete_State := None; Item.Config.Matching_Begin_Done := False; Local_Config_Heap.Add (Item.Config); if Trace_McKenzie > Detail then Base.Put (""fast forward enqueue"", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; return Abandon; end if; exception when Bad_Config => return Abandon; end Fast_Forward; function Check (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) return Check_Status is use Config_Op_Arrays, Config_Op_Array_Refs; use Parse.Parse_Item_Arrays; use all type Semantic_Checks.Check_Status_Label; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Result : Check_Status := Continue; function Max_Push_Back_Token_Index (Ops : aliased in Config_Op_Arrays.Vector) return WisiToken.Base_Token_Index is Result : WisiToken.Base_Token_Index := WisiToken.Base_Token_Index'First; begin -- For Ops since last Fast_Forward, return maximum Token_Index in a -- Push_Back. If there are no such ops, return a value that will be -- less than the current token index. for I in reverse First_Index (Ops) .. Last_Index (Ops) loop declare Op : Config_Op renames Constant_Ref (Ops, I); begin exit when Op.Op = Fast_Forward; if Op.Op = Push_Back and then Op.PB_Token_Index > Result then Result := Op.PB_Token_Index; end if; end; end loop; return Result; end Max_Push_Back_Token_Index; begin if Parse.Parse (Super, Shared, Parser_Index, Parse_Items, Config, Config.Resume_Token_Goal, All_Conflicts => False, Trace_Prefix => ""check"") then Config.Error_Token.ID := Invalid_Token_ID; -- FIXME: if there were conflicts, enqueue them; they might yield a -- cheaper or same cost solution? return Success; end if; -- Set Config.error to reflect failure, if it is at current token, so -- Use_Minimal_Complete_Actions can see it. declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, First_Index (Parse_Items)); begin if Item.Config.Check_Status.Label /= Ok then Config.Check_Status := Item.Config.Check_Status; Config.Error_Token := Item.Config.Error_Token; -- Explore cannot fix a check fail; only Language_Fixes can. The -- ""ignore error"" case is handled immediately on return from -- Language_Fixes in Process_One, below. Result := Abandon; elsif Item.Config.Error_Token.ID /= Invalid_Token_ID then if Item.Shift_Count = 0 then Config.Error_Token := Item.Config.Error_Token; Config.Check_Status := (Label => Ok); else -- Error is not at current token, but Explore might find something -- that will help (see test_mckenzie_recover.adb Extra_Begin). On the -- other hand, this can lead to lots of bogus configs (see -- If_In_Handler). Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => Ok); end if; end if; end; -- All Parse_Items either failed or were not parsed; if they failed -- and made progress, enqueue them so Language_Fixes can try to fix -- them. for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Config.Error_Token.ID /= Invalid_Token_ID and then Item.Shift_Count > 0 and then Max_Push_Back_Token_Index (Item.Config.Ops) < Item.Config.Current_Shared_Token - 1 then -- Some progress was made; explore at the new error point. It is -- likely that there is only one actual error point, and this moves -- away from it, so we give it a cost. begin Item.Config.Minimal_Complete_State := None; Item.Config.Matching_Begin_Done := False; if Constant_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).Op = Fast_Forward then Item.Config.Cost := Item.Config.Cost + McKenzie_Param.Fast_Forward; Variable_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).FF_Token_Index := Item.Config.Current_Shared_Token; else Item.Config.Cost := Item.Config.Cost + McKenzie_Param.Fast_Forward; if Is_Full (Item.Config.Ops) then Super.Config_Full (""check 1"", Parser_Index); raise Bad_Config; else Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token)); end if; end if; end; Local_Config_Heap.Add (Item.Config); if Trace_McKenzie > Detail then Base.Put (""new error point "", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""check result: "" & Result'Image); end if; return Result; exception when Bad_Config => return Abandon; end Check; function Check_Reduce_To_Start (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Orig_Config : in Configuration) return Boolean -- Returns True if Config reduces to the start nonterm. is Table : Parse_Table renames Shared.Table.all; function To_Reduce_Action (Item : in Minimal_Action) return Reduce_Action_Rec is begin return (Reduce, (Item.Nonterm, 0), null, null, Item.Token_Count); end To_Reduce_Action; Local_Config_Heap : Config_Heaps.Heap_Type; -- never used, because Do_Language_Fixes is False. Config : Configuration := Orig_Config; Actions : Minimal_Action_Arrays.Vector := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; begin loop case Actions.Length is when 0 => if (for some Item of Table.States (Config.Stack.Peek.State).Kernel => Item.LHS = Super.Trace.Descriptor.Accept_ID) then return True; else return False; end if; when 1 => case Actions (Actions.First_Index).Verb is when Shift => return False; when Reduce => Do_Reduce_1 ("""", Super, Shared, Parser_Index, Local_Config_Heap, Config, To_Reduce_Action (Actions (Actions.First_Index)), Do_Language_Fixes => False); Actions := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; end case; when others => return False; end case; -- loop only exits via returns above end loop; exception when Bad_Config => -- From Do_Reduce_1 return False; end Check_Reduce_To_Start; procedure Try_Push_Back (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Trace : WisiToken.Trace'Class renames Super.Trace.all; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Token : constant Recover_Token := Config.Stack.Peek.Token; begin -- Try pushing back the stack top, to allow insert and other -- operations at that point. -- -- Since we are not actually changing the source text, it is tempting -- to give this operation zero cost. But then we keep doing push_back -- forever, making no progress. So we give it a cost. if not Token.Virtual then -- If Virtual, this is from earlier in this recover session; no point -- in trying to redo it. declare use Config_Op_Arrays; New_Config : Configuration := Config; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); New_Config.Stack.Pop; if Is_Full (New_Config.Ops) then Super.Config_Full (""push_back 1"", Parser_Index); raise Bad_Config; else if Token.Min_Terminal_Index = Invalid_Token_Index then -- Token is empty; Config.current_shared_token does not change, no -- cost increase. Append (New_Config.Ops, (Push_Back, Token.ID, New_Config.Current_Shared_Token)); else New_Config.Cost := New_Config.Cost + McKenzie_Param.Push_Back (Token.ID); Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); New_Config.Current_Shared_Token := Token.Min_Terminal_Index; end if; end if; New_Config.Strategy_Counts (Explore_Table) := New_Config.Strategy_Counts (Explore_Table) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put (""push_back "" & Image (Token.ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Push_Back; function Just_Pushed_Back_Or_Deleted (Config : in Configuration; ID : in Token_ID) return Boolean is use Config_Op_Arrays, Config_Op_Array_Refs; use all type Ada.Containers.Count_Type; begin if Length (Config.Ops) = 0 then return False; else declare Last_Op : Config_Op renames Constant_Ref (Config.Ops, Last_Index (Config.Ops)); begin return (Last_Op.Op = Push_Back and then Last_Op.PB_ID = ID) or (Last_Op.Op = Delete and then Last_Op.Del_ID = ID); end; end if; end Just_Pushed_Back_Or_Deleted; procedure Try_Undo_Reduce (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Trace : WisiToken.Trace'Class renames Super.Trace.all; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Token : constant Recover_Token := Config.Stack.Peek.Token; begin -- Try expanding the nonterm on the stack top, to allow pushing_back -- its components, or insert and other operations at that point. if Undo_Reduce_Valid (Config.Stack, Super.Parser_State (Parser_Index).Tree) then declare use Config_Op_Arrays; New_Config : Configuration := Config; Token_Count : Ada.Containers.Count_Type; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Token_Count := Undo_Reduce (New_Config.Stack, Super.Parser_State (Parser_Index).Tree); if Token.Min_Terminal_Index /= Invalid_Token_Index then -- If Token is empty no cost increase. New_Config.Cost := New_Config.Cost + McKenzie_Param.Undo_Reduce (Token.ID); end if; if Is_Full (New_Config.Ops) then Super.Config_Full (""undo_reduce 1"", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Undo_Reduce, Token.ID, Token_Count)); end if; New_Config.Strategy_Counts (Explore_Table) := New_Config.Strategy_Counts (Explore_Table) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put (""undo_reduce "" & Image (Token.ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Undo_Reduce; procedure Insert_From_Action_List (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Minimal_Insert : in Token_ID_Arrays.Vector; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Table : Parse_Table renames Shared.Table.all; EOF_ID : Token_ID renames Super.Trace.Descriptor.EOI_ID; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; -- Find terminal insertions from the current state's action_list to try. -- -- We perform any needed reductions and one shift, so the config is -- in a consistent state, and enqueue the result. If there are any -- conflicts or semantic check fails encountered, they create other -- configs to enqueue. Current_Token : constant Token_ID := Current_Token_ID_Peek (Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete); Cached_Config : Configuration; Cached_Action : Reduce_Action_Rec; -- Most of the time, all the reductions in a state are the same. So -- we cache the first result. This includes one reduction; if an -- associated semantic check failed, this does not include the fixes. I : Parse_Action_Node_Ptr; begin for Node of Table.States (Config.Stack.Peek.State).Action_List loop I := Node.Actions; loop exit when I = null; declare ID : constant Token_ID := Node.Symbol; Action : Parse_Action_Rec renames I.Item; begin if ID /= EOF_ID and then -- can't insert eof ID /= Invalid_Token_ID -- invalid when Verb = Error then if Just_Pushed_Back_Or_Deleted (Config, ID) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Insert: abandon "" & Image (ID, Descriptor) & "": undo push_back""); end if; elsif ID = Current_Token then -- This needed because we allow explore when the error is not at the -- explore point; it prevents inserting useless tokens (ie -- 'identifier ;' in ada_lite). if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Insert: abandon "" & Image (ID, Descriptor) & "": current token""); end if; elsif (for some Minimal of Minimal_Insert => ID = Minimal) then -- Was inserted by Insert_Minimal_Complete_Actions null; else case Action.Verb is when Shift => declare New_Config : Configuration := Config; begin Do_Shift (""Insert"", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, ID, Cost_Delta => 0, Strategy => Explore_Table); end; when Reduce => if not Equal (Action, Cached_Action) then declare New_Config : Configuration := Config; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Do_Reduce_1 (""Insert"", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action); Cached_Config := New_Config; Cached_Action := Action; Do_Reduce_2 (""Insert"", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID, Cost_Delta => 0, Strategy => Explore_Table); end; else declare New_Config : Configuration := Cached_Config; begin Do_Reduce_2 (""Insert"", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID, Cost_Delta => 0, Strategy => Explore_Table); end; end if; when Accept_It => raise SAL.Programmer_Error with ""found test case for Process_One Accept_It""; when Error => null; end case; end if; end if; end; I := I.Next; end loop; end loop; end Insert_From_Action_List; function Insert_Minimal_Complete_Actions (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Orig_Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) return Token_ID_Arrays.Vector -- Return tokens inserted (empty if none). is use Ada.Containers; Table : Parse_Table renames Shared.Table.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Inserted : Token_ID_Array (1 .. 10) := (others => Invalid_Token_ID); Inserted_Last : Integer := Inserted'First - 1; type Work_Item is record Action : Minimal_Action; Config : Configuration; end record; package Item_Queues is new SAL.Gen_Bounded_Definite_Queues (Work_Item); use Item_Queues; Work : Queue_Type (10); -- The required queue size depends on the number of multiple-item -- Minimal_Complete_Actions encountered. That is limited by compound -- statement nesting, and by the frequency of such actions. function To_Reduce_Action (Action : in Minimal_Action) return Reduce_Action_Rec is (Reduce, (Action.Nonterm, 0), null, null, Action.Token_Count); procedure Minimal_Do_Shift (Action : in Minimal_Action; Config : in out Configuration) is use Config_Op_Arrays, Config_Op_Array_Refs; begin -- Check for a cycle. We compare stack depth as well as state, so -- nested compound statements don't look like a cycle; see -- test_mckenzie_recover Push_Back_1. We don't check for cycles in -- Insert_From_Action_List because we assume cost eliminates cycles -- there; Minimal_Complete_Delta is usually negative, so cost does -- not necessarily increase here. for I in reverse First_Index (Config.Ops) .. Last_Index (Config.Ops) loop declare Op : Config_Op renames Constant_Ref (Config.Ops, I); begin if Op.Op = Insert and then (Op.Ins_ID = Action.ID and Op.State = Action.State and Op.Stack_Depth = Config.Stack.Depth) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions: abandon "" & Image (Action.ID, Descriptor) & Action.State'Image & "": cycle""); end if; return; end if; end; end loop; -- We don't check Action.ID = Current_Token; the error is at the -- explore point, so ID is valid. if Just_Pushed_Back_Or_Deleted (Config, Action.ID) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions: abandon "" & Image (Action.ID, Descriptor) & "": undo push back""); end if; else Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Config.Minimal_Complete_State := Active; Inserted_Last := Inserted_Last + 1; Inserted (Inserted_Last) := Action.ID; Do_Shift (""Minimal_Complete_Actions"", Super, Shared, Parser_Index, Local_Config_Heap, Config, Action.State, Action.ID, Table.McKenzie_Param.Minimal_Complete_Cost_Delta, Strategy => Minimal_Complete); end if; end Minimal_Do_Shift; procedure Enqueue_Min_Actions (Label : in String; Actions : in Minimal_Action_Arrays.Vector; Recursive : in Boolean; Config : in Configuration; Reduce_Only : in Boolean) is use SAL; Length : array (Actions.First_Index .. Actions.Last_Index) of Count_Type := (others => Count_Type'Last); Item_Not_Recursive : array (Actions.First_Index .. Actions.Last_Index) of Boolean := (others => False); Not_Recursive_Count : Count_Type := 0; Min_Length : Count_Type := Count_Type'Last; Use_Recursive : Boolean; begin -- Enqueue non-minimal actions on Work, if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions: "" & Label & Image (Actions, Descriptor) & (if Recursive then "" recursive"" else """")); end if; if Actions.Length = 0 then return; elsif Actions.Length = 1 then if (not Reduce_Only) or Actions (Actions.First_Index).Verb = Reduce then if Is_Full (Work) then Super.Config_Full (""Minimal_Complete_Actions 1"", Parser_Index); raise Bad_Config; else Add (Work, (Actions (Actions.First_Index), Config)); end if; end if; return; end if; for I in Actions.First_Index .. Actions.Last_Index loop declare Action : Minimal_Action renames Actions (I); Next_State : constant State_Index := (case Action.Verb is when Shift => Action.State, when Reduce => Goto_For (Shared.Table.all, Config.Stack.Peek (Base_Peek_Type (Action.Token_Count) + 1).State, Action.Nonterm)); Before_Dot : constant Token_ID := (case Action.Verb is when Shift => Action.ID, when Reduce => Action.Nonterm); Kernel : Kernel_Info_Arrays.Vector renames Shared.Table.States (Next_State).Kernel; begin if (not Reduce_Only) or Action.Verb = Reduce then for Item of Kernel loop Item_Not_Recursive (I) := Item_Not_Recursive (I) or not Item.Recursive; if Item.Before_Dot = Before_Dot and Item.Length_After_Dot < Length (I) then Length (I) := Item.Length_After_Dot; if Length (I) < Min_Length then Min_Length := Length (I); end if; end if; end loop; end if; end; if Item_Not_Recursive (I) then Not_Recursive_Count := Not_Recursive_Count + 1; end if; end loop; Use_Recursive := Recursive and Not_Recursive_Count > 0 and Not_Recursive_Count < Actions.Length; for I in Length'Range loop if (Use_Recursive and Item_Not_Recursive (I)) or ((not Use_Recursive) and Length (I) = Min_Length) then if Is_Full (Work) then Super.Config_Full (""Minimal_Complete_Actions 2"", Parser_Index); raise Bad_Config; else Add (Work, (Actions (I), Config)); end if; elsif Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions: drop "" & Image (Actions (I), Descriptor)); end if; end loop; end Enqueue_Min_Actions; begin if Orig_Config.Stack.Depth = 1 then -- Get here with an empty source file, or a syntax error on the first -- token. return Token_ID_Arrays.Empty_Vector; elsif Orig_Config.Minimal_Complete_State = Done then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions: done""); end if; return Token_ID_Arrays.Empty_Vector; end if; Enqueue_Min_Actions ("""", Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions, Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions_Recursive, Orig_Config, Reduce_Only => False); loop exit when Is_Empty (Work); declare Item : Work_Item := Get (Work); begin if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions: dequeue work item "" & Image (Item.Action, Descriptor)); end if; case Item.Action.Verb is when Reduce => -- Do a reduce, look at resulting state. Keep reducing until we can't -- anymore. declare Reduce_Action : Reduce_Action_Rec := To_Reduce_Action (Item.Action); Actions : Minimal_Action_Arrays.Vector; Recursive : Boolean; begin loop Do_Reduce_1 (""Minimal_Complete_Actions"", Super, Shared, Parser_Index, Local_Config_Heap, Item.Config, Reduce_Action, Do_Language_Fixes => False); Actions := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions; Recursive := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions_Recursive; case Actions.Length is when 0 => if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Minimal_Complete_Actions abandoned: no actions""); end if; exit; when 1 => case Actions (Actions.First_Index).Verb is when Shift => Minimal_Do_Shift (Actions (Actions.First_Index), Item.Config); exit; when Reduce => Reduce_Action := To_Reduce_Action (Actions (Actions.First_Index)); end case; when others => Enqueue_Min_Actions (""multiple actions "", Actions, Recursive, Item.Config, Reduce_Only => True); exit; end case; end loop; end; when Shift => Minimal_Do_Shift (Item.Action, Item.Config); end case; end; end loop; if Inserted_Last = Inserted'First - 1 then if Orig_Config.Minimal_Complete_State = Active then Orig_Config.Minimal_Complete_State := Done; end if; end if; return To_Vector (Inserted (1 .. Inserted_Last)); end Insert_Minimal_Complete_Actions; procedure Insert_Matching_Begin (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type; Matching_Begin_Tokens : in Token_ID_Arrays.Vector) is Table : Parse_Table renames Shared.Table.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; begin -- We don't check for insert = current token; that's either ok or a -- severe bug in Language_Use_Minimal_Complete. if Config.Matching_Begin_Done then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Matching_Begin abandoned: done""); end if; return; end if; if Just_Pushed_Back_Or_Deleted (Config, Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index)) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Matching_Begin abandoned "" & Image (Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index), Descriptor) & "": undo push_back""); end if; return; end if; declare New_Config : Configuration := Config; begin for ID of Matching_Begin_Tokens loop Insert (New_Config, ID); end loop; declare use Parse.Parse_Item_Arrays; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Dummy : constant Boolean := Parse.Parse (Super, Shared, Parser_Index, Parse_Items, New_Config, Shared_Token_Goal => Invalid_Token_Index, All_Conflicts => True, Trace_Prefix => ""parse Matching_Begin""); begin for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then Item.Config.Matching_Begin_Done := True; Item.Config.Cost := Item.Config.Cost + Table.McKenzie_Param.Matching_Begin; Item.Config.Strategy_Counts (Matching_Begin) := Item.Config.Strategy_Counts (Matching_Begin) + 1; Item.Config.Error_Token.ID := Invalid_Token_ID; Item.Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); if Trace_McKenzie > Detail then Base.Put (""Matching_Begin: insert "" & Image (Matching_Begin_Tokens, Descriptor), Super, Shared, Parser_Index, Item.Config); end if; Local_Config_Heap.Add (Item.Config); else if Trace_McKenzie > Detail then Base.Put (""Matching_Begin: abandon "" & Image (Matching_Begin_Tokens, Descriptor) & "": parse fail"", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; end; end; exception when SAL.Container_Full => -- From config_ops_sorted Super.Config_Full (""Minimal_Complete_Actions 3"", Parser_Index); end Insert_Matching_Begin; procedure Try_Insert_Terminal (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use all type WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access; use all type Ada.Containers.Count_Type; Tokens : Token_ID_Array_1_3; Matching_Begin_Tokens : Token_ID_Arrays.Vector; Forbid_Minimal_Insert : Boolean := False; Minimal_Inserted : Token_ID_Arrays.Vector; begin if Shared.Language_Matching_Begin_Tokens /= null then Current_Token_ID_Peek_3 (Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete, Super.Parser_State (Parser_Index).Prev_Deleted, Tokens); Shared.Language_Matching_Begin_Tokens (Tokens, Config, Matching_Begin_Tokens, Forbid_Minimal_Insert); end if; if not Forbid_Minimal_Insert then -- See test_mckenzie_recover.adb Forbid_Minimal_Insert for rationale. Minimal_Inserted := Insert_Minimal_Complete_Actions (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; if Matching_Begin_Tokens.Length > 0 then Insert_Matching_Begin (Super, Shared, Parser_Index, Config, Local_Config_Heap, Matching_Begin_Tokens); end if; -- We always do all three Insert_Minimal_Complete (unless -- Forbid_Minimal_Insert), Insert_Matching_Begin, -- Insert_From_Action_List; in general it's not possible to tell when -- one will be better (see test_mckenzie_recover.adb -- Always_Minimal_Complete, Always_Matching_Begin). -- Insert_From_Action does not insert the Minimal_Inserted tokens, -- and it will never insert the Matching_Begin_Tokens, so there is no -- duplication. Insert_From_Action_List will normally be more -- expensive. Insert_From_Action_List (Super, Shared, Parser_Index, Config, Minimal_Inserted, Local_Config_Heap); -- It is tempting to use the Goto_List to find nonterms to insert. -- But that can easily lead to error states, and it turns out to be -- not useful, especially if the grammar has been relaxed so most -- expressions and lists can be empty. exception when Bad_Config => null; end Try_Insert_Terminal; procedure Try_Insert_Quote (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use Config_Op_Arrays; use all type Parser.Language_String_ID_Set_Access; Descriptor : WisiToken.Descriptor renames Shared.Trace.Descriptor.all; Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit; Current_Line : constant Line_Number_Type := Shared.Terminals.all (Config.Current_Shared_Token).Line; Lexer_Error_Token_Index : Base_Token_Index; Lexer_Error_Token : Base_Token; function Recovered_Lexer_Error (Line : in Line_Number_Type) return Base_Token_Index is begin -- We are assuming the list of lexer errors is short, so binary -- search would not be significantly faster. for Err of reverse Shared.Lexer.Errors loop if Err.Recover_Token /= Invalid_Token_Index and then Shared.Terminals.all (Err.Recover_Token).Line = Line then return Err.Recover_Token; end if; end loop; return Invalid_Token_Index; end Recovered_Lexer_Error; function String_ID_Set (String_ID : in Token_ID) return Token_ID_Set is begin if Shared.Language_String_ID_Set = null then return (String_ID .. String_ID => True); else return Shared.Language_String_ID_Set (Descriptor, String_ID); end if; end String_ID_Set; procedure String_Literal_In_Stack (Label : in String; New_Config : in out Configuration; Matching : in SAL.Peek_Type; String_Literal_ID : in Token_ID) is use Parse.Parse_Item_Arrays; Saved_Shared_Token : constant WisiToken.Token_Index := New_Config.Current_Shared_Token; Tok : Recover_Token; J : WisiToken.Token_Index; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; begin -- Matching is the index of a token on New_Config.Stack containing a string -- literal. Push back thru that token, then delete all tokens after -- the string literal to Saved_Shared_Token. if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Matching)) then Super.Config_Full (""insert quote 1 "" & Label, Parser_Index); raise Bad_Config; end if; for I in 1 .. Matching loop Tok := New_Config.Stack.Pop.Token; Append (New_Config.Ops, (Push_Back, Tok.ID, Tok.Min_Terminal_Index)); end loop; New_Config.Current_Shared_Token := Tok.Min_Terminal_Index; -- Find last string literal in pushed back terminals. J := Saved_Shared_Token - 1; loop exit when Shared.Terminals.all (J).ID = String_Literal_ID; J := J - 1; end loop; begin if Parse.Parse (Super, Shared, Parser_Index, Parse_Items, New_Config, Shared_Token_Goal => J, All_Conflicts => False, Trace_Prefix => ""insert quote parse pushback "" & Label) then -- The non-deleted tokens parsed without error. We don't care if any -- conflicts were encountered; we are not using the parse result. New_Config := Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1).Config; Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token)); else raise SAL.Programmer_Error; end if; exception when Bad_Config => raise SAL.Programmer_Error; end; if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Saved_Shared_Token - 1 - New_Config.Current_Shared_Token)) then Super.Config_Full (""insert quote 2 "" & Label, Parser_Index); raise Bad_Config; end if; for J in New_Config.Current_Shared_Token .. Saved_Shared_Token - 1 loop Append (New_Config.Ops, (Delete, Shared.Terminals.all (J).ID, J)); end loop; New_Config.Current_Shared_Token := Saved_Shared_Token; end String_Literal_In_Stack; procedure Finish (Label : in String; New_Config : in out Configuration; First, Last : in Base_Token_Index) is begin -- Delete tokens First .. Last; either First - 1 or Last + 1 should -- be a String_Literal. Leave Current_Shared_Token at Last + 1. New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); -- This is a guess, so we give it a nominal cost New_Config.Cost := New_Config.Cost + 1; if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Last - First)) then Super.Config_Full (""insert quote 3 "" & Label, Parser_Index); raise Bad_Config; end if; for I in First .. Last loop Append (New_Config.Ops, (Delete, Shared.Terminals.all (I).ID, I)); end loop; New_Config.Current_Shared_Token := Last + 1; -- Let explore do insert after these deletes. Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token)); if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit; if Trace_McKenzie > Detail then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""resume_token_goal:"" & WisiToken.Token_Index'Image (New_Config.Resume_Token_Goal)); end if; end if; New_Config.Strategy_Counts (String_Quote) := New_Config.Strategy_Counts (String_Quote) + 1; if Trace_McKenzie > Detail then Base.Put (""insert quote "" & Label & "" "", Super, Shared, Parser_Index, New_Config); end if; end Finish; begin -- When the lexer finds an unbalanced quote, it inserts a virtual -- balancing quote at the same character position as the unbalanced -- quote, returning an empty string literal token there. The parser -- does not see that as an error; it encounters a syntax error -- before, at, or after that string literal. -- -- Here we assume the parse error in Config.Error_Token is due to -- putting the balancing quote in the wrong place, and attempt to -- find a better place to put the balancing quote. Then all tokens -- from the balancing quote to the unbalanced quote are now part of a -- string literal, so delete them, leaving just the string literal -- created by Lexer error recovery. -- First we check to see if there is an unbalanced quote in the -- current line; if not, just return. Some lexer errors are for other -- unrecognized characters; see ada_mode-recover_bad_char.adb. -- -- An alternate strategy is to treat the lexer error as a parse error -- immediately, but that complicates the parse logic. Config.String_Quote_Checked := Current_Line; Lexer_Error_Token_Index := Recovered_Lexer_Error (Current_Line); if Lexer_Error_Token_Index = Invalid_Token_Index then return; end if; Lexer_Error_Token := Shared.Terminals.all (Lexer_Error_Token_Index); -- It is not possible to tell where the best place to put the -- balancing quote is, so we always try all reasonable places. if Lexer_Error_Token.Byte_Region.First = Config.Error_Token.Byte_Region.First then -- The parse error token is the string literal at the lexer error. -- -- case a: Insert the balancing quote somewhere before the error -- point. There is no way to tell how far back to put the balancing -- quote, so we just do one non-empty token. See -- test_mckenzie_recover.adb String_Quote_0. So far we have not found -- a test case for more than one token. declare New_Config : Configuration := Config; Token : Recover_Token; begin loop Token := New_Config.Stack.Pop.Token; if Token.Byte_Region /= Null_Buffer_Region then if Is_Full (New_Config.Ops) then Super.Config_Full (""insert quote 4 a"", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); end if; exit; end if; end loop; Finish (""a"", New_Config, Token.Min_Terminal_Index, Config.Current_Shared_Token - 1); Local_Config_Heap.Add (New_Config); end; -- Note that it is not reasonable to insert a quote after the error -- in this case. If that were the right solution, the parser error -- token would not be the lexer repaired string literal, since a -- string literal would be legal here. elsif Lexer_Error_Token.Byte_Region.First < Config.Error_Token.Byte_Region.First then -- The unbalanced quote is before the parse error token; see -- test_mckenzie_recover.adb String_Quote_2. -- -- The missing quote belongs after the parse error token, before or -- at the end of the current line; try inserting it at the end of -- the current line. -- -- The lexer repaired string literal may be in a reduced token on the -- stack. declare Matching : SAL.Peek_Type := 1; begin Find_Descendant_ID (Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set (Lexer_Error_Token.ID), Matching); if Matching = Config.Stack.Depth then -- String literal is in a virtual nonterm; give up. So far this only -- happens in a high cost non critical config. if Trace_McKenzie > Detail then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""insert quote b abandon; string literal in virtual""); end if; return; end if; declare New_Config : Configuration := Config; begin String_Literal_In_Stack (""b"", New_Config, Matching, Lexer_Error_Token.ID); Finish (""b"", New_Config, Config.Current_Shared_Token, Shared.Line_Begin_Token.all (Current_Line + 1) - 1); Local_Config_Heap.Add (New_Config); end; end; else -- The unbalanced quote is after the parse error token. -- case c: Assume a missing quote belongs immediately before the current token. -- See test_mckenzie_recover.adb String_Quote_3. declare New_Config : Configuration := Config; begin Finish (""c"", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index - 1); Local_Config_Heap.Add (New_Config); exception when Bad_Config => null; end; -- case d: Assume a missing quote belongs somewhere farther before -- the current token; try one non-empty (as in case a above). See -- test_mckenzie_recover.adb String_Quote_4. declare New_Config : Configuration := Config; Token : Recover_Token; begin loop Token := New_Config.Stack.Pop.Token; if Token.Byte_Region /= Null_Buffer_Region then if Is_Full (New_Config.Ops) then Super.Config_Full (""insert quote 5 d"", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); end if; exit; end if; end loop; Finish (""d"", New_Config, Token.Min_Terminal_Index, Lexer_Error_Token_Index - 1); Local_Config_Heap.Add (New_Config); exception when SAL.Container_Empty => -- From Stack.Pop null; when Bad_Config => null; end; -- case e: Assume the actual error is an extra quote that terminates -- an intended string literal early, in which case there is a token -- on the stack containing the string literal that should be extended -- to the found quote. See test_mckenzie_recover.adb String_Quote_1. declare Matching : SAL.Peek_Type := 1; begin -- Lexer_Error_Token is a string literal; find a matching one. Find_Descendant_ID (Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set (Lexer_Error_Token.ID), Matching); if Matching = Config.Stack.Depth then -- No matching string literal, so this case does not apply. null; else declare New_Config : Configuration := Config; begin String_Literal_In_Stack (""e"", New_Config, Matching, Lexer_Error_Token.ID); Finish (""e"", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index); Local_Config_Heap.Add (New_Config); end; end if; end; end if; exception when Bad_Config => null; end Try_Insert_Quote; procedure Try_Delete_Input (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is -- Try deleting (= skipping) the current shared input token. use Config_Op_Arrays, Config_Op_Array_Refs; use all type Ada.Containers.Count_Type; Trace : WisiToken.Trace'Class renames Super.Trace.all; EOF_ID : Token_ID renames Trace.Descriptor.EOI_ID; Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; ID : constant Token_ID := Shared.Terminals.all (Config.Current_Shared_Token).ID; begin if ID /= EOF_ID and then -- can't delete EOF (Length (Config.Ops) = 0 or else -- Don't delete an ID we just inserted; waste of time (not Equal (Constant_Ref (Config.Ops, Last_Index (Config.Ops)), (Insert, ID, Config.Current_Shared_Token, 1, 0)))) then declare New_Config : Configuration := Config; function Matching_Push_Back return Boolean is begin for I in reverse First_Index (New_Config.Ops) .. Last_Index (New_Config.Ops) loop declare Op : Config_Op renames Config_Op_Array_Refs.Variable_Ref (New_Config.Ops, I).Element.all; begin exit when not (Op.Op in Undo_Reduce | Push_Back | Delete); if Op = (Push_Back, ID, New_Config.Current_Shared_Token) then return True; end if; end; end loop; return False; end Matching_Push_Back; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); New_Config.Cost := New_Config.Cost + McKenzie_Param.Delete (ID); New_Config.Strategy_Counts (Explore_Table) := Config.Strategy_Counts (Explore_Table) + 1; if Matching_Push_Back then -- We are deleting a push_back; cancel the push_back cost, to make -- this the same as plain deleting. New_Config.Cost := Natural'Max (Natural'First, New_Config.Cost - McKenzie_Param.Push_Back (ID)); end if; if Is_Full (New_Config.Ops) then Super.Config_Full (""delete"", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Delete, ID, Config.Current_Shared_Token)); end if; New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1; loop exit when not Super.Parser_State (Parser_Index).Prev_Deleted.Contains (New_Config.Current_Shared_Token); New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1; end loop; if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit; end if; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put (""delete "" & Image (ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Delete_Input; procedure Process_One (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Config_Status : out Base.Config_Status) is -- Get one config from Super, check to see if it is a viable -- solution. If not, enqueue variations to check. use all type Base.Config_Status; use all type Parser.Language_Fixes_Access; use all type Semantic_Checks.Check_Status_Label; Trace : WisiToken.Trace'Class renames Super.Trace.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Table : Parse_Table renames Shared.Table.all; Parser_Index : SAL.Base_Peek_Type; Config : Configuration; Local_Config_Heap : Config_Heaps.Heap_Type; -- We collect all the variants to enqueue, then deliver them all at -- once to Super, to minimizes task interactions. begin Super.Get (Parser_Index, Config, Config_Status); if Config_Status = All_Done then return; end if; if Trace_McKenzie > Detail then Base.Put (""dequeue"", Super, Shared, Parser_Index, Config); if Trace_McKenzie > Extra then Put_Line (Trace, Super.Label (Parser_Index), ""stack: "" & Image (Config.Stack, Trace.Descriptor.all)); end if; end if; -- Fast_Forward; parse Insert, Delete in Config.Ops that have not -- been parsed yet. 'parse' here means adjusting Config.Stack and -- Current_Terminal_Index. Code in this file always parses when -- adding ops to Config (except as noted); Language_Fixes should use -- McKenzie_Recover.Insert, Delete instead. if Config.Current_Insert_Delete = 1 then -- Config.Current_Insert_Delete > 1 is a programming error. case Fast_Forward (Super, Shared, Parser_Index, Local_Config_Heap, Config) is when Abandon => -- We know Local_Config_Heap is empty; just tell -- Super we are done working. Super.Put (Parser_Index, Local_Config_Heap); return; when Continue => -- We don't increase cost for this Fast_Forward, since it is due to a -- Language_Fixes. null; end case; end if; pragma Assert (Config.Current_Insert_Delete = 0); -- Language_Fixes: let it enqueue configs. if Config.Error_Token.ID /= Invalid_Token_ID then if Shared.Language_Fixes = null then null; else Shared.Language_Fixes (Trace, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap, Config); -- The solutions enqueued by Language_Fixes should be lower cost than -- others (typically 0), so they will be checked first. if Config.Check_Status.Label = Ok then -- Parse table Error action. -- -- We don't clear Config.Error_Token here, because -- Language_Use_Minimal_Complete_Actions needs it. We only clear it -- when a parse results in no error (or a different error), or a -- push_back moves the Current_Token. null; else -- Assume ""ignore check error"" is a viable solution. But give it a -- cost, so a solution provided by Language_Fixes is preferred. declare New_State : Unknown_State_Index; begin Config.Cost := Config.Cost + Table.McKenzie_Param.Ignore_Check_Fail; -- finish reduce. Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count)); New_State := Goto_For (Table, Config.Stack.Peek.State, Config.Error_Token.ID); if New_State = Unknown_State then if Config.Stack.Depth = 1 then -- Stack is empty, and we did not get Accept; really bad syntax got -- us here; abandon this config. See ada_mode-recover_bad_char.adb. Super.Put (Parser_Index, Local_Config_Heap); return; else raise SAL.Programmer_Error with ""process_one found test case for new_state = Unknown; old state "" & Trimmed_Image (Config.Stack.Peek.State) & "" nonterm "" & Image (Config.Error_Token.ID, Trace.Descriptor.all); end if; end if; Config.Stack.Push ((New_State, Syntax_Trees.Invalid_Node_Index, Config.Error_Token)); -- We clear Check_Status and Error_Token so the check error is ignored. Config.Check_Status := (Label => Ok); Config.Error_Token.ID := Invalid_Token_ID; end; end if; end if; end if; -- Call Check to see if this config succeeds. Note that Check does -- more than Fast_Forward, so the fact that Fast_Forward succeeds -- does not mean we don't need to call Check. case Check (Super, Shared, Parser_Index, Config, Local_Config_Heap) is when Success => Super.Success (Parser_Index, Config, Local_Config_Heap); return; when Abandon => Super.Put (Parser_Index, Local_Config_Heap); return; when Continue => null; end case; if Trace_McKenzie > Detail then Base.Put (""continuing"", Super, Shared, Parser_Index, Config); if Trace_McKenzie > Extra then Put_Line (Trace, Super.Label (Parser_Index), ""stack: "" & Image (Config.Stack, Trace.Descriptor.all)); end if; end if; -- Grouping these operations (push_back, delete, insert) ensures that -- there are no duplicate solutions found. We reset the grouping -- after each fast_forward. -- -- We do delete before insert so Insert_Matching_Begin can operate on -- the new next token, before Fast_Forwarding past it. -- -- All possible permutations will be explored. pragma Assert (Config.Stack.Depth > 0); Try_Insert_Terminal (Super, Shared, Parser_Index, Config, Local_Config_Heap); if None_Since_FF (Config.Ops, Delete) and then None_Since_FF (Config.Ops, Insert) and then Config.Stack.Depth > 1 and then -- can't delete the first state (not Check_Reduce_To_Start (Super, Shared, Parser_Index, Config)) -- If Config reduces to the start nonterm, there's no point in push_back. then Try_Push_Back (Super, Shared, Parser_Index, Config, Local_Config_Heap); Try_Undo_Reduce (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; if None_Since_FF (Config.Ops, Insert) then Try_Delete_Input (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; -- This is run once per input line, independent of what other ops -- have been done. if Config.Check_Status.Label = Ok and (Descriptor.String_1_ID /= Invalid_Token_ID or Descriptor.String_2_ID /= Invalid_Token_ID) and (Config.String_Quote_Checked = Invalid_Line_Number or else Config.String_Quote_Checked < Shared.Terminals.all (Config.Current_Shared_Token).Line) then -- See if there is a mismatched quote. The solution is to delete -- tokens, replacing them with a string literal. So we try this when -- it is ok to try delete. Try_Insert_Quote (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; Super.Put (Parser_Index, Local_Config_Heap); exception when Bad_Config => -- Just abandon this config; tell Super we are done. Super.Put (Parser_Index, Local_Config_Heap); when E : others => Super.Put (Parser_Index, Local_Config_Heap); if Debug_Mode then raise; elsif Trace_McKenzie > Outline then Put_Line (Super.Trace.all, Super.Label (Parser_Index), ""Process_One: unhandled exception "" & Ada.Exceptions.Exception_Name (E) & "": "" & Ada.Exceptions.Exception_Message (E)); end if; end Process_One; end WisiToken.Parse.LR.McKenzie_Recover.Explore; ",16168,True,3779.321191646509,median "------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J . E N V -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Fmap; with Makeutl; use Makeutl; with Opt; with Osint; use Osint; with Output; use Output; with Prj.Com; use Prj.Com; with Sdefault; with Tempdir; with Ada.Text_IO; use Ada.Text_IO; with GNAT.Directory_Operations; use GNAT.Directory_Operations; package body Prj.Env is Buffer_Initial : constant := 1_000; -- Initial arbitrary size of buffers Uninitialized_Prefix : constant String := '#' & Path_Separator; -- Prefix to indicate that the project path has not been initialized yet. -- Must be two characters long No_Project_Default_Dir : constant String := ""-""; -- Indicator in the project path to indicate that the default search -- directories should not be added to the path ----------------------- -- Local Subprograms -- ----------------------- package Source_Path_Table is new GNAT.Dynamic_Tables (Table_Component_Type => Name_Id, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 50, Table_Increment => 100); -- A table to store the source dirs before creating the source path file package Object_Path_Table is new GNAT.Dynamic_Tables (Table_Component_Type => Path_Name_Type, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 50, Table_Increment => 100); -- A table to store the object dirs, before creating the object path file procedure Add_To_Buffer (S : String; Buffer : in out String_Access; Buffer_Last : in out Natural); -- Add a string to Buffer, extending Buffer if needed procedure Add_To_Path (Source_Dirs : String_List_Id; Shared : Shared_Project_Tree_Data_Access; Buffer : in out String_Access; Buffer_Last : in out Natural); -- Add to Ada_Path_Buffer all the source directories in string list -- Source_Dirs, if any. procedure Add_To_Path (Dir : String; Buffer : in out String_Access; Buffer_Last : in out Natural); -- If Dir is not already in the global variable Ada_Path_Buffer, add it. -- If Buffer_Last /= 0, prepend a Path_Separator character to Path. procedure Add_To_Source_Path (Source_Dirs : String_List_Id; Shared : Shared_Project_Tree_Data_Access; Source_Paths : in out Source_Path_Table.Instance); -- Add to Ada_Path_B all the source directories in string list -- Source_Dirs, if any. Increment Ada_Path_Length. procedure Add_To_Object_Path (Object_Dir : Path_Name_Type; Object_Paths : in out Object_Path_Table.Instance); -- Add Object_Dir to object path table. Make sure it is not duplicate -- and it is the last one in the current table. ---------------------- -- Ada_Include_Path -- ---------------------- function Ada_Include_Path (Project : Project_Id; In_Tree : Project_Tree_Ref; Recursive : Boolean := False) return String is Buffer : String_Access; Buffer_Last : Natural := 0; procedure Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean); -- Add source dirs of Project to the path --------- -- Add -- --------- procedure Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean) is begin Add_To_Path (Project.Source_Dirs, In_Tree.Shared, Buffer, Buffer_Last); end Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Add); Dummy : Boolean := False; -- Start of processing for Ada_Include_Path begin if Recursive then -- If it is the first time we call this function for this project, -- compute the source path. if Project.Ada_Include_Path = null then Buffer := new String (1 .. Buffer_Initial); For_All_Projects (Project, In_Tree, Dummy, Include_Aggregated => True); Project.Ada_Include_Path := new String'(Buffer (1 .. Buffer_Last)); Free (Buffer); end if; return Project.Ada_Include_Path.all; else Buffer := new String (1 .. Buffer_Initial); Add_To_Path (Project.Source_Dirs, In_Tree.Shared, Buffer, Buffer_Last); declare Result : constant String := Buffer (1 .. Buffer_Last); begin Free (Buffer); return Result; end; end if; end Ada_Include_Path; ---------------------- -- Ada_Objects_Path -- ---------------------- function Ada_Objects_Path (Project : Project_Id; In_Tree : Project_Tree_Ref; Including_Libraries : Boolean := True) return String_Access is Buffer : String_Access; Buffer_Last : Natural := 0; procedure Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean); -- Add all the object directories of a project to the path --------- -- Add -- --------- procedure Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean) is pragma Unreferenced (In_Tree); Path : constant Path_Name_Type := Get_Object_Directory (Project, Including_Libraries => Including_Libraries, Only_If_Ada => False); begin if Path /= No_Path then Add_To_Path (Get_Name_String (Path), Buffer, Buffer_Last); end if; end Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Add); Dummy : Boolean := False; Result : String_Access; -- Start of processing for Ada_Objects_Path begin -- If it is the first time we call this function for -- this project, compute the objects path if Including_Libraries and then Project.Ada_Objects_Path /= null then return Project.Ada_Objects_Path; elsif not Including_Libraries and then Project.Ada_Objects_Path_No_Libs /= null then return Project.Ada_Objects_Path_No_Libs; else Buffer := new String (1 .. Buffer_Initial); For_All_Projects (Project, In_Tree, Dummy); Result := new String'(Buffer (1 .. Buffer_Last)); Free (Buffer); if Including_Libraries then Project.Ada_Objects_Path := Result; else Project.Ada_Objects_Path_No_Libs := Result; end if; return Result; end if; end Ada_Objects_Path; ------------------- -- Add_To_Buffer -- ------------------- procedure Add_To_Buffer (S : String; Buffer : in out String_Access; Buffer_Last : in out Natural) is Last : constant Natural := Buffer_Last + S'Length; begin while Last > Buffer'Last loop declare New_Buffer : constant String_Access := new String (1 .. 2 * Buffer'Last); begin New_Buffer (1 .. Buffer_Last) := Buffer (1 .. Buffer_Last); Free (Buffer); Buffer := New_Buffer; end; end loop; Buffer (Buffer_Last + 1 .. Last) := S; Buffer_Last := Last; end Add_To_Buffer; ------------------------ -- Add_To_Object_Path -- ------------------------ procedure Add_To_Object_Path (Object_Dir : Path_Name_Type; Object_Paths : in out Object_Path_Table.Instance) is begin -- Check if the directory is already in the table for Index in Object_Path_Table.First .. Object_Path_Table.Last (Object_Paths) loop -- If it is, remove it, and add it as the last one if Object_Paths.Table (Index) = Object_Dir then for Index2 in Index + 1 .. Object_Path_Table.Last (Object_Paths) loop Object_Paths.Table (Index2 - 1) := Object_Paths.Table (Index2); end loop; Object_Paths.Table (Object_Path_Table.Last (Object_Paths)) := Object_Dir; return; end if; end loop; -- The directory is not already in the table, add it Object_Path_Table.Append (Object_Paths, Object_Dir); end Add_To_Object_Path; ----------------- -- Add_To_Path -- ----------------- procedure Add_To_Path (Source_Dirs : String_List_Id; Shared : Shared_Project_Tree_Data_Access; Buffer : in out String_Access; Buffer_Last : in out Natural) is Current : String_List_Id; Source_Dir : String_Element; begin Current := Source_Dirs; while Current /= Nil_String loop Source_Dir := Shared.String_Elements.Table (Current); Add_To_Path (Get_Name_String (Source_Dir.Display_Value), Buffer, Buffer_Last); Current := Source_Dir.Next; end loop; end Add_To_Path; procedure Add_To_Path (Dir : String; Buffer : in out String_Access; Buffer_Last : in out Natural) is Len : Natural; New_Buffer : String_Access; Min_Len : Natural; function Is_Present (Path : String; Dir : String) return Boolean; -- Return True if Dir is part of Path ---------------- -- Is_Present -- ---------------- function Is_Present (Path : String; Dir : String) return Boolean is Last : constant Integer := Path'Last - Dir'Length + 1; begin for J in Path'First .. Last loop -- Note: the order of the conditions below is important, since -- it ensures a minimal number of string comparisons. if (J = Path'First or else Path (J - 1) = Path_Separator) and then (J + Dir'Length > Path'Last or else Path (J + Dir'Length) = Path_Separator) and then Dir = Path (J .. J + Dir'Length - 1) then return True; end if; end loop; return False; end Is_Present; -- Start of processing for Add_To_Path begin if Is_Present (Buffer (1 .. Buffer_Last), Dir) then -- Dir is already in the path, nothing to do return; end if; Min_Len := Buffer_Last + Dir'Length; if Buffer_Last > 0 then -- Add 1 for the Path_Separator character Min_Len := Min_Len + 1; end if; -- If Ada_Path_Buffer is too small, increase it Len := Buffer'Last; if Len < Min_Len then loop Len := Len * 2; exit when Len >= Min_Len; end loop; New_Buffer := new String (1 .. Len); New_Buffer (1 .. Buffer_Last) := Buffer (1 .. Buffer_Last); Free (Buffer); Buffer := New_Buffer; end if; if Buffer_Last > 0 then Buffer_Last := Buffer_Last + 1; Buffer (Buffer_Last) := Path_Separator; end if; Buffer (Buffer_Last + 1 .. Buffer_Last + Dir'Length) := Dir; Buffer_Last := Buffer_Last + Dir'Length; end Add_To_Path; ------------------------ -- Add_To_Source_Path -- ------------------------ procedure Add_To_Source_Path (Source_Dirs : String_List_Id; Shared : Shared_Project_Tree_Data_Access; Source_Paths : in out Source_Path_Table.Instance) is Current : String_List_Id; Source_Dir : String_Element; Add_It : Boolean; begin -- Add each source directory Current := Source_Dirs; while Current /= Nil_String loop Source_Dir := Shared.String_Elements.Table (Current); Add_It := True; -- Check if the source directory is already in the table for Index in Source_Path_Table.First .. Source_Path_Table.Last (Source_Paths) loop -- If it is already, no need to add it if Source_Paths.Table (Index) = Source_Dir.Value then Add_It := False; exit; end if; end loop; if Add_It then Source_Path_Table.Append (Source_Paths, Source_Dir.Display_Value); end if; -- Next source directory Current := Source_Dir.Next; end loop; end Add_To_Source_Path; -------------------------------- -- Create_Config_Pragmas_File -- -------------------------------- procedure Create_Config_Pragmas_File (For_Project : Project_Id; In_Tree : Project_Tree_Ref) is type Naming_Id is new Nat; package Naming_Table is new GNAT.Dynamic_Tables (Table_Component_Type => Lang_Naming_Data, Table_Index_Type => Naming_Id, Table_Low_Bound => 1, Table_Initial => 5, Table_Increment => 100); Default_Naming : constant Naming_Id := Naming_Table.First; Namings : Naming_Table.Instance; -- Table storing the naming data for gnatmake/gprmake Buffer : String_Access := new String (1 .. Buffer_Initial); Buffer_Last : Natural := 0; File_Name : Path_Name_Type := No_Path; File : File_Descriptor := Invalid_FD; Current_Naming : Naming_Id; procedure Check (Project : Project_Id; In_Tree : Project_Tree_Ref; State : in out Integer); -- Recursive procedure that put in the config pragmas file any non -- standard naming schemes, if it is not already in the file, then call -- itself for any imported project. procedure Put (Source : Source_Id); -- Put an SFN pragma in the temporary file procedure Put (S : String); procedure Put_Line (S : String); -- Output procedures, analogous to normal Text_IO procs of same name. -- The text is put in Buffer, then it will be written into a temporary -- file with procedure Write_Temp_File below. procedure Write_Temp_File; -- Create a temporary file and put the content of the buffer in it ----------- -- Check -- ----------- procedure Check (Project : Project_Id; In_Tree : Project_Tree_Ref; State : in out Integer) is pragma Unreferenced (State); Lang : constant Language_Ptr := Get_Language_From_Name (Project, ""ada""); Naming : Lang_Naming_Data; Iter : Source_Iterator; Source : Source_Id; begin if Current_Verbosity = High then Debug_Output (""Checking project file:"", Project.Name); end if; if Lang = null then if Current_Verbosity = High then Debug_Output (""Languages does not contain Ada, nothing to do""); end if; return; end if; -- Visit all the files and process those that need an SFN pragma Iter := For_Each_Source (In_Tree, Project); while Element (Iter) /= No_Source loop Source := Element (Iter); if not Source.Locally_Removed and then Source.Unit /= null and then (Source.Index >= 1 or else Source.Naming_Exception /= No) then Put (Source); end if; Next (Iter); end loop; Naming := Lang.Config.Naming_Data; -- Is the naming scheme of this project one that we know? Current_Naming := Default_Naming; while Current_Naming <= Naming_Table.Last (Namings) and then Namings.Table (Current_Naming).Dot_Replacement = Naming.Dot_Replacement and then Namings.Table (Current_Naming).Casing = Naming.Casing and then Namings.Table (Current_Naming).Separate_Suffix = Naming.Separate_Suffix loop Current_Naming := Current_Naming + 1; end loop; -- If we don't know it, add it if Current_Naming > Naming_Table.Last (Namings) then Naming_Table.Increment_Last (Namings); Namings.Table (Naming_Table.Last (Namings)) := Naming; -- Put the SFN pragmas for the naming scheme -- Spec Put_Line (""pragma Source_File_Name_Project""); Put_Line ("" (Spec_File_Name => """"*"" & Get_Name_String (Naming.Spec_Suffix) & """""",""); Put_Line ("" Casing => "" & Image (Naming.Casing) & "",""); Put_Line ("" Dot_Replacement => """""" & Get_Name_String (Naming.Dot_Replacement) & """""");""); -- and body Put_Line (""pragma Source_File_Name_Project""); Put_Line ("" (Body_File_Name => """"*"" & Get_Name_String (Naming.Body_Suffix) & """""",""); Put_Line ("" Casing => "" & Image (Naming.Casing) & "",""); Put_Line ("" Dot_Replacement => """""" & Get_Name_String (Naming.Dot_Replacement) & """""");""); -- and maybe separate if Naming.Body_Suffix /= Naming.Separate_Suffix then Put_Line (""pragma Source_File_Name_Project""); Put_Line ("" (Subunit_File_Name => """"*"" & Get_Name_String (Naming.Separate_Suffix) & """""",""); Put_Line ("" Casing => "" & Image (Naming.Casing) & "",""); Put_Line ("" Dot_Replacement => """""" & Get_Name_String (Naming.Dot_Replacement) & """""");""); end if; end if; end Check; --------- -- Put -- --------- procedure Put (Source : Source_Id) is begin -- Put the pragma SFN for the unit kind (spec or body) Put (""pragma Source_File_Name_Project (""); Put (Namet.Get_Name_String (Source.Unit.Name)); if Source.Kind = Spec then Put ("", Spec_File_Name => """"""); else Put ("", Body_File_Name => """"""); end if; Put (Namet.Get_Name_String (Source.File)); Put (""""""""); if Source.Index /= 0 then Put ("", Index =>""); Put (Source.Index'Img); end if; Put_Line ("");""); end Put; procedure Put (S : String) is begin Add_To_Buffer (S, Buffer, Buffer_Last); if Current_Verbosity = High then Write_Str (S); end if; end Put; -------------- -- Put_Line -- -------------- procedure Put_Line (S : String) is begin -- Add an ASCII.LF to the string. As this config file is supposed to -- be used only by the compiler, we don't care about the characters -- for the end of line. In fact we could have put a space, but -- it is more convenient to be able to read gnat.adc during -- development, for which the ASCII.LF is fine. Put (S); Put (S => (1 => ASCII.LF)); end Put_Line; --------------------- -- Write_Temp_File -- --------------------- procedure Write_Temp_File is Status : Boolean := False; Last : Natural; begin Tempdir.Create_Temp_File (File, File_Name); if File /= Invalid_FD then Last := Write (File, Buffer (1)'Address, Buffer_Last); if Last = Buffer_Last then Close (File, Status); end if; end if; if not Status then Prj.Com.Fail (""unable to create temporary file""); end if; end Write_Temp_File; procedure Check_Imported_Projects is new For_Every_Project_Imported (Integer, Check); Dummy : Integer := 0; -- Start of processing for Create_Config_Pragmas_File begin if not For_Project.Config_Checked then Naming_Table.Init (Namings); -- Check the naming schemes Check_Imported_Projects (For_Project, In_Tree, Dummy, Imported_First => False); -- If there are no non standard naming scheme, issue the GNAT -- standard naming scheme. This will tell the compiler that -- a project file is used and will forbid any pragma SFN. if Buffer_Last = 0 then Put_Line (""pragma Source_File_Name_Project""); Put_Line ("" (Spec_File_Name => """"*.ads"""",""); Put_Line ("" Dot_Replacement => """"-"""",""); Put_Line ("" Casing => lowercase);""); Put_Line (""pragma Source_File_Name_Project""); Put_Line ("" (Body_File_Name => """"*.adb"""",""); Put_Line ("" Dot_Replacement => """"-"""",""); Put_Line ("" Casing => lowercase);""); end if; -- Close the temporary file Write_Temp_File; if Opt.Verbose_Mode then Write_Str (""Created configuration file """"""); Write_Str (Get_Name_String (File_Name)); Write_Line (""""""""); end if; For_Project.Config_File_Name := File_Name; For_Project.Config_File_Temp := True; For_Project.Config_Checked := True; end if; Free (Buffer); end Create_Config_Pragmas_File; -------------------- -- Create_Mapping -- -------------------- procedure Create_Mapping (In_Tree : Project_Tree_Ref) is Data : Source_Id; Iter : Source_Iterator; begin Fmap.Reset_Tables; Iter := For_Each_Source (In_Tree); loop Data := Element (Iter); exit when Data = No_Source; if Data.Unit /= No_Unit_Index then if Data.Locally_Removed and then not Data.Suppressed then Fmap.Add_Forbidden_File_Name (Data.File); else Fmap.Add_To_File_Map (Unit_Name => Unit_Name_Type (Data.Unit.Name), File_Name => Data.File, Path_Name => File_Name_Type (Data.Path.Display_Name)); end if; end if; Next (Iter); end loop; end Create_Mapping; ------------------------- -- Create_Mapping_File -- ------------------------- procedure Create_Mapping_File (Project : Project_Id; Language : Name_Id; In_Tree : Project_Tree_Ref; Name : out Path_Name_Type) is File : File_Descriptor := Invalid_FD; Buffer : String_Access := new String (1 .. Buffer_Initial); Buffer_Last : Natural := 0; procedure Put_Name_Buffer; -- Put the line contained in the Name_Buffer in the global buffer procedure Process (Project : Project_Id; In_Tree : Project_Tree_Ref; State : in out Integer); -- Generate the mapping file for Project (not recursively) --------------------- -- Put_Name_Buffer -- --------------------- procedure Put_Name_Buffer is begin if Current_Verbosity = High then Debug_Output (Name_Buffer (1 .. Name_Len)); end if; Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := ASCII.LF; Add_To_Buffer (Name_Buffer (1 .. Name_Len), Buffer, Buffer_Last); end Put_Name_Buffer; ------------- -- Process -- ------------- procedure Process (Project : Project_Id; In_Tree : Project_Tree_Ref; State : in out Integer) is pragma Unreferenced (State); Source : Source_Id; Suffix : File_Name_Type; Iter : Source_Iterator; begin Debug_Output (""Add mapping for project"", Project.Name); Iter := For_Each_Source (In_Tree, Project, Language => Language); loop Source := Prj.Element (Iter); exit when Source = No_Source; if not Source.Suppressed and then Source.Replaced_By = No_Source and then Source.Path.Name /= No_Path and then (Source.Language.Config.Kind = File_Based or else Source.Unit /= No_Unit_Index) then if Source.Unit /= No_Unit_Index then -- Put the encoded unit name in the name buffer declare Uname : constant String := Get_Name_String (Source.Unit.Name); begin Name_Len := 0; for J in Uname'Range loop if Uname (J) in Upper_Half_Character then Store_Encoded_Character (Get_Char_Code (Uname (J))); else Add_Char_To_Name_Buffer (Uname (J)); end if; end loop; end; if Source.Language.Config.Kind = Unit_Based then -- ??? Mapping_Spec_Suffix could be set in the case of -- gnatmake as well Add_Char_To_Name_Buffer ('%'); if Source.Kind = Spec then Add_Char_To_Name_Buffer ('s'); else Add_Char_To_Name_Buffer ('b'); end if; else case Source.Kind is when Spec => Suffix := Source.Language.Config.Mapping_Spec_Suffix; when Impl | Sep => Suffix := Source.Language.Config.Mapping_Body_Suffix; end case; if Suffix /= No_File then Add_Str_To_Name_Buffer (Get_Name_String (Suffix)); end if; end if; Put_Name_Buffer; end if; Get_Name_String (Source.Display_File); Put_Name_Buffer; if Source.Locally_Removed then Name_Len := 1; Name_Buffer (1) := '/'; else Get_Name_String (Source.Path.Display_Name); end if; Put_Name_Buffer; end if; Next (Iter); end loop; end Process; procedure For_Every_Imported_Project is new For_Every_Project_Imported (State => Integer, Action => Process); -- Local variables Dummy : Integer := 0; -- Start of processing for Create_Mapping_File begin if Current_Verbosity = High then Debug_Output (""Create mapping file for"", Debug_Name (In_Tree)); end if; Create_Temp_File (In_Tree.Shared, File, Name, ""mapping""); if Current_Verbosity = High then Debug_Increase_Indent (""Create mapping file "", Name_Id (Name)); end if; For_Every_Imported_Project (Project, In_Tree, Dummy, Include_Aggregated => False); declare Last : Natural; Status : Boolean := False; begin if File /= Invalid_FD then Last := Write (File, Buffer (1)'Address, Buffer_Last); if Last = Buffer_Last then GNAT.OS_Lib.Close (File, Status); end if; end if; if not Status then Prj.Com.Fail (""could not write mapping file""); end if; end; Free (Buffer); Debug_Decrease_Indent (""Done create mapping file""); end Create_Mapping_File; ---------------------- -- Create_Temp_File -- ---------------------- procedure Create_Temp_File (Shared : Shared_Project_Tree_Data_Access; Path_FD : out File_Descriptor; Path_Name : out Path_Name_Type; File_Use : String) is begin Tempdir.Create_Temp_File (Path_FD, Path_Name); if Path_Name /= No_Path then if Current_Verbosity = High then Write_Line (""Create temp file ("" & File_Use & "") "" & Get_Name_String (Path_Name)); end if; Record_Temp_File (Shared, Path_Name); else Prj.Com.Fail (""unable to create temporary "" & File_Use & "" file""); end if; end Create_Temp_File; -------------------------- -- Create_New_Path_File -- -------------------------- procedure Create_New_Path_File (Shared : Shared_Project_Tree_Data_Access; Path_FD : out File_Descriptor; Path_Name : out Path_Name_Type) is begin Create_Temp_File (Shared, Path_FD, Path_Name, ""path file""); end Create_New_Path_File; ------------------------------------ -- File_Name_Of_Library_Unit_Body -- ------------------------------------ function File_Name_Of_Library_Unit_Body (Name : String; Project : Project_Id; In_Tree : Project_Tree_Ref; Main_Project_Only : Boolean := True; Full_Path : Boolean := False) return String is Lang : constant Language_Ptr := Get_Language_From_Name (Project, ""ada""); The_Project : Project_Id := Project; Original_Name : String := Name; Unit : Unit_Index; The_Original_Name : Name_Id; The_Spec_Name : Name_Id; The_Body_Name : Name_Id; begin -- ??? Same block in Project_Of Canonical_Case_File_Name (Original_Name); Name_Len := Original_Name'Length; Name_Buffer (1 .. Name_Len) := Original_Name; The_Original_Name := Name_Find; if Lang /= null then declare Naming : constant Lang_Naming_Data := Lang.Config.Naming_Data; Extended_Spec_Name : String := Name & Namet.Get_Name_String (Naming.Spec_Suffix); Extended_Body_Name : String := Name & Namet.Get_Name_String (Naming.Body_Suffix); begin Canonical_Case_File_Name (Extended_Spec_Name); Name_Len := Extended_Spec_Name'Length; Name_Buffer (1 .. Name_Len) := Extended_Spec_Name; The_Spec_Name := Name_Find; Canonical_Case_File_Name (Extended_Body_Name); Name_Len := Extended_Body_Name'Length; Name_Buffer (1 .. Name_Len) := Extended_Body_Name; The_Body_Name := Name_Find; end; else Name_Len := Name'Length; Name_Buffer (1 .. Name_Len) := Name; Canonical_Case_File_Name (Name_Buffer); The_Spec_Name := Name_Find; The_Body_Name := The_Spec_Name; end if; if Current_Verbosity = High then Write_Str (""Looking for file name of """"""); Write_Str (Name); Write_Char ('""'); Write_Eol; Write_Str ("" Extended Spec Name = """"""); Write_Str (Get_Name_String (The_Spec_Name)); Write_Char ('""'); Write_Eol; Write_Str ("" Extended Body Name = """"""); Write_Str (Get_Name_String (The_Body_Name)); Write_Char ('""'); Write_Eol; end if; -- For extending project, search in the extended project if the source -- is not found. For non extending projects, this loop will be run only -- once. loop -- Loop through units Unit := Units_Htable.Get_First (In_Tree.Units_HT); while Unit /= null loop -- Check for body if not Main_Project_Only or else (Unit.File_Names (Impl) /= null and then Unit.File_Names (Impl).Project = The_Project) then declare Current_Name : File_Name_Type; begin -- Case of a body present if Unit.File_Names (Impl) /= null then Current_Name := Unit.File_Names (Impl).File; if Current_Verbosity = High then Write_Str ("" Comparing with """"""); Write_Str (Get_Name_String (Current_Name)); Write_Char ('""'); Write_Eol; end if; -- If it has the name of the original name, return the -- original name. if Unit.Name = The_Original_Name or else Current_Name = File_Name_Type (The_Original_Name) then if Current_Verbosity = High then Write_Line ("" OK""); end if; if Full_Path then return Get_Name_String (Unit.File_Names (Impl).Path.Name); else return Get_Name_String (Current_Name); end if; -- If it has the name of the extended body name, -- return the extended body name elsif Current_Name = File_Name_Type (The_Body_Name) then if Current_Verbosity = High then Write_Line ("" OK""); end if; if Full_Path then return Get_Name_String (Unit.File_Names (Impl).Path.Name); else return Get_Name_String (The_Body_Name); end if; else if Current_Verbosity = High then Write_Line ("" not good""); end if; end if; end if; end; end if; -- Check for spec if not Main_Project_Only or else (Unit.File_Names (Spec) /= null and then Unit.File_Names (Spec).Project = The_Project) then declare Current_Name : File_Name_Type; begin -- Case of spec present if Unit.File_Names (Spec) /= null then Current_Name := Unit.File_Names (Spec).File; if Current_Verbosity = High then Write_Str ("" Comparing with """"""); Write_Str (Get_Name_String (Current_Name)); Write_Char ('""'); Write_Eol; end if; -- If name same as original name, return original name if Unit.Name = The_Original_Name or else Current_Name = File_Name_Type (The_Original_Name) then if Current_Verbosity = High then Write_Line ("" OK""); end if; if Full_Path then return Get_Name_String (Unit.File_Names (Spec).Path.Name); else return Get_Name_String (Current_Name); end if; -- If it has the same name as the extended spec name, -- return the extended spec name. elsif Current_Name = File_Name_Type (The_Spec_Name) then if Current_Verbosity = High then Write_Line ("" OK""); end if; if Full_Path then return Get_Name_String (Unit.File_Names (Spec).Path.Name); else return Get_Name_String (The_Spec_Name); end if; else if Current_Verbosity = High then Write_Line ("" not good""); end if; end if; end if; end; end if; Unit := Units_Htable.Get_Next (In_Tree.Units_HT); end loop; -- If we are not in an extending project, give up exit when not Main_Project_Only or else The_Project.Extends = No_Project; -- Otherwise, look in the project we are extending The_Project := The_Project.Extends; end loop; -- We don't know this file name, return an empty string return """"; end File_Name_Of_Library_Unit_Body; ------------------------- -- For_All_Object_Dirs -- ------------------------- procedure For_All_Object_Dirs (Project : Project_Id; Tree : Project_Tree_Ref) is procedure For_Project (Prj : Project_Id; Tree : Project_Tree_Ref; Dummy : in out Integer); -- Get all object directories of Prj ----------------- -- For_Project -- ----------------- procedure For_Project (Prj : Project_Id; Tree : Project_Tree_Ref; Dummy : in out Integer) is pragma Unreferenced (Tree); begin -- ??? Set_Ada_Paths has a different behavior for library project -- files, should we have the same ? if Prj.Object_Directory /= No_Path_Information then Get_Name_String (Prj.Object_Directory.Display_Name); Action (Name_Buffer (1 .. Name_Len)); end if; end For_Project; procedure Get_Object_Dirs is new For_Every_Project_Imported (Integer, For_Project); Dummy : Integer := 1; -- Start of processing for For_All_Object_Dirs begin Get_Object_Dirs (Project, Tree, Dummy); end For_All_Object_Dirs; ------------------------- -- For_All_Source_Dirs -- ------------------------- procedure For_All_Source_Dirs (Project : Project_Id; In_Tree : Project_Tree_Ref) is procedure For_Project (Prj : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Integer); -- Get all object directories of Prj ----------------- -- For_Project -- ----------------- procedure For_Project (Prj : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Integer) is Current : String_List_Id := Prj.Source_Dirs; The_String : String_Element; begin -- If there are Ada sources, call action with the name of every -- source directory. if Has_Ada_Sources (Prj) then while Current /= Nil_String loop The_String := In_Tree.Shared.String_Elements.Table (Current); Action (Get_Name_String (The_String.Display_Value)); Current := The_String.Next; end loop; end if; end For_Project; procedure Get_Source_Dirs is new For_Every_Project_Imported (Integer, For_Project); Dummy : Integer := 1; -- Start of processing for For_All_Source_Dirs begin Get_Source_Dirs (Project, In_Tree, Dummy); end For_All_Source_Dirs; ------------------- -- Get_Reference -- ------------------- procedure Get_Reference (Source_File_Name : String; In_Tree : Project_Tree_Ref; Project : out Project_Id; Path : out Path_Name_Type) is begin -- Body below could use some comments ??? if Current_Verbosity > Default then Write_Str (""Getting Reference_Of (""""""); Write_Str (Source_File_Name); Write_Str ("""""") ... ""); end if; declare Original_Name : String := Source_File_Name; Unit : Unit_Index; begin Canonical_Case_File_Name (Original_Name); Unit := Units_Htable.Get_First (In_Tree.Units_HT); while Unit /= null loop if Unit.File_Names (Spec) /= null and then not Unit.File_Names (Spec).Locally_Removed and then Unit.File_Names (Spec).File /= No_File and then (Namet.Get_Name_String (Unit.File_Names (Spec).File) = Original_Name or else (Unit.File_Names (Spec).Path /= No_Path_Information and then Namet.Get_Name_String (Unit.File_Names (Spec).Path.Name) = Original_Name)) then Project := Ultimate_Extending_Project_Of (Unit.File_Names (Spec).Project); Path := Unit.File_Names (Spec).Path.Display_Name; if Current_Verbosity > Default then Write_Str (""Done: Spec.""); Write_Eol; end if; return; elsif Unit.File_Names (Impl) /= null and then Unit.File_Names (Impl).File /= No_File and then not Unit.File_Names (Impl).Locally_Removed and then (Namet.Get_Name_String (Unit.File_Names (Impl).File) = Original_Name or else (Unit.File_Names (Impl).Path /= No_Path_Information and then Namet.Get_Name_String (Unit.File_Names (Impl).Path.Name) = Original_Name)) then Project := Ultimate_Extending_Project_Of (Unit.File_Names (Impl).Project); Path := Unit.File_Names (Impl).Path.Display_Name; if Current_Verbosity > Default then Write_Str (""Done: Body.""); Write_Eol; end if; return; end if; Unit := Units_Htable.Get_Next (In_Tree.Units_HT); end loop; end; Project := No_Project; Path := No_Path; if Current_Verbosity > Default then Write_Str (""Cannot be found.""); Write_Eol; end if; end Get_Reference; ---------------------- -- Get_Runtime_Path -- ---------------------- function Get_Runtime_Path (Self : Project_Search_Path; Name : String) return String_Access is function Find_Rts_In_Path is new Prj.Env.Find_Name_In_Path (Check_Filename => Is_Directory); begin return Find_Rts_In_Path (Self, Name); end Get_Runtime_Path; ---------------- -- Initialize -- ---------------- procedure Initialize (In_Tree : Project_Tree_Ref) is begin In_Tree.Shared.Private_Part.Current_Source_Path_File := No_Path; In_Tree.Shared.Private_Part.Current_Object_Path_File := No_Path; end Initialize; ------------------- -- Print_Sources -- ------------------- -- Could use some comments in this body ??? procedure Print_Sources (In_Tree : Project_Tree_Ref) is Unit : Unit_Index; begin Write_Line (""List of Sources:""); Unit := Units_Htable.Get_First (In_Tree.Units_HT); while Unit /= No_Unit_Index loop Write_Str ("" ""); Write_Line (Namet.Get_Name_String (Unit.Name)); if Unit.File_Names (Spec).File /= No_File then if Unit.File_Names (Spec).Project = No_Project then Write_Line ("" No project""); else Write_Str ("" Project: ""); Get_Name_String (Unit.File_Names (Spec).Project.Path.Name); Write_Line (Name_Buffer (1 .. Name_Len)); end if; Write_Str ("" spec: ""); Write_Line (Namet.Get_Name_String (Unit.File_Names (Spec).File)); end if; if Unit.File_Names (Impl).File /= No_File then if Unit.File_Names (Impl).Project = No_Project then Write_Line ("" No project""); else Write_Str ("" Project: ""); Get_Name_String (Unit.File_Names (Impl).Project.Path.Name); Write_Line (Name_Buffer (1 .. Name_Len)); end if; Write_Str ("" body: ""); Write_Line (Namet.Get_Name_String (Unit.File_Names (Impl).File)); end if; Unit := Units_Htable.Get_Next (In_Tree.Units_HT); end loop; Write_Line (""end of List of Sources.""); end Print_Sources; ---------------- -- Project_Of -- ---------------- function Project_Of (Name : String; Main_Project : Project_Id; In_Tree : Project_Tree_Ref) return Project_Id is Result : Project_Id := No_Project; Original_Name : String := Name; Lang : constant Language_Ptr := Get_Language_From_Name (Main_Project, ""ada""); Unit : Unit_Index; Current_Name : File_Name_Type; The_Original_Name : File_Name_Type; The_Spec_Name : File_Name_Type; The_Body_Name : File_Name_Type; begin -- ??? Same block in File_Name_Of_Library_Unit_Body Canonical_Case_File_Name (Original_Name); Name_Len := Original_Name'Length; Name_Buffer (1 .. Name_Len) := Original_Name; The_Original_Name := Name_Find; if Lang /= null then declare Naming : Lang_Naming_Data renames Lang.Config.Naming_Data; Extended_Spec_Name : String := Name & Namet.Get_Name_String (Naming.Spec_Suffix); Extended_Body_Name : String := Name & Namet.Get_Name_String (Naming.Body_Suffix); begin Canonical_Case_File_Name (Extended_Spec_Name); Name_Len := Extended_Spec_Name'Length; Name_Buffer (1 .. Name_Len) := Extended_Spec_Name; The_Spec_Name := Name_Find; Canonical_Case_File_Name (Extended_Body_Name); Name_Len := Extended_Body_Name'Length; Name_Buffer (1 .. Name_Len) := Extended_Body_Name; The_Body_Name := Name_Find; end; else The_Spec_Name := The_Original_Name; The_Body_Name := The_Original_Name; end if; Unit := Units_Htable.Get_First (In_Tree.Units_HT); while Unit /= null loop -- Case of a body present if Unit.File_Names (Impl) /= null then Current_Name := Unit.File_Names (Impl).File; -- If it has the name of the original name or the body name, -- we have found the project. if Unit.Name = Name_Id (The_Original_Name) or else Current_Name = The_Original_Name or else Current_Name = The_Body_Name then Result := Unit.File_Names (Impl).Project; exit; end if; end if; -- Check for spec if Unit.File_Names (Spec) /= null then Current_Name := Unit.File_Names (Spec).File; -- If name same as the original name, or the spec name, we have -- found the project. if Unit.Name = Name_Id (The_Original_Name) or else Current_Name = The_Original_Name or else Current_Name = The_Spec_Name then Result := Unit.File_Names (Spec).Project; exit; end if; end if; Unit := Units_Htable.Get_Next (In_Tree.Units_HT); end loop; return Ultimate_Extending_Project_Of (Result); end Project_Of; ------------------- -- Set_Ada_Paths -- ------------------- procedure Set_Ada_Paths (Project : Project_Id; In_Tree : Project_Tree_Ref; Including_Libraries : Boolean; Include_Path : Boolean := True; Objects_Path : Boolean := True) is Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared; Source_Paths : Source_Path_Table.Instance; Object_Paths : Object_Path_Table.Instance; -- List of source or object dirs. Only computed the first time this -- procedure is called (since Source_FD is then reused) Source_FD : File_Descriptor := Invalid_FD; Object_FD : File_Descriptor := Invalid_FD; -- The temporary files to store the paths. These are only created the -- first time this procedure is called, and reused from then on. Process_Source_Dirs : Boolean := False; Process_Object_Dirs : Boolean := False; Status : Boolean; -- For calls to Close Last : Natural; Buffer : String_Access := new String (1 .. Buffer_Initial); Buffer_Last : Natural := 0; procedure Recursive_Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean); -- Recursive procedure to add the source/object paths of extended/ -- imported projects. ------------------- -- Recursive_Add -- ------------------- procedure Recursive_Add (Project : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean) is pragma Unreferenced (In_Tree); Path : Path_Name_Type; begin if Process_Source_Dirs then -- Add to path all source directories of this project if there are -- Ada sources. if Has_Ada_Sources (Project) then Add_To_Source_Path (Project.Source_Dirs, Shared, Source_Paths); end if; end if; if Process_Object_Dirs then Path := Get_Object_Directory (Project, Including_Libraries => Including_Libraries, Only_If_Ada => True); if Path /= No_Path then Add_To_Object_Path (Path, Object_Paths); end if; end if; end Recursive_Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Recursive_Add); Dummy : Boolean := False; -- Start of processing for Set_Ada_Paths begin -- If it is the first time we call this procedure for this project, -- compute the source path and/or the object path. if Include_Path and then Project.Include_Path_File = No_Path then Source_Path_Table.Init (Source_Paths); Process_Source_Dirs := True; Create_New_Path_File (Shared, Source_FD, Project.Include_Path_File); end if; -- For the object path, we make a distinction depending on -- Including_Libraries. if Objects_Path and Including_Libraries then if Project.Objects_Path_File_With_Libs = No_Path then Object_Path_Table.Init (Object_Paths); Process_Object_Dirs := True; Create_New_Path_File (Shared, Object_FD, Project.Objects_Path_File_With_Libs); end if; elsif Objects_Path then if Project.Objects_Path_File_Without_Libs = No_Path then Object_Path_Table.Init (Object_Paths); Process_Object_Dirs := True; Create_New_Path_File (Shared, Object_FD, Project.Objects_Path_File_Without_Libs); end if; end if; -- If there is something to do, set Seen to False for all projects, -- then call the recursive procedure Add for Project. if Process_Source_Dirs or Process_Object_Dirs then For_All_Projects (Project, In_Tree, Dummy); end if; -- Write and close any file that has been created. Source_FD is not set -- when this subprogram is called a second time or more, since we reuse -- the previous version of the file. if Source_FD /= Invalid_FD then Buffer_Last := 0; for Index in Source_Path_Table.First .. Source_Path_Table.Last (Source_Paths) loop Get_Name_String (Source_Paths.Table (Index)); Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := ASCII.LF; Add_To_Buffer (Name_Buffer (1 .. Name_Len), Buffer, Buffer_Last); end loop; Last := Write (Source_FD, Buffer (1)'Address, Buffer_Last); if Last = Buffer_Last then Close (Source_FD, Status); else Status := False; end if; if not Status then Prj.Com.Fail (""could not write temporary file""); end if; end if; if Object_FD /= Invalid_FD then Buffer_Last := 0; for Index in Object_Path_Table.First .. Object_Path_Table.Last (Object_Paths) loop Get_Name_String (Object_Paths.Table (Index)); Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := ASCII.LF; Add_To_Buffer (Name_Buffer (1 .. Name_Len), Buffer, Buffer_Last); end loop; Last := Write (Object_FD, Buffer (1)'Address, Buffer_Last); if Last = Buffer_Last then Close (Object_FD, Status); else Status := False; end if; if not Status then Prj.Com.Fail (""could not write temporary file""); end if; end if; -- Set the env vars, if they need to be changed, and set the -- corresponding flags. if Include_Path and then Shared.Private_Part.Current_Source_Path_File /= Project.Include_Path_File then Shared.Private_Part.Current_Source_Path_File := Project.Include_Path_File; Set_Path_File_Var (Project_Include_Path_File, Get_Name_String (Shared.Private_Part.Current_Source_Path_File)); end if; if Objects_Path then if Including_Libraries then if Shared.Private_Part.Current_Object_Path_File /= Project.Objects_Path_File_With_Libs then Shared.Private_Part.Current_Object_Path_File := Project.Objects_Path_File_With_Libs; Set_Path_File_Var (Project_Objects_Path_File, Get_Name_String (Shared.Private_Part.Current_Object_Path_File)); end if; else if Shared.Private_Part.Current_Object_Path_File /= Project.Objects_Path_File_Without_Libs then Shared.Private_Part.Current_Object_Path_File := Project.Objects_Path_File_Without_Libs; Set_Path_File_Var (Project_Objects_Path_File, Get_Name_String (Shared.Private_Part.Current_Object_Path_File)); end if; end if; end if; Free (Buffer); end Set_Ada_Paths; --------------------- -- Add_Directories -- --------------------- procedure Add_Directories (Self : in out Project_Search_Path; Path : String; Prepend : Boolean := False) is Tmp : String_Access; begin if Self.Path = null then Self.Path := new String'(Uninitialized_Prefix & Path); else Tmp := Self.Path; if Prepend then Self.Path := new String'(Path & Path_Separator & Tmp.all); else Self.Path := new String'(Tmp.all & Path_Separator & Path); end if; Free (Tmp); end if; if Current_Verbosity = High then Debug_Output (""Adding directories to Project_Path: """""" & Path & '""'); end if; end Add_Directories; -------------------- -- Is_Initialized -- -------------------- function Is_Initialized (Self : Project_Search_Path) return Boolean is begin return Self.Path /= null and then (Self.Path'Length = 0 or else Self.Path (Self.Path'First) /= '#'); end Is_Initialized; ---------------------- -- Initialize_Empty -- ---------------------- procedure Initialize_Empty (Self : in out Project_Search_Path) is begin Free (Self.Path); Self.Path := new String'(""""); end Initialize_Empty; ------------------------------------- -- Initialize_Default_Project_Path -- ------------------------------------- procedure Initialize_Default_Project_Path (Self : in out Project_Search_Path; Target_Name : String; Runtime_Name : String := """") is Add_Default_Dir : Boolean := Target_Name /= ""-""; First : Positive; Last : Positive; Ada_Project_Path : constant String := ""ADA_PROJECT_PATH""; Gpr_Project_Path : constant String := ""GPR_PROJECT_PATH""; Gpr_Project_Path_File : constant String := ""GPR_PROJECT_PATH_FILE""; -- Names of alternate env. variable that contain path name(s) of -- directories where project files may reside. They are taken into -- account in this order: GPR_PROJECT_PATH_FILE, GPR_PROJECT_PATH, -- ADA_PROJECT_PATH. Gpr_Prj_Path_File : String_Access; Gpr_Prj_Path : String_Access; Ada_Prj_Path : String_Access; -- The path name(s) of directories where project files may reside. -- May be empty. Prefix : String_Ptr; Runtime : String_Ptr; procedure Add_Target; -- Add :/ to the project path ---------------- -- Add_Target -- ---------------- procedure Add_Target is begin Add_Str_To_Name_Buffer (Path_Separator & Prefix.all & Target_Name); -- Note: Target_Name has a trailing / when it comes from Sdefault if Name_Buffer (Name_Len) /= '/' then Add_Char_To_Name_Buffer (Directory_Separator); end if; end Add_Target; -- Start of processing for Initialize_Default_Project_Path begin if Is_Initialized (Self) then return; end if; -- The current directory is always first in the search path. Since the -- Project_Path currently starts with '#:' as a sign that it isn't -- initialized, we simply replace '#' with '.' if Self.Path = null then Self.Path := new String'('.' & Path_Separator); else Self.Path (Self.Path'First) := '.'; end if; -- Then the reset of the project path (if any) currently contains the -- directories added through Add_Search_Project_Directory -- If environment variables are defined and not empty, add their content Gpr_Prj_Path_File := Getenv (Gpr_Project_Path_File); Gpr_Prj_Path := Getenv (Gpr_Project_Path); Ada_Prj_Path := Getenv (Ada_Project_Path); if Gpr_Prj_Path_File.all /= """" then declare File : Ada.Text_IO.File_Type; Line : String (1 .. 10_000); Last : Natural; Tmp : String_Access; begin Open (File, In_File, Gpr_Prj_Path_File.all); while not End_Of_File (File) loop Get_Line (File, Line, Last); if Last /= 0 and then (Last = 1 or else Line (1 .. 2) /= ""--"") then Tmp := Self.Path; Self.Path := new String' (Tmp.all & Path_Separator & Line (1 .. Last)); Free (Tmp); end if; if Current_Verbosity = High then Debug_Output (""Adding directory to Project_Path: """""" & Line (1 .. Last) & '""'); end if; end loop; Close (File); exception when others => Write_Str (""warning: could not read project path file """"""); Write_Str (Gpr_Prj_Path_File.all); Write_Line (""""""""); end; end if; if Gpr_Prj_Path.all /= """" then Add_Directories (Self, Gpr_Prj_Path.all); end if; Free (Gpr_Prj_Path); if Ada_Prj_Path.all /= """" then Add_Directories (Self, Ada_Prj_Path.all); end if; Free (Ada_Prj_Path); -- Copy to Name_Buffer, since we will need to manipulate the path Name_Len := Self.Path'Length; Name_Buffer (1 .. Name_Len) := Self.Path.all; -- Scan the directory path to see if ""-"" is one of the directories. -- Remove each occurrence of ""-"" and set Add_Default_Dir to False. -- Also resolve relative paths and symbolic links. First := 3; loop while First <= Name_Len and then (Name_Buffer (First) = Path_Separator) loop First := First + 1; end loop; exit when First > Name_Len; Last := First; while Last < Name_Len and then Name_Buffer (Last + 1) /= Path_Separator loop Last := Last + 1; end loop; -- If the directory is ""-"", set Add_Default_Dir to False and -- remove from path. if Name_Buffer (First .. Last) = No_Project_Default_Dir then Add_Default_Dir := False; for J in Last + 1 .. Name_Len loop Name_Buffer (J - No_Project_Default_Dir'Length - 1) := Name_Buffer (J); end loop; Name_Len := Name_Len - No_Project_Default_Dir'Length - 1; -- After removing the '-', go back one character to get the next -- directory correctly. Last := Last - 1; else declare New_Dir : constant String := Normalize_Pathname (Name_Buffer (First .. Last), Resolve_Links => Opt.Follow_Links_For_Dirs); New_Len : Positive; New_Last : Positive; begin -- If the absolute path was resolved and is different from -- the original, replace original with the resolved path. if New_Dir /= Name_Buffer (First .. Last) and then New_Dir'Length /= 0 then New_Len := Name_Len + New_Dir'Length - (Last - First + 1); New_Last := First + New_Dir'Length - 1; Name_Buffer (New_Last + 1 .. New_Len) := Name_Buffer (Last + 1 .. Name_Len); Name_Buffer (First .. New_Last) := New_Dir; Name_Len := New_Len; Last := New_Last; end if; end; end if; First := Last + 1; end loop; Free (Self.Path); -- Set the initial value of Current_Project_Path if Add_Default_Dir then if Sdefault.Search_Dir_Prefix = null then -- gprbuild case Prefix := new String'(Executable_Prefix_Path); else Prefix := new String'(Sdefault.Search_Dir_Prefix.all & "".."" & Dir_Separator & "".."" & Dir_Separator & "".."" & Dir_Separator & "".."" & Dir_Separator); end if; if Prefix.all /= """" then if Target_Name /= """" then if Runtime_Name /= """" then if Base_Name (Runtime_Name) = Runtime_Name then -- $prefix/$target/$runtime/lib/gnat Add_Target; Add_Str_To_Name_Buffer (Runtime_Name & Directory_Separator & ""lib"" & Directory_Separator & ""gnat""); -- $prefix/$target/$runtime/share/gpr Add_Target; Add_Str_To_Name_Buffer (Runtime_Name & Directory_Separator & ""share"" & Directory_Separator & ""gpr""); else Runtime := new String'(Normalize_Pathname (Runtime_Name)); -- $runtime_dir/lib/gnat Add_Str_To_Name_Buffer (Path_Separator & Runtime.all & Directory_Separator & ""lib"" & Directory_Separator & ""gnat""); -- $runtime_dir/share/gpr Add_Str_To_Name_Buffer (Path_Separator & Runtime.all & Directory_Separator & ""share"" & Directory_Separator & ""gpr""); end if; end if; -- $prefix/$target/lib/gnat Add_Target; Add_Str_To_Name_Buffer (""lib"" & Directory_Separator & ""gnat""); -- $prefix/$target/share/gpr Add_Target; Add_Str_To_Name_Buffer (""share"" & Directory_Separator & ""gpr""); end if; -- $prefix/share/gpr Add_Str_To_Name_Buffer (Path_Separator & Prefix.all & ""share"" & Directory_Separator & ""gpr""); -- $prefix/lib/gnat Add_Str_To_Name_Buffer (Path_Separator & Prefix.all & ""lib"" & Directory_Separator & ""gnat""); end if; Free (Prefix); end if; Self.Path := new String'(Name_Buffer (1 .. Name_Len)); end Initialize_Default_Project_Path; -------------- -- Get_Path -- -------------- procedure Get_Path (Self : Project_Search_Path; Path : out String_Access) is begin pragma Assert (Is_Initialized (Self)); Path := Self.Path; end Get_Path; -------------- -- Set_Path -- -------------- procedure Set_Path (Self : in out Project_Search_Path; Path : String) is begin Free (Self.Path); Self.Path := new String'(Path); Projects_Paths.Reset (Self.Cache); end Set_Path; ----------------------- -- Find_Name_In_Path -- ----------------------- function Find_Name_In_Path (Self : Project_Search_Path; Path : String) return String_Access is First : Natural; Last : Natural; begin if Current_Verbosity = High then Debug_Output (""Trying "" & Path); end if; if Is_Absolute_Path (Path) then if Check_Filename (Path) then return new String'(Path); else return null; end if; else -- Because we don't want to resolve symbolic links, we cannot use -- Locate_Regular_File. So, we try each possible path successively. First := Self.Path'First; while First <= Self.Path'Last loop while First <= Self.Path'Last and then Self.Path (First) = Path_Separator loop First := First + 1; end loop; exit when First > Self.Path'Last; Last := First; while Last < Self.Path'Last and then Self.Path (Last + 1) /= Path_Separator loop Last := Last + 1; end loop; Name_Len := 0; if not Is_Absolute_Path (Self.Path (First .. Last)) then Add_Str_To_Name_Buffer (Get_Current_Dir); -- ??? System call Add_Char_To_Name_Buffer (Directory_Separator); end if; Add_Str_To_Name_Buffer (Self.Path (First .. Last)); Add_Char_To_Name_Buffer (Directory_Separator); Add_Str_To_Name_Buffer (Path); if Current_Verbosity = High then Debug_Output (""Testing file "" & Name_Buffer (1 .. Name_Len)); end if; if Check_Filename (Name_Buffer (1 .. Name_Len)) then return new String'(Name_Buffer (1 .. Name_Len)); end if; First := Last + 1; end loop; end if; return null; end Find_Name_In_Path; ------------------ -- Find_Project -- ------------------ procedure Find_Project (Self : in out Project_Search_Path; Project_File_Name : String; Directory : String; Path : out Namet.Path_Name_Type) is Result : String_Access; Has_Dot : Boolean := False; Key : Name_Id; File : constant String := Project_File_Name; -- Have to do a copy, in case the parameter is Name_Buffer, which we -- modify below. Cached_Path : Namet.Path_Name_Type; -- This should be commented rather than making us guess from the name??? function Try_Path_Name is new Find_Name_In_Path (Check_Filename => Is_Regular_File); -- Find a file in the project search path -- Start of processing for Find_Project begin pragma Assert (Is_Initialized (Self)); if Current_Verbosity = High then Debug_Increase_Indent (""Searching for project """""" & File & """""" in """""" & Directory & '""'); end if; -- Check the project cache Name_Len := File'Length; Name_Buffer (1 .. Name_Len) := File; Key := Name_Find; Cached_Path := Projects_Paths.Get (Self.Cache, Key); -- Check if File contains an extension (a dot before a -- directory separator). If it is the case we do not try project file -- with an added extension as it is not possible to have multiple dots -- on a project file name. Check_Dot : for K in reverse File'Range loop if File (K) = '.' then Has_Dot := True; exit Check_Dot; end if; exit Check_Dot when Is_Directory_Separator (File (K)); end loop Check_Dot; if not Is_Absolute_Path (File) then -- If we have found project in the cache, check if in the directory if Cached_Path /= No_Path then declare Cached : constant String := Get_Name_String (Cached_Path); begin if (not Has_Dot and then Cached = GNAT.OS_Lib.Normalize_Pathname (File & Project_File_Extension, Directory => Directory, Resolve_Links => Opt.Follow_Links_For_Files, Case_Sensitive => True)) or else Cached = GNAT.OS_Lib.Normalize_Pathname (File, Directory => Directory, Resolve_Links => Opt.Follow_Links_For_Files, Case_Sensitive => True) then Path := Cached_Path; Debug_Decrease_Indent; return; end if; end; end if; -- First we try /. if not Has_Dot then Result := Try_Path_Name (Self, Directory & Directory_Separator & File & Project_File_Extension); end if; -- Then we try / if Result = null then Result := Try_Path_Name (Self, Directory & Directory_Separator & File); end if; end if; -- If we found the path in the cache, this is the one if Result = null and then Cached_Path /= No_Path then Path := Cached_Path; Debug_Decrease_Indent; return; end if; -- Then we try . if Result = null and then not Has_Dot then Result := Try_Path_Name (Self, File & Project_File_Extension); end if; -- Then we try if Result = null then Result := Try_Path_Name (Self, File); end if; -- If we cannot find the project file, we return an empty string if Result = null then Path := Namet.No_Path; return; else declare Final_Result : constant String := GNAT.OS_Lib.Normalize_Pathname (Result.all, Directory => Directory, Resolve_Links => Opt.Follow_Links_For_Files, Case_Sensitive => True); begin Free (Result); Name_Len := Final_Result'Length; Name_Buffer (1 .. Name_Len) := Final_Result; Path := Name_Find; Projects_Paths.Set (Self.Cache, Key, Path); end; end if; Debug_Decrease_Indent; end Find_Project; ---------- -- Free -- ---------- procedure Free (Self : in out Project_Search_Path) is begin Free (Self.Path); Projects_Paths.Reset (Self.Cache); end Free; ---------- -- Copy -- ---------- procedure Copy (From : Project_Search_Path; To : out Project_Search_Path) is begin Free (To); if From.Path /= null then To.Path := new String'(From.Path.all); end if; -- No need to copy the Cache, it will be recomputed as needed end Copy; end Prj.Env; ",16185,True,2960.985958787244,median "/* Feathers Copyright 2012-2021 Bowler Hat LLC. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls.text { import feathers.core.FocusManager; import feathers.core.IIMETextEditor; import feathers.core.INativeFocusOwner; import feathers.events.FeathersEventType; import feathers.skins.IStyleProvider; import feathers.utils.text.TextEditorIMEClient; import feathers.utils.text.TextInputNavigation; import feathers.utils.text.TextInputRestrict; import flash.desktop.Clipboard; import flash.desktop.ClipboardFormats; import flash.display.DisplayObjectContainer; import flash.display.Sprite; import flash.display.Stage; import flash.events.Event; import flash.events.TextEvent; import flash.geom.Point; import flash.geom.Rectangle; import flash.text.TextFormatAlign; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.ime.CompositionAttributeRange; import flash.ui.Keyboard; import starling.core.Starling; import starling.display.DisplayObject; import starling.display.Quad; import starling.events.Event; import starling.events.KeyboardEvent; import starling.events.Touch; import starling.events.TouchEvent; import starling.events.TouchPhase; import starling.rendering.Painter; import starling.utils.Pool; /** * Dispatched when the text property changes. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @see #text * * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] /** * Dispatched when the user presses the Enter key while the editor has * focus. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @eventType feathers.events.FeathersEventType.ENTER */ [Event(name=""enter"",type=""starling.events.Event"")] /** * Dispatched when the text editor receives focus. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @eventType feathers.events.FeathersEventType.FOCUS_IN */ [Event(name=""focusIn"",type=""starling.events.Event"")] /** * Dispatched when the text editor loses focus. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @eventType feathers.events.FeathersEventType.FOCUS_OUT */ [Event(name=""focusOut"",type=""starling.events.Event"")] /** * Text that may be edited at runtime by the user with the * TextInput component, rendered with a native * flash.text.engine.TextBlock from * Flash Text Engine * (sometimes abbreviated as FTE). Draws the text to BitmapData * to convert to Starling textures. Textures are managed internally by this * component, and they will be automatically disposed when the component is * disposed. * *

Warning: This text editor is intended for use in * desktop applications only, and it does not provide support for software * keyboards on mobile devices.

* *

The following example shows how to use * TextBlockTextEditor with a TextInput:

* * * var input:TextInput = new TextInput(); * input.textEditorFactory = function():ITextEditor * { * return new TextBlockTextEditor(); * }; * this.addChild( input ); * * @see feathers.controls.TextInput * @see ../../../../help/text-editors.html Introduction to Feathers text editors * @see http://help.adobe.com/en_US/as3/dev/WS9dd7ed846a005b294b857bfa122bd808ea6-8000.html Using the Flash Text Engine in ActionScript 3.0 Developer's Guide * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/engine/TextBlock.html flash.text.engine.TextBlock * * @productversion Feathers 2.0.0 */ public class TextBlockTextEditor extends TextBlockTextRenderer implements IIMETextEditor, INativeFocusOwner { /** * The text will be positioned to the left edge. * * @see feathers.controls.text.TextBlockTextRenderer#textAlign */ public static const TEXT_ALIGN_LEFT:String = ""left""; /** * The text will be centered horizontally. * * @see feathers.controls.text.TextBlockTextRenderer#textAlign */ public static const TEXT_ALIGN_CENTER:String = ""center""; /** * The text will be positioned to the right edge. * * @see feathers.controls.text.TextBlockTextRenderer#textAlign */ public static const TEXT_ALIGN_RIGHT:String = ""right""; /** * The default IStyleProvider for all TextBlockTextEditor * components. * * @default null * @see feathers.core.FeathersControl#styleProvider */ public static var globalStyleProvider:IStyleProvider; /** * Constructor. */ public function TextBlockTextEditor() { super(); this._text = """"; this._textElement = new TextElement(this._text); this._content = this._textElement; this.isQuickHitAreaEnabled = true; this.truncateToFit = false; this.addEventListener(TouchEvent.TOUCH, textEditor_touchHandler); } /** * @private */ override protected function get defaultStyleProvider():IStyleProvider { return globalStyleProvider; } /** * @private */ protected var _ignoreNextTextInputEvent:Boolean = false; /** * @private */ protected var _imeText:String; /** * @private */ protected var _imeCursorIndex:int = -1; /** * @private */ protected var _selectionSkin:DisplayObject; /** * The skin that indicates the currently selected range of text. */ public function get selectionSkin():DisplayObject { return this._selectionSkin; } /** * @private */ public function set selectionSkin(value:DisplayObject):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._selectionSkin == value) { return; } if(this._selectionSkin && this._selectionSkin.parent == this) { this._selectionSkin.removeFromParent(); } this._selectionSkin = value; if(this._selectionSkin) { this._selectionSkin.visible = false; this.addChildAt(this._selectionSkin, 0); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _cursorDelay:Number = 0.53; /** * @private */ protected var _cursorDelayID:uint = uint.MAX_VALUE; /** * @private */ protected var _cursorSkin:DisplayObject; /** * The skin that indicates the current position where text may be * entered. */ public function get cursorSkin():DisplayObject { return this._cursorSkin; } /** * @private */ public function set cursorSkin(value:DisplayObject):void { if(this.processStyleRestriction(arguments.callee)) { return; } if(this._cursorSkin === value) { return; } if(this._cursorSkin !== null && this._cursorSkin.parent === this) { this._cursorSkin.removeFromParent(); } this._cursorSkin = value; if(this._cursorSkin !== null) { this._cursorSkin.visible = false; this.addChild(this._cursorSkin); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _unmaskedText:String; /** * @private */ protected var _displayAsPassword:Boolean = false; /** *

This property is managed by the TextInput.

* * @copy feathers.controls.TextInput#displayAsPassword * * @see feathers.controls.TextInput#displayAsPassword * * @see #passwordCharCode */ public function get displayAsPassword():Boolean { return this._displayAsPassword; } /** * @private */ public function set displayAsPassword(value:Boolean):void { if(this._displayAsPassword == value) { return; } this._displayAsPassword = value; if(this._displayAsPassword) { this._unmaskedText = this._text; this.refreshMaskedText(); } else { this._text = this._unmaskedText; this._unmaskedText = null; } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _passwordCharCode:int = 42; //asterisk /** * The character code of the character used to display a password. * *

In the following example, the substitute character for passwords * is set to a bullet:

* * * textEditor.displayAsPassword = true; * textEditor.passwordCharCode = ""•"".charCodeAt(0); * * @default 42 (asterisk) * * @see #displayAsPassword */ public function get passwordCharCode():int { return this._passwordCharCode; } /** * @private */ public function set passwordCharCode(value:int):void { if(this._passwordCharCode == value) { return; } this._passwordCharCode = value; if(this._displayAsPassword) { this.refreshMaskedText(); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _isEditable:Boolean = true; /** *

This property is managed by the TextInput.

* * @copy feathers.controls.TextInput#isEditable * * @see feathers.controls.TextInput#isEditable */ public function get isEditable():Boolean { return this._isEditable; } /** * @private */ public function set isEditable(value:Boolean):void { if(this._isEditable == value) { return; } this._isEditable = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _isSelectable:Boolean = true; /** *

This property is managed by the TextInput.

* * @copy feathers.controls.TextInput#isSelectable * * @see feathers.controls.TextInput#isSelectable */ public function get isSelectable():Boolean { return this._isSelectable; } /** * @private */ public function set isSelectable(value:Boolean):void { if(this._isSelectable == value) { return; } this._isSelectable = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @inheritDoc * * @default false */ public function get setTouchFocusOnEndedPhase():Boolean { return false; } /** * @private */ override public function get text():String { if(this._displayAsPassword) { return this._unmaskedText; } return this._text; } /** * @private */ override public function set text(value:String):void { if(value === null) { //don't allow null or undefined value = """"; } var currentValue:String = this._text; if(this._displayAsPassword) { currentValue = this._unmaskedText; } if(currentValue == value) { return; } if(this._displayAsPassword) { this._unmaskedText = value; this.refreshMaskedText(); } else { super.text = value; } var textLength:int = this._text.length; //we need to account for the possibility that the text is in the //middle of being selected when it changes if(this._selectionAnchorIndex > textLength) { this._selectionAnchorIndex = textLength; } //then, we need to make sure the selected range is still valid if(this._selectionBeginIndex > textLength) { this.selectRange(textLength, textLength); } else if(this._selectionEndIndex > textLength) { this.selectRange(this._selectionBeginIndex, textLength); } this.dispatchEventWith(starling.events.Event.CHANGE); } /** * @private */ protected var _maxChars:int = 0; /** *

This property is managed by the TextInput.

* * @copy feathers.controls.TextInput#maxChars * * @see feathers.controls.TextInput#maxChars */ public function get maxChars():int { return this._maxChars; } /** * @private */ public function set maxChars(value:int):void { if(this._maxChars == value) { return; } this._maxChars = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _restrict:TextInputRestrict; /** *

This property is managed by the TextInput.

* * @copy feathers.controls.TextInput#restrict * * @see feathers.controls.TextInput#restrict */ public function get restrict():String { if(!this._restrict) { return null; } return this._restrict.restrict; } /** * @private */ public function set restrict(value:String):void { if(this._restrict && this._restrict.restrict === value) { return; } if(!this._restrict && value === null) { return; } if(value === null) { this._restrict = null; } else { if(this._restrict) { this._restrict.restrict = value; } else { this._restrict = new TextInputRestrict(value); } } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _selectionBeginIndex:int = 0; /** * @inheritDoc * * @see #selectionEndIndex */ public function get selectionBeginIndex():int { return this._selectionBeginIndex; } /** * @private */ protected var _selectionEndIndex:int = 0; /** * @inheritDoc * * @see #selectionBeginIndex */ public function get selectionEndIndex():int { return this._selectionEndIndex; } /** * @private */ protected var _selectionAnchorIndex:int = 0; /** * @inheritDoc * * @see #selectionActiveIndex */ public function get selectionAnchorIndex():int { return this._selectionAnchorIndex; } /** * @inheritDoc * * @see #selectionAnchorIndex */ public function get selectionActiveIndex():int { if(this._selectionAnchorIndex == this._selectionBeginIndex) { return this._selectionEndIndex; } return this._selectionBeginIndex; } /** * @private */ protected var touchPointID:int = -1; /** * @private */ protected var _nativeFocus:Sprite; /** * @copy feathers.core.INativeFocusOwner#nativeFocus */ public function get nativeFocus():Object { return this._nativeFocus; } /** * @private */ protected var _isWaitingToSetFocus:Boolean = false; /** * @inheritDoc */ public function setFocus(position:Point = null):void { if(this._hasFocus && !position) { //we already have focus, and there isn't a touch position, we //can ignore this because nothing would change return; } if(this._nativeFocus !== null) { if(this._nativeFocus.parent === null) { var starling:Starling = this.stage !== null ? this.stage.starling : Starling.current; starling.nativeStage.addChild(this._nativeFocus); } var newIndex:int = -1; if(position !== null) { newIndex = this.getSelectionIndexAtPoint(position.x, position.y); } if(newIndex >= 0) { this.selectRange(newIndex, newIndex); } this.focusIn(); } else { this._isWaitingToSetFocus = true; } } /** * @inheritDoc */ public function clearFocus():void { if(!this._hasFocus) { return; } this._hasFocus = false; this._cursorSkin.visible = false; this._selectionSkin.visible = false; this.refreshCursorBlink(); this.stage.removeEventListener(TouchEvent.TOUCH, stage_touchHandler); this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); this.removeEventListener(starling.events.Event.ENTER_FRAME, hasFocus_enterFrameHandler); var starling:Starling = this.stage !== null ? this.stage.starling : Starling.current; var nativeStage:Stage = starling.nativeStage; if(nativeStage.focus === this._nativeFocus) { //only clear the native focus when our native target has focus //because otherwise another component may lose focus. //for consistency with StageTextTextEditor and //TextFieldTextEditor, we set the native stage's focus to null //here instead of setting it to the native stage due to issues //with those text editors on Android. nativeStage.focus = null; } this.dispatchEventWith(FeathersEventType.FOCUS_OUT); } /** * @inheritDoc */ public function selectRange(beginIndex:int, endIndex:int):void { if(!this._isEditable && !this._isSelectable) { return; } if(endIndex < beginIndex) { var temp:int = endIndex; endIndex = beginIndex; beginIndex = temp; } this._selectionBeginIndex = beginIndex; this._selectionEndIndex = endIndex; if(beginIndex == endIndex) { this._selectionAnchorIndex = beginIndex; if(beginIndex < 0) { this._cursorSkin.visible = false; } else { //cursor skin is not shown if isSelectable === true and //isEditable is false this._cursorSkin.visible = this._hasFocus && this._isEditable; } this._selectionSkin.visible = false; } else { this._cursorSkin.visible = false; this._selectionSkin.visible = true; } this.refreshCursorBlink(); this.invalidate(INVALIDATION_FLAG_SELECTED); } /** * @private */ override public function dispose():void { if(this._nativeFocus && this._nativeFocus.parent) { this._nativeFocus.parent.removeChild(this._nativeFocus); } this._nativeFocus = null; super.dispose(); } /** * @private */ override public function render(painter:Painter):void { var oldSnapshotX:Number = this._textSnapshotOffsetX; var oldCursorX:Number = this._cursorSkin.x; this._cursorSkin.x -= this._textSnapshotScrollX; super.render(painter); this._textSnapshotOffsetX = oldSnapshotX; this._cursorSkin.x = oldCursorX; } /** * @private */ override protected function initialize():void { if(!this._nativeFocus) { this._nativeFocus = new TextEditorIMEClient(this, imeClientStartCallback, imeClientUpdateCallback, imeClientConfirmCallback); //let's ensure that this can only get focus through code this._nativeFocus.tabEnabled = false; this._nativeFocus.tabChildren = false; this._nativeFocus.mouseEnabled = false; this._nativeFocus.mouseChildren = false; //adds support for mobile this._nativeFocus.needsSoftKeyboard = true; } this._nativeFocus.addEventListener(flash.events.Event.CUT, nativeFocus_cutHandler, false, 0, true); this._nativeFocus.addEventListener(flash.events.Event.COPY, nativeFocus_copyHandler, false, 0, true); this._nativeFocus.addEventListener(flash.events.Event.PASTE, nativeFocus_pasteHandler, false, 0, true); this._nativeFocus.addEventListener(flash.events.Event.SELECT_ALL, nativeFocus_selectAllHandler, false, 0, true); this._nativeFocus.addEventListener(TextEvent.TEXT_INPUT, nativeFocus_textInputHandler, false, 0, true); if(this._cursorSkin === null) { this.ignoreNextStyleRestriction(); this.cursorSkin = new Quad(1, 1, 0x000000); } if(this._selectionSkin === null) { this.ignoreNextStyleRestriction(); this.selectionSkin = new Quad(1, 1, 0x000000); } super.initialize(); } /** * @private */ override protected function draw():void { var dataInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DATA); var selectionInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SELECTED); super.draw(); if(dataInvalid || selectionInvalid) { this.positionCursorAtCharIndex(this.getCursorIndexFromSelectionRange()); this.positionSelectionBackground(); } } /** * @private */ override protected function refreshTextElementText():void { if(this._textElement === null) { return } var displayText:String = this._text; if(this._imeText !== null) { displayText = this._imeText; } if(displayText) { this._textElement.text = displayText; if(displayText !== null && displayText.charAt(displayText.length - 1) == "" "") { //add an invisible control character because FTE apparently //doesn't think that it's important to include trailing //spaces in its width measurement. this._textElement.text += String.fromCharCode(3); } } else { //similar to above. this hack ensures that the baseline is //measured properly when the text is an empty string. this._textElement.text = String.fromCharCode(3); } } /** * @private */ override protected function refreshTextLines(textLines:Vector., textLineParent:DisplayObjectContainer, width:Number, height:Number, result:MeasureTextResult = null):MeasureTextResult { result = super.refreshTextLines(textLines, textLineParent, width, height, result); if(textLines !== this._measurementTextLines && textLineParent.width > width) { this.alignTextLines(textLines, width, TextFormatAlign.LEFT); } return result; } /** * @private */ protected function refreshMaskedText():void { var newText:String = """"; var textLength:int = this._unmaskedText.length; var maskChar:String = String.fromCharCode(this._passwordCharCode); for(var i:int = 0; i < textLength; i++) { newText += maskChar; } super.text = newText; } /** * @private */ protected function focusIn():void { var showSelection:Boolean = (this._isEditable || this._isSelectable) && this._selectionBeginIndex >= 0 && this._selectionBeginIndex != this._selectionEndIndex; var showCursor:Boolean = this._isEditable && this._selectionBeginIndex >= 0 && this._selectionBeginIndex == this._selectionEndIndex; this._cursorSkin.visible = showCursor; this._selectionSkin.visible = showSelection; this.refreshCursorBlink(); if(!FocusManager.isEnabledForStage(this.stage)) { var starling:Starling = this.stage !== null ? this.stage.starling : Starling.current; //if there isn't a focus manager, we need to set focus manually starling.nativeStage.focus = this._nativeFocus; } if(this._isEditable) { this._nativeFocus.requestSoftKeyboard(); } if(this._hasFocus) { return; } //we're reusing this variable. since this isn't a display object //that the focus manager can see, it's not being used anyway. this._hasFocus = true; this.stage.addEventListener(TouchEvent.TOUCH, stage_touchHandler); this.stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); this.addEventListener(starling.events.Event.ENTER_FRAME, hasFocus_enterFrameHandler); this.dispatchEventWith(FeathersEventType.FOCUS_IN); } /** * @private */ protected function refreshCursorBlink():void { var starling:Starling = this.stage !== null ? this.stage.starling : Starling.current; if(this._cursorDelayID == uint.MAX_VALUE && this._cursorSkin.visible) { this._cursorSkin.alpha = 1; this._cursorDelayID = starling.juggler.delayCall(toggleCursorSkin, this._cursorDelay); } else if(this._cursorDelayID != uint.MAX_VALUE && !this._cursorSkin.visible) { starling.juggler.removeByID(this._cursorDelayID); this._cursorDelayID = uint.MAX_VALUE; } } /** * @private */ protected function toggleCursorSkin():void { if(this._cursorSkin.alpha > 0) { this._cursorSkin.alpha = 0; } else { this._cursorSkin.alpha = 1; } var starling:Starling = this.stage !== null ? this.stage.starling : Starling.current; this._cursorDelayID = starling.juggler.delayCall(toggleCursorSkin, this._cursorDelay); } /** * @private */ protected function getSelectionIndexAtPoint(pointX:Number, pointY:Number):int { if(!this._text || this._textLines.length == 0) { return 0; } var line:TextLine = this._textLines[0]; if((pointX - line.x) <= 0) { if(this._bidiLevel == 1) { return this._text.length; } return 0; } else if((pointX - line.x) >= line.width) { if(this._bidiLevel == 1) { return 0; } return this._text.length; } var atomIndex:int = line.getAtomIndexAtPoint(pointX, pointY); if(atomIndex < 0) { //try again with the middle of the line atomIndex = line.getAtomIndexAtPoint(pointX, line.ascent / 2); } if(atomIndex < 0) { //worse case: we couldn't figure it out at all return this._text.length; } //we're constraining the atom index to the text length because we //may have added an invisible control character at the end due to //the fact that FTE won't include trailing spaces in measurement if(atomIndex > this._text.length) { atomIndex = this._text.length; } var atomBounds:Rectangle = line.getAtomBounds(atomIndex); if((pointX - line.x - atomBounds.x) > atomBounds.width / 2) { return atomIndex + 1; } return atomIndex; } /** * @private */ protected function getXPositionOfCharIndex(index:int):Number { var displayText:String = this._text; if(this._imeText !== null) { displayText = this._imeText; } if(!displayText || this._textLines.length == 0) { if(this._currentHorizontalAlign == TextFormatAlign.CENTER) { return Math.round(this.actualWidth / 2); } else if(this._currentHorizontalAlign == TextFormatAlign.RIGHT) { return this.actualWidth; } return 0; } var line:TextLine = this._textLines[0]; if(index === displayText.length) { if(this._bidiLevel == 1) { return line.x; } return line.x + line.width; } var atomIndex:int = line.getAtomIndexAtCharIndex(index); var atomBounds:Rectangle = line.getAtomBounds(atomIndex); var result:Number = line.x + atomBounds.x; if(this._bidiLevel == 1) { result += atomBounds.width; } return result; } /** * @private */ protected function positionCursorAtCharIndex(index:int):void { if(index < 0) { index = 0; } var cursorX:Number = this.getXPositionOfCharIndex(index); cursorX = int(cursorX - (this._cursorSkin.width / 2)); this._cursorSkin.x = cursorX; this._cursorSkin.y = this._verticalAlignOffsetY; if(this._textLines.length > 0) { var line:TextLine = this._textLines[0]; this._cursorSkin.height = this.calculateLineAscent(line) + line.totalDescent; } else { this._cursorSkin.height = this.currentElementFormat.fontSize; } //then we update the scroll to always show the cursor var minScrollX:Number = cursorX + this._cursorSkin.width - this.actualWidth; var displayText:String = this._text; if(this._imeText !== null) { displayText = this._imeText; } var maxScrollX:Number = this.getXPositionOfCharIndex(displayText.length) - this.actualWidth; if(maxScrollX < 0) { maxScrollX = 0; } var oldScrollX:Number = this._textSnapshotScrollX; if(this._textSnapshotScrollX < minScrollX) { this._textSnapshotScrollX = minScrollX; } else if(this._textSnapshotScrollX > cursorX) { this._textSnapshotScrollX = cursorX; } if(this._textSnapshotScrollX > maxScrollX) { this._textSnapshotScrollX = maxScrollX; } if(this._textSnapshotScrollX != oldScrollX) { this.invalidate(INVALIDATION_FLAG_DATA); } } /** * @private */ protected function getCursorIndexFromSelectionRange():int { if(this._imeCursorIndex >= 0) { return this._imeCursorIndex; } var cursorIndex:int = this._selectionEndIndex; if(this.touchPointID >= 0 && this._selectionAnchorIndex >= 0 && this._selectionAnchorIndex == this._selectionEndIndex) { cursorIndex = this._selectionBeginIndex; } return cursorIndex; } /** * @private */ protected function positionSelectionBackground():void { var displayText:String = this._text; if(this._imeText !== null) { displayText = this._imeText; } var beginIndex:int = this._selectionBeginIndex; if(beginIndex > displayText.length) { beginIndex = displayText.length; } var startX:Number = this.getXPositionOfCharIndex(beginIndex) - this._textSnapshotScrollX; if(startX < 0) { startX = 0; } var endIndex:int = this._selectionEndIndex; if(endIndex > displayText.length) { endIndex = displayText.length; } var endX:Number = this.getXPositionOfCharIndex(endIndex) - this._textSnapshotScrollX; if(endX < 0) { endX = 0; } else if(endX > this.actualWidth) { endX = this.actualWidth; } this._selectionSkin.x = startX; this._selectionSkin.width = endX - startX; this._selectionSkin.y = this._verticalAlignOffsetY; if(this._textLines.length > 0) { var line:TextLine = this._textLines[0]; this._selectionSkin.height = this.calculateLineAscent(line) + line.totalDescent; } else { this._selectionSkin.height = this.currentElementFormat.fontSize; } } /** * @private */ protected function getSelectedText():String { if(this._selectionBeginIndex == this._selectionEndIndex) { return null; } return this._text.substr(this._selectionBeginIndex, this._selectionEndIndex - this._selectionBeginIndex); } /** * @private */ protected function deleteSelectedText():void { var currentValue:String = this._text; if(this._displayAsPassword) { currentValue = this._unmaskedText; } this.text = currentValue.substr(0, this._selectionBeginIndex) + currentValue.substr(this._selectionEndIndex); this.validate(); this.selectRange(this._selectionBeginIndex, this._selectionBeginIndex); } /** * @private */ protected function replaceSelectedText(text:String):void { var currentValue:String = this._text; if(this._displayAsPassword) { currentValue = this._unmaskedText; } var newText:String = currentValue.substr(0, this._selectionBeginIndex) + text + currentValue.substr(this._selectionEndIndex); if(this._maxChars > 0 && newText.length > this._maxChars) { return; } this.text = newText; this.validate(); var selectionIndex:int = this._selectionBeginIndex + text.length; this.selectRange(selectionIndex, selectionIndex); } /** * @private */ protected function imeClientStartCallback():void { } /** * @private */ protected function imeClientUpdateCallback(text:String, attributes:Vector., compositionStartIndex:int, compositionEndIndex:int):void { var currentValue:String = this._text; if(this._displayAsPassword) { currentValue = this._unmaskedText; } this._imeText = currentValue.substr(0, this._selectionBeginIndex) + text + currentValue.substr(this._selectionEndIndex); this._imeCursorIndex = this._selectionBeginIndex + compositionStartIndex; this._cursorSkin.visible = this._hasFocus; this._selectionSkin.visible = false; this.setInvalidationFlag(INVALIDATION_FLAG_DATA); this.validate(); } /** * @private */ protected function imeClientConfirmCallback(text:String = null, preserveSelection:Boolean = false):void { //the focus will dispatch an extra TextEvent.TEXT_INPUT event, for //some reason. we need to ignore it or extra text will be displayed. this._ignoreNextTextInputEvent = true; } /** * @private */ protected function hasFocus_enterFrameHandler(event:starling.events.Event):void { var target:DisplayObject = this; do { if(!target.visible) { this.clearFocus(); break; } target = target.parent; } while(target) } /** * @private */ protected function textEditor_touchHandler(event:TouchEvent):void { if(!this._isEnabled || (!this._isEditable && !this._isSelectable)) { this.touchPointID = -1; return; } if(this.touchPointID >= 0) { var touch:Touch = event.getTouch(this, null, this.touchPointID); var point:Point = Pool.getPoint(); touch.getLocation(this, point); point.x += this._textSnapshotScrollX; this.selectRange(this._selectionAnchorIndex, this.getSelectionIndexAtPoint(point.x, point.y)); Pool.putPoint(point); if(touch.phase == TouchPhase.ENDED) { this.touchPointID = -1; } } else //if we get here, we don't have a saved touch ID yet { touch = event.getTouch(this, TouchPhase.BEGAN); if(!touch) { return; } if(touch.tapCount == 2) { var start:int = TextInputNavigation.findCurrentWordStartIndex(this._text, this._selectionBeginIndex); var end:int = TextInputNavigation.findCurrentWordEndIndex(this._text, this._selectionEndIndex); this.selectRange(start, end); return; } else if(touch.tapCount > 2) { this.selectRange(0, this._text.length); return; } this.touchPointID = touch.id; point = Pool.getPoint(); touch.getLocation(this, point); point.x += this._textSnapshotScrollX; if(event.shiftKey) { if(this._selectionAnchorIndex < 0) { this._selectionAnchorIndex = this._selectionBeginIndex; } this.selectRange(this._selectionAnchorIndex, this.getSelectionIndexAtPoint(point.x, point.y)); } else { this.setFocus(point); } Pool.putPoint(point); } } /** * @private */ protected function stage_touchHandler(event:TouchEvent):void { if(FocusManager.isEnabledForStage(this.stage)) { //let the focus manager handle clearing focus return; } var touch:Touch = event.getTouch(this.stage, TouchPhase.BEGAN); if(!touch) //we only care about began touches { return; } var point:Point = Pool.getPoint(); touch.getLocation(this.stage, point); var isInBounds:Boolean = this.contains(this.stage.hitTest(point)); Pool.putPoint(point); if(isInBounds) //if the touch is in the text editor, it's all good { return; } //if the touch begins anywhere else, it's a focus out! this.clearFocus(); } /** * @private */ protected function stage_keyDownHandler(event:KeyboardEvent):void { if(!this._isEnabled || (!this._isEditable && !this._isSelectable) || this.touchPointID >= 0 || event.isDefaultPrevented()) { return; } //ignore select all, cut, copy, and paste var charCode:uint = event.charCode; if(event.ctrlKey && (charCode == 97 || charCode == 99 || charCode == 118 || charCode == 120)) //a, c, p, and x { return; } var newIndex:int = -1; if(!FocusManager.isEnabledForStage(this.stage) && event.keyCode == Keyboard.TAB) { this.clearFocus(); return; } else if(event.keyCode == Keyboard.HOME || event.keyCode == Keyboard.UP) { newIndex = 0; if(event.shiftKey) { this.selectRange(newIndex, this._selectionAnchorIndex); return; } } else if(event.keyCode == Keyboard.END || event.keyCode == Keyboard.DOWN) { newIndex = this._text.length; if(event.shiftKey) { this.selectRange(this._selectionAnchorIndex, newIndex); return; } } else if(event.keyCode == Keyboard.LEFT) { if(event.shiftKey) { if(this._selectionAnchorIndex >= 0 && this._selectionAnchorIndex == this._selectionBeginIndex && this._selectionBeginIndex != this._selectionEndIndex) { newIndex = this._selectionEndIndex - 1; this.selectRange(this._selectionBeginIndex, newIndex); } else { newIndex = this._selectionBeginIndex - 1; if(newIndex < 0) { newIndex = 0; } this.selectRange(newIndex, this._selectionEndIndex); } return; } else if(this._selectionBeginIndex != this._selectionEndIndex) { newIndex = this._selectionBeginIndex; } else { if(event.altKey || event.ctrlKey) { newIndex = TextInputNavigation.findPreviousWordStartIndex(this._text, this._selectionBeginIndex); } else { newIndex = this._selectionBeginIndex - 1; } if(newIndex < 0) { newIndex = 0; } } } else if(event.keyCode == Keyboard.RIGHT) { if(event.shiftKey) { if(this._selectionAnchorIndex >= 0 && this._selectionAnchorIndex == this._selectionEndIndex && this._selectionBeginIndex != this._selectionEndIndex) { newIndex = this._selectionBeginIndex + 1; this.selectRange(newIndex, this._selectionEndIndex); } else { newIndex = this._selectionEndIndex + 1; if(newIndex < 0 || newIndex > this._text.length) { newIndex = this._text.length; } this.selectRange(this._selectionBeginIndex, newIndex); } return; } else if(this._selectionBeginIndex != this._selectionEndIndex) { newIndex = this._selectionEndIndex; } else { if(event.altKey || event.ctrlKey) { newIndex = TextInputNavigation.findNextWordStartIndex(this._text, this._selectionEndIndex); } else { newIndex = this._selectionEndIndex + 1; } if(newIndex < 0 || newIndex > this._text.length) { newIndex = this._text.length; } } } if(newIndex < 0) { if(event.keyCode == Keyboard.ENTER) { this.dispatchEventWith(FeathersEventType.ENTER); return; } //everything after this point edits the text, so return if the text //editor isn't editable. if(!this._isEditable) { return; } var currentValue:String = this._text; if(this._displayAsPassword) { currentValue = this._unmaskedText; } if(event.keyCode == Keyboard.DELETE) { if(event.altKey || event.ctrlKey) { var nextWordStartIndex:int = TextInputNavigation.findNextWordStartIndex(this._text, this._selectionEndIndex); this.text = currentValue.substr(0, this._selectionBeginIndex) + currentValue.substr(nextWordStartIndex); } else if(this._selectionBeginIndex != this._selectionEndIndex) { this.deleteSelectedText(); } else if(this._selectionEndIndex < currentValue.length) { this.text = currentValue.substr(0, this._selectionBeginIndex) + currentValue.substr(this._selectionEndIndex + 1); } } else if(event.keyCode == Keyboard.BACKSPACE) { if(event.altKey || event.ctrlKey) { newIndex = TextInputNavigation.findPreviousWordStartIndex(this._text, this._selectionBeginIndex); this.text = currentValue.substr(0, newIndex) + currentValue.substr(this._selectionEndIndex); } else if(this._selectionBeginIndex != this._selectionEndIndex) { this.deleteSelectedText(); } else if(this._selectionBeginIndex > 0) { newIndex = this._selectionBeginIndex - 1; this.text = currentValue.substr(0, this._selectionBeginIndex - 1) + currentValue.substr(this._selectionEndIndex); } } } if(newIndex >= 0) { this.validate(); this.selectRange(newIndex, newIndex); } } /** * @private */ protected function nativeFocus_textInputHandler(event:TextEvent):void { if(this._ignoreNextTextInputEvent) { this._ignoreNextTextInputEvent = false; return; } if(!this._isEditable || !this._isEnabled) { return; } this._imeText = null; this._imeCursorIndex = -1; var text:String = event.text; if(text === CARRIAGE_RETURN || text === LINE_FEED) { //ignore new lines return; } var charCode:int = text.charCodeAt(0); if(!this._restrict || this._restrict.isCharacterAllowed(charCode)) { this.replaceSelectedText(text); } } /** * @private */ protected function nativeFocus_selectAllHandler(event:flash.events.Event):void { if(!this._isEnabled || (!this._isEditable && !this._isSelectable)) { return; } this._selectionAnchorIndex = 0; this.selectRange(0, this._text.length); } /** * @private */ protected function nativeFocus_cutHandler(event:flash.events.Event):void { if(!this._isEnabled || (!this._isEditable && !this._isSelectable) || this._selectionBeginIndex == this._selectionEndIndex || this._displayAsPassword) { return; } Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, this.getSelectedText()); if(!this._isEditable) { return; } this.deleteSelectedText(); } /** * @private */ protected function nativeFocus_copyHandler(event:flash.events.Event):void { if(!this._isEnabled || (!this._isEditable && !this._isSelectable) || this._selectionBeginIndex == this._selectionEndIndex || this._displayAsPassword) { return; } Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, this.getSelectedText()); } /** * @private */ protected function nativeFocus_pasteHandler(event:flash.events.Event):void { if(!this._isEditable || !this._isEnabled) { return; } var pastedText:String = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT) as String; if(pastedText === null) { //the clipboard doesn't contain any text to paste return; } //new lines are not allowed pastedText = pastedText.replace(/[\\n\\r]/g, """"); if(this._restrict) { pastedText = this._restrict.filterText(pastedText); } this.replaceSelectedText(pastedText); } } } ",12062,False,2190.7457341415025,median "-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the ""Software""), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --< @group Vulkan Math GenMatrix -------------------------------------------------------------------------------- --< @summary --< This generic package provides constructors, getters, and setters for generic --< matrix types. --< --< @description --< The Vkm_Matrix type is a generic floating point matrix that can contain up to --< 4 rows and 4 columns. -------------------------------------------------------------------------------- generic type Base_Type is digits <>; type Base_Vector_Type (<>) is tagged private; with function Image (instance : Base_Vector_Type) return String; ---------------------------------------------------------------------------- --< @summary --< Retrieve the x-component of the vector. --< --< @description --< Retrieve the x-component of the vector. --< --< @param vec --< The vector to retrieve the x-component from. --< --< @return --< The x-component of the vector. ---------------------------------------------------------------------------- with function x (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Retrieve the y-component of the vector. --< --< @description --< Retrieve the y-component of the vector. --< --< @param vec --< The vector to retrieve the y-component from. --< --< @return --< The y-component of the vector. ---------------------------------------------------------------------------- with function y (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Retrieve the z-component of the vector. --< --< @description --< Retrieve the z-component of the vector. --< --< @param vec --< The vector to retrieve the z-component from. --< --< @return --< The z-component of the vector. ---------------------------------------------------------------------------- with function z (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Retrieve the w-component of the vector. --< --< @description --< Retrieve the w-component of the vector. --< --< @param vec --< The vector to retrieve the w-component from. --< --< @return --< The w-component of the vector. ---------------------------------------------------------------------------- with function w (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Set the component of the vector. --< --< @description --< Set the component of the vector. --< --< @param vec --< The vector to set the component for. --< ---------------------------------------------------------------------------- with procedure Set(vec : in out Base_Vector_Type; index : in Vkm_Indices; value : in Base_Type); with function Get(vec : in Base_Vector_Type; index : in Vkm_Indices) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Construct a Base_Vector_Type. --< --< @description --< Construct a Base_Vector_Type. --< --< @param size --< The number of components in the Base_Vector_Type. --< --< @param value1 --< The value to set for the x-component of the Base_Vector_Type. --< --< @param value2 --< The value to set for the y-component of the Base_Vector_Type. --< --< @param value3 --< The value to set for the z-component of the Base_Vector_Type. --< --< @param value4 --< The value to set for the w-component of the Base_Vector_Type. --< --< @return --< The w-component of the vector. ---------------------------------------------------------------------------- with function Make_GenType ( size : in Vkm_Length; value1, value2, value3, value4 : in Base_Type := 0.0) return Base_Vector_Type; package Vulkan.Math.GenMatrix is pragma Preelaborate; pragma Pure; INCOMPATIBLE_MATRICES : exception; ---------------------------------------------------------------------------- -- Types ---------------------------------------------------------------------------- --< The matrix type is a 2D array with indices in the range of the Vkm_Indices --< type [0 .. 3]. Because of this, the number of columns is 1-4 and the --< number of rows is 1-4. type Vkm_Matrix is array(Vkm_Indices range <>, Vkm_Indices range <>) of aliased Base_Type; pragma Convention(C,Vkm_Matrix); --< The matrix is a discriminant tagged record which encapsulates the --< Vkm_Matrix type. This allows use of ""."" to perform functions on an --< instance of matrix. --< --< @field last_column_index --< The discriminant, last_column_index, determines the number of columns in the --< matrix. --< --< @field last_row_index --< The discriminant, last_row_index, determines the number of rows in the matrix. --< --< @field data --< The matrix data for the record. This information is able to be --< passed to a C/C++ context. type Vkm_GenMatrix(last_column_index : Vkm_Indices; last_row_index : Vkm_Indices) is tagged record data : Vkm_Matrix(Vkm_Indices'First .. last_column_index, Vkm_Indices'First .. last_row_index); end record; --< A reference to a generic matrix type. The Vkm_GenMatrix instance is --< automatically dereferenced on use. type Vkm_GenMatrix_Reference(instance : not null access Vkm_GenMatrix) is null record with Implicit_Dereference => instance; ---------------------------------------------------------------------------- --< @summary --< The image of the matrix --< --< @description --< Generates a human readable string which contains the contents of the --< instance of Vkm_GenMatrix. For a 2x2 matrix, this appears as a list of --< the row vectors --< --< ""[ "" & Image(mat.r0) & "", "" & Image(mat.r1) & "" ]"" --< --< The Image() subprogram that is supplied during generic instantiation is used --< to print the component of Base_Vector_Type. --< --< @param instance --< The instance of Vkm_GenMatrix. --< --< @return --< The human readable image of the matrix ---------------------------------------------------------------------------- function Image (instance : in Vkm_GenMatrix) return String; ---------------------------------------------------------------------------- -- Element Getters ---------------------------------------------------------------------------- --< @summary --< Vkm_GenMatrix element accessor. --< --< @description --< Gets the value of an element at the specified column and row index. --< --< @param instance --< The Vkm_GenMatrix instance to get the element value of. --< --< @param col_index --< The index of the column at which to get an element. --< --< @param row_index --< The index of the row at which to get an element. --< --< @return --< The value of the specified element. ---------------------------------------------------------------------------- function Element(instance : in Vkm_GenMatrix; col_index, row_index : in Vkm_Indices) return Base_Type; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 3)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 3)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 3)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 3)) with Inline; ---------------------------------------------------------------------------- -- Element Setters ---------------------------------------------------------------------------- --< @summary --< Vkm_GenMatrix element accessor. --< --< @description --< Sets the element at the specified column and row index to a value. --< --< @param instance --< The Vkm_GenMatrix instance to set the element of. --< --< @param col_index --< The index of the column at which to set an element. --< --< @param row_index --< The index of the row at which to set an element. --< --< @param value --< The value to set the specified element. ---------------------------------------------------------------------------- procedure Element( instance : in out Vkm_GenMatrix; col_index, row_index : in Vkm_Indices; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r3( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r3( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r3( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r3( instance : in out Vkm_GenMatrix; value : in Base_Type); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenMatrix element accessor. --< --< @description --< Sets the element at the specified column and row index to a value. A --< reference to the matrix is returned upon completion. --< --< @param instance --< The Vkm_GenMatrix instance to set the element of. --< --< @param col_index --< The index of the column at which to set an element. --< --< @param row_index --< The index of the row at which to set an element. --< --< @param value --< The value to set the specified element. --< --< @return --< A reference to the Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Element( instance : in out Vkm_GenMatrix; col_index, row_index : in Vkm_Indices ; value : in Base_Type ) return Vkm_GenMatrix_Reference; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 3, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 3, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 3, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 3, value)) with Inline; ---------------------------------------------------------------------------- -- Column Accessors ---------------------------------------------------------------------------- --< @summary --< Get the indicated column of the matrix as a vector. --< --< @description --< Retrieve the indicated column of the matrix as a vector: --< --< cI := [ instance.cIr0 instance.cIr1 ... instance.cIrN ] --< --< @param instance --< The instance of Vkm_GenMatrix from which the column is retrieved. --< --< @param col_index --< The index of the column to retrieve from the matrix. --< --< @return --< The vector that contains all elements in the indicated column. ---------------------------------------------------------------------------- function Column ( instance : in Vkm_GenMatrix; col_index : in Vkm_Indices) return Base_Vector_Type is (Make_GenType( To_Vkm_Length(instance.last_row_index), instance.Element(col_index, 0), instance.Element(col_index, 1), instance.Element(col_index, 2), instance.Element(col_index, 3))) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c0 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 0)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c1 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 1)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c2 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 2)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c3 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 3)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Set the indicated column of the matrix given a vector. --< --< @description --< Sets the indicated column of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the column is set. --< --< @param col_index --< The index of the column to set for the matrix. --< --< @param col_val --< The vector value to set the column to. ---------------------------------------------------------------------------- procedure Column ( instance : in out Vkm_GenMatrix; col_index : in Vkm_Indices; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c0 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c1 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c2 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c3 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); ---------------------------------------------------------------------------- --< @summary --< Set the indicated column of the matrix given a vector. --< --< @description --< Sets the indicated column of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the column is set. --< --< @param col_index --< The index of the column to set for the matrix. --< --< @param col_val --< The vector value to set the column to. --< --< @return --< A reference to the Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Column( instance : in out Vkm_GenMatrix; col_index : in Vkm_Indices ; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c0 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 0, col_val)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c1 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 1, col_val)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c2 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 2, col_val)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c3 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 3, col_val)) with Inline; ---------------------------------------------------------------------------- -- Row Accessors ---------------------------------------------------------------------------- --< @summary --< Get the indicated row of the matrix as a vector. --< --< @description --< Retrieve the indicated row of the matrix as a vector: --< --< rI := [ instance.c0rI instance.c1rI ... instance.cNrI ] --< --< @param instance --< The instance of Vkm_GenMatrix from which the row is retrieved. --< --< @param row_index --< The index of the row to retrieve from the matrix. --< --< @return --< The vector that contains all elements in the indicated row. ---------------------------------------------------------------------------- function Row ( instance : in Vkm_GenMatrix; row_index : in Vkm_Indices) return Base_Vector_Type is (Make_GenType( To_Vkm_Length(instance.last_column_index), instance.Element(0, row_index), instance.Element(1, row_index), instance.Element(2, row_index), instance.Element(3, row_index))) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r0 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 0)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r1 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 1)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r2 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 2)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r3 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 3)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Set the indicated row of the matrix given a vector. --< --< @description --< Sets the indicated row of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the row is set. --< --< @param row_index --< The index of the row to set for the matrix. --< --< @param row_val --< The vector value to set the row to. ---------------------------------------------------------------------------- procedure Row ( instance : in out Vkm_GenMatrix; row_index : in Vkm_Indices; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r0 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r1 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r2 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r3 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); ---------------------------------------------------------------------------- --< @summary --< Set the indicated row of the matrix given a vector. --< --< @description --< Sets the indicated row of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the row is set. --< --< @param row_index --< The index of the row to set for the matrix. --< --< @param row_val --< The vector value to set the row to. --< --< @return --< A reference to the Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Row ( instance : in out Vkm_GenMatrix; row_index : in Vkm_Indices; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r0 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 0, row_val)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r1 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 1, row_val)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r2 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 2, row_val)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r3 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 3, row_val)) with Inline; ---------------------------------------------------------------------------- -- Operations ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \\ c0 c1 c2 c3 cN --< r0 | c0r0_val c1r0_val c2r0_val c3r0_val | --< r1 | c0r1_val c1r1_val c2r1_val c3r1_val | --< r2 | c0r2_val c1r2_val c2r2_val c3r2_val | --< r3 | c0r3_val c1r3_val c2r3_val c3r3_val | --< rN --< --< If no value is supplied for an element a default value of 0.0 is used. --< If the indices in the element name are not within matrix bounds, value --< specifiedis ignored. --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param c0r0_val --< The value to set for the element at column 0 and row 0. --< --< @param c0r1_val --< The value to set for the element at column 0 and row 1. --< --< @param c0r2_val --< The value to set for the element at column 0 and row 2. --< --< @param c0r3_val --< The value to set for the element at column 0 and row 3. --< --< @param c1r0_val --< The value to set for the element at column 1 and row 0. --< --< @param c1r1_val --< The value to set for the element at column 1 and row 1. --< --< @param c1r2_val --< The value to set for the element at column 1 and row 2. --< --< @param c1r3_val --< The value to set for the element at column 1 and row 3. --< --< @param c2r0_val --< The value to set for the element at column 2 and row 0. --< --< @param c2r1_val --< The value to set for the element at column 2 and row 1. --< --< @param c2r2_val --< The value to set for the element at column 2 and row 2. --< --< @param c2r3_val --< The value to set for the element at column 2 and row 3. --< --< @param c3r0_val --< The value to set for the element at column 3 and row 0. --< --< @param c3r1_val --< The value to set for the element at column 3 and row 1. --< --< @param c3r2_val --< The value to set for the element at column 3 and row 2. --< --< @param c3r3_val --< The value to set for the element at column 3 and row 3. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; c0r0_val, c0r1_val, c0r2_val, c0r3_val, c1r0_val, c1r1_val, c1r2_val, c1r3_val, c2r0_val, c2r1_val, c2r2_val, c2r3_val, c3r0_val, c3r1_val, c3r2_val, c3r3_val : in Base_Type := 0.0) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \\ c0 c1 c2 c3 cN --< r0 | diag 0.0 0.0 0.0 | --< r1 | 0.0 diag 0.0 0.0 | --< r2 | 0.0 0.0 diag 0.0 | --< r3 | 0.0 0.0 0.0 diag | --< rN --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param diag --< The value to set on the diagonal. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; diag : in Base_Type) return Vkm_GenMatrix is (Make_GenMatrix( cN => cN, rN => rN, c0r0_val => diag, c1r1_val => diag, c2r2_val => diag, c3r3_val => diag)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \\ c0 c1 c2 c3 cN --< r0 | sub.c0r0 sub.c1r0 sub.c2r0 sub.c3r0 | --< r1 | sub.c0r1 sub.c1r1 sub.c2r1 sub.c3r1 | --< r2 | sub.c0r2 sub.c1r2 sub.c2r2 sub.c3r2 | --< r3 | sub.c0r3 sub.c1r3 sub.c2r3 sub.c3r3 | --< rN --< --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param sub --< The submatrix used to initialize elements of the new instance of matrix. --< If an element is out of bounds for the submatrix, the corresponding value --< of the identity matrix is used instead. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; sub : in Vkm_GenMatrix) return Vkm_GenMatrix is (Make_GenMatrix( cN => cN, rN => rN, c0r0_val => sub.c0r0, c0r1_val => sub.c0r1, c0r2_val => sub.c0r2, c0r3_val => sub.c0r3, c1r0_val => sub.c1r0, c1r1_val => sub.c1r1, c1r2_val => sub.c1r2, c1r3_val => sub.c1r3, c2r0_val => sub.c2r0, c2r1_val => sub.c2r1, c2r2_val => sub.c2r2, c2r3_val => sub.c2r3, c3r0_val => sub.c3r0, c3r1_val => sub.c3r1, c3r2_val => sub.c3r2, c3r3_val => sub.c3r3)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \\ c0 c1 c2 c3 cN --< r0 | diag.x 0.0 0.0 0.0 | --< r1 | 0.0 diag.y 0.0 0.0 | --< r2 | 0.0 0.0 diag.z 0.0 | --< r3 | 0.0 0.0 0.0 diag.w | --< rN --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param diag --< The value to set on the diagonal. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; diag : in Base_Vector_Type) return Vkm_GenMatrix is (Make_GenMatrix( cN => cN, rN => rN, c0r0_val => x(diag), c1r1_val => y(diag), c2r2_val => z(diag), c3r3_val => w(diag))) with Inline; ---------------------------------------------------------------------------- --< @summary --< Determine whether two matrices are equal to each other. --< --< @description --< Determines whether every element of the two matrices are equal to each --< other. --< --< @param left --< The variable that is to the left of the equality operator. --< --< @param right --< The variable that is to the right of the equality operator. --< --< @return --< True if the matrices are equal to each other. Otherwise, false. ---------------------------------------------------------------------------- function Op_Is_Equal( left, right : in Vkm_GenMatrix) return Vkm_Bool; ---------------------------------------------------------------------------- --< @summary --< Linear algebraic matrix multiplication --< --< @description --< Perform linear algebraic matrix multiplication for the two matrices. --< --< @param left --< The left matrix in the computation. --< --< @param right --< The right matrix in the computation. --< --< The result of linear algebraic multiplication for the two matrices. ---------------------------------------------------------------------------- function Op_Matrix_Mult_Matrix ( left, right : in Vkm_GenMatrix) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Multiplication operator for a Vkm_GenMatrix matrix and a Vkm_GenFType value. --< --< @description --< Perform Multiplication component-wise on the matrix and vector. --< --< @param left --< The matrix that is multiplied with the vector. --< --< @param right --< The vector that is multiplied by the matrix. --< --< @return --< The product of the matrix with the vector. ---------------------------------------------------------------------------- function Op_Matrix_Mult_Vector ( left : in Vkm_GenMatrix; right : in Base_Vector_Type ) return Base_Vector_Type; ---------------------------------------------------------------------------- --< @summary --< Multiplication operator for a Vkm_GenMatrix matrix and a Vkm_GenFType value. --< --< @description --< Perform Multiplication component-wise on the matrix and vector. --< --< @param left --< The vector that is multiplied with the matrix. --< --< @param right --< The matrix that is multiplied by the vector. --< --< @return --< The product of the vector with the matrix. ---------------------------------------------------------------------------- function Op_Vector_Mult_Matrix ( left : in Base_Vector_Type; right : in Vkm_GenMatrix) return Base_Vector_Type; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on a matrix --< --< @description --< Applies function component-wise on a matrix, yielding the following --< matrix: --< --< | Func(im1.c0r0) ... Func(im1.cNr0) | --< | ... ... | --< | Func(im1.c0rN) ... Func(im1.cNrN) | --< --< @param im1 --< The input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on a --< matrix. ---------------------------------------------------------------------------- generic with function Func (is1 : in Base_Type) return Base_Type; function Apply_Func_IM_RM (im1 : in Vkm_GenMatrix) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on two matrices. --< --< @description --< Applies function component-wise on two matrices, yielding the following --< matrix: --< --< | Func(im1.c0r0, im2.c0r0) ... Func(im1.cNr0, im2.cNr0) | --< | ... ... | --< | Func(im1.c0rN, im2.c0rN) ... Func(im1.cNrN, im2.cNrN) | --< --< @param im1 --< The first input Vkm_GenMatrix parameter. --< --< @param im2 --< The second input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on both --< matrices. ---------------------------------------------------------------------------- generic with function Func (is1, is2 : in Base_Type) return Base_Type; function Apply_Func_IM_IM_RM (im1, im2 : in Vkm_GenMatrix) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on a matrix and a scalar. --< --< @description --< Applies function component-wise on a matrix and a scalar, yielding the --< following matrix: --< --< | Func(im1.c0r0, is1) ... Func(im1.cNr0, is1) | --< | ... ... | --< | Func(im1.c0rN, is1) ... Func(im1.cNrN, is1) | --< --< @param im1 --< The first input Vkm_GenMatrix parameter. --< --< @param is1 --< The second input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on both --< matrices. ---------------------------------------------------------------------------- generic with function Func (is1, is2 : in Base_Type) return Base_Type; function Apply_Func_IM_IS_RM ( im1 : in Vkm_GenMatrix; is1 : in Base_Type ) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on a matrix and a scalar. --< --< @description --< Applies function component-wise on a matrix and a scalar, yielding the --< following matrix: --< --< | Func(is1, im1.c0r0) ... Func(is1, im1.cNr0) | --< | ... ... | --< | Func(is1, im1.c0rN) ... Func(is1, im1.cNrN) | --< --< @param is1 --< The first input Vkm_GenMatrix parameter. --< --< @param im1 --< The second input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on both --< matrices. ---------------------------------------------------------------------------- generic with function Func (is1, is2 : in Base_Type) return Base_Type; function Apply_Func_IS_IM_RM ( is1 : in Base_Type; im1 : in Vkm_GenMatrix) return Vkm_GenMatrix; end Vulkan.Math.GenMatrix; ",16212,True,4108.462509491786,median "------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- Containment iterator for elements of UML metamodel. It should be used with -- metamodel independent containment iterator (and others metamodel specific -- containment iterators when necessary) to construct concrete usabe iterator. ------------------------------------------------------------------------------ with AMF.UML.Abstractions; with AMF.UML.Accept_Call_Actions; with AMF.UML.Accept_Event_Actions; with AMF.UML.Action_Execution_Specifications; with AMF.UML.Action_Input_Pins; with AMF.UML.Activities; with AMF.UML.Activity_Final_Nodes; with AMF.UML.Activity_Parameter_Nodes; with AMF.UML.Activity_Partitions; with AMF.UML.Actors; with AMF.UML.Add_Structural_Feature_Value_Actions; with AMF.UML.Add_Variable_Value_Actions; with AMF.UML.Any_Receive_Events; with AMF.UML.Artifacts; with AMF.UML.Associations; with AMF.UML.Association_Classes; with AMF.UML.Behavior_Execution_Specifications; with AMF.UML.Broadcast_Signal_Actions; with AMF.UML.Call_Behavior_Actions; with AMF.UML.Call_Events; with AMF.UML.Call_Operation_Actions; with AMF.UML.Central_Buffer_Nodes; with AMF.UML.Change_Events; with AMF.UML.Classes; with AMF.UML.Classifier_Template_Parameters; with AMF.UML.Clauses; with AMF.UML.Clear_Association_Actions; with AMF.UML.Clear_Structural_Feature_Actions; with AMF.UML.Clear_Variable_Actions; with AMF.UML.Collaborations; with AMF.UML.Collaboration_Uses; with AMF.UML.Combined_Fragments; with AMF.UML.Comments; with AMF.UML.Communication_Paths; with AMF.UML.Components; with AMF.UML.Component_Realizations; with AMF.UML.Conditional_Nodes; with AMF.UML.Connectable_Element_Template_Parameters; with AMF.UML.Connection_Point_References; with AMF.UML.Connectors; with AMF.UML.Connector_Ends; with AMF.UML.Consider_Ignore_Fragments; with AMF.UML.Constraints; with AMF.UML.Continuations; with AMF.UML.Control_Flows; with AMF.UML.Create_Link_Actions; with AMF.UML.Create_Link_Object_Actions; with AMF.UML.Create_Object_Actions; with AMF.UML.Data_Store_Nodes; with AMF.UML.Data_Types; with AMF.UML.Decision_Nodes; with AMF.UML.Dependencies; with AMF.UML.Deployments; with AMF.UML.Deployment_Specifications; with AMF.UML.Destroy_Link_Actions; with AMF.UML.Destroy_Object_Actions; with AMF.UML.Destruction_Occurrence_Specifications; with AMF.UML.Devices; with AMF.UML.Durations; with AMF.UML.Duration_Constraints; with AMF.UML.Duration_Intervals; with AMF.UML.Duration_Observations; with AMF.UML.Element_Imports; with AMF.UML.Enumerations; with AMF.UML.Enumeration_Literals; with AMF.UML.Exception_Handlers; with AMF.UML.Execution_Environments; with AMF.UML.Execution_Occurrence_Specifications; with AMF.UML.Expansion_Nodes; with AMF.UML.Expansion_Regions; with AMF.UML.Expressions; with AMF.UML.Extends; with AMF.UML.Extensions; with AMF.UML.Extension_Ends; with AMF.UML.Extension_Points; with AMF.UML.Final_States; with AMF.UML.Flow_Final_Nodes; with AMF.UML.Fork_Nodes; with AMF.UML.Function_Behaviors; with AMF.UML.Gates; with AMF.UML.General_Orderings; with AMF.UML.Generalizations; with AMF.UML.Generalization_Sets; with AMF.UML.Images; with AMF.UML.Includes; with AMF.UML.Information_Flows; with AMF.UML.Information_Items; with AMF.UML.Initial_Nodes; with AMF.UML.Input_Pins; with AMF.UML.Instance_Specifications; with AMF.UML.Instance_Values; with AMF.UML.Interactions; with AMF.UML.Interaction_Constraints; with AMF.UML.Interaction_Operands; with AMF.UML.Interaction_Uses; with AMF.UML.Interfaces; with AMF.UML.Interface_Realizations; with AMF.UML.Interruptible_Activity_Regions; with AMF.UML.Intervals; with AMF.UML.Interval_Constraints; with AMF.UML.Join_Nodes; with AMF.UML.Lifelines; with AMF.UML.Link_End_Creation_Datas; with AMF.UML.Link_End_Datas; with AMF.UML.Link_End_Destruction_Datas; with AMF.UML.Literal_Booleans; with AMF.UML.Literal_Integers; with AMF.UML.Literal_Nulls; with AMF.UML.Literal_Reals; with AMF.UML.Literal_Strings; with AMF.UML.Literal_Unlimited_Naturals; with AMF.UML.Loop_Nodes; with AMF.UML.Manifestations; with AMF.UML.Merge_Nodes; with AMF.UML.Messages; with AMF.UML.Message_Occurrence_Specifications; with AMF.UML.Models; with AMF.UML.Nodes; with AMF.UML.Object_Flows; with AMF.UML.Occurrence_Specifications; with AMF.UML.Opaque_Actions; with AMF.UML.Opaque_Behaviors; with AMF.UML.Opaque_Expressions; with AMF.UML.Operations; with AMF.UML.Operation_Template_Parameters; with AMF.UML.Output_Pins; with AMF.UML.Packages; with AMF.UML.Package_Imports; with AMF.UML.Package_Merges; with AMF.UML.Parameters; with AMF.UML.Parameter_Sets; with AMF.UML.Part_Decompositions; with AMF.UML.Ports; with AMF.UML.Primitive_Types; with AMF.UML.Profiles; with AMF.UML.Profile_Applications; with AMF.UML.Properties; with AMF.UML.Protocol_Conformances; with AMF.UML.Protocol_State_Machines; with AMF.UML.Protocol_Transitions; with AMF.UML.Pseudostates; with AMF.UML.Qualifier_Values; with AMF.UML.Raise_Exception_Actions; with AMF.UML.Read_Extent_Actions; with AMF.UML.Read_Is_Classified_Object_Actions; with AMF.UML.Read_Link_Actions; with AMF.UML.Read_Link_Object_End_Actions; with AMF.UML.Read_Link_Object_End_Qualifier_Actions; with AMF.UML.Read_Self_Actions; with AMF.UML.Read_Structural_Feature_Actions; with AMF.UML.Read_Variable_Actions; with AMF.UML.Realizations; with AMF.UML.Receptions; with AMF.UML.Reclassify_Object_Actions; with AMF.UML.Redefinable_Template_Signatures; with AMF.UML.Reduce_Actions; with AMF.UML.Regions; with AMF.UML.Remove_Structural_Feature_Value_Actions; with AMF.UML.Remove_Variable_Value_Actions; with AMF.UML.Reply_Actions; with AMF.UML.Send_Object_Actions; with AMF.UML.Send_Signal_Actions; with AMF.UML.Sequence_Nodes; with AMF.UML.Signals; with AMF.UML.Signal_Events; with AMF.UML.Slots; with AMF.UML.Start_Classifier_Behavior_Actions; with AMF.UML.Start_Object_Behavior_Actions; with AMF.UML.States; with AMF.UML.State_Invariants; with AMF.UML.State_Machines; with AMF.UML.Stereotypes; with AMF.UML.String_Expressions; with AMF.UML.Structured_Activity_Nodes; with AMF.UML.Substitutions; with AMF.UML.Template_Bindings; with AMF.UML.Template_Parameters; with AMF.UML.Template_Parameter_Substitutions; with AMF.UML.Template_Signatures; with AMF.UML.Test_Identity_Actions; with AMF.UML.Time_Constraints; with AMF.UML.Time_Events; with AMF.UML.Time_Expressions; with AMF.UML.Time_Intervals; with AMF.UML.Time_Observations; with AMF.UML.Transitions; with AMF.UML.Triggers; with AMF.UML.Unmarshall_Actions; with AMF.UML.Usages; with AMF.UML.Use_Cases; with AMF.UML.Value_Pins; with AMF.UML.Value_Specification_Actions; with AMF.UML.Variables; with AMF.Visitors.UML_Iterators; generic type Base_Iterator is abstract tagged limited private; package AMF.Visitors.Generic_UML_Containment is type UML_Containment_Iterator is limited new Base_Iterator and AMF.Visitors.UML_Iterators.UML_Iterator with private; overriding procedure Visit_Abstraction (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Abstractions.UML_Abstraction_Access; Control : in out Traverse_Control); overriding procedure Visit_Accept_Call_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Accept_Call_Actions.UML_Accept_Call_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Accept_Event_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Accept_Event_Actions.UML_Accept_Event_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Action_Execution_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Action_Execution_Specifications.UML_Action_Execution_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Action_Input_Pin (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access; Control : in out Traverse_Control); overriding procedure Visit_Activity (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Activities.UML_Activity_Access; Control : in out Traverse_Control); overriding procedure Visit_Activity_Final_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Activity_Final_Nodes.UML_Activity_Final_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Activity_Parameter_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Activity_Parameter_Nodes.UML_Activity_Parameter_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Activity_Partition (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Activity_Partitions.UML_Activity_Partition_Access; Control : in out Traverse_Control); overriding procedure Visit_Actor (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Actors.UML_Actor_Access; Control : in out Traverse_Control); overriding procedure Visit_Add_Structural_Feature_Value_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Add_Structural_Feature_Value_Actions.UML_Add_Structural_Feature_Value_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Add_Variable_Value_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Add_Variable_Value_Actions.UML_Add_Variable_Value_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Any_Receive_Event (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Any_Receive_Events.UML_Any_Receive_Event_Access; Control : in out Traverse_Control); overriding procedure Visit_Artifact (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Artifacts.UML_Artifact_Access; Control : in out Traverse_Control); overriding procedure Visit_Association (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Associations.UML_Association_Access; Control : in out Traverse_Control); overriding procedure Visit_Association_Class (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Association_Classes.UML_Association_Class_Access; Control : in out Traverse_Control); overriding procedure Visit_Behavior_Execution_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Behavior_Execution_Specifications.UML_Behavior_Execution_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Broadcast_Signal_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Broadcast_Signal_Actions.UML_Broadcast_Signal_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Call_Behavior_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Call_Behavior_Actions.UML_Call_Behavior_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Call_Event (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Call_Events.UML_Call_Event_Access; Control : in out Traverse_Control); overriding procedure Visit_Call_Operation_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Central_Buffer_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Central_Buffer_Nodes.UML_Central_Buffer_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Change_Event (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Change_Events.UML_Change_Event_Access; Control : in out Traverse_Control); overriding procedure Visit_Class (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Classes.UML_Class_Access; Control : in out Traverse_Control); overriding procedure Visit_Classifier_Template_Parameter (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access; Control : in out Traverse_Control); overriding procedure Visit_Clause (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Clauses.UML_Clause_Access; Control : in out Traverse_Control); overriding procedure Visit_Clear_Association_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Clear_Association_Actions.UML_Clear_Association_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Clear_Structural_Feature_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Clear_Structural_Feature_Actions.UML_Clear_Structural_Feature_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Clear_Variable_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Clear_Variable_Actions.UML_Clear_Variable_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Collaboration (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Collaborations.UML_Collaboration_Access; Control : in out Traverse_Control); overriding procedure Visit_Collaboration_Use (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access; Control : in out Traverse_Control); overriding procedure Visit_Combined_Fragment (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Combined_Fragments.UML_Combined_Fragment_Access; Control : in out Traverse_Control); overriding procedure Visit_Comment (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Comments.UML_Comment_Access; Control : in out Traverse_Control); overriding procedure Visit_Communication_Path (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Communication_Paths.UML_Communication_Path_Access; Control : in out Traverse_Control); overriding procedure Visit_Component (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Components.UML_Component_Access; Control : in out Traverse_Control); overriding procedure Visit_Component_Realization (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Component_Realizations.UML_Component_Realization_Access; Control : in out Traverse_Control); overriding procedure Visit_Conditional_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Conditional_Nodes.UML_Conditional_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Connectable_Element_Template_Parameter (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access; Control : in out Traverse_Control); overriding procedure Visit_Connection_Point_Reference (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Connection_Point_References.UML_Connection_Point_Reference_Access; Control : in out Traverse_Control); overriding procedure Visit_Connector (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Connectors.UML_Connector_Access; Control : in out Traverse_Control); overriding procedure Visit_Connector_End (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Connector_Ends.UML_Connector_End_Access; Control : in out Traverse_Control); overriding procedure Visit_Consider_Ignore_Fragment (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Consider_Ignore_Fragments.UML_Consider_Ignore_Fragment_Access; Control : in out Traverse_Control); overriding procedure Visit_Constraint (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Constraints.UML_Constraint_Access; Control : in out Traverse_Control); overriding procedure Visit_Continuation (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Continuations.UML_Continuation_Access; Control : in out Traverse_Control); overriding procedure Visit_Control_Flow (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Control_Flows.UML_Control_Flow_Access; Control : in out Traverse_Control); overriding procedure Visit_Create_Link_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Create_Link_Actions.UML_Create_Link_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Create_Link_Object_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Create_Link_Object_Actions.UML_Create_Link_Object_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Create_Object_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Create_Object_Actions.UML_Create_Object_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Data_Store_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Data_Type (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Data_Types.UML_Data_Type_Access; Control : in out Traverse_Control); overriding procedure Visit_Decision_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Decision_Nodes.UML_Decision_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Dependency (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Dependencies.UML_Dependency_Access; Control : in out Traverse_Control); overriding procedure Visit_Deployment (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Deployments.UML_Deployment_Access; Control : in out Traverse_Control); overriding procedure Visit_Deployment_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Deployment_Specifications.UML_Deployment_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Destroy_Link_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Destroy_Link_Actions.UML_Destroy_Link_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Destroy_Object_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Destruction_Occurrence_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Destruction_Occurrence_Specifications.UML_Destruction_Occurrence_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Device (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Devices.UML_Device_Access; Control : in out Traverse_Control); overriding procedure Visit_Duration (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Durations.UML_Duration_Access; Control : in out Traverse_Control); overriding procedure Visit_Duration_Constraint (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Duration_Constraints.UML_Duration_Constraint_Access; Control : in out Traverse_Control); overriding procedure Visit_Duration_Interval (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Duration_Intervals.UML_Duration_Interval_Access; Control : in out Traverse_Control); overriding procedure Visit_Duration_Observation (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Duration_Observations.UML_Duration_Observation_Access; Control : in out Traverse_Control); overriding procedure Visit_Element_Import (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Element_Imports.UML_Element_Import_Access; Control : in out Traverse_Control); overriding procedure Visit_Enumeration (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Enumerations.UML_Enumeration_Access; Control : in out Traverse_Control); overriding procedure Visit_Enumeration_Literal (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access; Control : in out Traverse_Control); overriding procedure Visit_Exception_Handler (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Exception_Handlers.UML_Exception_Handler_Access; Control : in out Traverse_Control); overriding procedure Visit_Execution_Environment (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Execution_Environments.UML_Execution_Environment_Access; Control : in out Traverse_Control); overriding procedure Visit_Execution_Occurrence_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Execution_Occurrence_Specifications.UML_Execution_Occurrence_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Expansion_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Expansion_Region (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Expansion_Regions.UML_Expansion_Region_Access; Control : in out Traverse_Control); overriding procedure Visit_Expression (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Expressions.UML_Expression_Access; Control : in out Traverse_Control); overriding procedure Visit_Extend (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Extends.UML_Extend_Access; Control : in out Traverse_Control); overriding procedure Visit_Extension (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Extensions.UML_Extension_Access; Control : in out Traverse_Control); overriding procedure Visit_Extension_End (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Extension_Ends.UML_Extension_End_Access; Control : in out Traverse_Control); overriding procedure Visit_Extension_Point (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Extension_Points.UML_Extension_Point_Access; Control : in out Traverse_Control); overriding procedure Visit_Final_State (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Final_States.UML_Final_State_Access; Control : in out Traverse_Control); overriding procedure Visit_Flow_Final_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Flow_Final_Nodes.UML_Flow_Final_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Fork_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Fork_Nodes.UML_Fork_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Function_Behavior (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Function_Behaviors.UML_Function_Behavior_Access; Control : in out Traverse_Control); overriding procedure Visit_Gate (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Gates.UML_Gate_Access; Control : in out Traverse_Control); overriding procedure Visit_General_Ordering (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.General_Orderings.UML_General_Ordering_Access; Control : in out Traverse_Control); overriding procedure Visit_Generalization (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Generalizations.UML_Generalization_Access; Control : in out Traverse_Control); overriding procedure Visit_Generalization_Set (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Generalization_Sets.UML_Generalization_Set_Access; Control : in out Traverse_Control); overriding procedure Visit_Image (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Images.UML_Image_Access; Control : in out Traverse_Control); overriding procedure Visit_Include (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Includes.UML_Include_Access; Control : in out Traverse_Control); overriding procedure Visit_Information_Flow (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Information_Flows.UML_Information_Flow_Access; Control : in out Traverse_Control); overriding procedure Visit_Information_Item (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Information_Items.UML_Information_Item_Access; Control : in out Traverse_Control); overriding procedure Visit_Initial_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Initial_Nodes.UML_Initial_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Input_Pin (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Input_Pins.UML_Input_Pin_Access; Control : in out Traverse_Control); overriding procedure Visit_Instance_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Instance_Specifications.UML_Instance_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Instance_Value (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Instance_Values.UML_Instance_Value_Access; Control : in out Traverse_Control); overriding procedure Visit_Interaction (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interactions.UML_Interaction_Access; Control : in out Traverse_Control); overriding procedure Visit_Interaction_Constraint (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interaction_Constraints.UML_Interaction_Constraint_Access; Control : in out Traverse_Control); overriding procedure Visit_Interaction_Operand (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access; Control : in out Traverse_Control); overriding procedure Visit_Interaction_Use (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interaction_Uses.UML_Interaction_Use_Access; Control : in out Traverse_Control); overriding procedure Visit_Interface (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interfaces.UML_Interface_Access; Control : in out Traverse_Control); overriding procedure Visit_Interface_Realization (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interface_Realizations.UML_Interface_Realization_Access; Control : in out Traverse_Control); overriding procedure Visit_Interruptible_Activity_Region (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access; Control : in out Traverse_Control); overriding procedure Visit_Interval (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Intervals.UML_Interval_Access; Control : in out Traverse_Control); overriding procedure Visit_Interval_Constraint (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Interval_Constraints.UML_Interval_Constraint_Access; Control : in out Traverse_Control); overriding procedure Visit_Join_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Join_Nodes.UML_Join_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Lifeline (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Lifelines.UML_Lifeline_Access; Control : in out Traverse_Control); overriding procedure Visit_Link_End_Creation_Data (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access; Control : in out Traverse_Control); overriding procedure Visit_Link_End_Data (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Link_End_Datas.UML_Link_End_Data_Access; Control : in out Traverse_Control); overriding procedure Visit_Link_End_Destruction_Data (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Link_End_Destruction_Datas.UML_Link_End_Destruction_Data_Access; Control : in out Traverse_Control); overriding procedure Visit_Literal_Boolean (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access; Control : in out Traverse_Control); overriding procedure Visit_Literal_Integer (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Literal_Integers.UML_Literal_Integer_Access; Control : in out Traverse_Control); overriding procedure Visit_Literal_Null (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Literal_Nulls.UML_Literal_Null_Access; Control : in out Traverse_Control); overriding procedure Visit_Literal_Real (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Literal_Reals.UML_Literal_Real_Access; Control : in out Traverse_Control); overriding procedure Visit_Literal_String (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Literal_Strings.UML_Literal_String_Access; Control : in out Traverse_Control); overriding procedure Visit_Literal_Unlimited_Natural (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access; Control : in out Traverse_Control); overriding procedure Visit_Loop_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Loop_Nodes.UML_Loop_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Manifestation (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Manifestations.UML_Manifestation_Access; Control : in out Traverse_Control); overriding procedure Visit_Merge_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Merge_Nodes.UML_Merge_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Message (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Messages.UML_Message_Access; Control : in out Traverse_Control); overriding procedure Visit_Message_Occurrence_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Message_Occurrence_Specifications.UML_Message_Occurrence_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Model (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Models.UML_Model_Access; Control : in out Traverse_Control); overriding procedure Visit_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Nodes.UML_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Object_Flow (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Object_Flows.UML_Object_Flow_Access; Control : in out Traverse_Control); overriding procedure Visit_Occurrence_Specification (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Occurrence_Specifications.UML_Occurrence_Specification_Access; Control : in out Traverse_Control); overriding procedure Visit_Opaque_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Opaque_Actions.UML_Opaque_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Opaque_Behavior (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Opaque_Behaviors.UML_Opaque_Behavior_Access; Control : in out Traverse_Control); overriding procedure Visit_Opaque_Expression (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access; Control : in out Traverse_Control); overriding procedure Visit_Operation (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Operations.UML_Operation_Access; Control : in out Traverse_Control); overriding procedure Visit_Operation_Template_Parameter (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Operation_Template_Parameters.UML_Operation_Template_Parameter_Access; Control : in out Traverse_Control); overriding procedure Visit_Output_Pin (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Output_Pins.UML_Output_Pin_Access; Control : in out Traverse_Control); overriding procedure Visit_Package (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Packages.UML_Package_Access; Control : in out Traverse_Control); overriding procedure Visit_Package_Import (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Package_Imports.UML_Package_Import_Access; Control : in out Traverse_Control); overriding procedure Visit_Package_Merge (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Package_Merges.UML_Package_Merge_Access; Control : in out Traverse_Control); overriding procedure Visit_Parameter (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Parameters.UML_Parameter_Access; Control : in out Traverse_Control); overriding procedure Visit_Parameter_Set (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Parameter_Sets.UML_Parameter_Set_Access; Control : in out Traverse_Control); overriding procedure Visit_Part_Decomposition (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Part_Decompositions.UML_Part_Decomposition_Access; Control : in out Traverse_Control); overriding procedure Visit_Port (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Ports.UML_Port_Access; Control : in out Traverse_Control); overriding procedure Visit_Primitive_Type (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Primitive_Types.UML_Primitive_Type_Access; Control : in out Traverse_Control); overriding procedure Visit_Profile (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Profiles.UML_Profile_Access; Control : in out Traverse_Control); overriding procedure Visit_Profile_Application (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Profile_Applications.UML_Profile_Application_Access; Control : in out Traverse_Control); overriding procedure Visit_Property (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Properties.UML_Property_Access; Control : in out Traverse_Control); overriding procedure Visit_Protocol_Conformance (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Protocol_Conformances.UML_Protocol_Conformance_Access; Control : in out Traverse_Control); overriding procedure Visit_Protocol_State_Machine (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access; Control : in out Traverse_Control); overriding procedure Visit_Protocol_Transition (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Protocol_Transitions.UML_Protocol_Transition_Access; Control : in out Traverse_Control); overriding procedure Visit_Pseudostate (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Pseudostates.UML_Pseudostate_Access; Control : in out Traverse_Control); overriding procedure Visit_Qualifier_Value (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Qualifier_Values.UML_Qualifier_Value_Access; Control : in out Traverse_Control); overriding procedure Visit_Raise_Exception_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Raise_Exception_Actions.UML_Raise_Exception_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Extent_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Extent_Actions.UML_Read_Extent_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Is_Classified_Object_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Is_Classified_Object_Actions.UML_Read_Is_Classified_Object_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Link_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Link_Actions.UML_Read_Link_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Link_Object_End_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Link_Object_End_Actions.UML_Read_Link_Object_End_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Link_Object_End_Qualifier_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Link_Object_End_Qualifier_Actions.UML_Read_Link_Object_End_Qualifier_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Self_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Self_Actions.UML_Read_Self_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Structural_Feature_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Structural_Feature_Actions.UML_Read_Structural_Feature_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Read_Variable_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Read_Variable_Actions.UML_Read_Variable_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Realization (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Realizations.UML_Realization_Access; Control : in out Traverse_Control); overriding procedure Visit_Reception (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Receptions.UML_Reception_Access; Control : in out Traverse_Control); overriding procedure Visit_Reclassify_Object_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Reclassify_Object_Actions.UML_Reclassify_Object_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Redefinable_Template_Signature (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access; Control : in out Traverse_Control); overriding procedure Visit_Reduce_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Reduce_Actions.UML_Reduce_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Region (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Regions.UML_Region_Access; Control : in out Traverse_Control); overriding procedure Visit_Remove_Structural_Feature_Value_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Remove_Structural_Feature_Value_Actions.UML_Remove_Structural_Feature_Value_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Remove_Variable_Value_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Reply_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Reply_Actions.UML_Reply_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Send_Object_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Send_Signal_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Send_Signal_Actions.UML_Send_Signal_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Sequence_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Sequence_Nodes.UML_Sequence_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Signal (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Signals.UML_Signal_Access; Control : in out Traverse_Control); overriding procedure Visit_Signal_Event (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Signal_Events.UML_Signal_Event_Access; Control : in out Traverse_Control); overriding procedure Visit_Slot (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Slots.UML_Slot_Access; Control : in out Traverse_Control); overriding procedure Visit_Start_Classifier_Behavior_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Start_Classifier_Behavior_Actions.UML_Start_Classifier_Behavior_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Start_Object_Behavior_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Start_Object_Behavior_Actions.UML_Start_Object_Behavior_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_State (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.States.UML_State_Access; Control : in out Traverse_Control); overriding procedure Visit_State_Invariant (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.State_Invariants.UML_State_Invariant_Access; Control : in out Traverse_Control); overriding procedure Visit_State_Machine (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.State_Machines.UML_State_Machine_Access; Control : in out Traverse_Control); overriding procedure Visit_Stereotype (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Stereotypes.UML_Stereotype_Access; Control : in out Traverse_Control); overriding procedure Visit_String_Expression (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.String_Expressions.UML_String_Expression_Access; Control : in out Traverse_Control); overriding procedure Visit_Structured_Activity_Node (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access; Control : in out Traverse_Control); overriding procedure Visit_Substitution (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Substitutions.UML_Substitution_Access; Control : in out Traverse_Control); overriding procedure Visit_Template_Binding (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Template_Bindings.UML_Template_Binding_Access; Control : in out Traverse_Control); overriding procedure Visit_Template_Parameter (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Template_Parameters.UML_Template_Parameter_Access; Control : in out Traverse_Control); overriding procedure Visit_Template_Parameter_Substitution (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Template_Parameter_Substitutions.UML_Template_Parameter_Substitution_Access; Control : in out Traverse_Control); overriding procedure Visit_Template_Signature (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Template_Signatures.UML_Template_Signature_Access; Control : in out Traverse_Control); overriding procedure Visit_Test_Identity_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Test_Identity_Actions.UML_Test_Identity_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Time_Constraint (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Time_Constraints.UML_Time_Constraint_Access; Control : in out Traverse_Control); overriding procedure Visit_Time_Event (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Time_Events.UML_Time_Event_Access; Control : in out Traverse_Control); overriding procedure Visit_Time_Expression (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Time_Expressions.UML_Time_Expression_Access; Control : in out Traverse_Control); overriding procedure Visit_Time_Interval (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Time_Intervals.UML_Time_Interval_Access; Control : in out Traverse_Control); overriding procedure Visit_Time_Observation (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Time_Observations.UML_Time_Observation_Access; Control : in out Traverse_Control); overriding procedure Visit_Transition (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Transitions.UML_Transition_Access; Control : in out Traverse_Control); overriding procedure Visit_Trigger (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Triggers.UML_Trigger_Access; Control : in out Traverse_Control); overriding procedure Visit_Unmarshall_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Unmarshall_Actions.UML_Unmarshall_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Usage (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Usages.UML_Usage_Access; Control : in out Traverse_Control); overriding procedure Visit_Use_Case (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Use_Cases.UML_Use_Case_Access; Control : in out Traverse_Control); overriding procedure Visit_Value_Pin (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Value_Pins.UML_Value_Pin_Access; Control : in out Traverse_Control); overriding procedure Visit_Value_Specification_Action (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Value_Specification_Actions.UML_Value_Specification_Action_Access; Control : in out Traverse_Control); overriding procedure Visit_Variable (Self : in out UML_Containment_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.UML.Variables.UML_Variable_Access; Control : in out Traverse_Control); private type UML_Containment_Iterator is limited new Base_Iterator and AMF.Visitors.UML_Iterators.UML_Iterator with null record; end AMF.Visitors.Generic_UML_Containment; ",16163,True,5675.220498835376,median "//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the ""License""); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an ""AS IS"" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.controls.advancedDataGridClasses { /* import flash.display.DisplayObject; import flash.events.Event; */ import mx.controls.AdvancedDataGrid; import mx.controls.TextInput; import mx.controls.dataGridClasses.DataGridColumn; import mx.core.ClassFactory; import mx.core.IFactory; import mx.core.mx_internal; import mx.utils.StringUtil; import org.apache.royale.core.UIBase; import org.apache.royale.events.Event; use namespace mx_internal; //-------------------------------------- // Styles //-------------------------------------- //include ""../../styles/metadata/TextStyles.as""; /** * The background color of the column. * The default value is undefined, which means it uses the value of the * backgroundColor style of the associated AdvancedDataGrid control. * The default value for the AdvancedDataGrid control is 0xFFFFFF. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ [Style(name=""backgroundColor"", type=""uint"", format=""Color"", inherit=""no"")] /** * The name of a CSS style declaration for controlling other aspects of * the appearance of the column headers. * The default value is undefined, which means it uses the value of the * headerStyleName style of the associated AdvancedDataGrid control. * The default value for the AdvancedDataGrid control is * "".advancedDataGridStyles"". * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ [Style(name=""headerStyleName"", type=""String"", inherit=""no"")] /** * The number of pixels between the container's left border and its content * area. * There is no default value for this style. * An item renderer's setting of the paddingLeft property * is used to determine the default. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //[Style(name=""paddingLeft"", type=""Number"", format=""Length"", inherit=""no"")] /** * The number of pixels between the container's right border and its content * area. * There is no default value for this style. * An item renderer's setting of the paddingRight property * is used to determine the default. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //[Style(name=""paddingRight"", type=""Number"", format=""Length"", inherit=""no"")] /** * The AdvancedDataGridColumn class describes a column in an AdvancedDataGrid control. * There is one AdvancedDataGridColumn per displayable column, even if a column * is hidden or off-screen. * The data provider items of an AdvancedDataGrid control * can contain properties that are not displayed, * and therefore, do not need an AdvancedDataGridColumn. * An AdvancedDataGridColumn allows specification of the color and font of the text * in a column; specification of what kind of component displays the data for the column; * specification of whether the column is editable, sortable, or resizeable; * and specification of the text for the column header. * *

Notes:

    *
  • An AdvancedDataGridColumn only holds information about a column; * it is not the parent of the item renderers in the column.
  • *
  • If you specify an AdvancedDataGridColumn class without a dataField * property, you must specify a sortCompareFunction * property. Otherwise, sort operations may cause run-time errors.
*

* * @mxml * *

You use the <mx.AdvancedDataGridcolumn> tag to configure a column * of a AdvancedDataGrid control. * You specify the <mx.AdvancedDataGridcolumn> tag as a child * of the columns property in MXML. * The <mx.AdvancedDataGridcolumn> tag inherits all of the * tag attributes of its superclass, and adds the following tag attributes:

* *
 *  <mx:AdvancedDataGridColumn
 *  Properties 
 *    dataField=""No default""
 *    dataTipField=""No default""
 *    dataTipFunction=""No default""
 *    editable=""true|false""
 *    editorDataField=""text""
 *    editorHeightOffset=""0""
 *    editorUsesEnterKey=""false|true""
 *    editorWidthOffset=""0""
 *    editorXOffset=""0""
 *    editorYOffset=""0""
 *    formatter=""null""
 *    headerRenderer=""AdvancedDataGridHeaderRenderer""
 *    headerText=""No default""
 *    headerWordWrap=""undefined""
 *    imeMode=""null""
 *    itemEditor=""TextInput""
 *    itemRenderer=""AdvancedDataGridItemRenderer""
 *    labelFunction=""No default""
 *    minWidth=""20""
 *    rendererIsEditor=""false|true""
 *    resizable=""true|false""
 *    showDataTips=""false|true""
 *    sortable=""true|false""
 *    sortCompareFunction=""No default""
 *    sortDescending=""false|true""
 *    styleFunction=""No default""
 *    visible=""true|false""
 *    width=""100""
 *    wordWrap=""false|true""
 * 
 *  Styles
 *    backgroundColor=""0xFFFFFF""
 *    color=""No default.""
 *    disabledColor=""0xAAB3B3""
 *    fontAntiAliasType=""advanced""
 *    fontFamily=""No default""
 *    fontGridFitType=""pixel""
 *    fontSharpness=""0""
 *    fontSize=""No default""
 *    fontStyle=""normal|italic""
 *    fontThickness=""0""
 *    fontWeight=""normal|bold""
 *    headerStyleName=""No default""
 *    kerning=""false|true""
 *    letterSpacing=""0""
 *    paddingLeft=""0""
 *    paddingRight=""0""
 *    textAlign=""right|center|left""
 *    textDecoration=""none|underline""
 *    textIndent=""0""
 *  />
 *  
* * @see mx.controls.AdvancedDataGrid * * @see mx.styles.CSSStyleDeclaration * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 * @royalesuppresspublicvarwarning */ public class AdvancedDataGridColumn extends DataGridColumn {//extends CSSStyleDeclaration implements IIMESupport //include ""../../core/Version.as""; //-------------------------------------------------------------------------- // // Class variables // //-------------------------------------------------------------------------- //---------------------------------- // embeddedFontRegistry //---------------------------------- // private static var noEmbeddedFonts:Boolean; /** * @private * Storage for the embeddedFontRegistry property. * This gets initialized on first access, * not at static initialization time, in order to ensure * that the Singleton registry has already been initialized. */ // private static var _embeddedFontRegistry:IEmbeddedFontRegistry; /** * @private * A reference to the embedded font registry. * Single registry in the system. * Used to look up the moduleFactory of a font. */ /* private static function get embeddedFontRegistry():IEmbeddedFontRegistry { if (!_embeddedFontRegistry && !noEmbeddedFonts) { try { _embeddedFontRegistry = IEmbeddedFontRegistry( Singleton.getInstance(""mx.core::IEmbeddedFontRegistry"")); } catch (e:Error) { noEmbeddedFonts = true; } } return _embeddedFontRegistry; } */ private static var _defaultItemEditorFactory:IFactory; mx_internal static function get defaultItemEditorFactory():IFactory { if (!_defaultItemEditorFactory) _defaultItemEditorFactory = new ClassFactory(TextInput); return _defaultItemEditorFactory; } //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @param columnName The name of the field in the data provider * associated with the column, and the text for the header cell of this * column. This is equivalent to setting the dataField * and headerText properties. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function AdvancedDataGridColumn(columnName:String = null) { super(columnName); /* if (columnName) { dataField = columnName; headerText = columnName; } */ } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- // mx_internal var list:UIBase; //BaseEx; /** * @private */ // mx_internal var explicitWidth:Number; /** * @private * Holds the last recorded value of the module factory used to create the font. */ // private var oldEmbeddedFontContext:IFlexModuleFactory = null; /** * @private * * true if font properties do not need to be set. */ // private var fontPropertiesSet:Boolean = false; /** * @private * True if createInFontContext has been called. */ // private var hasFontContextBeenSaved:Boolean = false; // preferred width is the number we should use when measuring // regular width will be changed if we shrink columns to fit. // mx_internal var preferredWidth:Number = 100; //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- // ------------------------------------------------ // fontWeight // ------------------------------------------------ public function get fontWeight():String { return ""normal""; } public function set fontWeight(value:String):void { } // ------------------------------------------------ // fontSize // ------------------------------------------------ public function get fontSize():Number { return 11; } public function set fontSize(value:Number):void { } // ------------------------------------------------ // color // ------------------------------------------------ public function get color():uint { return 0x0B333C; } public function set color(value:uint):void { } //---------------------------------- // sortDescending //---------------------------------- /** * Indicates whether the column sort is * in ascending order, false, * or descending order, true. * * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ // public var sortDescending:Boolean = false; //---------------------------------- // dataTipField //---------------------------------- /** * @private * Storage for the dataTipField property. */ /* private var _dataTipField:String; [Bindable(""dataTipFieldChanged"")] [Inspectable(category=""Advanced"", defaultValue=""label"")] */ /** * The name of the field in the data provider to display as the data tip. * By default, the AdvancedDataGrid control looks for a property named * label on each data provider item and displays it. * However, if the data provider does not contain a label * property, you can set the dataTipField property to * specify a different property. * For example, you could set the value to ""FullName"" when a user views a * set of people's names included from a database. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get dataTipField():String { return _dataTipField; } */ /** * @private */ /* public function set dataTipField(value:String):void { _dataTipField = value; if (owner) { owner.invalidateList(); } dispatchEvent(new Event(""dataTipChanged"")); } */ //---------------------------------- // dataTipFunction //---------------------------------- /** * @private * Storage for the dataTipFunction property. */ /* private var _dataTipFunction:Function; [Bindable(""dataTipFunctionChanged"")] [Inspectable(category=""Advanced"")] */ /** * Specifies a callback function to run on each item of the data provider * to determine its data tip. * This property is used by the itemToDataTip() method. * *

By default, the control looks for a property named label * on each data provider item and displays it as its dataTip. * However, some data providers do not have a label property * or another property that you can use for displaying data * in the rows. * For example, you might have a data provider that contains a lastName * and firstName fields, but you want to display full names as the dataTip. * You can specify a function to the dataTipFunction property * that returns a single String containing the value of both fields. You * can also use the dataTipFunction property for handling * formatting and localization.

* *

The function must take a single Object parameter, and return a String. * For the header cell of a column, the Object parameter is of type AdvancedDataGridColumn. * For table cells, the Object parameter contains the data provider element for the cell.

* *

Shown below is an example implementation of the function. * For the header cell, return ""Column Name"". * For the table cells, return the name property of the Object:

*
     *  private function tipFunc(value:Object):String
     *  {
     *      if (value is AdvancedDataGridColumn)
     *          return ""Column Name"";
     *                 
     *      // Use the 'name' property of the data provider element.
     *      return ""Name: "" + value[""name""];
     *  }
* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get dataTipFunction():Function { return _dataTipFunction; } */ /** * @private */ /* public function set dataTipFunction(value:Function):void { _dataTipFunction = value; if (owner) { owner.invalidateList(); } dispatchEvent(new Event(""labelFunctionChanged"")); } */ //---------------------------------- // draggable //---------------------------------- // [Inspectable(category=""General"")] /** * A flag that indicates whether the user is allowed to drag * the column to a new position * If true, the user can drag the * the column headers to a new position * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //public var draggable:Boolean = true; //---------------------------------- // editable //---------------------------------- [Inspectable(category=""General"")] /** * A flag that indicates whether the items in the column are editable. * If true, and the AdvancedDataGrid's editable * property is also true, the items in a column are * editable and can be individually edited * by clicking an item or by navigating to the item with the * Tab and Arrow keys. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editable:Boolean = true; //---------------------------------- // itemEditor //---------------------------------- [Inspectable(category=""General"")] /** * A class factory for the instances of the item editor to use for the * column, when it is editable. * *

The default value is the mx.controls.TextInput control.

* * @see mx.controls.TextInput * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var itemEditor:IFactory = defaultItemEditorFactory; //---------------------------------- // editorDataField //---------------------------------- [Inspectable(category=""General"")] /** * The name of the property of the item editor that contains the new * data for the list item. * For example, the default itemEditor is * TextInput, so the default value of the editorDataField * property is ""text"", which specifies the * text property of the TextInput control. * * @default ""text"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorDataField:String = ""text""; //---------------------------------- // editorHeightOffset //---------------------------------- [Inspectable(category=""General"", defaultValue=""0"")] /** * The height of the item editor, in pixels, relative to the size of the * item renderer. This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorHeightOffset:Number = 0; //---------------------------------- // editorWidthOffset //---------------------------------- //[Inspectable(category=""General"", defaultValue=""0"")] /** * The width of the item editor, in pixels, relative to the size of the * item renderer. This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorWidthOffset:Number = 0; //---------------------------------- // editorXOffset //---------------------------------- // [Inspectable(category=""General"", defaultValue=""0"")] /** * The x location of the upper-left corner of the item editor, * in pixels, relative to the upper-left corner of the item. * This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorXOffset:Number = 0; //---------------------------------- // editorYOffset //---------------------------------- //[Inspectable(category=""General"", defaultValue=""0"")] /** * The y location of the upper-left corner of the item editor, * in pixels, relative to the upper-left corner of the item. * This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorYOffset:Number = 0; //---------------------------------- // editorUsesEnterKey //---------------------------------- //[Inspectable(category=""General"", defaultValue=""false"")] /** * A flag that indicates whether the item editor uses Enter key. * If true the item editor uses the Enter key and the * AdvancedDataGrid will not look for the Enter key and move the editor in * response. * Note that changing this value while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorUsesEnterKey:Boolean = false; //---------------------------------- // headerRenderer //---------------------------------- /** * @private * Storage for the headerRenderer property. */ private var _headerRenderer:IFactory; [Bindable(""headerRendererChanged"")] [Inspectable(category=""Other"")] /** * The class factory for item renderer instances that display the * column header for the column. * You can specify a drop-in item renderer, * an inline item renderer, or a custom item renderer component as the * value of this property. * *

The default item renderer is the AdvancedDataGridItemRenderer class, * which displays the item data as text.

* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function get headerRenderer():IFactory { return _headerRenderer; } /** * @private */ public function set headerRenderer(value:IFactory):void { _headerRenderer = value; // rebuild the headers /* if (owner) { owner.invalidateList(); owner.columnRendererChanged(this); } dispatchEvent(new Event(""headerRendererChanged"")); */ } //---------------------------------- // headerWordWrap //---------------------------------- /** * @private * Storage for the headerWordWrap property. */ private var _headerWordWrap:*; [Inspectable(category=""Advanced"")] /** * Set to true to wrap the text in the column header * if it does not fit on one line. * If undefined, the AdvancedDataGrid control's wordWrap property * is used. * This property overrides the headerWordWrap property of * the AdvancedDataGrid control. * * @default undefined * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function get headerWordWrap():* { return _headerWordWrap; } /** * @private */ public function set headerWordWrap(value:*):void { _headerWordWrap = value; /* if (owner) { owner.invalidateList(); } */ } //---------------------------------- // enableIME //---------------------------------- /** * A flag that indicates whether the IME should * be enabled when the component receives focus. * * If an editor is up, it will set enableIME * accordingly. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ /* public function get enableIME():Boolean { return false; } */ //---------------------------------- // imeMode //---------------------------------- /** * @private * Storage for the imeMode property. */ /* private var _imeMode:String; [Inspectable(category=""Other"")] */ /** * Specifies the IME (input method editor) mode. * The IME mode enables users to enter text in Chinese, Japanese, and Korean. * Flex sets the IME mode when the itemFocusIn event occurs, * and sets it back * to the previous value when the itemFocusOut event occurs. * The flash.system.IMEConversionMode class defines constants for * the valid values for this property. * *

The default value is null, in which case it uses the value of the * AdvancedDataGrid control's imeMode property.

* * @see flash.system.IMEConversionMode * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get imeMode():String { return _imeMode; } */ /** * @private */ /* public function set imeMode(value:String):void { _imeMode = value; } */ /* //---------------------------------- // resizable //---------------------------------- [Inspectable(category=""General"")] /!** * Set to true if the user is allowed to resize * the width of the column. * If true, the user can drag the grid lines between * the column headers to resize the column. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public var resizable:Boolean = true; //---------------------------------- // showDataTips //---------------------------------- /!** * @private * Storage for the showDataTips property. *!/ private var _showDataTips:*; [Inspectable(category=""Advanced"")] /!** * Set to true to show data tips in the column. * If true, datatips are displayed for text in the rows. Datatips * are tooltips designed to show the text that is too long for the row. * * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public function get showDataTips():* { return _showDataTips; } /!** * @private *!/ public function set showDataTips(value:*):void { _showDataTips = value; /!* if (owner) { owner.invalidateList(); } *!/ } //---------------------------------- // sortable //---------------------------------- [Inspectable(category=""General"")] /!** * Set to true to indicate that the user can click on the * header of this column to sort the data provider. * If this property and the AdvancedDataGrid sortableColumns property * are both true, the AdvancedDataGrid control dispatches a * headerRelease event when a user releases the mouse button * on this column's header. * If no other handler calls the preventDefault() method on * the headerRelease event, the dataField * property or sortCompareFunction in the column is used * to reorder the items in the data provider. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public var sortable:Boolean = true; //---------------------------------- // sortCompareFunction //---------------------------------- /!** * @private * Storage for the sortCompareFunction property. *!/ private var _sortCompareFunction:Function; [Bindable(""sortCompareFunctionChanged"")] [Inspectable(category=""Advanced"")] /!** * * A callback function that gets called when sorting the data in * the column. If this property is not specified, the sort tries * to use a basic string or number sort on the data. * If the data is not a string or number or if the dataField * property is not a valid property of the data provider, the sort does * not work or will generate an exception. * If you specify a value of the labelFunction property, * you typically also provide a function to the sortCompareFunction property, * unless sorting is not allowed on this column. * That means you specify a function when the value from the column's dataField * does not sort in the same way as the computed value from the labelFunction property. * *

The AdvancedDataGrid control uses this function to sort the elements of the data * provider collection. The function signature of * the callback function takes two parameters and has the following form:

* *
mySortCompareFunction(obj1:Object, obj2:Object):int 
* *

obj1 — A data element to compare.

* *

obj2 — Another data element to compare with obj1.

* *

The function should return a value based on the comparison * of the objects:

*
    *
  • -1 if obj1 should appear before obj2 in ascending order.
  • *
  • 0 if obj1 = obj2.
  • *
  • 1 if obj1 should appear after obj2 in ascending order.
  • *
* *

Note: The obj1 and * obj2 parameters are entire data provider elements and not * just the data for the item.

* * @default null * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public function get sortCompareFunction():Function { return _sortCompareFunction; } /!** * @private *!/ public function set sortCompareFunction(value:Function):void { _sortCompareFunction = value; // dispatchEvent(new Event(""sortCompareFunctionChanged"")); } */ //---------------------------------- // sortCompareType //---------------------------------- /** * @private */ //private var _sortCompareType:String; /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 11.8 * @playerversion AIR 3.8 * @productversion Flex 4.11 */ /* [Bindable(""sortCompareTypeChanged"")] public function get sortCompareType():String { return _sortCompareType; } */ /** * @private */ /* public function set sortCompareType(value:String):void { if (_sortCompareType != value) { _sortCompareType = value; dispatchEvent(new Event(""sortCompareTypeChanged"")); } } */ /* //---------------------------------- // visible //---------------------------------- /!** * @private * Storage for the visible property. *!/ private var _visible:Boolean = true; [Inspectable(category=""General"", defaultValue=""true"")] /!** * If true, the column is visible. * Set to false to hide the column. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public function get visible():Boolean { return _visible; } /!** * @private *!/ public function set visible(value:Boolean):void { if (_visible != value) { _visible = value; if (owner) { (owner as AdvancedDataGrid).columnsInvalid(); // columns invisible at init don't get a dataprovider so // force assignment by faking a dp change (owner as AdvancedDataGrid).model.dispatchEvent(new Event(""dataProviderChanged"")); //owner.invalidateProperties(); //owner.invalidateSize(); //owner.invalidateList(); } } }*/ //---------------------------------- // styleFunction //---------------------------------- /** * @private */ private var _styleFunction:Function; /** * A callback function that is called when rendering each cell. * The signature of the function should be: * *
function myStyleFunction(data:Object, column:AdvancedDataGridColumn):Object
* *

data - data object associated with the item being rendered.

*

column - AdvancedDataGridColumn instance with * which the item renderer is associated.

* *

The return value should be a object with styles as properties * having the required values. * For example:

* *
{ color:0xFF0000, fontWeight:""bold"" }
* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function get styleFunction():Function { return _styleFunction; } /** * @private */ public function set styleFunction(value:Function):void { _styleFunction = value; /* if (owner) owner.invalidateDisplayList(); */ } //---------------------------------- // formatter //---------------------------------- /** * @private */ //private var _formatter:IFormatter; /** * An instance of a subclasses of mx.formatters.Formatter. * The control use this class to format the column text. * * @default null * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get formatter():IFormatter { return _formatter; } */ /** * @private */ /* public function set formatter(value:IFormatter):void { _formatter = value; if (owner) owner.invalidateDisplayList(); } */ //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private */ /* override mx_internal function addStyleToProtoChain( chain:Object, target:DisplayObject, filterMap:Object = null):Object { var parentGrid:AdvancedDataGridBaseEx = owner; var item:IListItemRenderer = IListItemRenderer(target); chain = super.addStyleToProtoChain(chain, target); // If the target data is a AdvancedDataGridColumn and has a data // field in its data, then it is a header so add the // AdvancedDataGrid.headerStyleName object to the head of the proto chain. if (item.data && (item.data is AdvancedDataGridColumn)) { var s:Object; var headerStyleName:Object = parentGrid.getStyle(""headerStyleName""); if (headerStyleName) { if (headerStyleName is String) { chain = addStylesToProtoChain(String(headerStyleName), chain, target); } if (headerStyleName is CSSStyleDeclaration) chain = headerStyleName.addStyleToProtoChain(chain, target); } headerStyleName = getStyle(""headerStyleName""); if (headerStyleName) { if (headerStyleName is String) { chain = addStylesToProtoChain(String(headerStyleName), chain, target); } if (headerStyleName is CSSStyleDeclaration) chain = headerStyleName.addStyleToProtoChain(chain, target); } } // save the current font context if (!fontPropertiesSet) { fontPropertiesSet = true; saveFontContext(owner ? owner.moduleFactory : null); } return chain; } */ /** * @private */ /* override public function setStyle(styleProp:String, value:*):void { fontPropertiesSet = false; var oldValue:Object = getStyle(styleProp); var regenerate:Boolean = false; // If this AdvancedDataGridColumn didn't previously have a factory, defaultFactory, or // overrides object, then this AdvancedDataGridColumn hasn't been added to the item // renderers proto chains. In that case, we need to regenerate all the item // renderers proto chains. if (factory == null && defaultFactory == null && !overrides && (oldValue !== value)) // must be !== { regenerate = true; } super.setLocalStyle(styleProp, value); // The default implementation of setStyle won't always regenerate // the proto chain when headerStyleName is set, and we need to make sure // that they are regenerated if (styleProp == ""headerStyleName"") { if (owner) { owner.regenerateStyleCache(true); owner.notifyStyleChangeInChildren(""headerStyleName"", true); } return; } if (owner) { if (regenerate) { owner.regenerateStyleCache(true); } if (hasFontContextChanged(owner.moduleFactory)) { owner.columnRendererChanged(this); } owner.invalidateList(); } } */ /** * @private */ /* override public function get specificity():int { // Return 10 as there is a sorting mechanism based on specificity now // and there could be ancestor specificity also!! return 10; } */ //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * @private * Internal function to allow the AdvancedDataGrid to set the width of the * column without locking it as an explicitWidth mx_internal function setWidth(value:Number):void { _width = value; } */ /** * @private * * Apply column's Formatter if present. * */ /* private function applyFormatting(data:String):String { if (formatter != null && data != null) { var label:String = formatter.format(data); // Silently ignore formatter errors. For example, errors occur when // the property corresponding to the dataField is not present in the // row object i.e. it'll be empty and it's not anybody's fault that // it's an error. const mxFormatter:Formatter = formatter as Formatter; if (mxFormatter && mxFormatter.error) return null; return label; } else { return data; } } */ /** * Returns the String that the item renderer displays for the given data object. * If the AdvancedDataGridColumn or its AdvancedDataGrid control * has a non-null labelFunction * property, it applies the function to the data object. * Otherwise, the method extracts the contents of the field specified by the * dataField property, or gets the string value of the data object. * If the method cannot convert the parameter to a String, it returns a * single space. * * @param data Object to be rendered. * * @param withFormatting It true specifies to return * the String with any formatting applied to it. * * @return Displayable String based on the data. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function itemToLabel(data:Object, withFormatting:Boolean=true):String { var label:String = itemToLabelWithoutFormatting(data); if (withFormatting) return applyFormatting(label); return label; } */ /** * @private * * This is the original AdvancedDataGrid.itemToLabel() that has been wrapped with applyFormatting() * */ /* private function itemToLabelWithoutFormatting(data:Object):String { var headerInfo:AdvancedDataGridHeaderInfo = owner.mx_internal::getHeaderInfo(this); // In case of Column grouping, when a column has a parent with dataField/labelFunction set, this column is // supposed to take value from what its parent supplies it if (headerInfo != null && headerInfo.internalLabelFunction != null) data = headerInfo.internalLabelFunction(data, this); if (!data) return "" ""; if (labelFunction != null) return labelFunction(data, this); if (owner.labelFunction != null) return owner.labelFunction(data, this); if (typeof(data) == ""object"" || typeof(data) == ""xml"") { if (dataField != null && dataField in data) data = data[dataField]; else return "" ""; // stops ""[object Object]"" showing } if (data is String) return String(data); try { return data.toString(); } catch(e:Error) { } return "" ""; } */ /** * Returns a String that the item renderer displays as the data tip for the given data object, * based on the dataTipField and dataTipFunction properties. * If the method cannot convert the parameter to a String, it returns a * single space. * *

This method is for use by developers who are creating subclasses * of the AdvancedDataGridColumn class. * It is not for use by application developers.

* * @param data Object to be rendered. * * @return Displayable String based on the data. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function itemToDataTip(data:Object):String { if (dataTipFunction != null) return dataTipFunction(data); if (owner.dataTipFunction != null) return owner.dataTipFunction(data); // for header items, return the header text if (data is AdvancedDataGridColumn) return AdvancedDataGridColumn(data).headerText; if (typeof(data) == ""object"" || typeof(data) == ""xml"") { var field:String = dataTipField; if (!field) field = owner.dataTipField; if (field != null) { if (field in data && data[field] != null) data = data[field]; } else if (dataField != null) { if (dataField in data && data[dataField] != null) data = data[dataField]; else data = null; } } if (data is String) return String(data); try { return data.toString(); } catch(e:Error) { } return "" ""; } */ /** * @private * * Save the current font context to member fields. */ /* private function saveFontContext(flexModuleFactory:IFlexModuleFactory):void { // Save for hasFontContextChanged() hasFontContextBeenSaved = true; var fontName:String = StringUtil.trimArrayElements(getStyle(""fontFamily""), "",""); var fontWeight:String = getStyle(""fontWeight""); var fontStyle:String = getStyle(""fontStyle""); var bold:Boolean = fontWeight == ""bold""; var italic:Boolean = fontStyle == ""italic""; oldEmbeddedFontContext = (noEmbeddedFonts || !embeddedFontRegistry) ? null : embeddedFontRegistry.getAssociatedModuleFactory( fontName, bold, italic, this, flexModuleFactory, owner.systemManager); } */ /** * @private * Test if the current font context has changed * since that last time saveFontContext() was called. */ /* mx_internal function hasFontContextChanged( flexModuleFactory:IFlexModuleFactory):Boolean { // If the font has not been saved yet, then return false, // the font context has not changed. if (!hasFontContextBeenSaved) return false; var fontName:String = StringUtil.trimArrayElements(getStyle(""fontFamily""), "",""); var fontWeight:String = getStyle(""fontWeight""); var fontStyle:String = getStyle(""fontStyle""); // Check if the module factory has changed. var bold:Boolean = fontWeight == ""bold""; var italic:Boolean = fontStyle == ""italic""; var fontContext:IFlexModuleFactory = (noEmbeddedFonts || !embeddedFontRegistry) ? null : embeddedFontRegistry.getAssociatedModuleFactory( fontName, bold, italic, this, flexModuleFactory, owner.systemManager); return fontContext != oldEmbeddedFontContext; } */ /** * @private */ /* private function addStylesToProtoChain(styles:String, chain:Object, target:DisplayObject):Object { var styleNames:Array = styles.split(/\\s+/); for (var c:int=0; c < styleNames.length; c++) { if (styleNames[c].length) { var declaration:CSSStyleDeclaration = owner.styleManager.getMergedStyleDeclaration(""."" + styleNames[c]); if (declaration) chain = declaration.addStyleToProtoChain(chain, target); } } return chain; } */ /** * @private * * Sets the properties of this Object to the given column. * * It sets only the required properties. * * @param col AdvancedDataGridColumn in which the properties are to be set. * */ /* protected function copyProperties(col:AdvancedDataGridColumn):void { // copy properties col.defaultFactory = this.defaultFactory; col.editable = this.editable; col.editorDataField = this.editorDataField; col.editorHeightOffset = this.editorHeightOffset; col.editorUsesEnterKey = this.editorUsesEnterKey; col.editorWidthOffset = this.editorWidthOffset; col.editorXOffset = this.editorXOffset; col.editorYOffset = this.editorYOffset; col.factory = this.factory; col.itemEditor = this.itemEditor; col.rendererIsEditor = this.rendererIsEditor; col.resizable = this.resizable; col.sortable = this.sortable; col.sortDescending = this.sortDescending; col.dataField = this.dataField; col.dataTipField = this.dataTipField; col.dataTipFunction = this.dataTipFunction; col.formatter = this.formatter; col.headerRenderer = this.headerRenderer; col.headerText = this.headerText; col.headerWordWrap = this.headerWordWrap; col.imeMode = this.imeMode; col.itemRenderer = this.itemRenderer; col.labelFunction = this.labelFunction; col.minWidth = this.minWidth; col.showDataTips = this.showDataTips; col.sortCompareFunction = this.sortCompareFunction; col.styleFunction = this.styleFunction; col.visible = this.visible; col.width = this.width; col.wordWrap = this.wordWrap; // copy styles col.public::setStyle(""backgroundColor"",this.getStyle(""backgroundColor"")); col.public::setStyle(""headerStyleName"",this.getStyle(""headerStyleName"")); col.public::setStyle(""paddingLeft"",this.getStyle(""paddingLeft"")); col.public::setStyle(""paddingRight"",this.getStyle(""paddingRight"")); // copy text styles col.public::setStyle(""color"",this.getStyle(""color"")); col.public::setStyle(""disabledColor"",this.getStyle(""disabledColor"")); col.public::setStyle(""fontAntiAliasType"",this.getStyle(""fontAntiAliasType"")); col.public::setStyle(""fontFamily"",this.getStyle(""fontFamily"")); col.public::setStyle(""fontGridFitType"",this.getStyle(""fontGridFitType"")); col.public::setStyle(""fontSharpness"",this.getStyle(""fontSharpness"")); col.public::setStyle(""fontSize"",this.getStyle(""fontSize"")); col.public::setStyle(""fontStyle"",this.getStyle(""fontStyle"")); col.public::setStyle(""fontThickness"",this.getStyle(""fontThickness"")); col.public::setStyle(""fontWeight"",this.getStyle(""fontWeight"")); col.public::setStyle(""kerning"",this.getStyle(""kerning"")); col.public::setStyle(""letterSpacing"",this.getStyle(""letterSpacing"")); col.public::setStyle(""textAlign"",this.getStyle(""textAlign"")); col.public::setStyle(""textDecoration"",this.getStyle(""textDecoration"")); col.public::setStyle(""textIndent"",this.getStyle(""textIndent"")); } */ /** * * Clone this column and return a new Column with the * same properties and styles as this one. * * It does not set all the available properties * * @return col AdvancedDataGridColumn. * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function clone():AdvancedDataGridColumn { // make a new column var col:AdvancedDataGridColumn = new AdvancedDataGridColumn(); // copy the properties //copyProperties(col); return col; } } } ",12444,True,2649.1347576417716,median "package game { import com.pickgliss.loader.BaseLoader; import com.pickgliss.loader.LoaderManager; import ddt.data.BallInfo; import ddt.data.BuffInfo; import ddt.data.FightBuffInfo; import ddt.data.goods.InventoryItemInfo; import ddt.data.map.MissionInfo; import ddt.data.player.PlayerInfo; import ddt.data.player.SelfInfo; import ddt.events.CrazyTankSocketEvent; import ddt.events.GameEvent; import ddt.manager.BallManager; import ddt.manager.BuffManager; import ddt.manager.ChatManager; import ddt.manager.LanguageMgr; import ddt.manager.PathManager; import ddt.manager.PetInfoManager; import ddt.manager.PetSkillManager; import ddt.manager.PlayerManager; import ddt.manager.QueueManager; import ddt.manager.SocketManager; import ddt.manager.StateManager; import ddt.manager.TimeManager; import ddt.states.StateType; import ddt.view.chat.ChatData; import ddt.view.chat.ChatFormats; import ddt.view.chat.ChatInputView; import flash.events.Event; import flash.events.EventDispatcher; import flash.geom.Point; import flash.utils.Dictionary; import game.model.GameInfo; import game.model.GameNeedMovieInfo; import game.model.GameNeedPetSkillInfo; import game.model.LocalPlayer; import game.model.Pet; import game.model.Player; import game.view.GameView; import game.view.effects.BloodNumberCreater; import game.view.experience.ExpTweenManager; import pet.date.PetInfo; import pet.date.PetSkillTemplateInfo; import road7th.comm.PackageIn; import road7th.data.DictionaryData; import room.RoomManager; import room.model.RoomInfo; import room.model.RoomPlayer; import trainer.controller.WeakGuildManager; public class GameManager extends EventDispatcher { public static const START_LOAD:String = ""StartLoading""; public static var MinLevelDuplicate:int = 8; public static const SKILL_INFO_INIT_GAME:String = ""skillInfoInitGame""; public static const ENTER_MISSION_RESULT:String = ""EnterMissionResult""; public static const ENTER_ROOM:String = ""EnterRoom""; public static const LEAVE_MISSION:String = ""leaveMission""; public static const ENTER_DUNGEON:String = ""EnterDungeon""; public static const PLAYER_CLICK_PAY:String = ""PlayerClickPay""; private static var _instance:GameManager; public static const MissionGiveup:int = 0; public static const MissionAgain:int = 1; public static const MissionTimeout:int = 2; private var _current:GameInfo; private var _numCreater:BloodNumberCreater; public var currentNum:int = 0; public var bossName:String = """"; private var _loaderArray:Array; private var _gameView:GameView; private var _addLivingEvtVec:Vector.; private var _setPropertyEvtVec:Vector.; private var _livingFallingEvtVec:Vector.; private var _livingShowBloodEvtVec:Vector.; private var _addMapThingEvtVec:Vector.; private var _livingActionMappingEvtVec:Vector.; private var _updatePhysicObjectEvtVec:Vector.; private var _playerBloodEvtVec:Vector.; public var viewCompleteFlag:Boolean; public var TryAgain:int = 0; public var petSkillList:Array; private var _recevieLoadSocket:Boolean; public function GameManager() { super(); } public static function isAcademyRoom(param1:GameInfo) : Boolean { return param1.roomType == RoomInfo.ACADEMY_DUNGEON_ROOM; } public static function isDungeonRoom(param1:GameInfo) : Boolean { return param1.roomType == RoomInfo.DUNGEON_ROOM || param1.roomType == RoomInfo.LANBYRINTH_ROOM || param1.roomType == RoomInfo.SPECIAL_ACTIVITY_DUNGEON; } public static function isLanbyrinthRoom(param1:GameInfo) : Boolean { return param1.roomType == RoomInfo.LANBYRINTH_ROOM; } public static function isFightLib(param1:GameInfo) : Boolean { return param1.roomType == RoomInfo.FIGHT_LIB_ROOM; } public static function isFreshMan(param1:GameInfo) : Boolean { return param1.roomType == RoomInfo.FRESHMAN_ROOM; } public static function get Instance() : GameManager { if(_instance == null) { _instance = new GameManager(); } return _instance; } public function get Current() : GameInfo { return this._current; } private function initData() : void { this._loaderArray = new Array(); this._addLivingEvtVec = new Vector.(); this._setPropertyEvtVec = new Vector.(); this._livingFallingEvtVec = new Vector.(); this._livingShowBloodEvtVec = new Vector.(); this._addMapThingEvtVec = new Vector.(); this._livingActionMappingEvtVec = new Vector.(); this._updatePhysicObjectEvtVec = new Vector.(); this._playerBloodEvtVec = new Vector.(); } public function set trainerCurrent(param1:GameInfo) : void { this._current = param1; } public function setup() : void { this.initData(); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.ADD_LIVING,this.__addLiving); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.PLAYER_PROPERTY,this.__objectSetProperty); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.LIVING_FALLING,this.__livingFalling); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.LIVING_SHOW_BLOOD,this.__livingShowBlood); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_CREATE,this.__createGame); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_START,this.__gameStart); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_LOAD,this.__beginLoad); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.LOAD,this.__loadprogress); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_ALL_MISSION_OVER,this.__missionAllOver); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_TAKE_OUT,this.__takeOut); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.SHOW_CARDS,this.__showAllCard); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_MISSION_INFO,this.__gameMissionInfo); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_MISSION_START,this.__gameMissionStart); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_MISSION_PREPARE,this.__gameMissionPrepare); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_ROOM_INFO,this.__missionInviteRoomInfo); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.PLAY_INFO_IN_GAME,this.__updatePlayInfoInGame); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.GAME_MISSION_TRY_AGAIN,this.__missionTryAgain); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.LOAD_RESOURCE,this.__loadResource); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.BUFF_OBTAIN,this.__buffObtain); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.BUFF_UPDATE,this.__buffUpdate); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.ADD_MAP_THINGS,this.__addMapThing); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.ACTION_MAPPING,this.__livingActionMapping); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.UPDATE_BOARD_STATE,this.__updatePhysicObject); SocketManager.Instance.addEventListener(CrazyTankSocketEvent.PLAYER_BLOOD,this.__playerBlood); } public function ClearAllCrazyTankSocketEvent() : void { this._addLivingEvtVec.length = 0; this._setPropertyEvtVec.length = 0; this._livingFallingEvtVec.length = 0; this._livingShowBloodEvtVec.length = 0; this._addMapThingEvtVec.length = 0; this._livingActionMappingEvtVec.length = 0; this._updatePhysicObjectEvtVec.length = 0; this._playerBloodEvtVec.length = 0; } protected function __addLiving(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._addLivingEvtVec.push(param1); } else { this._gameView.addliving(param1); } } protected function __updatePhysicObject(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._updatePhysicObjectEvtVec.push(param1); } else { this._gameView.updatePhysicObject(param1); } } protected function __livingActionMapping(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._livingActionMappingEvtVec.push(param1); } else { this._gameView.livingActionMapping(param1); } } protected function __addMapThing(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._addMapThingEvtVec.push(param1); } else { this._gameView.addMapThing(param1); } } protected function __playerBlood(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._playerBloodEvtVec.push(param1); } else { this._gameView.playerBlood(param1); } } protected function __objectSetProperty(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._setPropertyEvtVec.push(param1); } else { this._gameView.objectSetProperty(param1); } } protected function __livingFalling(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._livingFallingEvtVec.push(param1); } else { this._gameView.livingFalling(param1); } } protected function __livingShowBlood(param1:CrazyTankSocketEvent) : void { if(!this.viewCompleteFlag) { this._livingShowBloodEvtVec.push(param1); } else { this._gameView.livingShowBlood(param1); } } private function __missionTryAgain(param1:CrazyTankSocketEvent) : void { this.TryAgain = param1.pkg.readInt(); dispatchEvent(new GameEvent(GameEvent.MISSIONAGAIN,this.TryAgain)); } private function __skillInfoInit(param1:CrazyTankSocketEvent) : void { var _loc5_:int = 0; var _loc6_:int = 0; var _loc2_:PackageIn = param1.pkg; this.petSkillList = []; var _loc3_:int = _loc2_.readInt(); var _loc4_:int = 0; while(_loc4_ < _loc3_) { _loc5_ = _loc2_.readInt(); _loc6_ = _loc2_.readInt(); this.petSkillList.push({ ""id"":_loc5_, ""cd"":_loc6_ }); _loc2_.readInt(); _loc4_++; } dispatchEvent(new Event(SKILL_INFO_INIT_GAME)); } private function __updatePlayInfoInGame(param1:CrazyTankSocketEvent) : void { var _loc11_:Player = null; var _loc2_:RoomInfo = RoomManager.Instance.current; if(_loc2_ == null) { return; } var _loc3_:PackageIn = param1.pkg; var _loc4_:int = _loc3_.readInt(); var _loc5_:int = _loc3_.readInt(); var _loc6_:int = _loc3_.readInt(); var _loc7_:int = _loc3_.readInt(); var _loc8_:int = _loc3_.readInt(); var _loc9_:Boolean = _loc3_.readBoolean(); var _loc10_:RoomPlayer = RoomManager.Instance.current.findPlayerByID(_loc5_); if(_loc4_ != PlayerManager.Instance.Self.ZoneID || _loc10_ == null || this._current == null) { return; } if(_loc10_.isSelf) { _loc11_ = new LocalPlayer(PlayerManager.Instance.Self,_loc7_,_loc6_,_loc8_); } else { _loc11_ = new Player(_loc10_.playerInfo,_loc7_,_loc6_,_loc8_); } _loc11_.isReady = _loc9_; if(_loc11_.movie) { _loc11_.movie.setDefaultAction(_loc11_.movie.standAction); } this._current.addRoomPlayer(_loc10_); if(_loc10_.isViewer) { this._current.addGameViewer(_loc11_); } else { this._current.addGamePlayer(_loc11_); } if(_loc10_.isSelf) { StateManager.setState(StateType.MISSION_ROOM); } } private function __missionInviteRoomInfo(param1:CrazyTankSocketEvent) : void { var _loc2_:PackageIn = null; var _loc3_:GameInfo = null; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:MissionInfo = null; var _loc7_:int = 0; var _loc8_:PlayerInfo = null; var _loc9_:RoomPlayer = null; var _loc10_:Boolean = false; var _loc11_:int = 0; var _loc12_:String = null; var _loc13_:String = null; var _loc14_:int = 0; var _loc15_:int = 0; var _loc16_:int = 0; var _loc17_:int = 0; var _loc18_:Boolean = false; var _loc19_:Player = null; if(RoomManager.Instance.current) { _loc2_ = param1.pkg; _loc3_ = new GameInfo(); _loc3_.mapIndex = _loc2_.readInt(); _loc3_.roomType = _loc2_.readInt(); _loc3_.gameMode = _loc2_.readInt(); _loc3_.timeType = _loc2_.readInt(); RoomManager.Instance.current.timeType = _loc3_.timeType; _loc4_ = _loc2_.readInt(); _loc5_ = 0; while(_loc5_ < _loc4_) { _loc7_ = _loc2_.readInt(); _loc8_ = PlayerManager.Instance.findPlayer(_loc7_); _loc8_.beginChanges(); _loc9_ = RoomManager.Instance.current.findPlayerByID(_loc7_); if(_loc9_ == null) { _loc9_ = new RoomPlayer(_loc8_); _loc8_.ID = _loc7_; } _loc8_.ZoneID = PlayerManager.Instance.Self.ZoneID; _loc8_.NickName = _loc2_.readUTF(); _loc10_ = _loc2_.readBoolean(); _loc8_.typeVIP = _loc2_.readByte(); _loc8_.VIPLevel = _loc2_.readInt(); _loc8_.Sex = _loc2_.readBoolean(); _loc8_.Hide = _loc2_.readInt(); _loc8_.Style = _loc2_.readUTF(); _loc8_.Colors = _loc2_.readUTF(); _loc8_.Skin = _loc2_.readUTF(); _loc8_.Grade = _loc2_.readInt(); _loc8_.Repute = _loc2_.readInt(); _loc8_.WeaponID = _loc2_.readInt(); if(_loc8_.WeaponID > 0) { _loc11_ = _loc2_.readInt(); _loc12_ = _loc2_.readUTF(); _loc13_ = _loc2_.readDateString(); } _loc8_.DeputyWeaponID = _loc2_.readInt(); _loc8_.ConsortiaID = _loc2_.readInt(); _loc8_.ConsortiaName = _loc2_.readUTF(); _loc8_.badgeID = _loc2_.readInt(); _loc14_ = _loc2_.readInt(); _loc15_ = _loc2_.readInt(); _loc8_.DailyLeagueFirst = _loc2_.readBoolean(); _loc8_.DailyLeagueLastScore = _loc2_.readInt(); _loc8_.commitChanges(); _loc9_.team = _loc2_.readInt(); _loc3_.addRoomPlayer(_loc9_); _loc16_ = _loc2_.readInt(); _loc17_ = _loc2_.readInt(); _loc18_ = _loc2_.readBoolean(); if(_loc9_.isSelf) { _loc19_ = new LocalPlayer(PlayerManager.Instance.Self,_loc16_,_loc9_.team,_loc17_); } else { _loc19_ = new Player(_loc9_.playerInfo,_loc16_,_loc9_.team,_loc17_); } _loc19_.isReady = _loc18_; _loc19_.currentWeapInfo.refineryLevel = _loc11_; if(!_loc10_) { _loc3_.addGamePlayer(_loc19_); } else { if(_loc9_.isSelf) { _loc3_.setSelfGamePlayer(_loc19_); } _loc3_.addGameViewer(_loc19_); } _loc5_++; } this._current = _loc3_; _loc6_ = new MissionInfo(); _loc6_.name = _loc2_.readUTF(); _loc6_.pic = _loc2_.readUTF(); _loc6_.success = _loc2_.readUTF(); _loc6_.failure = _loc2_.readUTF(); _loc6_.description = _loc2_.readUTF(); _loc6_.totalMissiton = _loc2_.readInt(); _loc6_.missionIndex = _loc2_.readInt(); _loc6_.nextMissionIndex = _loc6_.missionIndex + 1; this._current.missionInfo = _loc6_; this._current.hasNextMission = true; } } private function __createGame(param1:CrazyTankSocketEvent) : void { var _loc2_:PackageIn = null; var _loc3_:GameInfo = null; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:int = 0; var _loc7_:String = null; var _loc8_:int = 0; var _loc9_:PlayerInfo = null; var _loc10_:RoomPlayer = null; var _loc11_:String = null; var _loc12_:Boolean = false; var _loc13_:int = 0; var _loc14_:int = 0; var _loc15_:int = 0; var _loc16_:int = 0; var _loc17_:Player = null; var _loc18_:int = 0; var _loc19_:int = 0; var _loc20_:int = 0; var _loc21_:String = null; var _loc22_:String = null; var _loc23_:int = 0; var _loc24_:PetInfo = null; var _loc25_:int = 0; var _loc26_:int = 0; var _loc27_:int = 0; var _loc28_:int = 0; var _loc29_:int = 0; if(RoomManager.Instance.current) { _loc2_ = param1.pkg; _loc3_ = new GameInfo(); _loc3_.roomType = _loc2_.readInt(); _loc3_.gameMode = _loc2_.readInt(); _loc3_.timeType = _loc2_.readInt(); RoomManager.Instance.current.timeType = _loc3_.timeType; _loc4_ = _loc2_.readInt(); _loc5_ = 0; while(_loc5_ < _loc4_) { _loc6_ = _loc2_.readInt(); _loc7_ = _loc2_.readUTF(); _loc8_ = _loc2_.readInt(); _loc9_ = PlayerManager.Instance.findPlayer(_loc8_,_loc6_); _loc9_.beginChanges(); _loc10_ = RoomManager.Instance.current.findPlayerByID(_loc8_,_loc6_); if(_loc10_ == null) { _loc10_ = new RoomPlayer(_loc9_); } _loc9_.ID = _loc8_; _loc9_.ZoneID = _loc6_; _loc11_ = _loc2_.readUTF(); _loc12_ = _loc2_.readBoolean(); if(_loc12_ && _loc10_.place < 8) { _loc10_.place = 8; } if(!(_loc10_ is SelfInfo)) { _loc9_.NickName = _loc11_; } _loc9_.typeVIP = _loc2_.readByte(); _loc9_.VIPLevel = _loc2_.readInt(); if(PlayerManager.Instance.isChangeStyleTemp(_loc9_.ID)) { _loc2_.readBoolean(); _loc2_.readInt(); _loc2_.readUTF(); _loc2_.readUTF(); _loc2_.readUTF(); } else { _loc9_.Sex = _loc2_.readBoolean(); _loc9_.Hide = _loc2_.readInt(); _loc9_.Style = _loc2_.readUTF(); _loc9_.Colors = _loc2_.readUTF(); _loc9_.Skin = _loc2_.readUTF(); } _loc9_.Grade = _loc2_.readInt(); _loc9_.Repute = _loc2_.readInt(); _loc9_.WeaponID = _loc2_.readInt(); if(_loc9_.WeaponID != 0) { _loc20_ = _loc2_.readInt(); _loc21_ = _loc2_.readUTF(); _loc22_ = _loc2_.readDateString(); } _loc9_.DeputyWeaponID = _loc2_.readInt(); _loc9_.Nimbus = _loc2_.readInt(); _loc9_.IsShowConsortia = _loc2_.readBoolean(); _loc9_.ConsortiaID = _loc2_.readInt(); _loc9_.ConsortiaName = _loc2_.readUTF(); _loc9_.badgeID = _loc2_.readInt(); _loc13_ = _loc2_.readInt(); _loc14_ = _loc2_.readInt(); _loc9_.WinCount = _loc2_.readInt(); _loc9_.TotalCount = _loc2_.readInt(); _loc9_.FightPower = _loc2_.readInt(); _loc9_.apprenticeshipState = _loc2_.readInt(); _loc9_.masterID = _loc2_.readInt(); _loc9_.setMasterOrApprentices(_loc2_.readUTF()); _loc9_.AchievementPoint = _loc2_.readInt(); _loc9_.honor = _loc2_.readUTF(); _loc9_.Offer = _loc2_.readInt(); _loc9_.DailyLeagueFirst = _loc2_.readBoolean(); _loc9_.DailyLeagueLastScore = _loc2_.readInt(); _loc9_.commitChanges(); _loc10_.playerInfo.IsMarried = _loc2_.readBoolean(); if(_loc10_.playerInfo.IsMarried) { _loc10_.playerInfo.SpouseID = _loc2_.readInt(); _loc10_.playerInfo.SpouseName = _loc2_.readUTF(); } _loc10_.additionInfo.resetAddition(); _loc10_.additionInfo.GMExperienceAdditionType = Number(_loc2_.readInt() / 100); _loc10_.additionInfo.AuncherExperienceAddition = Number(_loc2_.readInt() / 100); _loc10_.additionInfo.GMOfferAddition = Number(_loc2_.readInt() / 100); _loc10_.additionInfo.AuncherOfferAddition = Number(_loc2_.readInt() / 100); _loc10_.additionInfo.GMRichesAddition = Number(_loc2_.readInt() / 100); _loc10_.additionInfo.AuncherRichesAddition = Number(_loc2_.readInt() / 100); _loc10_.team = _loc2_.readInt(); _loc3_.addRoomPlayer(_loc10_); _loc15_ = _loc2_.readInt(); _loc16_ = _loc2_.readInt(); if(_loc10_.isSelf) { _loc17_ = new LocalPlayer(PlayerManager.Instance.Self,_loc15_,_loc10_.team,_loc16_); } else { _loc17_ = new Player(_loc10_.playerInfo,_loc15_,_loc10_.team,_loc16_); } _loc18_ = _loc2_.readInt(); _loc19_ = 0; while(_loc19_ < _loc18_) { _loc23_ = _loc2_.readInt(); _loc24_ = _loc9_.pets[_loc23_]; _loc25_ = _loc2_.readInt(); if(_loc24_ == null) { _loc24_ = new PetInfo(); _loc24_.TemplateID = _loc25_; PetInfoManager.fillPetInfo(_loc24_); } _loc24_.ID = _loc2_.readInt(); _loc24_.Name = _loc2_.readUTF(); _loc24_.UserID = _loc2_.readInt(); _loc24_.Level = _loc2_.readInt(); _loc24_.IsEquip = true; _loc24_.clearEquipedSkills(); _loc26_ = _loc2_.readInt(); _loc27_ = 0; while(_loc27_ < _loc26_) { _loc28_ = _loc2_.readInt(); _loc29_ = _loc2_.readInt(); _loc24_.equipdSkills.add(_loc28_,_loc29_); _loc27_++; } _loc24_.Place = _loc23_; _loc9_.pets.add(_loc24_.Place,_loc24_); _loc19_++; } _loc17_.zoneName = _loc7_; _loc17_.currentWeapInfo.refineryLevel = _loc20_; if(!_loc10_.isViewer) { _loc3_.addGamePlayer(_loc17_); } else { if(_loc10_.isSelf) { _loc3_.setSelfGamePlayer(_loc17_); } _loc3_.addGameViewer(_loc17_); } _loc5_++; } this._current = _loc3_; QueueManager.setLifeTime(0); } } private function __buffObtain(param1:CrazyTankSocketEvent) : void { var _loc2_:PackageIn = null; var _loc3_:int = 0; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:Boolean = false; var _loc7_:Date = null; var _loc8_:int = 0; var _loc9_:int = 0; var _loc10_:BuffInfo = null; if(this._current) { _loc2_ = param1.pkg; if(_loc2_.extend1 == this._current.selfGamePlayer.LivingID) { return; } if(this._current.findPlayer(_loc2_.extend1) != null) { _loc3_ = _loc2_.readInt(); _loc4_ = 0; while(_loc4_ < _loc3_) { _loc5_ = _loc2_.readInt(); _loc6_ = _loc2_.readBoolean(); _loc7_ = _loc2_.readDate(); _loc8_ = _loc2_.readInt(); _loc9_ = _loc2_.readInt(); _loc10_ = new BuffInfo(_loc5_,_loc6_,_loc7_,_loc8_,_loc9_); this._current.findPlayer(_loc2_.extend1).playerInfo.buffInfo.add(_loc10_.Type,_loc10_); _loc4_++; } param1.stopImmediatePropagation(); } } } private function __buffUpdate(param1:CrazyTankSocketEvent) : void { var _loc2_:PackageIn = null; var _loc3_:int = 0; var _loc4_:int = 0; var _loc5_:Boolean = false; var _loc6_:Date = null; var _loc7_:int = 0; var _loc8_:int = 0; var _loc9_:BuffInfo = null; if(this._current) { _loc2_ = param1.pkg; if(_loc2_.extend1 == this._current.selfGamePlayer.LivingID) { return; } if(this._current.findPlayer(_loc2_.extend1) != null) { _loc3_ = _loc2_.readInt(); _loc4_ = _loc2_.readInt(); _loc5_ = _loc2_.readBoolean(); _loc6_ = _loc2_.readDate(); _loc7_ = _loc2_.readInt(); _loc8_ = _loc2_.readInt(); _loc9_ = new BuffInfo(_loc4_,_loc5_,_loc6_,_loc7_,_loc8_); if(_loc5_) { this._current.findPlayer(_loc2_.extend1).playerInfo.buffInfo.add(_loc9_.Type,_loc9_); } else { this._current.findPlayer(_loc2_.extend1).playerInfo.buffInfo.remove(_loc9_.Type); } param1.stopImmediatePropagation(); } } } private function __beginLoad(param1:CrazyTankSocketEvent) : void { var _loc2_:int = 0; var _loc3_:int = 0; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:GameNeedMovieInfo = null; var _loc7_:GameNeedPetSkillInfo = null; StateManager.getInGame_Step_3 = true; this._recevieLoadSocket = true; if(this.Current) { StateManager.getInGame_Step_4 = true; this.Current.maxTime = param1.pkg.readInt(); this.Current.mapIndex = param1.pkg.readInt(); _loc2_ = param1.pkg.readInt(); _loc3_ = 1; while(_loc3_ <= _loc2_) { _loc6_ = new GameNeedMovieInfo(); _loc6_.type = param1.pkg.readInt(); _loc6_.path = param1.pkg.readUTF(); _loc6_.classPath = param1.pkg.readUTF(); this.Current.neededMovies.push(_loc6_); _loc3_++; } _loc4_ = param1.pkg.readInt(); _loc5_ = 0; while(_loc5_ < _loc4_) { _loc7_ = new GameNeedPetSkillInfo(); _loc7_.pic = param1.pkg.readUTF(); _loc7_.effect = param1.pkg.readUTF(); this.Current.neededPetSkillResource.push(_loc7_); _loc5_++; } } this.checkCanToLoader(); } private function __gameMissionStart(param1:CrazyTankSocketEvent) : void { var _loc2_:PackageIn = param1.pkg; var _loc3_:Object = new Object(); _loc3_.id = _loc2_.clientId; var _loc4_:Boolean = _loc2_.readBoolean(); } public function dispatchAllGameReadyState(param1:Array) : void { var _loc2_:CrazyTankSocketEvent = null; var _loc3_:PackageIn = null; var _loc4_:Object = null; var _loc5_:int = 0; var _loc6_:Player = null; var _loc7_:RoomPlayer = null; for each(_loc2_ in param1) { _loc3_ = _loc2_.pkg; _loc4_ = new Object(); _loc5_ = _loc3_.clientId; if(this._current) { _loc6_ = this._current.findPlayerByPlayerID(_loc5_); _loc6_.isReady = _loc3_.readBoolean(); if(!_loc6_.isSelf && _loc6_.isReady) { _loc7_ = RoomManager.Instance.current.findPlayerByID(_loc5_); _loc7_.isReady = true; } } _loc3_.position = SocketManager.PACKAGE_CONTENT_START_INDEX; } } private function __gameMissionPrepare(param1:CrazyTankSocketEvent) : void { if(RoomManager.Instance.current) { RoomManager.Instance.current.setPlayerReadyState(param1.pkg.clientId,param1.pkg.readBoolean()); } } private function __gameMissionInfo(param1:CrazyTankSocketEvent) : void { var _loc2_:String = null; var _loc3_:MissionInfo = null; if(this.Current == null) { return; } if(!this.Current.missionInfo) { _loc3_ = this.Current.missionInfo = new MissionInfo(); } else { _loc3_ = this.Current.missionInfo; } _loc3_.id = param1.pkg.readInt(); _loc3_.name = param1.pkg.readUTF(); _loc3_.success = param1.pkg.readUTF(); _loc3_.failure = param1.pkg.readUTF(); _loc3_.description = param1.pkg.readUTF(); _loc2_ = param1.pkg.readUTF(); _loc3_.totalMissiton = param1.pkg.readInt(); _loc3_.missionIndex = param1.pkg.readInt(); _loc3_.totalValue1 = param1.pkg.readInt(); _loc3_.totalValue2 = param1.pkg.readInt(); _loc3_.totalValue3 = param1.pkg.readInt(); _loc3_.totalValue4 = param1.pkg.readInt(); _loc3_.nextMissionIndex = _loc3_.missionIndex + 1; _loc3_.parseString(_loc2_); _loc3_.tryagain = param1.pkg.readInt(); _loc3_.pic = param1.pkg.readUTF(); this.checkCanToLoader(); } private function checkCanToLoader() : void { if(this._recevieLoadSocket && this.Current && (this.Current.missionInfo || !this.getRoomTypeNeedMissionInfo(this.Current.roomType))) { dispatchEvent(new Event(START_LOAD)); StateManager.getInGame_Step_5 = true; this._recevieLoadSocket = false; } } private function getRoomTypeNeedMissionInfo(param1:int) : Boolean { return param1 == 2 || param1 == 3 || param1 == 4 || param1 == 5 || param1 == 8 || param1 == 10 || param1 == 11 || param1 == 14 || param1 == 17 || param1 == 20 || param1 == 21; } private function __loadprogress(param1:CrazyTankSocketEvent) : void { var _loc2_:int = 0; var _loc3_:int = 0; var _loc4_:int = 0; var _loc5_:RoomPlayer = null; if(this._current) { _loc2_ = param1.pkg.readInt(); _loc3_ = param1.pkg.readInt(); _loc4_ = param1.pkg.readInt(); _loc5_ = this._current.findRoomPlayer(_loc4_,_loc3_); if(_loc5_ && !_loc5_.isSelf) { _loc5_.progress = _loc2_; } } } private function __gameStart(param1:CrazyTankSocketEvent) : void { var _loc2_:PackageIn = null; var _loc3_:int = 0; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:Player = null; var _loc7_:int = 0; var _loc8_:int = 0; var _loc9_:int = 0; var _loc10_:int = 0; var _loc11_:int = 0; var _loc12_:int = 0; var _loc13_:Vector. = null; var _loc14_:int = 0; var _loc15_:Boolean = false; var _loc16_:Boolean = false; var _loc17_:Boolean = false; var _loc18_:Boolean = false; var _loc19_:int = 0; var _loc20_:Dictionary = null; var _loc21_:int = 0; var _loc22_:FightBuffInfo = null; var _loc23_:int = 0; var _loc24_:FightBuffInfo = null; var _loc25_:String = null; var _loc26_:String = null; this.TryAgain = -1; ExpTweenManager.Instance.deleteTweens(); if(this._current) { param1.executed = false; _loc2_ = param1.pkg; _loc3_ = _loc2_.readInt(); _loc4_ = 1; while(_loc4_ <= _loc3_) { _loc5_ = _loc2_.readInt(); _loc6_ = this._current.findPlayer(_loc5_); if(_loc6_ != null) { _loc6_.reset(); _loc6_.pos = new Point(_loc2_.readInt(),_loc2_.readInt()); _loc6_.energy = 1; _loc6_.direction = _loc2_.readInt(); _loc7_ = _loc2_.readInt(); _loc8_ = _loc2_.readInt(); _loc6_.team = _loc2_.readInt(); _loc9_ = _loc2_.readInt(); _loc6_.powerRatio = _loc2_.readInt(); _loc6_.dander = _loc2_.readInt(); _loc6_.maxBlood = _loc8_; _loc6_.updateBlood(_loc7_,0,0); _loc6_.currentWeapInfo.refineryLevel = _loc9_; _loc10_ = _loc2_.readInt(); _loc11_ = 0; while(_loc11_ < _loc10_) { _loc22_ = BuffManager.creatBuff(_loc2_.readInt()); _loc23_ = _loc2_.readInt(); if(_loc22_) { _loc22_.data = _loc23_; _loc6_.addBuff(_loc22_); } _loc11_++; } _loc12_ = _loc2_.readInt(); _loc13_ = new Vector.(); _loc14_ = 0; while(_loc14_ < _loc12_) { _loc24_ = BuffManager.creatBuff(_loc2_.readInt()); _loc6_.outTurnBuffs.push(_loc24_); _loc14_++; } _loc15_ = _loc2_.readBoolean(); _loc16_ = _loc2_.readBoolean(); _loc17_ = _loc2_.readBoolean(); _loc18_ = _loc2_.readBoolean(); _loc19_ = _loc2_.readInt(); _loc20_ = new Dictionary(); _loc21_ = 0; while(_loc21_ < _loc19_) { _loc25_ = _loc2_.readUTF(); _loc26_ = _loc2_.readUTF(); _loc20_[_loc25_] = _loc26_; _loc21_++; } _loc6_.isFrozen = _loc15_; _loc6_.isHidden = _loc16_; _loc6_.isNoNole = _loc17_; _loc6_.outProperty = _loc20_; if(RoomManager.Instance.current.type != 5 && _loc6_.playerInfo.currentPet) { _loc6_.currentPet = new Pet(_loc6_.playerInfo.currentPet); this.petResLoad(_loc6_.playerInfo.currentPet); } } _loc4_++; } _loc2_.readDate(); if(RoomManager.Instance.current.type == 5) { StateManager.setState(StateType.FIGHT_LIB_GAMEVIEW,this._current); if(PathManager.isStatistics) { WeakGuildManager.Instance.statistics(4,TimeManager.Instance.enterFightTime); } } else if(RoomManager.Instance.current.type == RoomInfo.FRESHMAN_ROOM) { StateManager.setState(StateType.TRAINER,this._current); if(PathManager.isStatistics) { WeakGuildManager.Instance.statistics(4,TimeManager.Instance.enterFightTime); } } else if(_loc3_ == 0) { if(RoomManager.Instance.current.type == RoomInfo.DUNGEON_ROOM) { StateManager.setState(StateType.DUNGEON_LIST); } else { StateManager.setState(StateType.ROOM_LIST); } } else { StateManager.setState(StateType.FIGHTING,this._current); this._current.IsOneOnOne = _loc3_ == 2; if(PathManager.isStatistics) { WeakGuildManager.Instance.statistics(4,TimeManager.Instance.enterFightTime); } } RoomManager.Instance.resetAllPlayerState(); } } private function petResLoad(param1:PetInfo) : void { var _loc2_:int = 0; var _loc3_:PetSkillTemplateInfo = null; var _loc4_:BallInfo = null; if(param1) { LoaderManager.Instance.creatAndStartLoad(PathManager.solvePetGameAssetUrl(param1.GameAssetUrl),BaseLoader.MODULE_LOADER); for each(_loc2_ in param1.equipdSkills) { if(_loc2_ > 0) { _loc3_ = PetSkillManager.getSkillByID(_loc2_); if(_loc3_.EffectPic) { LoaderManager.Instance.creatAndStartLoad(PathManager.solvePetSkillEffect(_loc3_.EffectPic),BaseLoader.MODULE_LOADER); } if(_loc3_.NewBallID != -1) { _loc4_ = BallManager.findBall(_loc3_.NewBallID); _loc4_.loadBombAsset(); _loc4_.loadCraterBitmap(); } } } } } private function __missionAllOver(param1:CrazyTankSocketEvent) : void { var _loc4_:int = 0; var _loc7_:Object = null; var _loc8_:int = 0; var _loc9_:Player = null; var _loc10_:SelfInfo = null; var _loc2_:PackageIn = param1.pkg; var _loc3_:int = _loc2_.readInt(); if(this._current == null) { return; } while(_loc4_ < _loc3_) { _loc8_ = _loc2_.readInt(); _loc9_ = this._current.findPlayerByPlayerID(_loc8_); if(_loc9_.expObj) { _loc7_ = _loc9_.expObj; } else { _loc7_ = new Object(); } if(_loc9_) { _loc7_.killGP = _loc2_.readInt(); _loc7_.hertGP = _loc2_.readInt(); _loc7_.fightGP = _loc2_.readInt(); _loc7_.ghostGP = _loc2_.readInt(); _loc7_.gpForVIP = _loc2_.readInt(); _loc7_.gpForSpouse = _loc2_.readInt(); _loc7_.gpForServer = _loc2_.readInt(); _loc7_.gpForApprenticeOnline = _loc2_.readInt(); _loc7_.gpForApprenticeTeam = _loc2_.readInt(); _loc7_.gpForDoubleCard = _loc2_.readInt(); _loc7_.consortiaSkill = _loc2_.readInt(); _loc7_.luckyExp = _loc2_.readInt(); _loc7_.gainGP = _loc2_.readInt(); _loc9_.isWin = _loc2_.readBoolean(); _loc9_.expObj = _loc7_; } _loc4_++; } if(PathManager.solveExternalInterfaceEnabel() && this._current.selfGamePlayer.isWin) { _loc10_ = PlayerManager.Instance.Self; } this._current.missionInfo.missionOverNPCMovies = []; var _loc5_:int = _loc2_.readInt(); var _loc6_:int = 0; while(_loc6_ < _loc5_) { this._current.missionInfo.missionOverNPCMovies.push(_loc2_.readUTF()); _loc6_++; } } private function __takeOut(param1:CrazyTankSocketEvent) : void { if(this._current) { this._current.resultCard.push(param1); } } private function __showAllCard(param1:CrazyTankSocketEvent) : void { if(this._current) { this._current.showAllCard.push(param1); } } public function reset() : void { if(this._current) { this._current.dispose(); this._current = null; } } public function startLoading() : void { StateManager.setState(StateType.GAME_LOADING); } public function dispatchEnterRoom() : void { dispatchEvent(new Event(ENTER_ROOM)); } public function dispatchLeaveMission() : void { dispatchEvent(new Event(LEAVE_MISSION)); } public function dispatchPaymentConfirm() : void { dispatchEvent(new Event(PLAYER_CLICK_PAY)); } public function selfGetItemShowAndSound(param1:Dictionary) : Boolean { var _loc3_:InventoryItemInfo = null; var _loc4_:ChatData = null; var _loc5_:String = null; var _loc6_:Array = null; var _loc7_:String = null; var _loc2_:Boolean = false; for each(_loc3_ in param1) { _loc4_ = new ChatData(); _loc4_.channel = ChatInputView.SYS_NOTICE; _loc5_ = LanguageMgr.GetTranslation(""tank.data.player.FightingPlayerInfo.your""); _loc6_ = ChatFormats.getTagsByChannel(_loc4_.channel); _loc7_ = ChatFormats.creatGoodTag(""["" + _loc3_.Name + ""]"",ChatFormats.CLICK_GOODS,_loc3_.TemplateID,_loc3_.Quality,_loc3_.IsBinds,_loc4_); _loc4_.htmlMessage = _loc6_[0] + _loc5_ + _loc7_ + _loc6_[1] + ""
""; ChatManager.Instance.chat(_loc4_,false); if(_loc3_.Quality >= 3) { _loc2_ = true; } } return _loc2_; } public function isIdenticalGame(param1:int = 0) : Boolean { var _loc4_:RoomPlayer = null; var _loc2_:DictionaryData = RoomManager.Instance.current.players; var _loc3_:SelfInfo = PlayerManager.Instance.Self; if(param1 == _loc3_.ID) { return false; } for each(_loc4_ in _loc2_) { if(_loc4_.playerInfo.ID == param1 && _loc4_.playerInfo.ZoneID == _loc3_.ZoneID) { return true; } } return false; } private function __loadResource(param1:CrazyTankSocketEvent) : void { var _loc4_:GameNeedMovieInfo = null; this.setLoaderStop(); var _loc2_:int = param1.pkg.readInt(); var _loc3_:int = 0; while(_loc3_ < _loc2_) { _loc4_ = new GameNeedMovieInfo(); _loc4_.type = param1.pkg.readInt(); _loc4_.path = param1.pkg.readUTF(); _loc4_.classPath = param1.pkg.readUTF(); _loc4_.startLoad(); _loc3_++; } } private function setLoaderStop() : void { var _loc1_:int = this._loaderArray.length; var _loc2_:int = 0; while(_loc2_ < _loc1_) { if(!(this._loaderArray[_loc2_] as BaseLoader).isComplete) { (this._loaderArray[_loc2_] as BaseLoader).unload(); } _loc2_++; } this._loaderArray.length = 0; } public function get numCreater() : BloodNumberCreater { if(this._numCreater) { return this._numCreater; } this._numCreater = new BloodNumberCreater(); return this._numCreater; } public function disposeNumCreater() : void { if(this._numCreater) { this._numCreater.dispose(); } this._numCreater = null; } public function get gameView() : GameView { return this._gameView; } public function set gameView(param1:GameView) : void { this._gameView = param1; } public function get addLivingEvtVec() : Vector. { return this._addLivingEvtVec; } public function get setPropertyEvtVec() : Vector. { return this._setPropertyEvtVec; } public function get livingFallingEvtVec() : Vector. { return this._livingFallingEvtVec; } public function get livingShowBloodEvtVec() : Vector. { return this._livingShowBloodEvtVec; } public function get addMapThingEvtVec() : Vector. { return this._addMapThingEvtVec; } public function get livingActionMappingEvtVec() : Vector. { return this._livingActionMappingEvtVec; } public function get updatePhysicObjectEvtVec() : Vector. { return this._updatePhysicObjectEvtVec; } public function get playerBloodEvtVec() : Vector. { return this._playerBloodEvtVec; } } } ",12188,True,2571.2579837392245,median "package org.flemit.util { import flash.errors.IllegalOperationError; import flash.utils.getQualifiedClassName; public class ClassUtility { public static function assertAbstract(instance : Object, cls : Class) : void { var instanceName : String = getQualifiedClassName(instance); var className : String = getQualifiedClassName(cls); if (instanceName == className) { throw new IllegalOperationError(""Cannot create instance of abstract class '"" + className + ""'""); } } public static function isMatch(packageString : String, cls : *) : Boolean { var classString : String = null; if (cls is String) classString = cls as String; else classString = getQualifiedClassName(cls); classString = classString.replace('::','.'); classString = classString.replace(':','.'); var packageParts : Array = packageString.split('.'); var classParts : Array = classString.split('.'); for (var i:uint=0; i MAX_CREATECLASS_ARG_COUNT) { throw new ArgumentError(""Argument count greater than supported (10)""); } var delegate : Function = _createClassDelegates[args.length]; return delegate.apply(null, delegateArgs); } private static function createClass0(cls : Class) : Object { return new cls(); } private static function createClass1(cls : Class, p1 : *) : Object { return new cls(p1); } private static function createClass2(cls : Class, p1 : *, p2 : *) : Object { return new cls(p1, p2); } private static function createClass3(cls : Class, p1 : *, p2 : *, p3 : *) : Object { return new cls(p1, p2, p3); } private static function createClass4(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *) : Object { return new cls(p1, p2, p3, p4); } private static function createClass5(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *) : Object { return new cls(p1, p2, p3, p4, p5); } private static function createClass6(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6); } private static function createClass7(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7); } private static function createClass8(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8); } private static function createClass9(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9); } private static function createClass10(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); } private static function createClass11(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); } private static function createClass12(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); } private static function createClass13(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); } private static function createClass14(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); } private static function createClass15(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); } private static function createClass16(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16); } private static function createClass17(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17); } private static function createClass18(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18); } private static function createClass19(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19); } private static function createClass20(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20); } private static function createClass21(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21); } private static function createClass22(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22); } private static function createClass23(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23); } private static function createClass24(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24); } private static function createClass25(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25); } private static function createClass26(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26); } private static function createClass27(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27); } private static function createClass28(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28); } private static function createClass29(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29); } private static function createClass30(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30); } private static function createClass31(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31); } private static function createClass32(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32); } private static function createClass33(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33); } private static function createClass34(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34); } private static function createClass35(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35); } private static function createClass36(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36); } private static function createClass37(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37); } private static function createClass38(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38); } private static function createClass39(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39); } private static function createClass40(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40); } private static function createClass41(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41); } private static function createClass42(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42); } private static function createClass43(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43); } private static function createClass44(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44); } private static function createClass45(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *, p45 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45); } private static function createClass46(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *, p45 : *, p46 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46); } private static function createClass47(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *, p45 : *, p46 : *, p47 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47); } private static function createClass48(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *, p45 : *, p46 : *, p47 : *, p48 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48); } private static function createClass49(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *, p45 : *, p46 : *, p47 : *, p48 : *, p49 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49); } private static function createClass50(cls : Class, p1 : *, p2 : *, p3 : *, p4 : *, p5 : *, p6 : *, p7 : *, p8 : *, p9 : *, p10 : *, p11 : *, p12 : *, p13 : *, p14 : *, p15 : *, p16 : *, p17 : *, p18 : *, p19 : *, p20 : *, p21 : *, p22 : *, p23 : *, p24 : *, p25 : *, p26 : *, p27 : *, p28 : *, p29 : *, p30 : *, p31 : *, p32 : *, p33 : *, p34 : *, p35 : *, p36 : *, p37 : *, p38 : *, p39 : *, p40 : *, p41 : *, p42 : *, p43 : *, p44 : *, p45 : *, p46 : *, p47 : *, p48 : *, p49 : *, p50 : *) : Object { return new cls(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50); } public static const MAX_CREATECLASS_ARG_COUNT : uint = 50; private static var _createClassDelegates : Array = [ createClass0, createClass1, createClass2, createClass3, createClass4, createClass5, createClass6, createClass7, createClass8, createClass9, createClass10, createClass11, createClass12, createClass13, createClass14, createClass15, createClass16, createClass17, createClass18, createClass19, createClass20, createClass21, createClass22, createClass23, createClass24, createClass25, createClass26, createClass27, createClass28, createClass29, createClass30, createClass31, createClass32, createClass33, createClass34, createClass35, createClass36, createClass37, createClass38, createClass39, createClass40, createClass41, createClass42, createClass43, createClass44, createClass45, createClass46, createClass47, createClass48, createClass49, createClass50 ]; } }",12299,True,4755.9191979488305,median "pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_stdinc_h; with Interfaces.C.Strings; limited with SDL_joystick_h; package SDL_haptic_h is SDL_HAPTIC_CONSTANT : constant := (2**0); -- ..\\SDL2_tmp\\SDL_haptic.h:163 SDL_HAPTIC_SINE : constant := (2**1); -- ..\\SDL2_tmp\\SDL_haptic.h:172 SDL_HAPTIC_LEFTRIGHT : constant := (2**2); -- ..\\SDL2_tmp\\SDL_haptic.h:183 SDL_HAPTIC_TRIANGLE : constant := (2**3); -- ..\\SDL2_tmp\\SDL_haptic.h:195 SDL_HAPTIC_SAWTOOTHUP : constant := (2**4); -- ..\\SDL2_tmp\\SDL_haptic.h:204 SDL_HAPTIC_SAWTOOTHDOWN : constant := (2**5); -- ..\\SDL2_tmp\\SDL_haptic.h:213 SDL_HAPTIC_RAMP : constant := (2**6); -- ..\\SDL2_tmp\\SDL_haptic.h:222 SDL_HAPTIC_SPRING : constant := (2**7); -- ..\\SDL2_tmp\\SDL_haptic.h:232 SDL_HAPTIC_DAMPER : constant := (2**8); -- ..\\SDL2_tmp\\SDL_haptic.h:242 SDL_HAPTIC_INERTIA : constant := (2**9); -- ..\\SDL2_tmp\\SDL_haptic.h:252 SDL_HAPTIC_FRICTION : constant := (2**10); -- ..\\SDL2_tmp\\SDL_haptic.h:262 SDL_HAPTIC_CUSTOM : constant := (2**11); -- ..\\SDL2_tmp\\SDL_haptic.h:269 SDL_HAPTIC_GAIN : constant := (2**12); -- ..\\SDL2_tmp\\SDL_haptic.h:282 SDL_HAPTIC_AUTOCENTER : constant := (2**13); -- ..\\SDL2_tmp\\SDL_haptic.h:291 SDL_HAPTIC_STATUS : constant := (2**14); -- ..\\SDL2_tmp\\SDL_haptic.h:300 SDL_HAPTIC_PAUSE : constant := (2**15); -- ..\\SDL2_tmp\\SDL_haptic.h:310 SDL_HAPTIC_POLAR : constant := 0; -- ..\\SDL2_tmp\\SDL_haptic.h:323 SDL_HAPTIC_CARTESIAN : constant := 1; -- ..\\SDL2_tmp\\SDL_haptic.h:330 SDL_HAPTIC_SPHERICAL : constant := 2; -- ..\\SDL2_tmp\\SDL_haptic.h:337 SDL_HAPTIC_INFINITY : constant := 4294967295; -- ..\\SDL2_tmp\\SDL_haptic.h:352 -- Simple DirectMedia Layer -- Copyright (C) 1997-2018 Sam Lantinga -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. -- --* -- * \\file SDL_haptic.h -- * -- * \\brief The SDL haptic subsystem allows you to control haptic (force feedback) -- * devices. -- * -- * The basic usage is as follows: -- * - Initialize the subsystem (::SDL_INIT_HAPTIC). -- * - Open a haptic device. -- * - SDL_HapticOpen() to open from index. -- * - SDL_HapticOpenFromJoystick() to open from an existing joystick. -- * - Create an effect (::SDL_HapticEffect). -- * - Upload the effect with SDL_HapticNewEffect(). -- * - Run the effect with SDL_HapticRunEffect(). -- * - (optional) Free the effect with SDL_HapticDestroyEffect(). -- * - Close the haptic device with SDL_HapticClose(). -- * -- * \\par Simple rumble example: -- * \\code -- * SDL_Haptic *haptic; -- * -- * // Open the device -- * haptic = SDL_HapticOpen( 0 ); -- * if (haptic == NULL) -- * return -1; -- * -- * // Initialize simple rumble -- * if (SDL_HapticRumbleInit( haptic ) != 0) -- * return -1; -- * -- * // Play effect at 50% strength for 2 seconds -- * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) -- * return -1; -- * SDL_Delay( 2000 ); -- * -- * // Clean up -- * SDL_HapticClose( haptic ); -- * \\endcode -- * -- * \\par Complete example: -- * \\code -- * int test_haptic( SDL_Joystick * joystick ) { -- * SDL_Haptic *haptic; -- * SDL_HapticEffect effect; -- * int effect_id; -- * -- * // Open the device -- * haptic = SDL_HapticOpenFromJoystick( joystick ); -- * if (haptic == NULL) return -1; // Most likely joystick isn't haptic -- * -- * // See if it can do sine waves -- * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) { -- * SDL_HapticClose(haptic); // No sine effect -- * return -1; -- * } -- * -- * // Create the effect -- * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default -- * effect.type = SDL_HAPTIC_SINE; -- * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates -- * effect.periodic.direction.dir[0] = 18000; // Force comes from south -- * effect.periodic.period = 1000; // 1000 ms -- * effect.periodic.magnitude = 20000; // 20000/32767 strength -- * effect.periodic.length = 5000; // 5 seconds long -- * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength -- * effect.periodic.fade_length = 1000; // Takes 1 second to fade away -- * -- * // Upload the effect -- * effect_id = SDL_HapticNewEffect( haptic, &effect ); -- * -- * // Test the effect -- * SDL_HapticRunEffect( haptic, effect_id, 1 ); -- * SDL_Delay( 5000); // Wait for the effect to finish -- * -- * // We destroy the effect, although closing the device also does this -- * SDL_HapticDestroyEffect( haptic, effect_id ); -- * -- * // Close the device -- * SDL_HapticClose(haptic); -- * -- * return 0; // Success -- * } -- * \\endcode -- -- Set up for C function definitions, even when using C++ -- FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF). -- * -- * At the moment the magnitude variables are mixed between signed/unsigned, and -- * it is also not made clear that ALL of those variables expect a max of 0x7FFF. -- * -- * Some platforms may have higher precision than that (Linux FF, Windows XInput) -- * so we should fix the inconsistency in favor of higher possible precision, -- * adjusting for platforms that use different scales. -- * -flibit -- --* -- * \\typedef SDL_Haptic -- * -- * \\brief The haptic structure used to identify an SDL haptic. -- * -- * \\sa SDL_HapticOpen -- * \\sa SDL_HapticOpenFromJoystick -- * \\sa SDL_HapticClose -- type u_SDL_Haptic is null record; -- incomplete struct subtype SDL_Haptic is u_SDL_Haptic; -- ..\\SDL2_tmp\\SDL_haptic.h:141 --* -- * \\name Haptic features -- * -- * Different haptic features a device can have. -- -- @{ --* -- * \\name Haptic effects -- -- @{ --* -- * \\brief Constant effect supported. -- * -- * Constant haptic effect. -- * -- * \\sa SDL_HapticCondition -- --* -- * \\brief Sine wave effect supported. -- * -- * Periodic haptic effect that simulates sine waves. -- * -- * \\sa SDL_HapticPeriodic -- --* -- * \\brief Left/Right effect supported. -- * -- * Haptic effect for direct control over high/low frequency motors. -- * -- * \\sa SDL_HapticLeftRight -- * \\warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry, -- * we ran out of bits, and this is important for XInput devices. -- -- !!! FIXME: put this back when we have more bits in 2.1 -- #define SDL_HAPTIC_SQUARE (1<<2) --* -- * \\brief Triangle wave effect supported. -- * -- * Periodic haptic effect that simulates triangular waves. -- * -- * \\sa SDL_HapticPeriodic -- --* -- * \\brief Sawtoothup wave effect supported. -- * -- * Periodic haptic effect that simulates saw tooth up waves. -- * -- * \\sa SDL_HapticPeriodic -- --* -- * \\brief Sawtoothdown wave effect supported. -- * -- * Periodic haptic effect that simulates saw tooth down waves. -- * -- * \\sa SDL_HapticPeriodic -- --* -- * \\brief Ramp effect supported. -- * -- * Ramp haptic effect. -- * -- * \\sa SDL_HapticRamp -- --* -- * \\brief Spring effect supported - uses axes position. -- * -- * Condition haptic effect that simulates a spring. Effect is based on the -- * axes position. -- * -- * \\sa SDL_HapticCondition -- --* -- * \\brief Damper effect supported - uses axes velocity. -- * -- * Condition haptic effect that simulates dampening. Effect is based on the -- * axes velocity. -- * -- * \\sa SDL_HapticCondition -- --* -- * \\brief Inertia effect supported - uses axes acceleration. -- * -- * Condition haptic effect that simulates inertia. Effect is based on the axes -- * acceleration. -- * -- * \\sa SDL_HapticCondition -- --* -- * \\brief Friction effect supported - uses axes movement. -- * -- * Condition haptic effect that simulates friction. Effect is based on the -- * axes movement. -- * -- * \\sa SDL_HapticCondition -- --* -- * \\brief Custom effect is supported. -- * -- * User defined custom haptic effect. -- -- @} -- Haptic effects -- These last few are features the device has, not effects --* -- * \\brief Device can set global gain. -- * -- * Device supports setting the global gain. -- * -- * \\sa SDL_HapticSetGain -- --* -- * \\brief Device can set autocenter. -- * -- * Device supports setting autocenter. -- * -- * \\sa SDL_HapticSetAutocenter -- --* -- * \\brief Device can be queried for effect status. -- * -- * Device supports querying effect status. -- * -- * \\sa SDL_HapticGetEffectStatus -- --* -- * \\brief Device can be paused. -- * -- * Devices supports being paused. -- * -- * \\sa SDL_HapticPause -- * \\sa SDL_HapticUnpause -- --* -- * \\name Direction encodings -- -- @{ --* -- * \\brief Uses polar coordinates for the direction. -- * -- * \\sa SDL_HapticDirection -- --* -- * \\brief Uses cartesian coordinates for the direction. -- * -- * \\sa SDL_HapticDirection -- --* -- * \\brief Uses spherical coordinates for the direction. -- * -- * \\sa SDL_HapticDirection -- -- @} -- Direction encodings -- @} -- Haptic features -- * Misc defines. -- --* -- * \\brief Used to play a device an infinite number of times. -- * -- * \\sa SDL_HapticRunEffect -- --* -- * \\brief Structure that represents a haptic direction. -- * -- * This is the direction where the force comes from, -- * instead of the direction in which the force is exerted. -- * -- * Directions can be specified by: -- * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. -- * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. -- * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. -- * -- * Cardinal directions of the haptic device are relative to the positioning -- * of the device. North is considered to be away from the user. -- * -- * The following diagram represents the cardinal directions: -- * \\verbatim -- .--. -- |__| .-------. -- |=.| |.-----.| -- |--| || || -- | | |'-----'| -- |__|~')_____(' -- [ COMPUTER ] -- North (0,-1) -- ^ -- | -- | -- (-1,0) West <----[ HAPTIC ]----> East (1,0) -- | -- | -- v -- South (0,1) -- [ USER ] -- \\|||/ -- (o o) -- ---ooO-(_)-Ooo--- -- \\endverbatim -- * -- * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a -- * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses -- * the first \\c dir parameter. The cardinal directions would be: -- * - North: 0 (0 degrees) -- * - East: 9000 (90 degrees) -- * - South: 18000 (180 degrees) -- * - West: 27000 (270 degrees) -- * -- * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions -- * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses -- * the first three \\c dir parameters. The cardinal directions would be: -- * - North: 0,-1, 0 -- * - East: 1, 0, 0 -- * - South: 0, 1, 0 -- * - West: -1, 0, 0 -- * -- * The Z axis represents the height of the effect if supported, otherwise -- * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you -- * can use any multiple you want, only the direction matters. -- * -- * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. -- * The first two \\c dir parameters are used. The \\c dir parameters are as -- * follows (all values are in hundredths of degrees): -- * - Degrees from (1, 0) rotated towards (0, 1). -- * - Degrees towards (0, 0, 1) (device needs at least 3 axes). -- * -- * -- * Example of force coming from the south with all encodings (force coming -- * from the south means the user will have to pull the stick to counteract): -- * \\code -- * SDL_HapticDirection direction; -- * -- * // Cartesian directions -- * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. -- * direction.dir[0] = 0; // X position -- * direction.dir[1] = 1; // Y position -- * // Assuming the device has 2 axes, we don't need to specify third parameter. -- * -- * // Polar directions -- * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. -- * direction.dir[0] = 18000; // Polar only uses first parameter -- * -- * // Spherical coordinates -- * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding -- * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. -- * \\endcode -- * -- * \\sa SDL_HAPTIC_POLAR -- * \\sa SDL_HAPTIC_CARTESIAN -- * \\sa SDL_HAPTIC_SPHERICAL -- * \\sa SDL_HapticEffect -- * \\sa SDL_HapticNumAxes -- --*< The type of encoding. type SDL_HapticDirection_dir_array is array (0 .. 2) of aliased SDL_stdinc_h.Sint32; type SDL_HapticDirection is record c_type : aliased SDL_stdinc_h.Uint8; -- ..\\SDL2_tmp\\SDL_haptic.h:452 dir : aliased SDL_HapticDirection_dir_array; -- ..\\SDL2_tmp\\SDL_haptic.h:453 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticDirection); -- ..\\SDL2_tmp\\SDL_haptic.h:450 --*< The encoded direction. --* -- * \\brief A structure containing a template for a Constant effect. -- * -- * This struct is exclusively for the ::SDL_HAPTIC_CONSTANT effect. -- * -- * A constant effect applies a constant force in the specified direction -- * to the joystick. -- * -- * \\sa SDL_HAPTIC_CONSTANT -- * \\sa SDL_HapticEffect -- -- Header --*< ::SDL_HAPTIC_CONSTANT type SDL_HapticConstant is record c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:471 direction : aliased SDL_HapticDirection; -- ..\\SDL2_tmp\\SDL_haptic.h:472 length : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_haptic.h:475 c_delay : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:476 button : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:479 interval : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:480 level : aliased SDL_stdinc_h.Sint16; -- ..\\SDL2_tmp\\SDL_haptic.h:483 attack_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:486 attack_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:487 fade_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:488 fade_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:489 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticConstant); -- ..\\SDL2_tmp\\SDL_haptic.h:468 --*< Direction of the effect. -- Replay --*< Duration of the effect. --*< Delay before starting the effect. -- Trigger --*< Button that triggers the effect. --*< How soon it can be triggered again after button. -- Constant --*< Strength of the constant effect. -- Envelope --*< Duration of the attack. --*< Level at the start of the attack. --*< Duration of the fade. --*< Level at the end of the fade. --* -- * \\brief A structure containing a template for a Periodic effect. -- * -- * The struct handles the following effects: -- * - ::SDL_HAPTIC_SINE -- * - ::SDL_HAPTIC_LEFTRIGHT -- * - ::SDL_HAPTIC_TRIANGLE -- * - ::SDL_HAPTIC_SAWTOOTHUP -- * - ::SDL_HAPTIC_SAWTOOTHDOWN -- * -- * A periodic effect consists in a wave-shaped effect that repeats itself -- * over time. The type determines the shape of the wave and the parameters -- * determine the dimensions of the wave. -- * -- * Phase is given by hundredth of a degree meaning that giving the phase a value -- * of 9000 will displace it 25% of its period. Here are sample values: -- * - 0: No phase displacement. -- * - 9000: Displaced 25% of its period. -- * - 18000: Displaced 50% of its period. -- * - 27000: Displaced 75% of its period. -- * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. -- * -- * Examples: -- * \\verbatim -- SDL_HAPTIC_SINE -- __ __ __ __ -- / \\ / \\ / \\ / -- / \\__/ \\__/ \\__/ -- SDL_HAPTIC_SQUARE -- __ __ __ __ __ -- | | | | | | | | | | -- | |__| |__| |__| |__| | -- SDL_HAPTIC_TRIANGLE -- /\\ /\\ /\\ /\\ / / \\ / \\ / \\ / \\ / --/ -- / \\/ \\/ \\/ \\/ -- SDL_HAPTIC_SAWTOOTHUP -- /| /| /| /| /| /| /| -- / | / | / | / | / | / | / | -- / |/ |/ |/ |/ |/ |/ | -- SDL_HAPTIC_SAWTOOTHDOWN -- \\ |\\ |\\ |\\ |\\ |\\ |\\ | -- \\ | \\ | \\ | \\ | \\ | \\ | \\ | -- \\| \\| \\| \\| \\| \\| \\| -- \\endverbatim -- * -- * \\sa SDL_HAPTIC_SINE -- * \\sa SDL_HAPTIC_LEFTRIGHT -- * \\sa SDL_HAPTIC_TRIANGLE -- * \\sa SDL_HAPTIC_SAWTOOTHUP -- * \\sa SDL_HAPTIC_SAWTOOTHDOWN -- * \\sa SDL_HapticEffect -- -- Header --*< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, -- ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or -- ::SDL_HAPTIC_SAWTOOTHDOWN type SDL_HapticPeriodic is record c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:552 direction : aliased SDL_HapticDirection; -- ..\\SDL2_tmp\\SDL_haptic.h:555 length : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_haptic.h:558 c_delay : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:559 button : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:562 interval : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:563 period : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:566 magnitude : aliased SDL_stdinc_h.Sint16; -- ..\\SDL2_tmp\\SDL_haptic.h:567 offset : aliased SDL_stdinc_h.Sint16; -- ..\\SDL2_tmp\\SDL_haptic.h:568 phase : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:569 attack_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:572 attack_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:573 fade_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:574 fade_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:575 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticPeriodic); -- ..\\SDL2_tmp\\SDL_haptic.h:549 --*< Direction of the effect. -- Replay --*< Duration of the effect. --*< Delay before starting the effect. -- Trigger --*< Button that triggers the effect. --*< How soon it can be triggered again after button. -- Periodic --*< Period of the wave. --*< Peak value; if negative, equivalent to 180 degrees extra phase shift. --*< Mean value of the wave. --*< Positive phase shift given by hundredth of a degree. -- Envelope --*< Duration of the attack. --*< Level at the start of the attack. --*< Duration of the fade. --*< Level at the end of the fade. --* -- * \\brief A structure containing a template for a Condition effect. -- * -- * The struct handles the following effects: -- * - ::SDL_HAPTIC_SPRING: Effect based on axes position. -- * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. -- * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. -- * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. -- * -- * Direction is handled by condition internals instead of a direction member. -- * The condition effect specific members have three parameters. The first -- * refers to the X axis, the second refers to the Y axis and the third -- * refers to the Z axis. The right terms refer to the positive side of the -- * axis and the left terms refer to the negative side of the axis. Please -- * refer to the ::SDL_HapticDirection diagram for which side is positive and -- * which is negative. -- * -- * \\sa SDL_HapticDirection -- * \\sa SDL_HAPTIC_SPRING -- * \\sa SDL_HAPTIC_DAMPER -- * \\sa SDL_HAPTIC_INERTIA -- * \\sa SDL_HAPTIC_FRICTION -- * \\sa SDL_HapticEffect -- -- Header --*< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER, -- ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION type SDL_HapticCondition_right_sat_array is array (0 .. 2) of aliased SDL_stdinc_h.Uint16; type SDL_HapticCondition_left_sat_array is array (0 .. 2) of aliased SDL_stdinc_h.Uint16; type SDL_HapticCondition_right_coeff_array is array (0 .. 2) of aliased SDL_stdinc_h.Sint16; type SDL_HapticCondition_left_coeff_array is array (0 .. 2) of aliased SDL_stdinc_h.Sint16; type SDL_HapticCondition_deadband_array is array (0 .. 2) of aliased SDL_stdinc_h.Uint16; type SDL_HapticCondition_center_array is array (0 .. 2) of aliased SDL_stdinc_h.Sint16; type SDL_HapticCondition is record c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:605 direction : aliased SDL_HapticDirection; -- ..\\SDL2_tmp\\SDL_haptic.h:607 length : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_haptic.h:610 c_delay : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:611 button : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:614 interval : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:615 right_sat : aliased SDL_HapticCondition_right_sat_array; -- ..\\SDL2_tmp\\SDL_haptic.h:618 left_sat : aliased SDL_HapticCondition_left_sat_array; -- ..\\SDL2_tmp\\SDL_haptic.h:619 right_coeff : aliased SDL_HapticCondition_right_coeff_array; -- ..\\SDL2_tmp\\SDL_haptic.h:620 left_coeff : aliased SDL_HapticCondition_left_coeff_array; -- ..\\SDL2_tmp\\SDL_haptic.h:621 deadband : aliased SDL_HapticCondition_deadband_array; -- ..\\SDL2_tmp\\SDL_haptic.h:622 center : aliased SDL_HapticCondition_center_array; -- ..\\SDL2_tmp\\SDL_haptic.h:623 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticCondition); -- ..\\SDL2_tmp\\SDL_haptic.h:602 --*< Direction of the effect - Not used ATM. -- Replay --*< Duration of the effect. --*< Delay before starting the effect. -- Trigger --*< Button that triggers the effect. --*< How soon it can be triggered again after button. -- Condition --*< Level when joystick is to the positive side; max 0xFFFF. --*< Level when joystick is to the negative side; max 0xFFFF. --*< How fast to increase the force towards the positive side. --*< How fast to increase the force towards the negative side. --*< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. --*< Position of the dead zone. --* -- * \\brief A structure containing a template for a Ramp effect. -- * -- * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. -- * -- * The ramp effect starts at start strength and ends at end strength. -- * It augments in linear fashion. If you use attack and fade with a ramp -- * the effects get added to the ramp effect making the effect become -- * quadratic instead of linear. -- * -- * \\sa SDL_HAPTIC_RAMP -- * \\sa SDL_HapticEffect -- -- Header --*< ::SDL_HAPTIC_RAMP type SDL_HapticRamp is record c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:642 direction : aliased SDL_HapticDirection; -- ..\\SDL2_tmp\\SDL_haptic.h:643 length : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_haptic.h:646 c_delay : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:647 button : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:650 interval : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:651 start : aliased SDL_stdinc_h.Sint16; -- ..\\SDL2_tmp\\SDL_haptic.h:654 c_end : aliased SDL_stdinc_h.Sint16; -- ..\\SDL2_tmp\\SDL_haptic.h:655 attack_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:658 attack_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:659 fade_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:660 fade_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:661 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticRamp); -- ..\\SDL2_tmp\\SDL_haptic.h:639 --*< Direction of the effect. -- Replay --*< Duration of the effect. --*< Delay before starting the effect. -- Trigger --*< Button that triggers the effect. --*< How soon it can be triggered again after button. -- Ramp --*< Beginning strength level. --*< Ending strength level. -- Envelope --*< Duration of the attack. --*< Level at the start of the attack. --*< Duration of the fade. --*< Level at the end of the fade. --* -- * \\brief A structure containing a template for a Left/Right effect. -- * -- * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. -- * -- * The Left/Right effect is used to explicitly control the large and small -- * motors, commonly found in modern game controllers. The small (right) motor -- * is high frequency, and the large (left) motor is low frequency. -- * -- * \\sa SDL_HAPTIC_LEFTRIGHT -- * \\sa SDL_HapticEffect -- -- Header --*< ::SDL_HAPTIC_LEFTRIGHT type SDL_HapticLeftRight is record c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:679 length : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_haptic.h:682 large_magnitude : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:685 small_magnitude : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:686 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticLeftRight); -- ..\\SDL2_tmp\\SDL_haptic.h:676 -- Replay --*< Duration of the effect in milliseconds. -- Rumble --*< Control of the large controller motor. --*< Control of the small controller motor. --* -- * \\brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. -- * -- * This struct is exclusively for the ::SDL_HAPTIC_CUSTOM effect. -- * -- * A custom force feedback effect is much like a periodic effect, where the -- * application can define its exact shape. You will have to allocate the -- * data yourself. Data should consist of channels * samples Uint16 samples. -- * -- * If channels is one, the effect is rotated using the defined direction. -- * Otherwise it uses the samples in data for the different axes. -- * -- * \\sa SDL_HAPTIC_CUSTOM -- * \\sa SDL_HapticEffect -- -- Header --*< ::SDL_HAPTIC_CUSTOM type SDL_HapticCustom is record c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:707 direction : aliased SDL_HapticDirection; -- ..\\SDL2_tmp\\SDL_haptic.h:708 length : aliased SDL_stdinc_h.Uint32; -- ..\\SDL2_tmp\\SDL_haptic.h:711 c_delay : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:712 button : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:715 interval : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:716 channels : aliased SDL_stdinc_h.Uint8; -- ..\\SDL2_tmp\\SDL_haptic.h:719 period : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:720 samples : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:721 data : access SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:722 attack_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:725 attack_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:726 fade_length : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:727 fade_level : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:728 end record; pragma Convention (C_Pass_By_Copy, SDL_HapticCustom); -- ..\\SDL2_tmp\\SDL_haptic.h:704 --*< Direction of the effect. -- Replay --*< Duration of the effect. --*< Delay before starting the effect. -- Trigger --*< Button that triggers the effect. --*< How soon it can be triggered again after button. -- Custom --*< Axes to use, minimum of one. --*< Sample periods. --*< Amount of samples. --*< Should contain channels*samples items. -- Envelope --*< Duration of the attack. --*< Level at the start of the attack. --*< Duration of the fade. --*< Level at the end of the fade. --* -- * \\brief The generic template for any haptic effect. -- * -- * All values max at 32767 (0x7FFF). Signed values also can be negative. -- * Time values unless specified otherwise are in milliseconds. -- * -- * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 -- * value. Neither delay, interval, attack_length nor fade_length support -- * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. -- * -- * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of -- * ::SDL_HAPTIC_INFINITY. -- * -- * Button triggers may not be supported on all devices, it is advised to not -- * use them if possible. Buttons start at index 1 instead of index 0 like -- * the joystick. -- * -- * If both attack_length and fade_level are 0, the envelope is not used, -- * otherwise both values are used. -- * -- * Common parts: -- * \\code -- * // Replay - All effects have this -- * Uint32 length; // Duration of effect (ms). -- * Uint16 delay; // Delay before starting effect. -- * -- * // Trigger - All effects have this -- * Uint16 button; // Button that triggers effect. -- * Uint16 interval; // How soon before effect can be triggered again. -- * -- * // Envelope - All effects except condition effects have this -- * Uint16 attack_length; // Duration of the attack (ms). -- * Uint16 attack_level; // Level at the start of the attack. -- * Uint16 fade_length; // Duration of the fade out (ms). -- * Uint16 fade_level; // Level at the end of the fade. -- * \\endcode -- * -- * -- * Here we have an example of a constant effect evolution in time: -- * \\verbatim -- Strength -- ^ -- | -- | effect level --> _________________ -- | / | / | / | / | attack_level --> | | | | <--- fade_level --ade_level -- | -- +--------------------------------------------------> Time -- [--] [---] -- attack_length fade_length -- [------------------][-----------------------] -- delay length -- \\endverbatim -- * -- * Note either the attack_level or the fade_level may be above the actual -- * effect level. -- * -- * \\sa SDL_HapticConstant -- * \\sa SDL_HapticPeriodic -- * \\sa SDL_HapticCondition -- * \\sa SDL_HapticRamp -- * \\sa SDL_HapticLeftRight -- * \\sa SDL_HapticCustom -- -- Common for all force feedback effects --*< Effect type. type SDL_HapticEffect (discr : unsigned := 0) is record case discr is when 0 => c_type : aliased SDL_stdinc_h.Uint16; -- ..\\SDL2_tmp\\SDL_haptic.h:803 when 1 => c_constant : aliased SDL_HapticConstant; -- ..\\SDL2_tmp\\SDL_haptic.h:804 when 2 => periodic : aliased SDL_HapticPeriodic; -- ..\\SDL2_tmp\\SDL_haptic.h:805 when 3 => condition : aliased SDL_HapticCondition; -- ..\\SDL2_tmp\\SDL_haptic.h:806 when 4 => ramp : aliased SDL_HapticRamp; -- ..\\SDL2_tmp\\SDL_haptic.h:807 when 5 => leftright : aliased SDL_HapticLeftRight; -- ..\\SDL2_tmp\\SDL_haptic.h:808 when others => custom : aliased SDL_HapticCustom; -- ..\\SDL2_tmp\\SDL_haptic.h:809 end case; end record; pragma Convention (C_Pass_By_Copy, SDL_HapticEffect); pragma Unchecked_Union (SDL_HapticEffect); -- ..\\SDL2_tmp\\SDL_haptic.h:800 --*< Constant effect. --*< Periodic effect. --*< Condition effect. --*< Ramp effect. --*< Left/Right effect. --*< Custom effect. -- Function prototypes --* -- * \\brief Count the number of haptic devices attached to the system. -- * -- * \\return Number of haptic devices detected on the system. -- function SDL_NumHaptics return int; -- ..\\SDL2_tmp\\SDL_haptic.h:819 pragma Import (C, SDL_NumHaptics, ""SDL_NumHaptics""); --* -- * \\brief Get the implementation dependent name of a haptic device. -- * -- * This can be called before any joysticks are opened. -- * If no name can be found, this function returns NULL. -- * -- * \\param device_index Index of the device to get its name. -- * \\return Name of the device or NULL on error. -- * -- * \\sa SDL_NumHaptics -- function SDL_HapticName (device_index : int) return Interfaces.C.Strings.chars_ptr; -- ..\\SDL2_tmp\\SDL_haptic.h:832 pragma Import (C, SDL_HapticName, ""SDL_HapticName""); --* -- * \\brief Opens a haptic device for use. -- * -- * The index passed as an argument refers to the N'th haptic device on this -- * system. -- * -- * When opening a haptic device, its gain will be set to maximum and -- * autocenter will be disabled. To modify these values use -- * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). -- * -- * \\param device_index Index of the device to open. -- * \\return Device identifier or NULL on error. -- * -- * \\sa SDL_HapticIndex -- * \\sa SDL_HapticOpenFromMouse -- * \\sa SDL_HapticOpenFromJoystick -- * \\sa SDL_HapticClose -- * \\sa SDL_HapticSetGain -- * \\sa SDL_HapticSetAutocenter -- * \\sa SDL_HapticPause -- * \\sa SDL_HapticStopAll -- function SDL_HapticOpen (device_index : int) return access SDL_Haptic; -- ..\\SDL2_tmp\\SDL_haptic.h:856 pragma Import (C, SDL_HapticOpen, ""SDL_HapticOpen""); --* -- * \\brief Checks if the haptic device at index has been opened. -- * -- * \\param device_index Index to check to see if it has been opened. -- * \\return 1 if it has been opened or 0 if it hasn't. -- * -- * \\sa SDL_HapticOpen -- * \\sa SDL_HapticIndex -- function SDL_HapticOpened (device_index : int) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:867 pragma Import (C, SDL_HapticOpened, ""SDL_HapticOpened""); --* -- * \\brief Gets the index of a haptic device. -- * -- * \\param haptic Haptic device to get the index of. -- * \\return The index of the haptic device or -1 on error. -- * -- * \\sa SDL_HapticOpen -- * \\sa SDL_HapticOpened -- function SDL_HapticIndex (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:878 pragma Import (C, SDL_HapticIndex, ""SDL_HapticIndex""); --* -- * \\brief Gets whether or not the current mouse has haptic capabilities. -- * -- * \\return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. -- * -- * \\sa SDL_HapticOpenFromMouse -- function SDL_MouseIsHaptic return int; -- ..\\SDL2_tmp\\SDL_haptic.h:887 pragma Import (C, SDL_MouseIsHaptic, ""SDL_MouseIsHaptic""); --* -- * \\brief Tries to open a haptic device from the current mouse. -- * -- * \\return The haptic device identifier or NULL on error. -- * -- * \\sa SDL_MouseIsHaptic -- * \\sa SDL_HapticOpen -- function SDL_HapticOpenFromMouse return access SDL_Haptic; -- ..\\SDL2_tmp\\SDL_haptic.h:897 pragma Import (C, SDL_HapticOpenFromMouse, ""SDL_HapticOpenFromMouse""); --* -- * \\brief Checks to see if a joystick has haptic features. -- * -- * \\param joystick Joystick to test for haptic capabilities. -- * \\return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't -- * or -1 if an error occurred. -- * -- * \\sa SDL_HapticOpenFromJoystick -- function SDL_JoystickIsHaptic (joystick : access SDL_joystick_h.Class_SDL_Joystick.SDL_Joystick) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:908 pragma Import (C, SDL_JoystickIsHaptic, ""SDL_JoystickIsHaptic""); --* -- * \\brief Opens a haptic device for use from a joystick device. -- * -- * You must still close the haptic device separately. It will not be closed -- * with the joystick. -- * -- * When opening from a joystick you should first close the haptic device before -- * closing the joystick device. If not, on some implementations the haptic -- * device will also get unallocated and you'll be unable to use force feedback -- * on that device. -- * -- * \\param joystick Joystick to create a haptic device from. -- * \\return A valid haptic device identifier on success or NULL on error. -- * -- * \\sa SDL_HapticOpen -- * \\sa SDL_HapticClose -- function SDL_HapticOpenFromJoystick (joystick : access SDL_joystick_h.Class_SDL_Joystick.SDL_Joystick) return access SDL_Haptic; -- ..\\SDL2_tmp\\SDL_haptic.h:927 pragma Import (C, SDL_HapticOpenFromJoystick, ""SDL_HapticOpenFromJoystick""); --* -- * \\brief Closes a haptic device previously opened with SDL_HapticOpen(). -- * -- * \\param haptic Haptic device to close. -- procedure SDL_HapticClose (haptic : access SDL_Haptic); -- ..\\SDL2_tmp\\SDL_haptic.h:935 pragma Import (C, SDL_HapticClose, ""SDL_HapticClose""); --* -- * \\brief Returns the number of effects a haptic device can store. -- * -- * On some platforms this isn't fully supported, and therefore is an -- * approximation. Always check to see if your created effect was actually -- * created and do not rely solely on SDL_HapticNumEffects(). -- * -- * \\param haptic The haptic device to query effect max. -- * \\return The number of effects the haptic device can store or -- * -1 on error. -- * -- * \\sa SDL_HapticNumEffectsPlaying -- * \\sa SDL_HapticQuery -- function SDL_HapticNumEffects (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:951 pragma Import (C, SDL_HapticNumEffects, ""SDL_HapticNumEffects""); --* -- * \\brief Returns the number of effects a haptic device can play at the same -- * time. -- * -- * This is not supported on all platforms, but will always return a value. -- * Added here for the sake of completeness. -- * -- * \\param haptic The haptic device to query maximum playing effects. -- * \\return The number of effects the haptic device can play at the same time -- * or -1 on error. -- * -- * \\sa SDL_HapticNumEffects -- * \\sa SDL_HapticQuery -- function SDL_HapticNumEffectsPlaying (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:967 pragma Import (C, SDL_HapticNumEffectsPlaying, ""SDL_HapticNumEffectsPlaying""); --* -- * \\brief Gets the haptic device's supported features in bitwise manner. -- * -- * Example: -- * \\code -- * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { -- * printf(""We have constant haptic effect!\\n""); -- * } -- * \\endcode -- * -- * \\param haptic The haptic device to query. -- * \\return Haptic features in bitwise manner (OR'd). -- * -- * \\sa SDL_HapticNumEffects -- * \\sa SDL_HapticEffectSupported -- function SDL_HapticQuery (haptic : access SDL_Haptic) return unsigned; -- ..\\SDL2_tmp\\SDL_haptic.h:985 pragma Import (C, SDL_HapticQuery, ""SDL_HapticQuery""); --* -- * \\brief Gets the number of haptic axes the device has. -- * -- * \\sa SDL_HapticDirection -- function SDL_HapticNumAxes (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:993 pragma Import (C, SDL_HapticNumAxes, ""SDL_HapticNumAxes""); --* -- * \\brief Checks to see if effect is supported by haptic. -- * -- * \\param haptic Haptic device to check on. -- * \\param effect Effect to check to see if it is supported. -- * \\return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. -- * -- * \\sa SDL_HapticQuery -- * \\sa SDL_HapticNewEffect -- function SDL_HapticEffectSupported (haptic : access SDL_Haptic; effect : access SDL_HapticEffect) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1005 pragma Import (C, SDL_HapticEffectSupported, ""SDL_HapticEffectSupported""); --* -- * \\brief Creates a new haptic effect on the device. -- * -- * \\param haptic Haptic device to create the effect on. -- * \\param effect Properties of the effect to create. -- * \\return The identifier of the effect on success or -1 on error. -- * -- * \\sa SDL_HapticUpdateEffect -- * \\sa SDL_HapticRunEffect -- * \\sa SDL_HapticDestroyEffect -- function SDL_HapticNewEffect (haptic : access SDL_Haptic; effect : access SDL_HapticEffect) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1020 pragma Import (C, SDL_HapticNewEffect, ""SDL_HapticNewEffect""); --* -- * \\brief Updates the properties of an effect. -- * -- * Can be used dynamically, although behavior when dynamically changing -- * direction may be strange. Specifically the effect may reupload itself -- * and start playing from the start. You cannot change the type either when -- * running SDL_HapticUpdateEffect(). -- * -- * \\param haptic Haptic device that has the effect. -- * \\param effect Identifier of the effect to update. -- * \\param data New effect properties to use. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticNewEffect -- * \\sa SDL_HapticRunEffect -- * \\sa SDL_HapticDestroyEffect -- function SDL_HapticUpdateEffect (haptic : access SDL_Haptic; effect : int; data : access SDL_HapticEffect) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1040 pragma Import (C, SDL_HapticUpdateEffect, ""SDL_HapticUpdateEffect""); --* -- * \\brief Runs the haptic effect on its associated haptic device. -- * -- * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over -- * repeating the envelope (attack and fade) every time. If you only want the -- * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length -- * parameter. -- * -- * \\param haptic Haptic device to run the effect on. -- * \\param effect Identifier of the haptic effect to run. -- * \\param iterations Number of iterations to run the effect. Use -- * ::SDL_HAPTIC_INFINITY for infinity. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticStopEffect -- * \\sa SDL_HapticDestroyEffect -- * \\sa SDL_HapticGetEffectStatus -- function SDL_HapticRunEffect (haptic : access SDL_Haptic; effect : int; iterations : SDL_stdinc_h.Uint32) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1062 pragma Import (C, SDL_HapticRunEffect, ""SDL_HapticRunEffect""); --* -- * \\brief Stops the haptic effect on its associated haptic device. -- * -- * \\param haptic Haptic device to stop the effect on. -- * \\param effect Identifier of the effect to stop. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticRunEffect -- * \\sa SDL_HapticDestroyEffect -- function SDL_HapticStopEffect (haptic : access SDL_Haptic; effect : int) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1076 pragma Import (C, SDL_HapticStopEffect, ""SDL_HapticStopEffect""); --* -- * \\brief Destroys a haptic effect on the device. -- * -- * This will stop the effect if it's running. Effects are automatically -- * destroyed when the device is closed. -- * -- * \\param haptic Device to destroy the effect on. -- * \\param effect Identifier of the effect to destroy. -- * -- * \\sa SDL_HapticNewEffect -- procedure SDL_HapticDestroyEffect (haptic : access SDL_Haptic; effect : int); -- ..\\SDL2_tmp\\SDL_haptic.h:1090 pragma Import (C, SDL_HapticDestroyEffect, ""SDL_HapticDestroyEffect""); --* -- * \\brief Gets the status of the current effect on the haptic device. -- * -- * Device must support the ::SDL_HAPTIC_STATUS feature. -- * -- * \\param haptic Haptic device to query the effect status on. -- * \\param effect Identifier of the effect to query its status. -- * \\return 0 if it isn't playing, 1 if it is playing or -1 on error. -- * -- * \\sa SDL_HapticRunEffect -- * \\sa SDL_HapticStopEffect -- function SDL_HapticGetEffectStatus (haptic : access SDL_Haptic; effect : int) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1105 pragma Import (C, SDL_HapticGetEffectStatus, ""SDL_HapticGetEffectStatus""); --* -- * \\brief Sets the global gain of the device. -- * -- * Device must support the ::SDL_HAPTIC_GAIN feature. -- * -- * The user may specify the maximum gain by setting the environment variable -- * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to -- * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the -- * maximum. -- * -- * \\param haptic Haptic device to set the gain on. -- * \\param gain Value to set the gain to, should be between 0 and 100. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticQuery -- function SDL_HapticSetGain (haptic : access SDL_Haptic; gain : int) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1124 pragma Import (C, SDL_HapticSetGain, ""SDL_HapticSetGain""); --* -- * \\brief Sets the global autocenter of the device. -- * -- * Autocenter should be between 0 and 100. Setting it to 0 will disable -- * autocentering. -- * -- * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. -- * -- * \\param haptic Haptic device to set autocentering on. -- * \\param autocenter Value to set autocenter to, 0 disables autocentering. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticQuery -- function SDL_HapticSetAutocenter (haptic : access SDL_Haptic; autocenter : int) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1140 pragma Import (C, SDL_HapticSetAutocenter, ""SDL_HapticSetAutocenter""); --* -- * \\brief Pauses a haptic device. -- * -- * Device must support the ::SDL_HAPTIC_PAUSE feature. Call -- * SDL_HapticUnpause() to resume playback. -- * -- * Do not modify the effects nor add new ones while the device is paused. -- * That can cause all sorts of weird errors. -- * -- * \\param haptic Haptic device to pause. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticUnpause -- function SDL_HapticPause (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1157 pragma Import (C, SDL_HapticPause, ""SDL_HapticPause""); --* -- * \\brief Unpauses a haptic device. -- * -- * Call to unpause after SDL_HapticPause(). -- * -- * \\param haptic Haptic device to unpause. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticPause -- function SDL_HapticUnpause (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1169 pragma Import (C, SDL_HapticUnpause, ""SDL_HapticUnpause""); --* -- * \\brief Stops all the currently playing effects on a haptic device. -- * -- * \\param haptic Haptic device to stop. -- * \\return 0 on success or -1 on error. -- function SDL_HapticStopAll (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1177 pragma Import (C, SDL_HapticStopAll, ""SDL_HapticStopAll""); --* -- * \\brief Checks to see if rumble is supported on a haptic device. -- * -- * \\param haptic Haptic device to check to see if it supports rumble. -- * \\return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. -- * -- * \\sa SDL_HapticRumbleInit -- * \\sa SDL_HapticRumblePlay -- * \\sa SDL_HapticRumbleStop -- function SDL_HapticRumbleSupported (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1189 pragma Import (C, SDL_HapticRumbleSupported, ""SDL_HapticRumbleSupported""); --* -- * \\brief Initializes the haptic device for simple rumble playback. -- * -- * \\param haptic Haptic device to initialize for simple rumble playback. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticOpen -- * \\sa SDL_HapticRumbleSupported -- * \\sa SDL_HapticRumblePlay -- * \\sa SDL_HapticRumbleStop -- function SDL_HapticRumbleInit (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1202 pragma Import (C, SDL_HapticRumbleInit, ""SDL_HapticRumbleInit""); --* -- * \\brief Runs simple rumble on a haptic device -- * -- * \\param haptic Haptic device to play rumble effect on. -- * \\param strength Strength of the rumble to play as a 0-1 float value. -- * \\param length Length of the rumble to play in milliseconds. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticRumbleSupported -- * \\sa SDL_HapticRumbleInit -- * \\sa SDL_HapticRumbleStop -- function SDL_HapticRumblePlay (haptic : access SDL_Haptic; strength : float; length : SDL_stdinc_h.Uint32) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1216 pragma Import (C, SDL_HapticRumblePlay, ""SDL_HapticRumblePlay""); --* -- * \\brief Stops the simple rumble on a haptic device. -- * -- * \\param haptic Haptic to stop the rumble on. -- * \\return 0 on success or -1 on error. -- * -- * \\sa SDL_HapticRumbleSupported -- * \\sa SDL_HapticRumbleInit -- * \\sa SDL_HapticRumblePlay -- function SDL_HapticRumbleStop (haptic : access SDL_Haptic) return int; -- ..\\SDL2_tmp\\SDL_haptic.h:1228 pragma Import (C, SDL_HapticRumbleStop, ""SDL_HapticRumbleStop""); -- Ends C function definitions when using C++ -- vi: set ts=4 sw=4 expandtab: end SDL_haptic_h; ",16297,True,3502.086346206489,median